Closed Kay-Wolfe closed 2 years ago
Hi @Kay-Wolfe,
With reference to issue https://github.com/Vegz78/McAirpos/issues/3, I was sadly a little naive when I just before Christmas wanted to share working code based on my PS3 Controllers, which were the only controllers I had at hand at that moment. I turns out that the PS3 controller's RAW "DPAD" key events were not at all so universally used on other gamepads as I thought. Having ordered and just received a couple of new controllers, I'm currently working on some thoughts on a solution that supports more controllers out of the box AND let's the users configure it more freely(which at the moment unfortunately is hardcoded together with the autodetection of (PS3)controllers and blocks the edits of the arcade.py mapping files).
Thank you very much for your input above, and what would be very helpful for my soon to come fix is if you could please provide me with the RAW event info which both the game elf files and McAirpos launcher and ui-mapper uses for controllers?:
evtest
or run more /proc/bus/input/devices
/home/pi/McAirpos/McAirpos/uinput-mapper/input-read -v -p /dev/input/eventX
)This would be of great help to me for making a fix(and amends for, in retrospect, a little premature advertising...) sooner.
Hope to hear back from you again soon with the requested information.
Br, Vegard
PS: The more such copies of such key layouts as in point 2 above I get, for as many different controllers as possible, the more generic patterns and solutions I expect to find. If others could contribute, too, I would really appreciate it. ;-)
Hey there,
Here's the info you've requested
more /proc/bus/input/devices
I: Bus=0015 Vendor=0001 Product=0005 Version=0100
N: Name="GPIO Controller 1"
P: Phys=input0
S: Sysfs=/devices/virtual/input/input2
U: Uniq=
H: Handlers=js0 event2
B: PROP=0
B: EV=b
B: KEY=fff0000 0 0 0 0 0 0 0 0 0
B: ABS=3
/home/pi/McAirpos/McAirpos/uinput-mapper/input-read -v -p /dev/input/event2
pi@retropie:/etc/udev/rules.d $ /home/pi/McAirpos/McAirpos/uinput-mapper/input-read -v -p /dev/input/event2
Input: 0 Type: EV_KEY
BTN_SOUTH → ([0, EV_KEY], BTN_SOUTH)
BTN_B → ([0, EV_KEY], BTN_B)
BTN_C → ([0, EV_KEY], BTN_C)
BTN_X → ([0, EV_KEY], BTN_X)
BTN_Y → ([0, EV_KEY], BTN_Y)
BTN_Z → ([0, EV_KEY], BTN_Z)
BTN_TL → ([0, EV_KEY], BTN_TL)
BTN_TR → ([0, EV_KEY], BTN_TR)
BTN_TL2 → ([0, EV_KEY], BTN_TL2)
BTN_TR2 → ([0, EV_KEY], BTN_TR2)
BTN_SELECT → ([0, EV_KEY], BTN_SELECT)
BTN_START → ([0, EV_KEY], BTN_START)
Input: 0 Type: EV_ABS
ABS_X → ([0, EV_ABS], ABS_X)
Properties: Max: 1 Min: -1 Fuzz: 0 Flat: 0
ABS_Y → ([0, EV_ABS], ABS_Y)
Properties: Max: 1 Min: -1 Fuzz: 0 Flat: 0
Additional info:
The hat uses https://github.com/waveshare/mk_arcade_joystick_rpi joystick driver. With the config for Gamepi20 (/etc/modprobe.d/joystick.conf
):
options mk_arcade_joystick_rpi map=5 gpio=16,26,12,13,20,21,17,4,23,22,5,6
Running their test tool jstest /dev/input/js0
pi@retropie:/etc/modprobe.d $ jstest /dev/input/js0
Driver version is 2.1.0.
Joystick (GPIO Controller 1) has 2 axes (X, Y)
and 12 buttons (BtnA, BtnB, BtnC, BtnX, BtnY, BtnZ, BtnTL, BtnTR, BtnTL2, BtnTR2, BtnSelect, BtnStart).
Testing ... (interrupt to exit)
Axes: 0: 0 1: 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
Thank you very much, @Kay-Wolfe!!!
Hey there,
I'm not familiar with C (webdev here). But digging around I see this code
if (numberOfPads == 0) {
strcat(defaultEvent, tempString);
defaultEvent[strlen(defaultEvent)-1] = 0;
}
snprintf(sedCommand, 100, "sed -i \"1s&.*&\"%s\"&\" /sd/arcade.cfg", defaultEvent);
It seems like your code forced to change the /sd/arcade.cfg to 0, when no gamepad is detected. GPIO based like mine slips the check. (p/s I think the strlen -1 thing is a bug waiting to happen with > 9 item).
So what I did for now is:
event2
options mk_arcade_joystick_rpi map=5 gpio=17,22,5,6,26,16,21,13,4,20,12,23
(if anyone using this device is googling)/sd/arcade.cfg
with new button layoutGreat work, @Kay-Wolfe!
You are right about a number of things here.
...grep...’DPAD’...
to e.g. BTN_START
which increases the number of controllers detected, should also discover yours(I have already done this at home and can commit for you to test).But your workaround here should do the trick for now, and I will include it right away, so that we at least have increased working gamepad support from only PS3 controllers(and clones) to all rewireable arcade gamepads as well.
Could you please upload your arcade1.py config file here, which I hope to include in the repo?
My hope is to collect and make different config files for different gamepad types, which then easily can be customized and copied over the arcadeX.py files by the users.
Thanks for your help and what do you think?
UPDATE: Had a eureka moment here just now, when I discovered a way to solve the uinput-mapping from EV_ABS to EV_KEY in both directions, by reading the same eventX input twice and mapping negative and postive axis values seperately to different keys on the same output device.
Hopefully it will work also for your controller, without the need to rewire physically and remap buttons in RetroPie, when I just figure how to implement this with the least amount of possible mess.
yep EV_ABS to EV_KEY seems to be a pain. Which is why I abandoned uinput-mapper.
Users of :
My driver config (/etc/modprobe.d/joystick.conf):
options mk_arcade_joystick_rpi map=5 gpio=17,22,5,6,26,16,21,13,4,20,12,23
which will map X and Y axis away from any buttons for arcade (to R1, L1, X and Y)
SCAN_CODES=/dev/input/event0
BTN_LEFT=304
BTN_RIGHT=305
BTN_UP=307
BTN_DOWN=308
BTN_A=311
BTN_B=310
BTN_RESET=0
BTN_EXIT=314
BTN_MENU=315
BTN_RESET=0
note: I removed my debugging keyboard so it's event0 now.
During my struggle I found:
BTN_A=12,16
BTN_B=6,13
BTN_MENU=20
BTN_EXIT=22,23
BTN_RESET=26
JOYSTICK_ADDR=0x48
I'm not sure whether that works with elf's arcade.cfg.
My opinion: Maybe set an arg in the launcher to skip the input remapping for the tinkerers. Thanks for your hard work 😊
My opinion: Maybe set an arg in the launcher to skip the input remapping for the tinkerers. Thanks for your hard work
Thanks for all your help and tips, @Kay-Wolfe!
I've added the "nomap" argument you requested, so that you can skip auto-detection and -setup of controllers and manually use /sd/arcade.cfg directly with the elf game files instead.
I have also expanded and tested successfully autoconf and EV_ABS to EV_KEY mapping with uinput-mapper on a range of new controllers, which I would really appreciate if you also could test and confirm if it works with your GamePi20 controller(I hope) without the rewirings and remappings you were forced to do earlier.
I will then close this issue in a few days, if there are no unresolved related things pending.
I think I have a similar problem, with EG Start Arcade setup
I think I have a similar problem, with EG Start Arcade setup
Hi @lars-derichter, I have replied and moved your post to a new issue
I think we're overcomplicating the joypad situation.
/opt/retropie/configs/all/retroarch-joypads/[joypad name].cfg
A uinput-remapper replacement (or launcharc itself) that would:
/opt/retropie/configs/all/retroarch-joypads/
arc_player = 1
and arc_device = 0 (jsid)
Which will probably covers most use case, with minor config change (jsid and player num above)
I think we're overcomplicating the joypad situation.
You're probably right... Did you ever, with the new nomap
option, figure out how to set up a joystick directly in "one of the arcade.cfg included (the bonnet one) that you found?
I'm thinking about simplifying the uinput mapping for a 2nd/2 player controller to a fixed main 1 player controller in /sd/arcade.cfg, now that it is possible to auto-map without keyboard connected. There is some occasional instability, which might be caused by certain keyboard key combinations and/or heavy arcadeX.py mapping functions.
- Retropie/retroarch is using the linux joypad api https://www.kernel.org/doc/Documentation/input/joystick-api.txt The number on jstest sync up with cfg below
- And saved the config @
/opt/retropie/configs/all/retroarch-joypads/[joypad name].cfg
- uinput-mapper and arcade ELF uses device event which causes all this confusion
A uinput-remapper replacement (or launcharc itself) that would:
- Parse all cfg in
/opt/retropie/configs/all/retroarch-joypads/
- Look for settings we ask user to add during install like
arc_player = 1
andarc_device = 0 (jsid)
- Map/simulate keyboard presses based on those.
Which will probably covers most use case, with minor config change (jsid and player num above)
Great inputs, and I agree that there are still room for improvements and simplifications, and hopefully reuse of some existing solutions. I've been under the impression that the MakeCode Arcade elf game files have been locked to digital EV_KEY buttons, but if the bonnet arcade.cfg works, and works with EV_ABS, a lot would be much easier.
With the most recent reorganizations of the launCharc code, the uinput-mapper part is more or less a self contained module, which quite easily and with another option argument can be supplemented with with your parser idea here, or maybe one of the mappers you mentioned in your earlier comments.
At the moment, though, I need a small brake before I can start with bigger new ideas, and I would like to see if the increased flexibility with the namap
option solves some use cases, and whether I can(or definitely can not) get adequate controller support, stability and customizability through the existing uinput-mapper route.
But, if you have a working prototype for your idea(s), I would gladly have a look at it/accept a pull-request to incorporate it as an additional/optional module.
Thanks for your support and thorough efforts!!!
Hi @Kay-Wolfe,
Did you get your GamePi20 controller to work?
Closed due to missing response from @Kay-Wolfe. Unconfirmed whether the GamePi20 controller works or not.
Please update if you have new info regarding the GamePi20.
Hi @Kay-Wolfe,
It seems, with similar suggestions by the Waveshare Service Team, that your described attempt here with only using /sd/arcade.cfg, the nomap
option and remapping the GamePi20 driver GPIO button sequence itself should be working:
https://github.com/Vegz78/McAirpos/issues/5#issuecomment-760950633
However, there was a new attempt with the GamePi20, which has been confirmed to work with a special uinput-mapper arcade1.py configuration file, here: https://github.com/Vegz78/McAirpos/issues/18
I have GamePi20 kit and retropie and McAirpos is running perfectly on that. I only have trouble configuring the buttons for it. On my
/opt/retropie/configs/all/retroarch-joypads/GPIO Controller 1.cfg
:how do I translate this into McAirpos? i've tried changing
arcade.dfg.controller
.ps: my son made this to help me out https://makecode.com/_00RXmREYfK9q