Hi everyone !
I try to add custom buttons in my project. Those button should allow access to save state, loadstate etc… function in retroarch. I plugge my buttons on the GPIO a like described here for example
http://blog.thestateofme.com/2012/08/10/raspberry-pi-gpio-joystick/
Then I wrote a little python script in order to map my buttons and trigger some uinput keyboard events.
from time import sleep
import RPi.GPIO as GPIO
import uinput
keypad = uinput.Device([uinput.KEY_N])
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN)
pause = .1
while True:
if (GPIO.input(4)):
keypad.emit_click(uinput.KEY_N)
sleep(pause)
I launch the script as admin (needed for GPIO python lib).
The button press detection works without problem.
When I’m in console, I can see ‘n’ ar input. ‘n’ key is mapped to the “next shader” function in retroarch, this works with a usb keyboard… But not with my buttons.
Somehow, my script is only effective in console. As long as I launch emulstation or retroarch, it fails.
Help would be much appreciated. I can’t figure it out and I really want to implement this with python which should bring a great flexibility to my project !