1
$\begingroup$

I'm currently creating a PS1 'Character Select' style screen in Blender (Similar to games like Tekken etc.)
I've set this up in Geometry Nodes with Group inputs for the controls of everything I want to be able to change / scroll through:

enter image description here

I've managed to get it to work pretty much exactly how I want in the viewport but now I'm wanting to map the Group inputs to keyboard shortcuts, so that when I enter fullscreen mode I will still be able to change my controls without using my mouse in the viewport. (I would then map these custom keyboard shortcuts to buttons on my controller like below using a plugin I have installed)

enter image description here

I initially thought to set these up using shortcut keys assigned to the modifier itself, but there are 2 issues with this:

  1. Doesn't work on an integer input <> (separate Left and Right arrow inputs)
  2. I'm not sure if this is a known setback but keyboard shortcuts don't seem to work correctly with geometry nodes (Taking about 5 seconds to register once pressed and not executing the pressed input correctly - you can test this on my example file by pressing 'P' to enable the inventory overlay and see how it doesn't work)

enter image description here

Does anyone know a workaround to this or whether it would be possible to set something like this up in Python or another plugin?

(I know if this was for a proper game I would be better using Unity or Unreal engine but for my purposes I'm just wanting to use it for a presentation so I'm hoping to keep it all in Blender if possible.)

Any help would be greatly appreciated, thank you!

$\endgroup$

1 Answer 1

1
$\begingroup$

You can use an external program like this: https://alternativeto.net/software/antimicro/ to control the keyboard with a game-pad, create an operator that do the things you need via the python API and assign the shortcut to it.

import bpy

def update_ui():
    for wm in bpy.data.window_managers:
        for window in wm.windows:
            for area in window.screen.areas:
                for region in area.regions:
                    region.tag_redraw()

class TEST_OT_change_color(bpy.types.Operator):
    bl_idname = "wm.testtest_change_color"
    bl_label = "Change Color Test"

    def execute(self, context):

        object = bpy.data.objects['Game Setup']
        mod = object.modifiers['GeometryNodes']

        mod["Socket_3"] += 1
        mod["Socket_3"] %= 4
        
        mod["Socket_4"] = not mod["Socket_4"]

        object.update_tag()
        update_ui()
        
        return {'FINISHED'}


def menu_func(self, context):
    self.layout.operator(TEST_OT_change_color.bl_idname)

def register():
    bpy.utils.register_class(TEST_OT_change_color)
    bpy.types.TOPBAR_MT_edit.append(menu_func)


def unregister():
    bpy.utils.unregister_class(TEST_OT_change_color)
    bpy.types.TOPBAR_MT_edit.remove(menu_func)


if __name__ == "__main__":
    register()

The operator will appear in the top bar Edit menu.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .