Controller input mapping works in Emulation Station but not in emulators
-
@questions said in Controller input mapping works in Emulation Station but not in emulators:
Do you know where I can find some more detailed documentation on those menus? I found some information on this RetroArch Configuration page, but I feel like it leaves a lot out.
Upstream has some info about this in https://docs.libretro.com/guides/input-and-controls/, but I don't think they actually explain the menu.
For example, what do (C1), (C2), (C3), and (C4) mean? I thought they were related to the C buttons, but that doesn't seem to be the case. What does it mean if something says "Auto" next to it? What are all of the "N/A"s all over the place standing in for? I'm actually not even clear on what the difference between the two menus is.
So it looks like this
... .. Auto: Start(btn) B Button(C2) Auto: +2 (N/A) Z Trigger The left side is the mapping RetroArch has for your physical controller.
- the Auto prefix means it comes from an auto-configuration profile.
- the next string is the input number/name, depending on how it's registered in the config file. So for the 1st entry, the configuration profile has a label for the input and it's Start:
input_start_btn = "9" input_start_btn_label = "Start"
- If there's no label , then the actual number of the input is shown, with a N/A label. So, 2nd line shows because it's declared like:
input_l2_axis = "+2" # there's no 'input_l2_axis_label'
The right side is what the emulated core expects in terms of input - this depends on the emulated system. In your case, it shows how the left input on your controller is mapped to the emulated gamepad. The C3 and C2 buttons can be used as both A/B or C2/C3 buttons, but I'm not sure how they're toggled.
Is there somewhere I can change those values so they match up with EmulationStation?
I also noticed that, in EmulationStation input configuration and in the "N64 Controller.cfg" file I posted above, the A button on my controller has a value of 0, but in the RetroArch Menu, it has a value of 2.
Can't say why, do you have a screenshot with the port configuration ?
-
I have the same problem with hid-nx, it seems the buttons must be +2 higher,
autoconfiguration of retroarch N64 controller
N64 Controller.cfg
:input_device = "N64 Controller" input_driver = "udev" input_vendor_id = "1406" input_product_id = "8217" input_r_y_plus_btn = "8" input_left_btn = "h0left" input_left_btn_label = "D-Pad Left" input_state_slot_decrease_btn = "h0left" input_r_x_minus_btn = "9" input_right_btn = "h0right" input_right_btn_label = "D-Pad Right" input_state_slot_increase_btn = "h0right" input_r_btn = "4" input_save_state_btn = "4" input_down_btn = "h0down" input_down_btn_label = "D-Pad Down" input_r_y_minus_btn = "7" input_l_btn = "3" input_load_state_btn = "3" input_r_x_plus_btn = "10" input_y_btn = "12" input_x_btn = "2" input_menu_toggle_btn = "2" input_b_btn = "1" input_b_btn_label = "A" input_reset_btn = "1" input_a_btn = "0" 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"
and the working configuration is:
input_device = "N64 Controller" input_driver = "udev" input_vendor_id = "1406" input_product_id = "8217" input_r_y_plus_btn = "10" input_left_btn = "h0left" input_left_btn_label = "D-Pad Left" input_state_slot_decrease_btn = "h0left" input_r_x_minus_btn = "11" input_right_btn = "h0right" input_right_btn_label = "D-Pad Right" input_state_slot_increase_btn = "h0right" input_r_btn = "6" input_save_state_btn = "4" input_down_btn = "h0down" input_down_btn_label = "D-Pad Down" input_r_y_minus_btn = "9" input_l_btn = "5" input_load_state_btn = "3" input_r_x_plus_btn = "12" input_y_btn = "1" input_x_btn = "4" input_menu_toggle_btn = "2" input_b_btn = "3" input_b_btn_label = "A" input_reset_btn = "1" input_a_btn = "2" input_up_btn = "h0up" input_up_btn_label = "D-Pad Up" input_select_btn = "7" input_start_btn = "8" input_exit_emulator_btn = "6" input_enable_hotkey_btn = "7"
D-Pad was working, not working where the other buttons (if you compare, they are +2).
Emulationstation has this
es_input.cfg
:<?xml version="1.0"?> <inputList> <inputAction type="onfinish"> <command>/opt/retropie/supplementary/emulationstation/scripts/inputconfiguration.sh</command> </inputAction> <inputConfig type="joystick" deviceName="N64 Controller" deviceGUID="05001c5e7e0500001920000001800000"> <input name="rightanalogdown" type="button" id="8" value="1"/> <input name="left" type="hat" id="0" value="8"/> <input name="rightanalogleft" type="button" id="9" value="1"/> <input name="right" type="hat" id="0" value="2"/> <input name="pagedown" type="button" id="4" value="1"/> <input name="down" type="hat" id="0" value="4"/> <input name="rightanalogup" type="button" id="7" value="1"/> <input name="pageup" type="button" id="3" value="1"/> <input name="rightanalogright" type="button" id="10" value="1"/> <input name="y" type="button" id="12" value="1"/> <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="5" value="1"/> <input name="start" type="button" id="6" value="1"/> <input name="leftanalogright" type="axis" id="0" value="1"/> <input name="leftanalogup" type="axis" id="1" value="-1"/> <input name="leftanalogdown" type="axis" id="1" value="1"/> <input name="leftanalogleft" type="axis" id="0" value="-1"/> </inputConfig> <inputConfig type="keyboard" deviceName="Keyboard" deviceGUID="-1"> <input name="left" type="key" id="1073741904" value="1"/> <input name="right" type="key" id="1073741903" value="1"/> <input name="down" type="key" id="1073741905" value="1"/> <input name="y" type="key" id="118" value="1"/> <input name="x" type="key" id="99" value="1"/> <input name="b" type="key" id="120" value="1"/> <input name="a" type="key" id="122" value="1"/> <input name="up" type="key" id="1073741906" value="1"/> <input name="select" type="key" id="97" value="1"/> <input name="start" type="key" id="115" value="1"/> </inputConfig> </inputList>
Can you tell me the reason? Is something corrupted after changing from
dkms-hid-nintendo
tohid-nx
-
@mcpat said in Controller input mapping works in Emulation Station but not in emulators:
Emulationstation has this es_input.cfg:
[..]EmulationStation's config is consistent with the (wrong ?) auto-profile, so whatever SDL reports as button numbers it's added to the profile, nothing to do here.
Can you tell me the reason? Is something corrupted after changing from
dkms-hid-nintendo
tohid-nx
Did you re-configure your controller after changing the kernel module ? What does
jstest
reports as button numbers - is it consistent with the wrong configuration or not ? Please add some more info about your setup. -
Yes the config should be consistent with the "wrong" auto-profile.
And yes, I complete re-configure (means deleting all configs, unpair and repair, start from the beginning).
jstest
I can try today evening. My setup is a rpi zero 2w (~rpi3), with latest retropie. I suppose the reason are the buttons BTN_0 and BTN_1 fromhid-nx
if you look there and there. But I could also be wrong. As said, acc. this everything works. Except:- N64 controller the LEDs never stop to rotate even after connecting
- Megadrive controller is not working
So I switched to
hid-nx
, which is working except the autoconfig. -
And yes, I complete re-configure (means deleting all configs, unpair and repair, start from the beginning).
There's no need to delete anything. Please don't do so in the future.
jstest
I can try today evening. My setup is a rpi zero 2w (~rpi3), with latest retropie. I suppose the reason are the buttons BTN_0 and BTN_1 from hid-nx if you look there and there. But I could also be wrong. As said, acc. this everything works. Except:OK, let's see what it outputs. You can also try
evtest
(is not installed by default) and see if it reports different input values.Btw, you shouldn't have opened a Github issue until this issue is cleared here - whether it's a SDL or other component that's generating the wrong inputs. Do note that RetroPie's image has Linux kernel 5.10, while
hid-nx
is tested with5.16
and above. -
@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!
-
PS: please note acc.
hid-nx
I use udev rules99-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"
-
@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 withjstest /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
). -
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
-
@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 onevdev
.jstest
uses the 'legacy' API and enumerates the buttons starting from 0, while theevdev
one seems to start with 2, though it still advertisesBTN_0
andBTN_1
.
SDL (which is used by ES for input processing/mapping) is supposed to use theevdev
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 byevdev
. 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). -
@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!
-
-
@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.
-
@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 fromevdev
?
Now it's a pain to open a ssh connection and do the correction by hand.Thank you for your patience!
-
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).
-
@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). -
@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 :).
-
@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 */ }, };
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.