initial promotedtext, cleanups, prepare for consume non fenrirkey shortcuts
This commit is contained in:
parent
f210a8c777
commit
3c720b8b1a
@ -25,7 +25,7 @@ screenUpdateDelay=0.4
|
|||||||
|
|
||||||
[keyboard]
|
[keyboard]
|
||||||
device=all
|
device=all
|
||||||
grabDevices=True
|
grabDevices=False
|
||||||
ignoreShortcuts=False
|
ignoreShortcuts=False
|
||||||
keyboardLayout=test
|
keyboardLayout=test
|
||||||
charEcho=False
|
charEcho=False
|
||||||
@ -37,3 +37,8 @@ interruptOnKeyPress=False
|
|||||||
debugLevel=0
|
debugLevel=0
|
||||||
punctuationLevel=1
|
punctuationLevel=1
|
||||||
fenrirKeys=KEY_KP0
|
fenrirKeys=KEY_KP0
|
||||||
|
|
||||||
|
[promote]
|
||||||
|
enabled=True
|
||||||
|
inactiveTimeoutSec=5
|
||||||
|
list=
|
||||||
|
@ -37,3 +37,8 @@ interruptOnKeyPress=False
|
|||||||
debugLevel=0
|
debugLevel=0
|
||||||
punctuationLevel=1
|
punctuationLevel=1
|
||||||
fenrirKeys=KEY_KP0
|
fenrirKeys=KEY_KP0
|
||||||
|
|
||||||
|
[promote]
|
||||||
|
enabled=True
|
||||||
|
inactiveTimeoutSec=120
|
||||||
|
list=chrys,test
|
||||||
|
@ -76,3 +76,10 @@ debugLevel=0
|
|||||||
punctuationLevel=1
|
punctuationLevel=1
|
||||||
# define the current fenrir key
|
# define the current fenrir key
|
||||||
fenrirKeys=KEY_KP0
|
fenrirKeys=KEY_KP0
|
||||||
|
|
||||||
|
[promote]
|
||||||
|
enabled=True
|
||||||
|
inactiveTimeoutSec=120
|
||||||
|
list=
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,3 +37,8 @@ interruptOnKeyPress=False
|
|||||||
debugLevel=0
|
debugLevel=0
|
||||||
punctuationLevel=1
|
punctuationLevel=1
|
||||||
fenrirKeys=KEY_KP0
|
fenrirKeys=KEY_KP0
|
||||||
|
|
||||||
|
[promote]
|
||||||
|
enabled=True
|
||||||
|
inactiveTimeoutSec=120
|
||||||
|
list=
|
||||||
|
@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
generalInformation = {
|
generalInformation = {
|
||||||
'running': True,
|
'running': True,
|
||||||
|
'promotedTextList': ['$']
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/python
|
#!/bin/python
|
||||||
|
import time
|
||||||
|
|
||||||
input = {
|
input = {
|
||||||
'currShortcut': {},
|
'currShortcut': {},
|
||||||
@ -6,5 +7,5 @@ input = {
|
|||||||
'consumeKey': False,
|
'consumeKey': False,
|
||||||
'fenrirKey': ['82'],
|
'fenrirKey': ['82'],
|
||||||
'keyForeward': False,
|
'keyForeward': False,
|
||||||
|
'lastInputTime':time.time(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,10 +9,11 @@ class inputManager():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.iDevices = {}
|
self.iDevices = {}
|
||||||
self.uDevices = {}
|
self.uDevices = {}
|
||||||
self.getDevices()
|
self.getInputDevices()
|
||||||
|
self.grabDevices()
|
||||||
self.ignoreKeyRelease = 0
|
self.ignoreKeyRelease = 0
|
||||||
|
|
||||||
def getKeyPressed(self, environment):
|
def proceedInputEvents(self, environment):
|
||||||
timeout = True
|
timeout = True
|
||||||
if not environment['input']['keyForeward']:
|
if not environment['input']['keyForeward']:
|
||||||
self.ignoreKeyRelease = 0
|
self.ignoreKeyRelease = 0
|
||||||
@ -22,11 +23,10 @@ class inputManager():
|
|||||||
timeout = False
|
timeout = False
|
||||||
for fd in r:
|
for fd in r:
|
||||||
for event in self.iDevices[fd].read():
|
for event in self.iDevices[fd].read():
|
||||||
if self.isFenrirKey(environment, event): # a
|
if self.isFenrirKey(environment, event):
|
||||||
environment['input']['consumeKey'] = not environment['input']['keyForeward']
|
environment['input']['consumeKey'] = not environment['input']['keyForeward']
|
||||||
if not environment['input']['consumeKey'] or environment['input']['keyForeward']:
|
if self.isConsumeKeypress(environment):
|
||||||
self.uDevices[fd].write_event(event)
|
self.writeUInput(self.uDevices[fd], event)
|
||||||
self.uDevices[fd].syn()
|
|
||||||
keyString = ''
|
keyString = ''
|
||||||
if self.isFenrirKey(environment, event):
|
if self.isFenrirKey(environment, event):
|
||||||
keyString = 'FENRIR'
|
keyString = 'FENRIR'
|
||||||
@ -45,6 +45,7 @@ class inputManager():
|
|||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
environment['input']['currShortcutString'] = self.getShortcutString(environment)
|
environment['input']['currShortcutString'] = self.getShortcutString(environment)
|
||||||
if not timeout:
|
if not timeout:
|
||||||
|
environment['input']['lastInputTime'] = time.time()
|
||||||
environment['input']['consumeKey'] = environment['input']['currShortcut'] != {} and environment['input']['consumeKey']
|
environment['input']['consumeKey'] = environment['input']['currShortcut'] != {} and environment['input']['consumeKey']
|
||||||
if (environment['input']['keyForeward'] and environment['input']['currShortcut'] == {}):
|
if (environment['input']['keyForeward'] and environment['input']['currShortcut'] == {}):
|
||||||
self.ignoreKeyRelease += 1
|
self.ignoreKeyRelease += 1
|
||||||
@ -52,7 +53,16 @@ class inputManager():
|
|||||||
environment['input']['keyForeward'] = environment['input']['keyForeward'] and not environment['input']['currShortcut'] == {}
|
environment['input']['keyForeward'] = environment['input']['keyForeward'] and not environment['input']['currShortcut'] == {}
|
||||||
|
|
||||||
return environment, timeout
|
return environment, timeout
|
||||||
|
|
||||||
|
def isConsumeKeypress(self, environment):
|
||||||
|
return not environment['input']['consumeKey'] or \
|
||||||
|
environment['input']['keyForeward'] or \
|
||||||
|
not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices')
|
||||||
|
|
||||||
|
def writeUInput(self, uDevice, event):
|
||||||
|
uDevice.write_event(event)
|
||||||
|
uDevice.syn()
|
||||||
|
|
||||||
def getShortcutString(self, environment):
|
def getShortcutString(self, environment):
|
||||||
if environment['input']['currShortcut'] == {}:
|
if environment['input']['currShortcut'] == {}:
|
||||||
return ''
|
return ''
|
||||||
@ -64,10 +74,13 @@ class inputManager():
|
|||||||
def isFenrirKey(self,environment, event):
|
def isFenrirKey(self,environment, event):
|
||||||
return str(event.code) in environment['input']['fenrirKey']
|
return str(event.code) in environment['input']['fenrirKey']
|
||||||
|
|
||||||
def getDevices(self):
|
def getInputDevices(self):
|
||||||
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()}
|
self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()}
|
||||||
|
|
||||||
|
def grabDevices(self):
|
||||||
|
# if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices'):
|
||||||
|
# return
|
||||||
for fd in self.iDevices:
|
for fd in self.iDevices:
|
||||||
dev = self.iDevices[fd]
|
dev = self.iDevices[fd]
|
||||||
cap = dev.capabilities()
|
cap = dev.capabilities()
|
||||||
|
@ -34,6 +34,11 @@ settings = {
|
|||||||
'punctuationLevel': 1,
|
'punctuationLevel': 1,
|
||||||
'fenrirKeys':['82'],
|
'fenrirKeys':['82'],
|
||||||
},
|
},
|
||||||
|
'promote':{
|
||||||
|
'enabled': True,
|
||||||
|
'inactiveTimeoutSec':120,
|
||||||
|
'list':'',
|
||||||
|
},
|
||||||
'keyboard':{
|
'keyboard':{
|
||||||
'device':"all",
|
'device':"all",
|
||||||
'grabDevices':True,
|
'grabDevices':True,
|
||||||
|
@ -29,7 +29,7 @@ class fenrir():
|
|||||||
self.shutdown()
|
self.shutdown()
|
||||||
|
|
||||||
def onInput(self):
|
def onInput(self):
|
||||||
self.environment, timeout = self.environment['runtime']['inputManager'].getKeyPressed(self.environment)
|
self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvents(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')
|
||||||
|
Loading…
Reference in New Issue
Block a user