lorigio
Posts: 68
Joined: Tue Aug 20, 2013 8:38 pm

emulate keypress using python for emulationstation

Sun Jan 18, 2015 5:48 pm

Hi i'm trying to control emulationstation using gpio as keyboard. I have this code

Code: Select all

import time
from evdev import uinput, ecodes as e

def buttonEventHandler ():
   print "keypress"
   with uinput.UInput() as ui:
      ui.write(e.EV_KEY, e.KEY_UP, 1)   
      ui.syn()	  
      time.sleep(5)
      ui.write(e.EV_KEY, e.KEY_SPACE, 0)
      ui.syn()

def main():
     buttonEventHandler()
     while True:
         time.sleep(10)

if __name__=="__main__":
    main()
	
		
It works only if i first plug a real keyboard then i can disconnect the keyboard and the script starts working and i can see emulationstation reacting when i send the keys from the script. How can i make it working without plug a keyboard first?

Thanks!

Return to “Troubleshooting”