Homepage › Forums › RetroPie Project › Everything else related to the RetroPie Project › emulationstation 2 gpio input problem › Reply To: emulationstation 2 gpio input problem
[quote=14017]#!/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()[/quote]
the Python script is considering rebounce as in retrogame did you try with a “shot” button?