1

I'm emitting keys from a python script using python-uinput. Basic stuff such as up / down / enter / esc.

As far as I can see this works fine on my desktop, in the terminal, and with the browser. But when I run Kodi, it doesn't seem to respond at all. Is this something to do with it being a fullscreen application?

NB: I'm running Raspbian on model 3 Raspberry Pi.

digitalWestie
  • 2,647
  • 6
  • 28
  • 45

1 Answers1

0

Maybe you need to do: sudo modprobe uinput

The following script works for me to send Function key 12 to vice (a C64 emulator) based on a button press on a GPIO:

import uinput 
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)

wasPressed=False

# set up keystroke input
device = uinput.Device([uinput.KEY_F12])
while True:
    button_inactive = GPIO.input(21)
    if not button_inactive and not wasPressed:
        device.emit_click(uinput.KEY_F12)
        print "sending F12"
        wasPressed=True
    if button_inactive: 
        wasPressed=False
    time.sleep(0.1)

Note that I used uinput.KEY_F12 twice. The script should be run as root.

Jeroen
  • 16
  • 2
  • Does this work for you on a raspberry pi? I eventually ended up using the kodi json rpc API (http://kodi.wiki/view/JSON-RPC_API/v6) to issue kodi commands rather than simulate key presses. – digitalWestie Aug 20 '17 at 19:34