Input mapping / remapping: what are these codes in the console, and how do I use them?

CalyadCalyad Posts: 7Member
edited July 28 in Programming

I am trying to make a menu that allows the player to remap their input. Push anything (joypad axis, button, some crazy input method I don't even know exists, &c), and it allows remapping to that input.

For this question, let's assume that they only thing they remap is movement (up, down, left, right).

I could not find any tutorials that blended all possible input types, like keyboard and gamepad axis and gamepad buttons.

I used this to see how the InputMap was "seeing" the inputs as I had manually put them in the Project Settings:

for EachOfMyActions in InputMap.get_actions():
    print(EachOfMyActions, " evidently uses something called: ", InputMap.get_action_list(EachOfMyActions))

Which yielded the following:

move_up1 evidently uses something called: [[InputEventJoypadMotion:141]]
move_down1 evidently uses something called: [[InputEventJoypadMotion:143]]
move_right1 evidently uses something called: [[InputEventJoypadMotion:145]]
move_left1 evidently uses something called: [[InputEventJoypadMotion:147]]

I have no idea what these mysterious codes are. I cannot find anything in the official documentation that contains InputEvenJoypadMotion and one of these integers. The @globalscope doesn't mention them. I have no idea what these are, but I would like to be able to swiftly assign things with these codes, because they seem significantly easier than trying to get a joypad axis and then query its strength, or sorting through "is this a keyboard event or a gamepad button or a gamepad axis."

When I mapped things to keyboard inputs, I saw things that appeared in the globalscope documentation (here). But nothing on this page seems to match these weird codes I see for Gamepad buttons or any Gamepad axis.

So with that setup, there are two questions:

  1. What are these codes? Is there a documentation page somewhere that I have overlooked that explains them?
  2. What is the difference between the codes in the output of my function, and "event.axis == 5" (for a joypad axis)?

Best Answer

  • CalyadCalyad Posts: 7
    Accepted Answer

    I figured it out by messing around some more.

    It turns out that the number that appears after the : is an index of "this is the Xth input that exists in this InputMap."

    So yes, in my example, I have over 140 inputs in the InputMap.

Answers

  • CalyadCalyad Posts: 7Member
    Accepted Answer

    I figured it out by messing around some more.

    It turns out that the number that appears after the : is an index of "this is the Xth input that exists in this InputMap."

    So yes, in my example, I have over 140 inputs in the InputMap.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file