Using gpio_keys to control xbmc/raspbmc
#1
Question 
Hello,

I already posted this message on the raspberry pi forums but it seems more resonable to ask here since I believe that this might be related to xbmc in general.
I have attached a few pushbuttons to the raspberry pi P1-header pins. Then I configured the bcm2708 platform file of the kernel similar to http://www.raspberrypi.org/forums/viewto...=50&t=8842 and rebuilt the kernel with raspbmc's configuration.
After replacing the kernel and it's modules on the SD card, I turned on the pi and tried to hit some buttons.
While my normal usb keyboard worked fine, the GPIO keys didn't. After I shutdown xbmc and got a tty the gpio keys were accepted as usual keyboard input.

Has anybody tried out something similar to control xbmc and might have some advice?
Further thought's:
- Is raspbmc trying to reconfigure GPIO pins and thereby mocking everything up?


Thank you very much in advance and best regards,
Mysterious

-----------------------------------------------------------------------------------------

GPIO configuration (active low) seems to be ok:
Code:
pi@raspbmc:~$ sudo mount -t debugfs debugfs /sys/kernel/debug
pi@raspbmc:~$ sudo cat /sys/kernel/debug/gpio
GPIOs 0-53, bcm2708_gpio:
gpio-16  (led0                ) out hi
gpio-17  (gpio-keys: left     ) in  hi
gpio-22  (gpio-keys: enter    ) in  hi
gpio-23  (gpio-keys: down     ) in  hi
gpio-24  (gpio-keys: right    ) in  hi
gpio-27  (gpio-keys: up       ) in  hi

The device handlers are the same for gpio_keys and usb keyboard:
Code:
pi@raspbmc:~$ cat /proc/bus/input/devices
I: Bus=0003 Vendor=0e8f Product=0022 Version=0110
N: Name="GASIA USB KB V11"
P: Phys=usb-bcm2708_usb-1.2.2/input0
S: Sysfs=/devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2.2/1-1.2.2:1.0/input/input0
U: Uniq=
H: Handlers=sysrq kbd event0
B: PROP=0
B: EV=120013
B: KEY=10000 7 ff800000 7ff febeffdf f3cfffff ffffffff fffffffe
B: MSC=10
B: LED=7

I: Bus=0003 Vendor=0e8f Product=0022 Version=0110
N: Name="GASIA USB KB V11"
P: Phys=usb-bcm2708_usb-1.2.2/input1
S: Sysfs=/devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2.2/1-1.2.2:1.1/input/input1
U: Uniq=
H: Handlers=kbd event1
B: PROP=0
B: EV=1f
B: KEY=4837fff 72ff32d bf544446 0 0 1 20c10 b17c000 267bfa d941dfed 9e1680 4400 0 10000002
B: REL=40
B: ABS=1 0
B: MSC=10

I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="gpio-keys"
P: Phys=gpio-keys/input0
S: Sysfs=/devices/platform/gpio-keys/input/input2
U: Uniq=
H: Handlers=kbd event2
B: PROP=0
B: EV=100003
B: KEY=1680 0 0 10000000

Open file handlers are the same for keyboard and gpio_keys:
Code:
pi@raspbmc:~$ sudo lsof | grep /dev/input/
xbmc.bin   681              pi   25u      CHR      13,64      0t0        246 /dev/input/event0
xbmc.bin   681              pi   34u      CHR      13,65      0t0        250 /dev/input/event1
xbmc.bin   681              pi   36u      CHR      13,66      0t0        416 /dev/input/event2
ActiveAE   681  929         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
ActiveAE   681  929         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
ActiveAE   681  929         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
AESink     681  930         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
AESink     681  930         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
AESink     681  930         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
VCHIQ      681  932         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
VCHIQ      681  932         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
VCHIQ      681  932         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
HDispmanx  681  934         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
HDispmanx  681  934         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
HDispmanx  681  934         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
HTV        681  935         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
HTV        681  935         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
HTV        681  935         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
HCEC       681  936         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
HCEC       681  936         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
HCEC       681  936         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
AESink     681  941         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
AESink     681  941         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
AESink     681  941         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
ILCS_HOST  681  942         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
ILCS_HOST  681  942         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
ILCS_HOST  681  942         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
CRBPWorke  681  943         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
CRBPWorke  681  943         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
CRBPWorke  681  943         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
CECAdapte  681 1002         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
CECAdapte  681 1002         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
CECAdapte  681 1002         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
PeripBusC  681 1003         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
PeripBusC  681 1003         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
PeripBusC  681 1003         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
CECAdapte  681 1009         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
CECAdapte  681 1009         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
CECAdapte  681 1009         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
CECAdapte  681 1010         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
CECAdapte  681 1010         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
CECAdapte  681 1010         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
PeripBusU  681 1011         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
PeripBusU  681 1011         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
PeripBusU  681 1011         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
CECAdapte  681 1030         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
CECAdapte  681 1030         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
CECAdapte  681 1030         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
PVRManage  681 1034         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
PVRManage  681 1034         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
PVRManage  681 1034         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
PVRClient  681 1035         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
PVRClient  681 1035         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
PVRClient  681 1035         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
xbmc.bin   681 1169         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
xbmc.bin   681 1169         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
xbmc.bin   681 1169         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
xbmc.bin   681 1172         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
xbmc.bin   681 1172         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
xbmc.bin   681 1172         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
xbmc.bin   681 1173         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
xbmc.bin   681 1173         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
xbmc.bin   681 1173         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
EventServ  681 1174         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
EventServ  681 1174         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
EventServ  681 1174         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
TCPServer  681 1175         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
TCPServer  681 1175         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
TCPServer  681 1175         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
xbmc.bin   681 1176         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
xbmc.bin   681 1176         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
xbmc.bin   681 1176         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
AirPlaySe  681 1178         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
AirPlaySe  681 1178         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
AirPlaySe  681 1178         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
xbmc.bin   681 1249         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
xbmc.bin   681 1249         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
xbmc.bin   681 1249         pi   36u      CHR      13,66      0t0        416 /dev/input/event2
PAPlayer   681 1253         pi   25u      CHR      13,64      0t0        246 /dev/input/event0
PAPlayer   681 1253         pi   34u      CHR      13,65      0t0        250 /dev/input/event1
PAPlayer   681 1253         pi   36u      CHR      13,66      0t0        416 /dev/input/event2

With xbmc shut down evtest works ok:
Code:
pi@raspbmc:~$ evtest /dev/input/event2
    Input driver version is 1.0.1
    Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
    Input device name: "gpio-keys"
    Supported events:
      Event type 0 (EV_SYN)
      Event type 1 (EV_KEY)
        Event code 28 (KEY_ENTER)
        Event code 103 (KEY_UP)
        Event code 105 (KEY_LEFT)
        Event code 106 (KEY_RIGHT)
        Event code 108 (KEY_DOWN)
      Event type 20 (EV_REP)
    Properties:
    Testing ... (interrupt to exit)
    Event: time 1408287621.386607, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 1
    Event: time 1408287621.386607, -------------- SYN_REPORT ------------
    Event: time 1408287621.396600, type 1 (EV_KEY), code 108 (KEY_DOWN), value 1
    Event: time 1408287621.396600, -------------- SYN_REPORT ------------
    Event: time 1408287621.516587, type 1 (EV_KEY), code 108 (KEY_DOWN), value 0
    Event: time 1408287621.516587, -------------- SYN_REPORT ------------
    Event: time 1408287621.536613, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 0
    Event: time 1408287621.536613, -------------- SYN_REPORT ------------
    Event: time 1408287622.036580, type 1 (EV_KEY), code 28 (KEY_ENTER), value 1
    Event: time 1408287622.036580, -------------- SYN_REPORT ------------
    Event: time 1408287622.176647, type 1 (EV_KEY), code 105 (KEY_LEFT), value 1
    Event: time 1408287622.176647, -------------- SYN_REPORT ------------
    Event: time 1408287622.196688, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0
    Event: time 1408287622.196688, -------------- SYN_REPORT ------------
    Event: time 1408287622.246642, type 1 (EV_KEY), code 105 (KEY_LEFT), value 0
    Event: time 1408287622.246642, -------------- SYN_REPORT ------------
    Event: time 1408287622.656686, type 1 (EV_KEY), code 105 (KEY_LEFT), value 1
    Event: time 1408287622.656686, -------------- SYN_REPORT ------------
    Event: time 1408287622.836599, type 1 (EV_KEY), code 105 (KEY_LEFT), value 0
    Event: time 1408287622.836599, -------------- SYN_REPORT ------------
    Event: time 1408287623.366583, type 1 (EV_KEY), code 103 (KEY_UP), value 1
    Event: time 1408287623.366583, -------------- SYN_REPORT ------------
    Event: time 1408287623.486560, type 1 (EV_KEY), code 103 (KEY_UP), value 0
    Event: time 1408287623.486560, -------------- SYN_REPORT ------------
    Event: time 1408287623.866590, type 1 (EV_KEY), code 108 (KEY_DOWN), value 1
    Event: time 1408287623.866590, -------------- SYN_REPORT ------------
    Event: time 1408287623.886603, type 1 (EV_KEY), code 28 (KEY_ENTER), value 1
    Event: time 1408287623.886603, -------------- SYN_REPORT ------------
    Event: time 1408287624.016771, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0
    Event: time 1408287624.016771, -------------- SYN_REPORT ------------
    Event: time 1408287624.016805, type 1 (EV_KEY), code 108 (KEY_DOWN), value 0
    Event: time 1408287624.016805, -------------- SYN_REPORT ------------
Reply
#2
Hi. A lot of what you said is above my skill level. If you want to control xbmc why don't you just use a simple GPIO IR remote? I haven't tested it lately on Raspbmc but in Openelec it works right out of the box, no configuration required.
Reply

Logout Mark Read Team Forum Stats Members Help
Using gpio_keys to control xbmc/raspbmc0