我正在尝试触发返回键,或者从python按下鼠标左键来影响xbmc (raspbmc)。我以前用uinput在raspbian中这样做过,但这似乎不适用于raspbmc。我也尝试过使用adafruit的https://learn.adafruit.com/retro-gaming-with-raspberry-pi/buttons脚本,它也为我在raspbian上工作过。
谢谢你的帮助,谢谢汤姆
发布于 2014-05-07 20:09:41
在尝试了所有的解决方案之后,使用这个python json模块就成功了!不是按下键,而是像控制xbmc一样控制xbmc。
https://github.com/jcsaaddupuy/python-xbmc
这是我修改的代码,用于获取GPIO输入以触发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: https://stackoverflow.com/questions/23525983
复制相似问题