From 932034b560e40ab8de352ca5822eb31d96c679a8 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 18 Dec 2016 00:10:08 +0100 Subject: [PATCH] make fenrir useable with mouse and other nonwatched input events --- src/fenrir/inputDriver/evdev.py | 24 +++++++++++++++++++----- tools/traceEvdev.py | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/fenrir/inputDriver/evdev.py b/src/fenrir/inputDriver/evdev.py index 15e60cae..3724faf2 100644 --- a/src/fenrir/inputDriver/evdev.py +++ b/src/fenrir/inputDriver/evdev.py @@ -51,16 +51,30 @@ class driver(): if r != []: for fd in r: event = self.iDevices[fd].read_one() + foreward = False while(event): self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) if event.type == evdev.events.EV_KEY: if event.code != 0: - currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event) + currMapEvent = self.mapEvent(event) if not currMapEvent: - return currMapEvent - if currMapEvent['EventState'] in [0,1,2]: - return currMapEvent - event = self.iDevices[fd].read_one() + foreward = True + event = self.iDevices[fd].read_one() + continue + if not isinstance(currMapEvent['EventName'], str): + foreward = True + event = self.iDevices[fd].read_one() + continue + if not foreward: + if currMapEvent['EventState'] in [0,1,2]: + return currMapEvent + else: + if not event.type in [0,1,4]: + foreward = True + event = self.iDevices[fd].read_one() + if foreward: + self.writeEventBuffer() + self.clearEventBuffer() return None def writeEventBuffer(self): diff --git a/tools/traceEvdev.py b/tools/traceEvdev.py index c83374bc..d40e592c 100755 --- a/tools/traceEvdev.py +++ b/tools/traceEvdev.py @@ -15,6 +15,6 @@ while True: if r != []: for fd in r: for event in devices[fd].read(): - print('Devicename:'+ devices[fd].name + ' Devicepath:' + devices[fd].fn + ' Events:' + str(devices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value)) + print('Devicename:'+ devices[fd].name + ' Devicepath:' + devices[fd].fn + ' EventType: ' + str(event.type) + ' Events:' + str(devices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value))