diff --git a/config/settings/PromotedText.conf b/config/settings/PromotedText.conf deleted file mode 100644 index e69de29b..00000000 diff --git a/config/settings/settings.conf b/config/settings/settings.conf index cc08f707..500086fa 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -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= diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index 865b7cd4..6809ec00 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -37,3 +37,8 @@ interruptOnKeyPress=False debugLevel=0 punctuationLevel=1 fenrirKeys=KEY_KP0 + +[promote] +enabled=True +inactiveTimeoutSec=120 +list=chrys,test diff --git a/config/settings/settings.conf.orig b/config/settings/settings.conf.orig index 5d61af03..655c9673 100644 --- a/config/settings/settings.conf.orig +++ b/config/settings/settings.conf.orig @@ -76,3 +76,10 @@ debugLevel=0 punctuationLevel=1 # define the current fenrir key fenrirKeys=KEY_KP0 + +[promote] +enabled=True +inactiveTimeoutSec=120 +list= + + diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index 5430a01e..82378be3 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -37,3 +37,8 @@ interruptOnKeyPress=False debugLevel=0 punctuationLevel=1 fenrirKeys=KEY_KP0 + +[promote] +enabled=True +inactiveTimeoutSec=120 +list= diff --git a/src/fenrir-package/core/generalInformation.py b/src/fenrir-package/core/generalInformation.py index 2cacf530..d1058441 100644 --- a/src/fenrir-package/core/generalInformation.py +++ b/src/fenrir-package/core/generalInformation.py @@ -2,4 +2,5 @@ generalInformation = { 'running': True, +'promotedTextList': ['$'] } diff --git a/src/fenrir-package/core/input.py b/src/fenrir-package/core/input.py index 9e266cc5..308e384e 100644 --- a/src/fenrir-package/core/input.py +++ b/src/fenrir-package/core/input.py @@ -1,4 +1,5 @@ #!/bin/python +import time input = { 'currShortcut': {}, @@ -6,5 +7,5 @@ input = { 'consumeKey': False, 'fenrirKey': ['82'], 'keyForeward': False, +'lastInputTime':time.time(), } - diff --git a/src/fenrir-package/core/inputManager.py b/src/fenrir-package/core/inputManager.py index 4a3ae45d..75e7fde9 100644 --- a/src/fenrir-package/core/inputManager.py +++ b/src/fenrir-package/core/inputManager.py @@ -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 @@ -52,7 +53,16 @@ class inputManager(): environment['input']['keyForeward'] = environment['input']['keyForeward'] and not environment['input']['currShortcut'] == {} 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() diff --git a/src/fenrir-package/core/settings.py b/src/fenrir-package/core/settings.py index fd3ceff1..b132defc 100644 --- a/src/fenrir-package/core/settings.py +++ b/src/fenrir-package/core/settings.py @@ -34,6 +34,11 @@ settings = { 'punctuationLevel': 1, 'fenrirKeys':['82'], }, +'promote':{ + 'enabled': True, + 'inactiveTimeoutSec':120, + 'list':'', +}, 'keyboard':{ 'device':"all", 'grabDevices':True, diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index 6563e9ef..9d201f7f 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -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')