diff --git a/play zone/consumeEvents.py b/play zone/consumeEvents.py index f005f1e2..44b29c03 100755 --- a/play zone/consumeEvents.py +++ b/play zone/consumeEvents.py @@ -20,25 +20,22 @@ for fd in iDevices: # dev.info.bustype, # '/dev/uinput' ) - dev.grab() - i = 0 -while i < 100: +while i < 1000: r, w, x = select(iDevices, [], []) if r != []: i += 1 for fd in r: for event in iDevices[fd].read(): 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)) + print('Devicename:'+ iDevices[fd].name + ' Devicepath:' + iDevices[fd].fn + ' Events:' + str(iDevices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value)) else: print('this key is consumed') + break + break for fd in iDevices: - iDevices[fd].ungrab() iDevices[fd].close() uDevices[fd].close() diff --git a/src/fenrir-package/core/input.py b/src/fenrir-package/core/input.py index f0f06674..a9522901 100644 --- a/src/fenrir-package/core/input.py +++ b/src/fenrir-package/core/input.py @@ -5,7 +5,7 @@ input = { 'currInput': {}, 'prevInput': {}, 'currEvent': None, -'firstEvent': None +'firstEvent': None, 'firstEvent': None, 'currShortcutString': '', 'consumeKey': False, diff --git a/src/fenrir-package/core/inputManager.py b/src/fenrir-package/core/inputManager.py index 7101e918..cd8874a3 100644 --- a/src/fenrir-package/core/inputManager.py +++ b/src/fenrir-package/core/inputManager.py @@ -12,7 +12,10 @@ class inputManager(): return environment def proceedInputEvent(self, environment): timeout = True - environment, timeout = environment['runtime']['inputDriver'].getInput(environment) + event = environment['runtime']['inputDriver'].getInput(environment) + if event: + timeout = False + print(event) return environment, timeout def grabDevices(self, environment): diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index 1e23bd1d..cf2e9ee1 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -29,7 +29,7 @@ class fenrir(): self.shutdown() def handleProcess(self): - #self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvent(self.environment) + self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvent(self.environment) timeout = True try: self.environment = self.environment['runtime']['screenManager'].update(self.environment) diff --git a/src/fenrir-package/input/evdev.py b/src/fenrir-package/input/evdev.py index 3a7efb58..55489a37 100644 --- a/src/fenrir-package/input/evdev.py +++ b/src/fenrir-package/input/evdev.py @@ -16,38 +16,14 @@ class input(): def shutdown(self, environment): return environment def getInput(self, environment): - - try: - 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.iDevices[fd].read(): - if self.isFenrirKey(environment, event): - environment['input']['consumeKey'] = not environment['input']['keyForeward'] and not environment['generalInformation']['suspend'] - if self.isConsumeKeypress(environment): - self.writeUInput(self.uDevices[fd], event,environment) - keyString = '' - if self.isFenrirKey(environment, event): - keyString = 'FENRIR' - else: - keyString = str(event.code) - if event.type == evdev.ecodes.EV_KEY: - if event.value != 0: - environment['input']['currShortcut'][keyString] = 1 #event.value - else: - try: - del(environment['input']['currShortcut'][keyString]) - except: - pass - except Exception as e: - environment['runtime']['debug'].writeDebugOut(environment,"Error while inputHandling",debug.debugLevel.ERROR) - environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) - self.releaseDevices() - time.sleep(0.01) - - - return environment, timeout + event = None + r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay')) + print(len(list(r))) + if r != []: + for fd in r: + event = self.iDevices[fd].read_one() + return event + return None def writeUInput(self, uDevice, event,environment): uDevice.write_event(event) @@ -58,8 +34,6 @@ class input(): 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() @@ -73,7 +47,7 @@ class input(): #dev.info.bustype, #'/dev/uinput' ) - #dev.grab() + dev.grab() def releaseDevices(self): for fd in self.iDevices: