Controller input mapping works in Emulation Station but not in emulators
-
@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.