RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Controller input mapping works in Emulation Station but not in emulators

    Scheduled Pinned Locked Moved Help and Support
    input mappingcontroller mapinput config
    23 Posts 3 Posters 6.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mcpat @mitu
      last edited by

      @mitu
      Maybe it's simpler to start with the MD Controller (hier also +2) but has less buttons.
      es_input.cfg

        <inputConfig type="joystick" deviceName="MD/Gen Control Pad" deviceGUID="0500bfc17e0500001720000001800000">
          <input name="left" type="hat" id="0" value="8"/>
          <input name="right" type="hat" id="0" value="2"/>
          <input name="down" type="hat" id="0" value="4"/>
          <input name="x" type="button" id="2" value="1"/>
          <input name="b" type="button" id="1" value="1"/>
          <input name="a" type="button" id="0" value="1"/>
          <input name="up" type="hat" id="0" value="1"/>
          <input name="select" type="button" id="3" value="1"/>
          <input name="start" type="button" id="4" value="1"/>
        </inputConfig>
      

      MDGen Control Pad.cfg.orig

      input_device = "MD/Gen Control Pad"
      input_driver = "udev"
      input_vendor_id = "1406"
      input_product_id = "8215"
      input_left_btn = "h0left"
      input_left_btn_label = "D-Pad Left"
      input_state_slot_decrease_btn = "h0left"
      input_right_btn = "h0right"
      input_right_btn_label = "D-Pad Right"
      input_state_slot_increase_btn = "h0right"
      input_down_btn = "h0down"
      input_down_btn_label = "D-Pad Down"
      input_x_btn = "2"
      input_menu_toggle_btn = "2"
      input_b_btn = "1"
      input_reset_btn = "1"
      input_a_btn = "0"
      input_up_btn = "h0up"
      input_up_btn_label = "D-Pad Up"
      input_select_btn = "3"
      input_start_btn = "4"
      input_exit_emulator_btn = "4"
      input_enable_hotkey_btn = "3"
      

      MDGen Control Pad.cfg.patch

      input_device = "MD/Gen Control Pad"
      input_driver = "udev"
      input_vendor_id = "1406"
      input_product_id = "8215"
      input_left_btn = "h0left"
      input_left_btn_label = "D-Pad Left"
      input_state_slot_decrease_btn = "h0left"
      input_right_btn = "h0right"
      input_right_btn_label = "D-Pad Right"
      input_state_slot_increase_btn = "h0right"
      input_down_btn = "h0down"
      input_down_btn_label = "D-Pad Down"
      input_x_btn = "4"
      input_menu_toggle_btn = "2"
      input_b_btn = "3"
      input_reset_btn = "1"
      input_a_btn = "2"
      input_up_btn = "h0up"
      input_up_btn_label = "D-Pad Up"
      input_select_btn = "5"
      input_start_btn = "6"
      input_exit_emulator_btn = "6"
      input_enable_hotkey_btn = "5"
      

      evtest

      root@rpizerosm:~# evtest
      No device specified, trying to scan all of /dev/input/event*
      Available devices:
      /dev/input/event0:      SEMICO USB Keyboard
      /dev/input/event1:      SEMICO USB Keyboard Consumer Control
      /dev/input/event2:      SEMICO USB Keyboard System Control
      /dev/input/event3:      Rotary Encoder Volume
      /dev/input/event4:      N64 Controller
      /dev/input/event5:      MD/Gen Control Pad
      Select the device event number [0-5]: 5
      Input driver version is 1.0.1
      Input device ID: bus 0x5 vendor 0x57e product 0x2017 version 0x8001
      Input device name: "MD/Gen Control Pad"
      Supported events:
        Event type 0 (EV_SYN)
        Event type 1 (EV_KEY)
          Event code 256 (BTN_0)
          Event code 257 (BTN_1)
          Event code 304 (BTN_SOUTH)
          Event code 305 (BTN_EAST)
          Event code 308 (BTN_WEST)
          Event code 314 (BTN_SELECT)
          Event code 315 (BTN_START)
        Event type 3 (EV_ABS)
          Event code 16 (ABS_HAT0X)
            Value      0
            Min       -1
            Max        1
          Event code 17 (ABS_HAT0Y)
            Value      0
            Min       -1
            Max        1
      Properties:
      Testing ... (interrupt to exit)
      /* up */
      Event: time 1695273947.923814, type 3 (EV_ABS), code 17 (ABS_HAT0Y), value -1
      Event: time 1695273947.923814, -------------- SYN_REPORT ------------
      Event: time 1695273948.088852, type 3 (EV_ABS), code 17 (ABS_HAT0Y), value 0
      /* down */
      Event: time 1695273948.088852, -------------- SYN_REPORT ------------
      Event: time 1695273949.288930, type 3 (EV_ABS), code 17 (ABS_HAT0Y), value 1
      Event: time 1695273949.288930, -------------- SYN_REPORT ------------
      Event: time 1695273949.453942, type 3 (EV_ABS), code 17 (ABS_HAT0Y), value 0
      /* left */
      Event: time 1695273949.453942, -------------- SYN_REPORT ------------
      Event: time 1695273949.903987, type 3 (EV_ABS), code 16 (ABS_HAT0X), value -1
      Event: time 1695273949.903987, -------------- SYN_REPORT ------------
      Event: time 1695273950.084017, type 3 (EV_ABS), code 16 (ABS_HAT0X), value 0
      /* right */
      Event: time 1695273950.084017, -------------- SYN_REPORT ------------
      Event: time 1695273950.534079, type 3 (EV_ABS), code 16 (ABS_HAT0X), value 1
      Event: time 1695273950.534079, -------------- SYN_REPORT ------------
      Event: time 1695273950.684056, type 3 (EV_ABS), code 16 (ABS_HAT0X), value 0
      /* A */
      Event: time 1695273950.684056, -------------- SYN_REPORT ------------
      Event: time 1695273953.804411, type 1 (EV_KEY), code 304 (BTN_SOUTH), value 1
      Event: time 1695273953.804411, -------------- SYN_REPORT ------------
      Event: time 1695273953.939392, type 1 (EV_KEY), code 304 (BTN_SOUTH), value 0
      /* B */
      Event: time 1695273953.939392, -------------- SYN_REPORT ------------
      Event: time 1695273954.614390, type 1 (EV_KEY), code 305 (BTN_EAST), value 1
      Event: time 1695273954.614390, -------------- SYN_REPORT ------------
      Event: time 1695273954.749388, type 1 (EV_KEY), code 305 (BTN_EAST), value 0
      /* C */
      Event: time 1695273954.749388, -------------- SYN_REPORT ------------
      Event: time 1695273955.529501, type 1 (EV_KEY), code 308 (BTN_WEST), value 1
      Event: time 1695273955.529501, -------------- SYN_REPORT ------------
      Event: time 1695273955.649511, type 1 (EV_KEY), code 308 (BTN_WEST), value 0
      /* Select */
      Event: time 1695273955.649511, -------------- SYN_REPORT ------------
      Event: time 1695273960.824956, type 1 (EV_KEY), code 314 (BTN_SELECT), value 1
      Event: time 1695273960.824956, -------------- SYN_REPORT ------------
      Event: time 1695273961.004932, type 1 (EV_KEY), code 314 (BTN_SELECT), value 0
      /* Start */
      Event: time 1695273961.004932, -------------- SYN_REPORT ------------
      Event: time 1695273962.400159, type 1 (EV_KEY), code 315 (BTN_START), value 1
      Event: time 1695273962.400159, -------------- SYN_REPORT ------------
      Event: time 1695273962.520149, type 1 (EV_KEY), code 315 (BTN_START), value 0
      Event: time 1695273962.520149, -------------- SYN_REPORT ------------
      ^Croot@rpizerosm:~#
      

      How should I use jstest? Which parameters? I only saw two buttons...

      Thx for your help!

      M mituM 2 Replies Last reply Reply Quote 0
      • M
        mcpat @mcpat
        last edited by

        PS: please note acc. hid-nx I use udev rules

        99-joycond-ignore.rules

        # ignore Switch Pro controller by overriding tags
        ACTION=="add", SUBSYSTEM=="input", ATTRS{id/vendor}=="057e", ATTRS{id/product}=="2009", TAG="uaccess"
        ACTION=="add", SUBSYSTEM=="input", ATTRS{id/vendor}=="057e", ATTRS{id/product}=="2009", TAG+="seat"
        
        # ignore NSO SNES controller by overriding tags
        ACTION=="add", SUBSYSTEM=="input", ATTRS{id/vendor}=="057e", ATTRS{id/product}=="2017", TAG="uaccess"
        ACTION=="add", SUBSYSTEM=="input", ATTRS{id/vendor}=="057e", ATTRS{id/product}=="2017", TAG+="seat"
        
        # ignore NSO N64 controller by overriding tags
        ACTION=="add", SUBSYSTEM=="input", ATTRS{id/vendor}=="057e", ATTRS{id/product}=="2019", TAG="uaccess"
        ACTION=="add", SUBSYSTEM=="input", ATTRS{id/vendor}=="057e", ATTRS{id/product}=="2019", TAG+="seat"
        
        # ignore NSO Genesis controller by overriding tags
        ACTION=="add", SUBSYSTEM=="input", ATTRS{id/vendor}=="057e", ATTRS{id/product}=="201e", TAG="uaccess"
        ACTION=="add", SUBSYSTEM=="input", ATTRS{id/vendor}=="057e", ATTRS{id/product}=="201e", TAG+="seat"
        
        # ignore NES Joy-Con by overriding tags
        ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="NES Controller*", TAG="uaccess"
        ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="NES Controller*", TAG+="seat"
        
        1 Reply Last reply Reply Quote 0
        • mituM
          mitu Global Moderator @mcpat
          last edited by

          @mcpat said in Controller input mapping works in Emulation Station but not in emulators:

          How should I use jstest? Which parameters? I only saw two buttons...

          The idea is to run the test and compare the value of the input ID reported by the test utility with the value recorded by EmulationStation - you need to do this locally, since I can't infer from the output which button you chose.

          jstest can be run with

          jstest /dev/input/js0
          

          This will test the 1st detected joystick, if you need to test the 2nd one you increment the jsX part (i.e. /dev/input/js1).

          M 1 Reply Last reply Reply Quote 0
          • M
            mcpat @mitu
            last edited by

            @mitu

            root@rpizerosm:/opt/RetroPie-Setup# jstest /dev/input/js0
            Driver version is 2.1.0.
            Joystick (N64 Controller) has 4 axes (X, Y, Hat0X, Hat0Y)
            and 13 buttons (BtnA, BtnB, BtnZ, BtnTL, BtnTR, BtnTR2, BtnStart, (null), (null), (null), (null), Btn0, Btn1).
            Testing ... (interrupt to exit)
            Axes:  0:     0  1: -2234  2:     0  3:     0 Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 10:off 11:off 12:off
            

            Buttons are:

            0 = A
            1 = B
            2 = Z (Below in the middle)
            3= TL
            4 = TR
            5 = ZR (right button on the back site)
            6 = Start
            7 = Yellow up
            8 = Yellow down
            9 = Yellow left
            10 = Yellow right
            11 = "Power" (right round button on the back site)
            12 = "Square Button" on the left back site
            
            mituM 1 Reply Last reply Reply Quote 0
            • mituM
              mitu Global Moderator @mcpat
              last edited by

              @mcpat Looking at the jstest output, it seems to coincide with what ES input condfiguration recorded - A is 0, B is 1, X is 2, etc.
              Now in Linux there are 2 APIs for joystick - a 'legacy' one and one based on evdev. jstest uses the 'legacy' API and enumerates the buttons starting from 0, while the evdev one seems to start with 2, though it still advertises BTN_0 and BTN_1.
              SDL (which is used by ES for input processing/mapping) is supposed to use the evdev interface (but can fallback to the 'legacy' one) and so is RetroArch, but somehow the button numbering in SDL starts from 0 (?) instead of 2, as reported by evdev. I'm not sure whether it's a SDL bug (assuming buttons always start from 0) or maybe the Linux driver doesn't implement the 'legacy' joystick API (unlikely though).

              M 2 Replies Last reply Reply Quote 0
              • M
                mcpat @mitu
                last edited by

                @mitu
                thank you for the feedback.

                So how can we/I solve the problem? I tried to patch in the meantime hid-nx, joycond, ... but no success. If you can give me a hint where to look (e.g. SDL, emulationstation, retroarch, ...) I can try to find the button numbering.

                Thank you again!

                1 Reply Last reply Reply Quote 0
                • M
                  mcpat @mitu
                  last edited by

                  @mitu
                  Is it this line?

                  Really interested in patching ;)

                  mituM 1 Reply Last reply Reply Quote 0
                  • mituM
                    mitu Global Moderator @mcpat
                    last edited by

                    @mcpat said in Controller input mapping works in Emulation Station but not in emulators:

                    Is it this line?

                    No, EmulationStation doesn't use the gamecontroller subsystem, but the joystick subsystem. Regardless, the gamecontroller mapping doesn't change the button numbering, it's just a mapping.

                    M 1 Reply Last reply Reply Quote 0
                    • M
                      mcpat @mitu
                      last edited by

                      @mitu
                      so how can I solve the problem to be able to use autoconfig?
                      Where can I force "legacy" for ES? Or how can I force to do the autoconfig with the numbering from evdev?
                      Now it's a pain to open a ssh connection and do the correction by hand.

                      Thank you for your patience!

                      1 Reply Last reply Reply Quote 0
                      • mituM
                        mitu Global Moderator
                        last edited by

                        Didn't you already corrected the configuration profile ? It should be enough, the profile is written only when you change the input configuration in EmulationStation, so it's not going to be changed unless you re-configure your controller(s).

                        M 1 Reply Last reply Reply Quote 0
                        • M
                          mcpat @mitu
                          last edited by

                          @mitu
                          yes it's solved by now, but I am interested in how to solve it for the future and what is causing this +2 shift. If you are not willing to further support, I fully unterstand. It's more my personal interest to find and solve the bug so others don't have this problems.
                          I was googling a while to find it out, even I am not a beginner (in linux).

                          mituM 1 Reply Last reply Reply Quote 0
                          • mituM
                            mitu Global Moderator @mcpat
                            last edited by

                            @mcpat said in Controller input mapping works in Emulation Station but not in emulators:

                            If you are not willing to further support, I fully unterstand.

                            I would if I could :).

                            M 1 Reply Last reply Reply Quote 0
                            • M
                              mcpat @mitu
                              last edited by mcpat

                              @mitu
                              I solved the problem. It was in the source code of hid-nx....

                              see here. It was the BTN_0 and BTN_1

                              I modified the code like this for both controllers and they are now working correctly!

                              Can be found starting here

                              static const struct nx_con_button_mapping gencon_button_mappings[] = {
                              	{ BTN_SOUTH,	NX_CON_BTN_A,		},
                              	{ BTN_EAST,	NX_CON_BTN_B,		},
                              	{ BTN_WEST,	NX_CON_BTN_R,		},
                              	{ BTN_DPAD_LEFT,	NX_CON_BTN_X,		},
                              	{ BTN_DPAD_UP,		NX_CON_BTN_Y,		},
                              	{ BTN_DPAD_RIGHT,	NX_CON_BTN_L,		},
                              	{ BTN_THUMBL,	NX_CON_BTN_ZR,		},
                              	{ BTN_START,	NX_CON_BTN_PLUS,	},
                              	{ BTN_SELECT,	NX_CON_BTN_HOME,	},
                              	{ BTN_MODE,	NX_CON_BTN_CAP,		},
                              	{ /* sentinel */ },
                              };
                              
                              /*
                               * N64's C buttons get assigned to d-pad directions and registered as buttons.
                               */
                              static const struct nx_con_button_mapping n64con_button_mappings[] = {
                              	{ BTN_A,		NX_CON_BTN_A,		},
                              	{ BTN_B,		NX_CON_BTN_B,		},
                              	{ BTN_Z,		NX_CON_BTN_ZL,		},
                              	{ BTN_TL,		NX_CON_BTN_L,		},
                              	{ BTN_TR,		NX_CON_BTN_R,		},
                              	{ BTN_TR2,		NX_CON_BTN_LSTICK,	},
                              	{ BTN_START,		NX_CON_BTN_PLUS,	},
                              	{ BTN_DPAD_UP,		NX_CON_BTN_Y,		},
                              	{ BTN_DPAD_DOWN,	NX_CON_BTN_ZR,		},
                              	{ BTN_DPAD_LEFT,	NX_CON_BTN_X,		},
                              	{ BTN_DPAD_RIGHT,	NX_CON_BTN_MINUS,	},
                              	{ BTN_THUMBL,		NX_CON_BTN_HOME,	},
                              	{ BTN_MODE,		NX_CON_BTN_CAP,		},
                              	{ /* sentinel */ },
                              };
                              
                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post

                              Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                              Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.