Vegz78 / McAirpos

MakeCode Arcade games in RetroPie, Recalbox 7/8 and Batocera, running natively as ELF executables on Raspberry Pi OS/Linux ARM with 1-2 gamepads
https://Vegz78.github.io/McAirpos
MIT License
80 stars 10 forks source link

[Zero Delay Encoder] Custom hotkey(edit arcade1&2.py) #37

Closed megabob1985 closed 2 years ago

megabob1985 commented 2 years ago

Hello again, I am getting my arcade machine working perfectly with your code! I just have one issue though, whenever I play my games, I can't exit out with the HOTKEY like the other games on there. Is there a way to do so that I might not have tried yet? Thank you.

Vegz78 commented 2 years ago

(See here for the main Zero Decoder Arcade controller thread...)

Hi and thanks for trying out McAirpos and good to hear it is mostly working on your arcade!

The reason your hotkey is not working for exiting the MakeCode Arcade games is probably because MakeCode is unaware of your controller config in either RetroPie or Recalbox, and instead works and is mapped independently on a much lower level; directly in the raw/Linux Input Subsystem(with some mapping help from uinput-mapper if you did not configure your controller manually).

uinput-mapper’s default arcade1.py mapping config file covers many common gamepads’ button mappings, but since there’s a very wide variety, some gamepads work 100%, others only partly and others again incorrectly or not at all without some edits to this file.

MakeCode Arcade games features an exit button, a restart button and a menu button, which by default for e.g. the PS3 controller is mapped to its start, select and mode(middle) buttons, respectively: https://github.com/Vegz78/McAirpos#default-and-modifying-the-layout-for-controls

What controller are you using and which button on it would you like to work as the hotkey/exit button? (and with which button can you exit the games with now?)

(PS: you could run evtest in the console and press this button to get its EV_KEY code name)

Vegz78 commented 2 years ago

Working now?

megabob1985 commented 2 years ago

Working now?

Sorry for the long wait, I needed to get pictures and I couldn't get them until today. So I want the button on the side to be the HOTKEY. That's what I have set as the HOTKEY on the RECALLBOX menu.

IMG_0906 .

Vegz78 commented 2 years ago

Nice arcade!

Only the one blue button on the left side, or another red button on the right as well?

Please run evtest in the console, press the button(s) and take note of the ev_code(s).

Then replace BTN_START with this ev_code in …/uinput-mapper/configs/arcade1.py (and in arcade2.py if you actually have 2 separate controller devices); https://github.com/Vegz78/McAirpos/blob/df64590049a697f747f81c9220aeeb8bf0da624b/McAirpos/uinput-mapper/configs/arcade1.py#L254

Alternatively, replace it directly with the correct ev scancode number in /sd/arcade.cfg; https://github.com/Vegz78/McAirpos/blob/df64590049a697f747f81c9220aeeb8bf0da624b/McAirpos/MakeCode/sd/arcade.cfg#L15

Translation between EV key and number scancodes here: https://elixir.bootlin.com/linux/v4.6/source/include/uapi/linux/input-event-codes.h

Vegz78 commented 2 years ago

What is the brand/designation of the controller(s) in evtest, by the way? And is it connected by usb or GPIO?

megabob1985 commented 2 years ago

It says DragonRise Inc. Generic USB Joystick. And it is connected by USB. I seem to be having trouble finding the arcade1.py file. Is it supposed to already be on the microSD card when I installed Recalbox and the Makecode arcade ROM? Or am I supposed to add the Zip File from GItHub in there somehow? I'm sorry, I am not experienced at using GitHub and I just need to know where to start.

Vegz78 commented 2 years ago

Ok, thanks! How about the evtest readout EV scancode for the button you want to be Exit/Hotkey on the DragonRise?

arcade1.py(and ..2.py) is located under /home/pi/McAirpos/McAirpos/uinput-mapper/configs/

PS: If you give me the evtest readout for that particular button, I might be able to post a config that works as you would like.

Vegz78 commented 2 years ago

By the way, many generic joysticks are identified with the DragonRise driver/device name. What was the brand/name of the arcade controller kit that you bought?

megabob1985 commented 2 years ago

Right! It's called the Reyann Zero Delay Arcade USB Encoder And both scan codes for both side buttons is 4

megabob1985 commented 2 years ago
Screen Shot 2022-04-04 at 11 26 27 AM Screen Shot 2022-04-04 at 11 26 07 AM Screen Shot 2022-04-04 at 11 26 16 AM

So I'm looking on the card, but I can't find /home/pi/McAirpos/McAirpos/uinput-mapper/configs/ I'm really sorry if the answer is really obvious or something but I am really inexperienced.

Vegz78 commented 2 years ago

Right! It's called the Reyann Zero Delay Arcade USB Encoder And both scan codes for both side buttons is 4

Did the scancodes also have a name, like "BTN_Something"? (e.g. BTN_START)

Vegz78 commented 2 years ago

So I'm looking on the card, but I can't find /home/pi/McAirpos/McAirpos/uinput-mapper/configs/

You need to enter the CLI/console, like you did when you installed McAirpos. You won't find it on the network shared folder, which is in another subdirectory structure away from the root folder /...

megabob1985 commented 2 years ago

Right! It's called the Reyann Zero Delay Arcade USB Encoder And both scan codes for both side buttons is 4

Did the scancodes also have a name, like "BTN_Something"? (e.g. BTN_START)

BTN_BASE2

Vegz78 commented 2 years ago

Hi again,

Please download and replace arcade1.py and arcade2.py in /home/pi/McAirpos/McAirpos/uinput-mapper/configs with these two files in the zip archive and check if the side buttons work as EXIT now: arcade1_2.zip

megabob1985 commented 2 years ago

I DID IT! Thank you so much for your help! You have no idea how much you have helped me!

Vegz78 commented 2 years ago

I DID IT! Thank you so much for your help! You have no idea how much you have helped me!

Glad it worked and thanks for your greatful feedback!

For future reference, if you want to change other buttons:

The clue here was to edit arcade1&2.py of uinput-mapper, which sits and remaps buttons between your controller(s) and the MakeCode Arcade games:

...with the default configuration as shown in this table: https://github.com/Vegz78/McAirpos#default-button-mappings-with-corresponding-ev_abs-and-ev_key-codes

...which in your case was just to change BTN_BASE4 from the default arcade1&2.py files to the value BTN_BASE2 which you got from evtest for your button in question: https://github.com/Vegz78/McAirpos/blob/305cd845c20bc9924a54243984c95b8d27daefac/McAirpos/uinput-mapper/configs/arcade1.py#L282-L285

...which in the field 'code': 1, points to the MakeCode Arcade scancode for Exit(EVCODE=1) in the /sd/arcade.cfg_ file: https://github.com/Vegz78/McAirpos/blob/df64590049a697f747f81c9220aeeb8bf0da624b/McAirpos/MakeCode/sd/arcade.cfg#L15

Happy retro games making and playing! ;-)