Update evdevDriver.py

This commit is contained in:
chrys87 2018-06-28 10:10:01 +02:00 committed by GitHub
parent cc7caf4ec1
commit e1696ee077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,11 +88,12 @@ class driver(inputDriver):
def inputWatchdog(self,active , eventQueue): def inputWatchdog(self,active , eventQueue):
try: try:
while active.value: while active.value:
r, w, x = select(self.iDevices, [], [], 0.7) r, w, x = select(self.iDevices, [], [], 0.8)
for fd in r:
event = None event = None
foundKeyInSequence = False
foreward = False foreward = False
eventFired = False eventFired = False
for fd in r:
try: try:
event = self.iDevices[fd].read_one() event = self.iDevices[fd].read_one()
except: except:
@ -100,22 +101,23 @@ class driver(inputDriver):
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 not foundKeyInSequence:
foundKeyInSequence = True
if event.code != 0: if event.code != 0:
currMapEvent = self.mapEvent(event) currMapEvent = self.mapEvent(event)
if not currMapEvent: if not currMapEvent:
foreward = True continue
if not isinstance(currMapEvent['EventName'], str): if not isinstance(currMapEvent['EventName'], str):
foreward = True continue
if not foreward or eventFired:
if currMapEvent['EventState'] in [0,1,2]: if currMapEvent['EventState'] in [0,1,2]:
eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()}) eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()})
eventFired = True eventFired = True
else: else:
pass
if event.type in [2,3]: if event.type in [2,3]:
foreward = True foreward = True
event = self.iDevices[fd].read_one() event = self.iDevices[fd].read_one()
if not foundKeyInSequence:
if foreward and not eventFired: if foreward and not eventFired:
self.writeEventBuffer() self.writeEventBuffer()
self.clearEventBuffer() self.clearEventBuffer()