key events using udev are not reckognized
-
Image: retropie 4.0 or also retropie 4.3
target: compute module 1 or compute module 3
device: selfmade portable battery powered retropie device with TFT display and custom keys
problem: keys reach emulationstation but dont reach retroarchHello!
I use the standard linux "udev", like
fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
to feed my key events into the system.A USB hub is connected to the USB and to it I connected a USB keyboard and a USB ethernet adapter for remote access.
I start emulationstation with the keyboard and I can navigate with my own custom keys on my portable device. I choose a game for "lr-mame2003" and in the game no reaction on key presses. My USB keyboard works perfect so I quit with my USB keyboard and can navigate again in the ES with my custom keys. Launching any retroarch / libretro causing again no key inputs.
I found out, that if I do the following it works:
- start emulationstation
- navigate with "my" custom keys and start any libretro game (e.g. lr-mame2003)
- wait, until the game has started
- now my keys do not work any more (the USB keyboard does however)
- now I restart my "udev, key event daemon" like "sudo ./myrasp &" per remote shell
- suddenly I can control the game without any problem
- exit the game
- back in ES I start the game again
- again no reaction on key presses
- restart my key daemon, everything working, and so on........
So I came to the workaround to put the following into
/opt/retropie/configs/all/runcommand-onstart.shsudo pkill myrasp
sudo /home/pi/myrasp &
("myrasp" ist the name of my key input daemon)With this, it seems to work, because everytime the game starts the startup script kills the key daemon and restarts it.
Somehow this solution feels really bad so I wonder if I just missed to edit an entry in one of the configuration files.
So emulationstation sees the "udev" input events, retroarch (libretro?) does not (by the way: DOSBOX sees the key strokes...)
What I can also say (but I am not sure if it is useful but take it as a second question):
Retroarch says: "INFO: failed to set keyboard mode" when starting. Anyone knowing what that means?
(By the way, there is no entry in the "dev/shm/runcommand.log")I hope my description was not too confusing, anyway thanks for reading.
-
@alex said in key events using udev are not reckognized:
Retroarch says: "INFO: failed to set keyboard mode" when starting. Anyone knowing what that means?
You could look in the source code, it's available at github.com/libretro/retroarch. Probably you custom keyboard daemon does not implement a keyboard driver so it does not appear as a standard keyboard in Linux. How did you connect the buttons to the board ?
-
The buttons are connected in a matrix, two GPIOs select with a decoder "one out of four" lines, four lines are used as scan lines (so 16 buttons altogether). Can it be that emulationstation accepts a driver that retroarch does not accept?
Minutes ago I just implemented a "restart" functionality as a test: If a certain key (here it is raw key 6) is pressed, the following happens:
if (key== 6)
{
fprintf(stderr,"restart myrasp...\n");
ioctl(fd, UI_DEV_DESTROY);
close(fd);
Keys_Init();
}So the game is launched, keys do not work, I press the restart key "6" and everything works fine!
But again that cannot be a solution :-( -
@alex ES uses SDL for input handling, RA might be using
udev
default. You can try to switch RA to use thesdl
driver (input_driver=sdl
), but IMHO is not an elegant solution.
If you're using GPIO pins - look into the GPIO joystick drivers - they're included in Linux and provide gamepad emulation directly. -
Thank you for your suggestions.
What I cannot understand is why the things work with just a restart of the daemon after the game was launched. I havent changed something in a config file, I did not change my source or driver, just restart et voila!Here the last lines of the dmesg lines, just in case it points someone to a solution. One can see the restarts of the key daemon, probably not very helpful
[ 1943.989371] input: myrasp-uinput as /devices/virtual/input/input22
[ 1967.998192] input: myrasp-uinput as /devices/virtual/input/input23
[ 2005.033208] input: myrasp-uinput as /devices/virtual/input/input24I will have a look at what you said.
Very nice would be an "example" where somebody is using "udev" (uinput) like I do with success.
This 20 lines example would just open a virtual input device and send a "5" every lets say 10 seconds. The test then is:
Start ES with USB keyboard, start the example via SSH, in ES navigate with the USB keyboard to any "lr-mame2003" game, start the game and wait for the "coin in" event with receiving the next "5".
I say it will not happen. Now do nothing but restart the example and suddenly the coin is in!This should also be very easily reproducible.
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.