-
AuthorPosts
-
Hi all,
I use adafruit script retrogame.c to map gpio pins to emulate keyboard. It seems that raspbian (retropie image 2.2 from emulationstation site) and mame4all recognise the inputs, emulationstation not. Any hint? I noticed that snesdev is in status off and it’s ok… i use arcade controls connecting pin to ground. While configuring I noticed that only one time emulationstation recognised a gpio pin for menu up, seems something in conflict…I have the same problem as you. I asked Aloshi (creator of EmulationStation) on the Raspberry Pi Forums and this is what he said:
This probably has to do with the change from SDL 1.2 to SDL 2. SDL2 uses evdev for input handling (in the console in the Pi). I don’t remember what SDL 1.2 uses. Not much I can do about this, sorry.
Oh, bad news here!
This is the code I used:https://github.com/adafruit/Adafruit-Retrogame/blob/master/retrogame.c
How did you resolve the problem?
ChanchaiGuest07/10/2014 at 17:47Post count: 908I use gpio pin to emulate keyboard.
I use python language for programing.On RetroPie 1.9. I use python-uinput module. It work fine.
On RetroPie 2.x The python-uinput module is not work.I solve this problem. I use python-evdev module. It work fine.
I think. uinput is not work on RetroPie 2.x.
Maybe libevdev is work on RetroPie 2.x.Python-evdev Module
https://pythonhosted.org/evdev/Source code
https://github.com/gvalkov/python-evdevExample Code
I use gpio pin 24 for ESC Keyboard for exit game#!/usr/bin/python import time from evdev import UInput, ecodes as e import RPi.GPIO as GPIO # GPIO PIN pin_esc = 24 ui = UInput() # Bools to keep track of movement key_esc = False GPIO.setmode(GPIO.BCM) GPIO.setup(pin_esc, GPIO.IN, pull_up_down = GPIO.PUD_UP) try: while True: if (not key_esc) and (not GPIO.input(pin_esc)): key_esc = True #print("Button Pressed"); ui.write(e.EV_KEY, e.KEY_ESC, 1); # KEY_ESC down #ui.write(e.EV_KEY, e.KEY_F4, 1); # KEY_F4 down ui.syn() if (key_esc) and (GPIO.input(pin_esc)): key_esc = False #print("Button Released"); ui.write(e.EV_KEY, e.KEY_ESC, 0); # KEY_ESC up #ui.write(e.EV_KEY, e.KEY_F4, 0); # KEY_F4 up ui.syn() time.sleep(0.3); except KeyboardInterrupt: ui.close() GPIO.cleanup()
Does the python script take up more processing power?
The only other solution I can think of is to hook the buttons up to a Teensy.
ChanchaiGuest07/10/2014 at 18:31Post count: 908Please try to modify code of retrogame.c with libevdev.
libevdev : http://www.freedesktop.org/wiki/Software/libevdev/
Maybe it can solve your problem.
MicroByteGuest07/11/2014 at 01:52Post count: 908Any luck from anyone getting controls to work? This is a shame since I just finished building a new controller into my Gameboy mod that works outside of ES.
Is there anyway to run an older version of ES until the issue is resolved or a workaround is found?
In the meantime, is there a way to launch the emulators directly from the command line maybe?
I’m using mame4all-pi as emulator and It’s autoloaded via the /etc/profile file. Just changed “emulationstation” with “/…??/emulators/mame4all-pi/mame”
I wrote to retrogame.c programmer asking for help.
[quote=14017]#!/usr/bin/python
import time
from evdev import UInput, ecodes as e
import RPi.GPIO as GPIO# GPIO PIN
pin_esc = 24ui = UInput()
# Bools to keep track of movement
key_esc = FalseGPIO.setmode(GPIO.BCM)
GPIO.setup(pin_esc, GPIO.IN, pull_up_down = GPIO.PUD_UP)
try:
while True:
if (not key_esc) and (not GPIO.input(pin_esc)):
key_esc = True
#print(“Button Pressed”);
ui.write(e.EV_KEY, e.KEY_ESC, 1); # KEY_ESC down
#ui.write(e.EV_KEY, e.KEY_F4, 1); # KEY_F4 down
ui.syn()if (key_esc) and (GPIO.input(pin_esc)):
key_esc = False
#print(“Button Released”);
ui.write(e.EV_KEY, e.KEY_ESC, 0); # KEY_ESC up
#ui.write(e.EV_KEY, e.KEY_F4, 0); # KEY_F4 up
ui.syn()time.sleep(0.3);
except KeyboardInterrupt:
ui.close()
GPIO.cleanup()[/quote]the Python script is considering rebounce as in retrogame did you try with a “shot” button?
Maybe someone could mix snesDEV with retrogame… Any c programmer here?
bolchGuest07/13/2014 at 23:58Post count: 908Found this thread while looking for the same problem
Today I pulled apart a Dreamcast Arcade Stick with the intention of putting a Pi inside running Retro Pi.
After plugging the buttons into the GPIO ports, I used Retrogame as mentioned above to configure the keyboard buttons.
Works perfect in the emulators, just doesn’t work in the launcher :-(
I think the solution is quite simple, but we need a c or python script traslating from gpio to evdev, and someone who can write it. I think emulationstation programmer is not really interested on the problem because there is a gpio adapter we can buy on the site to connect retro joystick. So we have to find a solution by ourselves…
ChanchaiGuest07/15/2014 at 05:04Post count: 908I try to create simple python code.
I don’t have gpio joystick
#!/usr/bin/python import time from evdev import UInput, ecodes as e import RPi.GPIO as GPIO # GPIO PIN pin_esc = 24 pin_left = 25 pin_right = 9 pin_up = 10 pin_down = 17 pin_leftctrl = 23 pin_leftalt = 7 ui = UInput() # Bools to keep track of movement key_esc = False key_left = False key_right = False key_up = False key_down = False key_leftctrl = False key_leftalt = False GPIO.setmode(GPIO.BCM) GPIO.setup(pin_esc, GPIO.IN, pull_up_down = GPIO.PUD_UP) GPIO.setup(pin_left, GPIO.IN, pull_up_down = GPIO.PUD_UP) GPIO.setup(pin_right, GPIO.IN, pull_up_down = GPIO.PUD_UP) GPIO.setup(pin_up, GPIO.IN, pull_up_down = GPIO.PUD_UP) GPIO.setup(pin_down, GPIO.IN, pull_up_down = GPIO.PUD_UP) GPIO.setup(pin_leftctrl, GPIO.IN, pull_up_down = GPIO.PUD_UP) GPIO.setup(pin_leftalt, GPIO.IN, pull_up_down = GPIO.PUD_UP) try: while True: if (not key_esc) and (not GPIO.input(pin_esc)): key_esc = True ui.write(e.EV_KEY, e.KEY_ESC, 1); ui.syn() if (key_esc) and (GPIO.input(pin_esc)): key_esc = False ui.write(e.EV_KEY, e.KEY_ESC, 0); ui.syn() if (not key_left) and (not GPIO.input(pin_left)): key_left = True ui.write(e.EV_KEY, e.KEY_LEFT, 1); ui.syn() if (key_left) and (GPIO.input(pin_left)): key_left = False ui.write(e.EV_KEY, e.KEY_LEFT, 0); ui.syn() if (not key_right) and (not GPIO.input(pin_right)): key_right = True ui.write(e.EV_KEY, e.KEY_RIGHT, 1); ui.syn() if (key_right) and (GPIO.input(pin_right)): key_right = False ui.write(e.EV_KEY, e.KEY_RIGHT, 0); ui.syn() if (not key_up) and (not GPIO.input(pin_up)): key_up = True ui.write(e.EV_KEY, e.KEY_UP, 1); ui.syn() if (key_up) and (GPIO.input(pin_up)): key_up = False ui.write(e.EV_KEY, e.KEY_UP, 0); ui.syn() if (not key_down) and (not GPIO.input(pin_down)): key_down = True ui.write(e.EV_KEY, e.KEY_DOWN, 1); ui.syn() if (key_down) and (GPIO.input(pin_down)): key_down = False ui.write(e.EV_KEY, e.KEY_DOWN, 0); ui.syn() if (not key_leftctrl) and (not GPIO.input(pin_leftctrl)): key_leftctrl = True ui.write(e.EV_KEY, e.KEY_LEFTCTRL, 1); ui.syn() if (key_leftctrl) and (GPIO.input(pin_leftctrl)): key_leftctrl = False ui.write(e.EV_KEY, e.KEY_LEFTCTRL, 0); ui.syn() if (not key_leftalt) and (not GPIO.input(pin_leftalt)): key_leftalt = True ui.write(e.EV_KEY, e.KEY_LEFTALT, 1); ui.syn() if (key_leftalt) and (GPIO.input(pin_leftalt)): key_leftalt = False ui.write(e.EV_KEY, e.KEY_LEFTALT, 0); ui.syn() time.sleep(0.3); except KeyboardInterrupt: ui.close() GPIO.cleanup()
WilsonGuest07/17/2014 at 00:59Post count: 908I am also having the same issue. I just finished building a Porta-Pi that uses RetroPie 1.9.1 and I was hoping to upgrade to 2.2 but this definitely looks like a show stopper. Any luck with the retrogame.c developer?
No response at all.
WilsonGuest07/17/2014 at 16:55Post count: 908Ok, I also opened a ticket on Github in hopes to make the programmer aware of the challenge and maybe incorporate the changes in a future version…soon! :) The new version of RetroPie looks really nice and would love to upgrade to it.
WilsonGuest07/18/2014 at 23:40Post count: 908Confirmed working!
Many thanks to CrazySpence for his work!If you’re looking for the SDL2 folder, it’s in /opt/retropie/supplementary.
EDIT: works in ES but not for Retroarch. It might need to be recompiled again or something.
bolchGuest07/19/2014 at 16:25Post count: 908How do I get the new SDL to work? I downloaded it from github (https://github.com/CrazySpence/Adafruit-Retrogame) copied the new SDL_udev.c to /opt/retropie/supplementary/SDL-2.0.1/src/core/linux/ and restarted emulation station but it didn’t work
Is there something else I need to do (like Make), if so can you point this noobie in the right direction? Thanks
Bolch: You have to run “make” and “make install” for it to run.
I still haven’t gotten Retroarch to work, however (but it worked in 1.9.1). Does it use SDL2 as well?bolchGuest07/19/2014 at 20:35Post count: 908Thanks nbonaparte, worked perfectly after running make & make install in the SDL directory.
I found this (https://github.com/libretro/RetroArch/issues/799) which seems to suggest Retroarch it’s using SDL2
Putting my project on hold for the next couple of days as I’ve just bought the B+ so hoping there’s a fix by then
Great, thanks all
Do the controls on the RetroArch emulators (NES, Atari 2600, PSX, Mega Drive, etc.) work for you?
Marv2.0Guest07/20/2014 at 21:19Post count: 908hi guys, could give me a hand? Here’s what i’ve so far:
– downloaded SDL2-2.0.3, extracted and copied it to my home directory (/pi/SDL2-2.0.3)
– copied CrazySpence’s SDL_udev.c into /src/core/linux (overwrote the original one)
– run “make” or “sudo make” from the /pi/SDL2-2.0.3 and get this error:pi@raspberrypi ~/SDL2-2.0.3 $ make install
make: *** No rule to make target `install’. Stop.i also tried “make” from /src/core/linux, but I get the same error. Do i need to copy a makefile somewhere?
Thanks all.
Marv2.0Guest07/20/2014 at 21:24Post count: 908I copied the wrong error above. here’s the correct error when i type “make” inside SDL2-2.0.3
pi@raspberrypi ~/SDL2-2.0.3 $ make
make: *** No targets specified and no makefile found. Stop.You don’t download SDL 2.0.3. You use the one in /opt/retropie/supplementary and “make” and “make install” there.
Marv2.0Guest07/21/2014 at 05:29Post count: 908Thank you for your reply.
I did what you suggested, but I’m still getting errors. Below are all the different variations of “make” I tried. Any suggestions?
pi@raspberrypi /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux $ ls
SDL_udev.c SDL_udev.hpi@raspberrypi /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux $ make
make: *** No targets specified and no makefile found. Stop.pi@raspberrypi /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux $ make SDL_udev.c
make: Nothing to be done for `SDL_udev.c’.pi@raspberrypi /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux $ sudo make SDL_udev.c
make: Nothing to be done for `SDL_udev.c’.pi@raspberrypi /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux $ sudo make
make: *** No targets specified and no makefile found. Stop.Thank you again.
Do the controls on the RetroArch emulators (NES, Atari 2600, PSX, Mega Drive, etc.) work for you?
Sorry I didn’t try yet. I can suppose not, also for me.
You have to look for a file named Makefile.. I can’t verify now the exact position..
To clear everything up, here are the commands in order (after transferring SDL_udev.c):
cd /opt/retropie/supplementary/SDL2-2.0.1 sudo make sudo make install
Marv2.0Guest07/21/2014 at 18:42Post count: 908Thanks again… I was running make inside the linux folder. So now that I’m running it from the correct folder (/opt/retropie/supplementary/SDL2-2.0.1/) I get further…although I’m not successful just yet :)
I copied the SDL_udev.c from CrazySpence’s github and WinSCP it to /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux. I then ran the make command from /opt/retropie/supplementary/SDL2-2.0.1/ and get a bunch of errors like the below. I think I’m just going to get a keyboard encoder and attach the joystick hardware via USB…that being said if you guys feel good about giving me a helping hand on what all these errors may mean, I would greatly appreciate it! Thanks in advance.
*I didn’t copy/paste the entire error output*
/opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:69988: warning: multi-character character constant [-Wmultichar] /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:69998: warning: character constant too long for its type [enabled by default] /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:70047: warning: multi-character character constant [-Wmultichar] /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:70057: warning: character constant too long for its type [enabled by default] /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:70082: error: expected identifier or '(' before '<' token /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:70106: warning: multi-character character constant [-Wmultichar] /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:70116: warning: character constant too long for its type [enabled by default] /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:70146: warning: multi-character character constant [-Wmultichar] /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:70156: warning: character constant too long for its type [enabled by default] /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:70186: warning: multi-character character constant [-Wmultichar] /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:70196: warning: character constant too long for its type [enabled by default] /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:874:70082: error: stray '#' in program /opt/retropie/supplementary/SDL2-2.0.1/src/core/linux/SDL_udev.c:917:18: error: expected identifier or '(' before numeric constant make: *** [build/SDL_udev.lo] Error 1
In RetroPie 2.3, the SDL 2.0.1 folder is gone and there is no SDL_udev.c, so this hack fix might not work anymore.
kj holmGuest07/23/2014 at 01:32Post count: 908OK, totally bummed out here. I have built a really nice mini Mame arcade machine (all inside the iarcadie iphone cabinet) and I wired in the controls so as to use retrogame solution like the adafruit.com example shows. However, I like other, can’t get the GPIO direct wired inputs to work with emulationstation OR with any of the emulators. When I hit F4 to exit back to command prompt my joystick and buttons are registering button presses at the command prompt so I know the code (for retrogame revised using CrazySpence solution above) and wiring is fine.
No idea what to do now….
Anyone have any clues?
Marv2.0Guest07/23/2014 at 15:16Post count: 908KJ, did you get any errors when running ‘make’ or ‘make install’?
in regards to your question, nbonaparte mentioned that this hack may not work on retropie 2.3 (not working for me on 2.2) so make sure you use an older version.
-
AuthorPosts
- The forum ‘Everything else related to the RetroPie Project’ is closed to new topics and replies.