|
|
@@ -5,17 +5,20 @@ from evdev import ecodes, InputDevice, list_devices
|
|
|
|
|
|
|
|
|
class Keyboard(threading.Thread):
|
|
|
- def __init__(self,sock):
|
|
|
+ def __init__(self,next,prev,toggle):
|
|
|
super(Keyboard, self).__init__()
|
|
|
self.devices = [InputDevice(d) for d in list_devices("/dev/input/")]
|
|
|
- self.sock = sock
|
|
|
self.running = False
|
|
|
+ self.prev = prev
|
|
|
+ self.next = next
|
|
|
+ self.toggle = toggle
|
|
|
|
|
|
def run(self):
|
|
|
self.running=True
|
|
|
self.handleInput()
|
|
|
def handleInput(self):
|
|
|
- dev = InputDevice("/dev/input/by-id/usb-Microsoft_Comfort_Curve_Keyboard_3000-event-kbd")
|
|
|
+ #dev = InputDevice("/dev/input/by-id/usb-Microsoft_Comfort_Curve_Keyboard_3000-event-kbd")
|
|
|
+ dev = InputDevice("/dev/input/by-path/platform-i8042-serio-0-event-kbd")
|
|
|
VALID_KEYS = [ "KEY_PAGEUP", "KEY_PAGEDOWN", "KEY_F5" ]
|
|
|
while True:
|
|
|
r, w, e = select([dev], [], [])
|
|
|
@@ -23,7 +26,14 @@ class Keyboard(threading.Thread):
|
|
|
codename = '?'
|
|
|
if ev.type == ecodes.EV_SYN:
|
|
|
continue
|
|
|
+ if ev.value != 0:
|
|
|
+ continue
|
|
|
if ev.type in ecodes.bytype:
|
|
|
codename = ecodes.bytype[ev.type][ev.code]
|
|
|
- if codename in VALID_KEYS and ev.value==0:
|
|
|
- print(codename)
|
|
|
+
|
|
|
+ if codename == "KEY_PAGEUP":
|
|
|
+ self.prev()
|
|
|
+ if codename == "KEY_PAGEDOWN":
|
|
|
+ self.next()
|
|
|
+ if codename == "KEY_F5":
|
|
|
+ self.toggle()
|