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

Home Page:https://Vegz78.github.io/McAirpos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[GamePi20] Dark screen after running game and buttons mapping(detected&working)

marjian88 opened this issue · comments

I have a problem. I have gamepi20 and i would like to run some MakeCode games on it. I installed McAirpos from git as you described: curl -sL https://raw.githubusercontent.com/Vegz78/McAirpos/master/install.sh | bash -

Everything installed fine. But after running game I see dark screen and after about 15 seconds retropie shows game select menu again.

Anyone has the same problem? I tried to running games on built in screen and i connect monitor wiht HDMI and the problem is still occurs.

Thanks for help. I changed chmods for mods folder and every game works. Now i have problem with controler. Don't know how to remap keys. Nomap command on start .elf file don't work but this problem is for other topic.

👍
I have no personal experience in general with DIY arcade controllers, nor specific with the gamepi20.

But there is an issue, unknown if it was solved ultimately, for the gamepi20 here:
#5

And many other solved cases(issue topic starts with controller name in parentheses) concerning similar controllers here:
https://github.com/Vegz78/McAirpos/issues?q=is%3Aissue+is%3Aclosed

Usually, my impression is that you should get the physical wiring correct first, if possible, before starting to play with the rather complex McAirpos config files. Forget that it already works in RetroPie; McAirpos/MCA works on a lower raw and totally independent level of input devices. When it is working for MCA games, it is easy to reconfigure via the menus in RetroPie afterwards.

I have attempted to explain how the controllers work and are set up here:
https://github.com/Vegz78/McAirpos#default-and-modifying-the-layout-for-controls

PS: Since it seems that quite a few people who end up trying McAirpos are people who are building different DIY Arcade machines(I had various console controllers in mind and at home when I started), and since many have bought the GamePi20, it would be great to get a confirmed working example of the GamePi20 in use here. I am therefore interested in helping you as much as I am able, in exchange for that you write a decently detailed summary of how you got it to work afterwards, for others in the community to follow. What do you think?

Any progress on the Gamepi20, or anything I can do to help, @marjian88?

Still didn't make any progress. I was editing config arcade1.py and based on codes from "evtest" tried to remap controler but there was not better. Couple of buttons work, such as Up button works in game as right button, down button works as reset game button. Only right button works fine as it should but after a minute of playing in "Cat Jumper" the games crashes without any error and exits to retropie menu. I tried to replace some key codes in arcade1.py but without any succesful result. In retropie in my menu there is option which can remap the keys bu it only detects GPIO controler. When you run MakeCode application in system appears some kind MakeCode virtual controler but i don't know how to switch on him to remap it on RetroPie.

Thanks for your reply!

I can see that the possibility to rewire physically is difficult, since the controls are GPIO which are connected in a fixed connector between the RPi Zero and Gamepi20. So we can forget this approach.

However, unless you want to become an expert on complex and poorly documented uinput-mapper configs, I would suggest resetting back to the original/default McAirpos configs and continue from the bottom up.

Possibility 1:
There is a driver layer between physical GPIO pins and the Linux Input Subsystem(LIS)(/dev/input/eventX), which determines which GPIO pin/connected button that the driver reports as which LIS events. Seems to be in fbtft.conf file, as described by the Gamepi20 manufacturer. With the tool evtest you can continuously check which button then correspond to which LIS event code and value. When these for each button function correspond to the codes in the rightmost column in this table McAirpos will most probably work as-is.

Possibility 2:
Run McAirpos with nomap argument like @Kay-Wolfe attempted and try to map buttons directly with the EV_KEY codes from evtest. This is the least hardware demanding solution with direct button mappings and no remapping via uinput-mapper. However, there is the problem of getting MC Arcade games to interpret EV_ABS codes, which @Kay-Wolfe seems to solve(but never confirmed) by mapping the joystick’s directions to EV_KEY codes instead. -So this approach would maybe be a combination of Possibility 1 above or @Kay-Wolfe’s edits to /etc/modprobe.d/joystick.conf. There are hints from the Joy Bennet, that EV_ABS joystick events are indeed supported directly in /sd/arcade.cfg, but we still don’t know for certain if or how to map the JOYSTICK_ADDR=0x48 line. Also forget @Kay-Wolfe’s or any connection to the RetroPie/RecalBox controller configs, since this has nothing to do with MC Arcade games on the LIS level, and they can easily be reconfigured for RetroPie in their menus later, when McAirpos works somehow.

Possibility 3:
Configure ../uinput-mapper/configs/arcade1.py. Start with readings from evtest, identify the all event codes and values for each button and joystick direction, and change this accordingly for the input side(e.g. this line for the left-right axis) in the config section of the file, leaving everything else(e.g. /sd/arcade.cfg) alone with default content from a fresh installation of McAirpos.

Regarding games suddenly quitting, for me it is mostly a symptom of games receiving the exit command somehow unintentionally(bad connection in some old and worn PS3 controllers, or redundant inputs close to used buttons in arcade1.cfg), or maybe uinput-mapper is a bit too demanding for the RPi Zero. Anyhow, this might be optimized later, as soon as you get everything to play together ok:
https://github.com/Vegz78/McAirpos#optimizing-controller-performance

(sorry if my support does not hit precisely the mark, but I don’t have this equipment myself and cannot tinker and test directly. But I am sure we can manage together, and it would also be of great help to others with the GamePi20. Could you please upload the first screen from evtest here, before pressing any buttons?)
(JOYSTICK_ADDR does not seem to be the right approach yet: https://forum.makecode.com/t/help-with-raspberry-pi-0-download/6018/6?u=vegz78)

Could you please provide a copy of your evtest readout? Best for me to help if you mark on the readout which EV code is which button on the GamePi20.

From a similar readout from @Kay-Wolfe, the GamePi20 should be recognized(BTN_START&BTN_SOUTH), and at least BTN_SOUTH, BTN_B, BTN_START, BTN_SELECT, ABS_X(left-right) and ABS_Y(up-down) should be mapped on fresh install of McAirpos.
#5 (comment)

What do you see?

PS: The makecode virtual controller is uinput-mapper at work.

Sorry for late answer, but I just came back from summer holidays. Here is my log from evtest: https://photos.app.goo.gl/6XqySmZCNv6a9j9V6

The keys are:
code 59 left arrow button <-
code 32 right arrow button ->
code 30 up arrow button ^
code 1 down arrow button v
code 42 is the B button - right button on the right side of gamepi20
code 29 is the Y button - upper button on the right side of gamepi20
code 31 is the start button(on the right side of gamepi20)
code 17 is the select button(on the left side of gamepi20)

The rest buttons are not responding on evtest.

evtestlog

No worries and thanks for the log! Hope you had a nice summer holiday.

We're getting closer, but it looks like you chose "device event number" 1, which is the remapped "UInput_mapper MakeCode_Arcade" device.

Could you please do the same for "/dev/input/event0" - "GPIO Controller 1", so that I get the full picture of the direct physical controller device instead?:
evtest /dev/input/event0

Seems to be a slightly unusual default setup for the GamePi20, but based on button codes for /dev/input/event0, we should be able to get the GamePi20 to work with only "/sd/arcade.cfg" and launCharc with the nomap argument.

OK, Here is the log from GPIO:
evtest1
evtest2

The strange thing is that in the log is that left arrow button is prompted as BTN_SELECT, up arrow is ABS_X, right arrow is also ABS_X and the down arrow is BTN_START, Trigger right is BTN_TL so is not correct, Trigger left button is BTN_NORTH. Something is really wrong. But in other emulators, such as gameboy, everything works fine.

The strange thing is that in the log is that left arrow button is prompted as BTN_SELECT, up arrow is ABS_X, right arrow is also ABS_X and the down arrow is BTN_START, Trigger right is BTN_TL so is not correct, Trigger left button is BTN_NORTH. Something is really wrong. But in other emulators, such as gameboy, everything works fine.

Yeah, the GamePi20 device and/or driver has a highly unusual compliance to the "standard". But, then again, a button is just a button, and a name/code is just a name, which can be mapped however you like. That's why RetroPie lets you through this button mapping routine on every installation/newly connected controller, and why you experience that the controller works ok in all the other emulators in RetroPie/Retroarch.

But, as soon as we have the full picture, we can map the GamePi20's buttons manually likewise in MakeCode Arcade games, as well!

Please run evtest /dev/input/event0 again and fill in the missing EV_Codes from the table below for the GamePi20's A button, B button, X button, Y button, Start button and Select button, and whether the ABS_X values are positve or negative for the GamePi20's Right arrow and Up arrow, respectively.

GamePi20 button EV_Code EV_Value
Left arrow BTN_SELECT n/a
Right arrow ABS_X +1
Up arrow ABS_X -1
Down arrow BTN_START n/a
A button BTN_TR n/a
B button BTN_EAST n/a
X button BTN_WEST n/a
Y button BTN_SOUTH n/a
Start button ABS_Y +1
Select button ABS_Y -1
Trigger left BTN_NORTH n/a
Trigger right BTN_TL n/a

Here you go:
Left arrow BTN_SELECT n/a
Right arrow ABS_X positive
Up arrow ABS_X negative
Down arrow BTN_START n/a
A button BTN_TR n/a
B button BTN_EAST n/a
X button BTN_WEST n/a
Y button BTN_SOUTH n/a
Start button ABS_Y positive
Select button ABS_Y negative
Trigger left BTN_NORTH n/a
Trigger right BTN_TL n/a

Great! Give me some time, and I’ll put together a config file for you to test. Hopefully, we’re very close to a working solution now.

It's ok. Thanks for help. I can wait. I have also Tinkergen GameGO, so i have a quick test platform for makecode.

Allright @marjian88,

I am unable to test this file where I am at the moment, but I've tried to configure it according to the table above. Could you please download this file, rename it to arcade1.py and replace /home/pi/McAirpos/McAirpos/uinput-mapper/configs/arcade1.py with it?:
https://github.com/Vegz78/McAirpos/raw/master/McAirpos/uinput-mapper/configs/examples/arcade1.py_GamePi20
(or copy all its contents and replace everything in your current /home/pi/McAirpos/McAirpos/uinput-mapper/configs/arcade1.py)

Keep the original/default /sd/arcade.cfg as-is and run McAirpos without the nomap option.

Hope it works for you and looking forward to hearing back from you!

Now everything works fine. Really good job, thanks.

Your welcome, and thanks for helping out solving for the popular GamePi20!

A better solution would probably be to remap the GPIO to only EV_KEY event codes in the Waveshare config file, so that we did not need the uinput-mapper remapping. I have sent them a mail about the unusual mappings in the table above.

All working ok and stable now, @marjian88? I got a mail mentioning missing exit and reset buttons etc., a little different than your last message above… ;-)

If everything is working satisfactory, a star for the repo would be appreciated!

Yes at first i think that something is wrong because when i push start button the game freezes for 2 seconds and after that exits to retropie menu. And the same with reset button.

Yes at first i think that something is wrong because when i push start button the game freezes for 2 seconds and after that exits to retropie menu.

This sounds about right, as McAirpos uses a couple of seconds to ensure that all game processes are killed before returning to RetroPie.

And the same with reset button.

The reset button should only restart the game, while I think I mapped the left shoulder/trigger button to the “menu” function.

Do I need to make some small adjustments? How about game play? Games aren’t suddenly quit/shut down during game play any more?

Thanks for the star! ;-)

I played only a few games like "cat jumper" and "falling duck" and everything works fluently and stable.

Closing this issue, as McAirpos is confirmed working with the uinput-mapper configuration as mentioned here with instructions and download link:
#18 (comment)

A possibly better approach - only using the MCA games' _/sd/arcade.cfg directly and without the need for uinput-mapper - might be to configure the GamePi20 driver configuration to adhere more to the Linux Subsystem event button standard and the button keys McAirpos expects, as described earlier by @Kay-Wolfe and as suggested by the Waveshare Service Team:
image

Thanks, @marjian88 for your testing, feedbacks and patience!