WhiteMagic / JoystickGremlin

A tool for configuring and managing joystick devices.
http://whitemagic.github.io/JoystickGremlin/
GNU General Public License v3.0
313 stars 46 forks source link

User plugin detect key to press with PhysicalInputVariable #421

Open gavazquez opened 2 years ago

gavazquez commented 2 years ago

I want to create a plugin where the user can specify the key that needs to be pressed

import time
import gremlin
from gremlin.user_plugin import *

key = PhysicalInputVariable(
        "Key",
        "Key example",
        [gremlin.common.InputType.Keyboard]
)

It throws an error as it seems that it can't detect the guid form the keyboard. Is there something I'm missing?

image

Afterwards I want to use it on a macro like this:

key_macro = gremlin.macro.Macro()
key_macro.add_action(gremlin.macro.KeyAction(key.input_id, True))

But this triggers an error as the input_id is not valid for a key action Is there something I can do about this?

WhiteMagic commented 2 years ago

The PhysicalInputVariable is not intended to be used with a keyboard but only with joysticks. The workaround would be to use the StringVariable and use that key as the macro content.