improve input handling
This commit is contained in:
parent
6bf4098074
commit
204e9423ff
@ -68,8 +68,10 @@ class inputManager():
|
|||||||
def convertEventName(self, eventName):
|
def convertEventName(self, eventName):
|
||||||
if not eventName:
|
if not eventName:
|
||||||
return ''
|
return ''
|
||||||
|
print(eventName)
|
||||||
|
|
||||||
if eventName == 'KEY_LEFTCTRL':
|
if eventName == 'KEY_LEFTCTRL':
|
||||||
eventName == 'KEY_CTRL'
|
eventName = 'KEY_CTRL'
|
||||||
elif eventName == 'KEY_RIGHTCTRL':
|
elif eventName == 'KEY_RIGHTCTRL':
|
||||||
eventName = 'KEY_CTRL'
|
eventName = 'KEY_CTRL'
|
||||||
elif eventName == 'KEY_LEFTSHIFT':
|
elif eventName == 'KEY_LEFTSHIFT':
|
||||||
@ -80,6 +82,10 @@ class inputManager():
|
|||||||
eventName = 'KEY_ALT'
|
eventName = 'KEY_ALT'
|
||||||
elif eventName == 'KEY_RIGHTALT':
|
elif eventName == 'KEY_RIGHTALT':
|
||||||
eventName = 'KEY_ALT'
|
eventName = 'KEY_ALT'
|
||||||
|
elif eventName == 'KEY_LEFTMETA':
|
||||||
|
eventName = 'KEY_META'
|
||||||
|
elif eventName == 'KEY_RIGHTMETA':
|
||||||
|
eventName = 'KEY_META'
|
||||||
if self.isFenrirKey(eventName):
|
if self.isFenrirKey(eventName):
|
||||||
eventName = 'KEY_FENRIR'
|
eventName = 'KEY_FENRIR'
|
||||||
return eventName
|
return eventName
|
||||||
@ -97,6 +103,8 @@ class inputManager():
|
|||||||
def writeEventBuffer(self):
|
def writeEventBuffer(self):
|
||||||
try:
|
try:
|
||||||
self.env['runtime']['inputDriver'].writeEventBuffer()
|
self.env['runtime']['inputDriver'].writeEventBuffer()
|
||||||
|
time.sleep(0.005)
|
||||||
|
self.clearEventBuffer()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
self.env['runtime']['debug'].writeDebugOut("Error while writeUInput",debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Error while writeUInput",debug.debugLevel.ERROR)
|
||||||
|
@ -44,7 +44,7 @@ class fenrir():
|
|||||||
if not self.wasCommand:
|
if not self.wasCommand:
|
||||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||||
if self.wasCommand:
|
if self.wasCommand:
|
||||||
if not self.environment['runtime']['inputManager'].noKeyPressed():
|
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||||
self.wasCommand = False
|
self.wasCommand = False
|
||||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||||
@ -70,9 +70,10 @@ class fenrir():
|
|||||||
if self.environment['input']['keyForeward']:
|
if self.environment['input']['keyForeward']:
|
||||||
return
|
return
|
||||||
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut()
|
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut()
|
||||||
|
print(shortcut)
|
||||||
command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut)
|
command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut)
|
||||||
self.environment['runtime']['commandManager'].queueCommand(command)
|
self.environment['runtime']['commandManager'].queueCommand(command)
|
||||||
self.wasCommand = command != ''
|
self.wasCommand = command != ''
|
||||||
|
|
||||||
def handleCommands(self):
|
def handleCommands(self):
|
||||||
if time.time() - self.environment['commandInfo']['lastCommandExecutionTime'] < 0.2:
|
if time.time() - self.environment['commandInfo']['lastCommandExecutionTime'] < 0.2:
|
||||||
|
@ -37,7 +37,6 @@ class driver():
|
|||||||
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)
|
||||||
self.clearEventBuffer()
|
|
||||||
|
|
||||||
def clearEventBuffer(self):
|
def clearEventBuffer(self):
|
||||||
del self.env['input']['eventBuffer'][:]
|
del self.env['input']['eventBuffer'][:]
|
||||||
@ -53,7 +52,8 @@ class driver():
|
|||||||
# 1 Keys
|
# 1 Keys
|
||||||
# we try to filter out mices and other stuff here
|
# we try to filter out mices and other stuff here
|
||||||
self.iDevices = map(evdev.InputDevice, (evdev.list_devices()))
|
self.iDevices = map(evdev.InputDevice, (evdev.list_devices()))
|
||||||
self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()}
|
#self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()}
|
||||||
|
self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()}
|
||||||
self.ledDevices = map(evdev.InputDevice, (evdev.list_devices()))
|
self.ledDevices = map(evdev.InputDevice, (evdev.list_devices()))
|
||||||
self.ledDevices = {dev.fd: dev for dev in self.ledDevices if 1 in dev.capabilities() and 17 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()}
|
self.ledDevices = {dev.fd: dev for dev in self.ledDevices if 1 in dev.capabilities() and 17 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user