diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf new file mode 100644 index 00000000..0e95b91a --- /dev/null +++ b/config/keyboard/test.conf @@ -0,0 +1,21 @@ +1-KEY_KP0=fenrirKey +#1-KEY_LEFTCTRL=shut_up +1-KEY_KP0,1-KEY_RIGHTCTRL=shut_up +1-KEY_KP0,1-KEY_KP8=curr_line +1-KEY_KP0,1-KEY_KP7=prev_line +1-KEY_KP0,1-KEY_KP9=next_line +1-KEY_KP0,1-KEY_KP5=curr_word +1-KEY_KP0,1-KEY_KP4=prev_word +1-KEY_KP0,1-KEY_KP6=next_word +1-KEY_KP0,1-KEY_KP2=curr_char +1-KEY_KP0,1-KEY_KP1=prev_char +1-KEY_KP0,1-KEY_KP3=next_char +1-KEY_KP0,1-KEY_KPDOT=exit_review +#=curr_screen +#=last_incomming +1-KEY_KP0,1-KEY_F2=toggle_braille +1-KEY_KP0,1-KEY_F3=toggle_sound +1-KEY_KP0,1-KEY_F4=toggle_speech +#=toggle_output +#=toggle_autoRead +#=quit_fenrir diff --git a/config/settings/settings.conf b/config/settings/settings.conf index dfda5d78..0ea208d0 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -6,12 +6,12 @@ volume=1.0 [speech] enabled=True -driver=speechd +driver=espeak rate=0.75 pitch=0.5 module=espeak -voice=de -language=de +voice=en-us +language=en-us volume=1.0 autoReadIncomming=True @@ -28,7 +28,7 @@ device=all grabDevices=True ignoreShortcuts=False keyboardLayout=desktop -charEcho=True +charEcho=False charDeleteEcho=True wordEcho=True interruptOnKeyPress=False diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys new file mode 100644 index 00000000..d5946198 --- /dev/null +++ b/config/settings/settings.conf.chrys @@ -0,0 +1,38 @@ +[sound] +enabled=True +driver=sox +theme=default +volume=1.0 + +[speech] +enabled=True +driver=speechd +rate=0.75 +pitch=0.5 +module=espeak +voice=de +language=de +volume=1.0 +autoReadIncomming=True + +[braille] +enabled=False +layout=en + +[screen] +driver=linux +screenUpdateDelay=0.4 + +[keyboard] +device=all +grabDevices=True +ignoreShortcuts=False +keyboardLayout=test +charEcho=True +charDeleteEcho=True +wordEcho=True +interruptOnKeyPress=False + +[general] +debugLevel=0 +punctuationLevel=1 diff --git a/config/settings/settings.conf.orig b/config/settings/settings.conf.orig new file mode 100644 index 00000000..0ea208d0 --- /dev/null +++ b/config/settings/settings.conf.orig @@ -0,0 +1,38 @@ +[sound] +enabled=True +driver=sox +theme=default +volume=1.0 + +[speech] +enabled=True +driver=espeak +rate=0.75 +pitch=0.5 +module=espeak +voice=en-us +language=en-us +volume=1.0 +autoReadIncomming=True + +[braille] +enabled=False +layout=en + +[screen] +driver=linux +screenUpdateDelay=0.4 + +[keyboard] +device=all +grabDevices=True +ignoreShortcuts=False +keyboardLayout=desktop +charEcho=False +charDeleteEcho=True +wordEcho=True +interruptOnKeyPress=False + +[general] +debugLevel=0 +punctuationLevel=1 diff --git a/src/fenrir-package/consumeEvents.py b/play zone/consumeEvents.py similarity index 64% rename from src/fenrir-package/consumeEvents.py rename to play zone/consumeEvents.py index cbbf73d8..f005f1e2 100755 --- a/src/fenrir-package/consumeEvents.py +++ b/play zone/consumeEvents.py @@ -5,37 +5,46 @@ from select import select import time iDevices = map(evdev.InputDevice, (evdev.list_devices())) -iDevices = {dev.fd: dev for dev in iDevices if dev.fn in ['/dev/input/event18']} +iDevices = {dev.fd: dev for dev in iDevices if 1 in dev.capabilities()} uDevices = {} for fd in iDevices: dev = iDevices[fd] - dev.capabilities() - uDevices[fd] = UInput() - dev.grab() - -# dev.capabilities(), -# dev.name, -# dev.info.vendor, + cap = dev.capabilities() + del cap[0] + uDevices[fd] = UInput( + cap, + dev.name, + dev.info.vendor, # dev.info.product, # dev.version, # dev.info.bustype, -# '/dev/uinput' -# ) + # '/dev/uinput' + ) + dev.grab() i = 0 -while i < 10: +while i < 100: r, w, x = select(iDevices, [], []) if r != []: i += 1 for fd in r: for event in iDevices[fd].read(): - if event.code != 30: + if event.code != 30: # a uDevices[fd].write_event(event) uDevices[fd].syn() #print('Devicename:'+ devices[fd].name + ' Devicepath:' + devices[fd].fn + ' Events:' + str(devices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value)) + else: + print('this key is consumed') for fd in iDevices: iDevices[fd].ungrab() + iDevices[fd].close() + uDevices[fd].close() + + +iDevices.clear() +uDevices.clear() + diff --git a/src/fenrir-package/core/generalInformation.py b/src/fenrir-package/core/generalInformation.py index 2cacf530..448c9e11 100644 --- a/src/fenrir-package/core/generalInformation.py +++ b/src/fenrir-package/core/generalInformation.py @@ -2,4 +2,5 @@ generalInformation = { 'running': True, +'consumeKey': False, } diff --git a/src/fenrir-package/core/inputManager.py b/src/fenrir-package/core/inputManager.py index 10125f91..a4420455 100644 --- a/src/fenrir-package/core/inputManager.py +++ b/src/fenrir-package/core/inputManager.py @@ -1,35 +1,43 @@ #!/bin/python import evdev -from evdev import InputDevice +from evdev import InputDevice, UInput from select import select +import time class inputManager(): def __init__(self): - self.devices = map(evdev.InputDevice, (evdev.list_devices())) - self.devices = {dev.fd: dev for dev in self.devices} - #for dev in self.devices.values(): print(dev) + self.iDevices = {} + self.uDevices = {} + self.getDevices() def getKeyPressed(self, environment): timeout = True try: - r, w, x = select(self.devices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay')) - environment['runtime']['globalLock'].acquire(True) + r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay')) if r != []: timeout = False for fd in r: - for event in self.devices[fd].read(): - if event.type == evdev.ecodes.EV_KEY: - if event.value != 0: - environment['input']['currShortcut'][str(event.code)] = 1 #event.value - else: - try: - del(environment['input']['currShortcut'][str(event.code)]) - except: - pass - except: - pass + for event in self.iDevices[fd].read(): + if event.code == 82: # a + environment['generalInformation']['consumeKey'] = True + if not environment['generalInformation']['consumeKey']: + self.uDevices[fd].write_event(event) + self.uDevices[fd].syn() + time.sleep(0.01) + else: + if event.type == evdev.ecodes.EV_KEY: + if event.value != 0: + environment['input']['currShortcut'][str(event.code)] = 1 #event.value + else: + try: + del(environment['input']['currShortcut'][str(event.code)]) + except: + pass + except Exception as e: + self.freeDevices() environment['input']['currShortcutString'] = self.getShortcutString(environment) + environment['generalInformation']['consumeKey'] = environment['input']['currShortcut'] != {} return environment, timeout def getShortcutString(self, environment): @@ -40,4 +48,46 @@ class inputManager(): currShortcutStringList.append("%s-%s" % (environment['input']['currShortcut'][key], key)) currShortcutStringList = sorted(currShortcutStringList) return str(currShortcutStringList)[1:-1].replace(" ","").replace("'","") + + def getDevices(self): + self.iDevices = map(evdev.InputDevice, (evdev.list_devices())) + self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()} + + for fd in self.iDevices: + dev = self.iDevices[fd] + cap = dev.capabilities() + del cap[0] + print(dev.name) + self.uDevices[fd] = UInput( + cap, + dev.name, + dev.info.vendor + # dev.info.product, + # dev.version, + # dev.info.bustype, + # '/dev/uinput' + ) + dev.grab() + + def freeDevices(self): + for fd in self.iDevices: + try: + self.iDevices[fd].ungrab() + except: + pass + try: + self.iDevices[fd].close() + except: + pass + try: + self.uDevices[fd].close() + except: + pass + + self.iDevices.clear() + self.uDevices.clear() + + def __del__(self): + self.freeDevices() + diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index b6da6197..c27d93aa 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -37,14 +37,11 @@ class fenrir(): self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged') if self.environment['commandInfo']['currCommand'] != '': self.handleCommands() - self.environment['runtime']['globalLock'].release() def updateScreen(self): return - self.environment['runtime']['globalLock'].acquire(True) self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment,'updateScreen') self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged') - self.environment['runtime']['globalLock'].release() time.sleep(0.5) def handleCommands(self): @@ -61,6 +58,8 @@ class fenrir(): self.environment['runtime']['soundDriver'].shutdown() if self.environment['runtime']['speechDriver'] != None: self.environment['runtime']['speechDriver'].shutdown() + self.environment['runtime']['inputManager'].freeDevices() + def captureSignal(self, siginit, frame): self.shutdownRequest()