Merge branch 'inputHandlingRework' of https://github.com/chrys87/fenrir into inputHandlingRework
This commit is contained in:
commit
d287bc294d
@ -33,19 +33,21 @@ class inputManager():
|
|||||||
mEvent = self.env['runtime']['inputDriver'].getInputEvent()
|
mEvent = self.env['runtime']['inputDriver'].getInputEvent()
|
||||||
if mEvent:
|
if mEvent:
|
||||||
mEvent['EventName'] = self.convertEventName(mEvent['EventName'])
|
mEvent['EventName'] = self.convertEventName(mEvent['EventName'])
|
||||||
if mEvent['EventValue'] == 0:
|
|
||||||
return False
|
|
||||||
eventReceived = True
|
eventReceived = True
|
||||||
if mEvent['EventState'] == 0:
|
if mEvent['EventState'] == 0:
|
||||||
if mEvent['EventName'] in self.env['input']['currInput']:
|
if mEvent['EventName'] in self.env['input']['currInput']:
|
||||||
self.env['input']['currInput'].remove(mEvent['EventName'])
|
self.env['input']['currInput'].remove(mEvent['EventName'])
|
||||||
|
if len(self.env['input']['currInput']) > 1:
|
||||||
self.env['input']['currInput'] = sorted(self.env['input']['currInput'])
|
self.env['input']['currInput'] = sorted(self.env['input']['currInput'])
|
||||||
if len(self.env['input']['prevDeepestInput']) < len(self.env['input']['currInput']):
|
if len(self.env['input']['currInput']) == 0:
|
||||||
self.env['input']['prevDeepestInput'] = self.env['input']['currInput'].copy()
|
self.env['input']['prevDeepestInput'] = []
|
||||||
elif mEvent['EventState'] == 1:
|
elif mEvent['EventState'] == 1:
|
||||||
if not mEvent['EventName'] in self.env['input']['currInput']:
|
if not mEvent['EventName'] in self.env['input']['currInput']:
|
||||||
self.env['input']['currInput'].append(mEvent['EventName'])
|
self.env['input']['currInput'].append(mEvent['EventName'])
|
||||||
|
if len(self.env['input']['currInput']) > 1:
|
||||||
self.env['input']['currInput'] = sorted(self.env['input']['currInput'])
|
self.env['input']['currInput'] = sorted(self.env['input']['currInput'])
|
||||||
|
if len(self.env['input']['prevDeepestInput']) < len(self.env['input']['currInput']):
|
||||||
|
self.env['input']['prevDeepestInput'] = self.env['input']['currInput'].copy()
|
||||||
elif mEvent['EventState'] == 2:
|
elif mEvent['EventState'] == 2:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -50,7 +50,6 @@ class fenrir():
|
|||||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||||
if self.environment['input']['keyForeward'] > 0:
|
if self.environment['input']['keyForeward'] > 0:
|
||||||
self.environment['input']['keyForeward'] -=1
|
self.environment['input']['keyForeward'] -=1
|
||||||
self.environment['input']['prevDeepestInput'] = []
|
|
||||||
else:
|
else:
|
||||||
self.environment['runtime']['screenManager'].update()
|
self.environment['runtime']['screenManager'].update()
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
||||||
|
@ -31,19 +31,20 @@ class driver():
|
|||||||
for fd in r:
|
for fd in r:
|
||||||
event = self.iDevices[fd].read_one()
|
event = self.iDevices[fd].read_one()
|
||||||
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.code != 0:
|
||||||
return self.env['runtime']['inputDriver'].mapEvent(event)
|
return self.env['runtime']['inputDriver'].mapEvent(event)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def writeEventBuffer(self):
|
def writeEventBuffer(self):
|
||||||
for iDevice, uDevice, event in self.env['input']['eventBuffer']:
|
for iDevice, uDevice, event in self.env['input']['eventBuffer']:
|
||||||
self.writeUInput(uDevice, event)
|
self.writeUInput(uDevice, event)
|
||||||
|
uDevice.syn()
|
||||||
|
|
||||||
def clearEventBuffer(self):
|
def clearEventBuffer(self):
|
||||||
del self.env['input']['eventBuffer'][:]
|
del self.env['input']['eventBuffer'][:]
|
||||||
|
|
||||||
def writeUInput(self, uDevice, event):
|
def writeUInput(self, uDevice, event):
|
||||||
uDevice.write_event(event)
|
uDevice.write_event(event)
|
||||||
uDevice.syn()
|
|
||||||
|
|
||||||
def getInputDevices(self):
|
def getInputDevices(self):
|
||||||
# 3 pos absolute
|
# 3 pos absolute
|
||||||
@ -62,7 +63,7 @@ class driver():
|
|||||||
return None
|
return None
|
||||||
mEvent = inputEvent.inputEvent
|
mEvent = inputEvent.inputEvent
|
||||||
try:
|
try:
|
||||||
mEvent['EventName'] = evdev.ecodes.keys[event.code].upper()
|
mEvent['EventName'] = evdev.ecodes.keys[event.code]
|
||||||
mEvent['EventValue'] = event.code
|
mEvent['EventValue'] = event.code
|
||||||
mEvent['EventSec'] = event.sec
|
mEvent['EventSec'] = event.sec
|
||||||
mEvent['EventUsec'] = event.usec
|
mEvent['EventUsec'] = event.usec
|
||||||
|
Loading…
Reference in New Issue
Block a user