Closed harbdog closed 1 year ago
@quasilyte I've found where the problem is, it appears to only want to show the gamepad key names when a gamepad is connected. So it did end up showing the gamepad_* keys after I turned the gamepad back on.
gamepadConnected := h.GamepadConnected()
...
case keyGamepad, keyGamepadLeftStick, keyGamepadRightStick, keyGamepadStickMotion:
enabled = gamepadConnected && (mask&GamepadDevice != 0)
While this may make sense for some cases, in my case I'm wanting to use it to export all configuration to json after allowing in-game remapping, that can later be imported as done in the "configfile" example. It would not be good to lose gamepad configuration settings just because the gamepad isn't currently connected.
This gamepadConnected filter is redundant.
The DefaultInputMask
already tries to provide the same functionality. There is no point in duplicating this logic in ActionKeyNames function too.
So I guess it should just respect the given mask and return all keys if AnyDevice is used.
Would #31 solve this issue? I feel like this behavior would be more predictable.
Sorry for the late response. Sometimes the notifications just find their way to bypass me.
@quasilyte yes the code from PR #31 appears to resolve the issue 👍:
$ go run ./_examples/configfile/main.go
Pause: [space gamepad_start]
Restart: [ctrl+r gamepad_back]
Secret: [ctrl+shift+q]
Left: [left a gamepad_left]
Right: [right d gamepad_right]
According to the doc using the AnyDevice mask from the ActionKeyNames function should return key names for all devices, but it is currently only returning keys for keyboard and mouse devices, but not gamepad. Adding the following to the Init code of the configfile example shows the problem:
They keymap.json used in the example has some gamepad bindings, but they are not shown as expected of the AnyDevice mask