make key forewarding work
This commit is contained in:
parent
f974b48b1e
commit
2cd4328613
@ -18,4 +18,4 @@
|
|||||||
#=toggle_output
|
#=toggle_output
|
||||||
#=toggle_autoRead
|
#=toggle_autoRead
|
||||||
#=quit_fenrir
|
#=quit_fenrir
|
||||||
#=foreward_keypress
|
1-FENRIR,1-KEY_A=foreward_keypress
|
||||||
|
@ -10,9 +10,12 @@ class inputManager():
|
|||||||
self.iDevices = {}
|
self.iDevices = {}
|
||||||
self.uDevices = {}
|
self.uDevices = {}
|
||||||
self.getDevices()
|
self.getDevices()
|
||||||
|
self.ignoreKeyRelease = 0
|
||||||
|
|
||||||
def getKeyPressed(self, environment):
|
def getKeyPressed(self, environment):
|
||||||
timeout = True
|
timeout = True
|
||||||
|
if not environment['input']['keyForeward']:
|
||||||
|
self.ignoreKeyRelease = 0
|
||||||
try:
|
try:
|
||||||
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
|
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
|
||||||
if r != []:
|
if r != []:
|
||||||
@ -24,7 +27,6 @@ class inputManager():
|
|||||||
if not environment['input']['consumeKey'] or environment['input']['keyForeward']:
|
if not environment['input']['consumeKey'] or environment['input']['keyForeward']:
|
||||||
self.uDevices[fd].write_event(event)
|
self.uDevices[fd].write_event(event)
|
||||||
self.uDevices[fd].syn()
|
self.uDevices[fd].syn()
|
||||||
else:
|
|
||||||
keyString = ''
|
keyString = ''
|
||||||
if self.isFenrirKey(environment, event):
|
if self.isFenrirKey(environment, event):
|
||||||
keyString = 'FENRIR'
|
keyString = 'FENRIR'
|
||||||
@ -42,8 +44,13 @@ class inputManager():
|
|||||||
self.freeDevices()
|
self.freeDevices()
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
environment['input']['currShortcutString'] = self.getShortcutString(environment)
|
environment['input']['currShortcutString'] = self.getShortcutString(environment)
|
||||||
|
if not timeout:
|
||||||
environment['input']['consumeKey'] = environment['input']['currShortcut'] != {} and environment['input']['consumeKey']
|
environment['input']['consumeKey'] = environment['input']['currShortcut'] != {} and environment['input']['consumeKey']
|
||||||
environment['input']['keyForeward'] = environment['input']['keyForeward'] and environment['input']['currShortcut'] == {}
|
if (environment['input']['keyForeward'] and environment['input']['currShortcut'] == {}):
|
||||||
|
self.ignoreKeyRelease += 1
|
||||||
|
if self.ignoreKeyRelease >= 2: # a hack... has to bee done more clean
|
||||||
|
environment['input']['keyForeward'] = environment['input']['keyForeward'] and not environment['input']['currShortcut'] == {}
|
||||||
|
|
||||||
return environment, timeout
|
return environment, timeout
|
||||||
|
|
||||||
def getShortcutString(self, environment):
|
def getShortcutString(self, environment):
|
||||||
@ -68,11 +75,11 @@ class inputManager():
|
|||||||
self.uDevices[fd] = UInput(
|
self.uDevices[fd] = UInput(
|
||||||
cap,
|
cap,
|
||||||
dev.name,
|
dev.name,
|
||||||
dev.info.vendor
|
#dev.info.vendor,
|
||||||
# dev.info.product,
|
#dev.info.product,
|
||||||
# dev.version,
|
#dev.version,
|
||||||
# dev.info.bustype,
|
#dev.info.bustype,
|
||||||
# '/dev/uinput'
|
#'/dev/uinput'
|
||||||
)
|
)
|
||||||
dev.grab()
|
dev.grab()
|
||||||
|
|
||||||
|
@ -30,11 +30,12 @@ class fenrir():
|
|||||||
|
|
||||||
def onInput(self):
|
def onInput(self):
|
||||||
self.environment, timeout = self.environment['runtime']['inputManager'].getKeyPressed(self.environment)
|
self.environment, timeout = self.environment['runtime']['inputManager'].getKeyPressed(self.environment)
|
||||||
self.environment = self.environment['runtime']['commandManager'].getCommandForShortcut(self.environment)
|
|
||||||
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment, 'onInput')
|
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment, 'onInput')
|
||||||
if not timeout:
|
if not timeout:
|
||||||
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput')
|
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput')
|
||||||
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
||||||
|
if not self.environment['input']['keyForeward']:
|
||||||
|
self.environment = self.environment['runtime']['commandManager'].getCommandForShortcut(self.environment)
|
||||||
if self.environment['commandInfo']['currCommand'] != '':
|
if self.environment['commandInfo']['currCommand'] != '':
|
||||||
self.handleCommands()
|
self.handleCommands()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user