PunchablePlushie/godot-game-settings

Cannot remap inputs to arrow keys

Closed this issue · 6 comments

Trying to remap some inputs to arrow keys causes the right and left arrow to be saved as B and X respectively.

I suspect this occurs during saving or loading because setting it behaves normally. Exiting the setting menu and going back overwrites left and right with X and B.

I noticed it in our game, but I also tested it in the GGS demo, it happens just the same.

Steps to reproduce:

  • Start the demo UI
  • Set move inputs to the respective arrows
  • close the ui
  • start the UI again, observe the left and right input names

Digging a bit into the plugin_data.tres it seems the key is saved correctly, so the error should be in the loading step.

A few more small details:

  • I am using 4.0.2 stable.
  • The input is really replaced, B and X act like the respective keys it is not only visual in the settings editor.

So I found out the root cause of the issue.

When the addon applies the input setting it checks for its type in res://addons/ggs/classes/ggs_input_helper.gd:79:get_event_from_string().

Since the strings left and right appear in keywords ["gamepad_btn"] and are also used for the arrow key on the keyboard the event type is set to gamepad, which eventually causes the confusion.

Changing the gamepad keywords fixes the issue.

Do you prefer to change them or should I create a PR?

I was confused by this as well. Why do input classes have types if they aren't used in sensing the action type? I'd either remove the Type so an InputButton can be mapped to anything, or pass the Type into the ggs_input_helper to make sure mix-ups like this can't happen.

I think it is because usually games have the gamepad and kb+mouse settings coexisting.
Most games do it this way, I think that makes perfect sense.

Maybe to prevent future mixups the settings can be stored as input type+index instead of a string.
But even this is not necessary, as long as there is no name overlap everything works correctly.

I've changed the gamepad keywords and updated the wiki. This should fix the issue as suggested by previous replies. (See 8b2192f)
Thank you for bringing this up and providing the solution.

Happy to help! Thank you again for the great plugin!