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