I am trying to trigger a return keypress, or left mouse button press from python to affect xbmc (raspbmc). I have previously done this in raspbian with uinput
, but this doesn't seem to work for raspbmc. I have also tried with this script from adafruit https://learn.adafruit.com/retro-gaming-with-raspberry-pi/buttons which has also worked for me on raspbian.
Any help appreciated :) Thanks Tom
After trying seemingly every solution, using this python xbmc json module did the trick! Not quite a key press, but controls xbmc as if it were
https://github.com/jcsaaddupuy/python-xbmc
this is the code I modified to get GPIO input to trigger events in XBMC
import RPi.GPIO as GPIO
from xbmcjson import XBMC
xbmc = XBMC("http://127.0.0.1/jsonrpc")
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
def my_callback2(channel):
global XBMC
xbmc.Input.Select()
GPIO.add_event_detect(23, GPIO.FALLING, callback=my_callback2, bouncetime=300)
if __name__ == "__main__":
try:
print "Waiting for rising edge on port 24"
GPIO.wait_for_edge(24, GPIO.RISING)
print "Rising edge detected on port 24. Here endeth the third lesson."
except KeyboardInterrupt:
GPIO.cleanup() # clean up GPIO on CTRL+C exit
GPIO.cleanup() # clean up GPIO on normal exit try: