make fenrir useable with mouse and other nonwatched input events

This commit is contained in:
chrys 2016-12-18 00:10:08 +01:00
parent dec8b41b18
commit 932034b560
2 changed files with 20 additions and 6 deletions

View File

@ -51,16 +51,30 @@ class driver():
if r != []: if r != []:
for fd in r: for fd in r:
event = self.iDevices[fd].read_one() event = self.iDevices[fd].read_one()
foreward = False
while(event): while(event):
self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])
if event.type == evdev.events.EV_KEY: if event.type == evdev.events.EV_KEY:
if event.code != 0: if event.code != 0:
currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event) currMapEvent = self.mapEvent(event)
if not currMapEvent: if not currMapEvent:
return currMapEvent foreward = True
if currMapEvent['EventState'] in [0,1,2]: event = self.iDevices[fd].read_one()
return currMapEvent continue
event = self.iDevices[fd].read_one() 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 return None
def writeEventBuffer(self): def writeEventBuffer(self):

View File

@ -15,6 +15,6 @@ while True:
if r != []: if r != []:
for fd in r: for fd in r:
for event in devices[fd].read(): 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))