initial evdev driver
This commit is contained in:
		| @@ -20,25 +20,22 @@ for fd in iDevices: | |||||||
| #      dev.info.bustype, | #      dev.info.bustype, | ||||||
|  #     '/dev/uinput' |  #     '/dev/uinput' | ||||||
|       ) |       ) | ||||||
|     dev.grab() |  | ||||||
|  |  | ||||||
|  |  | ||||||
| i = 0 | i = 0 | ||||||
| while  i < 100: | while  i < 1000: | ||||||
|     r, w, x = select(iDevices, [], []) |     r, w, x = select(iDevices, [], []) | ||||||
|     if r != []: |     if r != []: | ||||||
|         i += 1 |         i += 1 | ||||||
|         for fd in r: |         for fd in r: | ||||||
|             for event in iDevices[fd].read(): |             for event in iDevices[fd].read(): | ||||||
|                 if event.code != 30:  # a |                 if event.code != 30:  # a | ||||||
|                     uDevices[fd].write_event(event) |                     print('Devicename:'+ iDevices[fd].name + '  Devicepath:' + iDevices[fd].fn + '  Events:' + str(iDevices[fd].active_keys(verbose=True)) + '  Value:' + str(event.value)) | ||||||
|                     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: |                 else: | ||||||
|                     print('this key is consumed') |                     print('this key is consumed') | ||||||
|  |             break | ||||||
|  |         break | ||||||
|  |  | ||||||
| for fd in iDevices: | for fd in iDevices: | ||||||
|     iDevices[fd].ungrab() |  | ||||||
|     iDevices[fd].close() |     iDevices[fd].close() | ||||||
|     uDevices[fd].close() |     uDevices[fd].close() | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ input = { | |||||||
| 'currInput': {}, | 'currInput': {}, | ||||||
| 'prevInput': {},  | 'prevInput': {},  | ||||||
| 'currEvent': None,  | 'currEvent': None,  | ||||||
| 'firstEvent': None | 'firstEvent': None, | ||||||
| 'firstEvent': None,  | 'firstEvent': None,  | ||||||
| 'currShortcutString': '', | 'currShortcutString': '', | ||||||
| 'consumeKey': False, | 'consumeKey': False, | ||||||
|   | |||||||
| @@ -12,7 +12,10 @@ class inputManager(): | |||||||
|         return environment |         return environment | ||||||
|     def proceedInputEvent(self, environment): |     def proceedInputEvent(self, environment): | ||||||
|         timeout = True    	 |         timeout = True    	 | ||||||
|         environment, timeout = environment['runtime']['inputDriver'].getInput(environment) |         event = environment['runtime']['inputDriver'].getInput(environment) | ||||||
|  |         if event: | ||||||
|  |             timeout = False | ||||||
|  |             print(event) | ||||||
|         return environment, timeout |         return environment, timeout | ||||||
|      |      | ||||||
|     def grabDevices(self, environment): |     def grabDevices(self, environment): | ||||||
|   | |||||||
| @@ -29,7 +29,7 @@ class fenrir(): | |||||||
|         self.shutdown() |         self.shutdown() | ||||||
|  |  | ||||||
|     def handleProcess(self): |     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 |         timeout = True | ||||||
|         try: |         try: | ||||||
|             self.environment = self.environment['runtime']['screenManager'].update(self.environment) |             self.environment = self.environment['runtime']['screenManager'].update(self.environment) | ||||||
|   | |||||||
| @@ -16,38 +16,14 @@ class input(): | |||||||
|     def shutdown(self, environment): |     def shutdown(self, environment): | ||||||
|         return environment |         return environment | ||||||
|     def getInput(self, environment): |     def getInput(self, environment): | ||||||
|  |         event = None | ||||||
|         try: |  | ||||||
|         r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay')) |         r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay')) | ||||||
|  |         print(len(list(r))) | ||||||
|         if r != []: |         if r != []: | ||||||
|                 timeout = False |  | ||||||
|             for fd in r: |             for fd in r: | ||||||
|                     for event in self.iDevices[fd].read(): |                 event = self.iDevices[fd].read_one() | ||||||
|                         if self.isFenrirKey(environment, event):  |                 return event | ||||||
|                             environment['input']['consumeKey'] = not environment['input']['keyForeward'] and not environment['generalInformation']['suspend'] |         return None | ||||||
|                         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 |  | ||||||
|  |  | ||||||
|     def writeUInput(self, uDevice, event,environment): |     def writeUInput(self, uDevice, event,environment): | ||||||
|         uDevice.write_event(event) |         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()} |         self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()} | ||||||
|  |  | ||||||
|     def grabDevices(self): |     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() | ||||||
| @@ -73,7 +47,7 @@ class input(): | |||||||
|               #dev.info.bustype, |               #dev.info.bustype, | ||||||
|               #'/dev/uinput' |               #'/dev/uinput' | ||||||
|               ) |               ) | ||||||
|             #dev.grab() |             dev.grab() | ||||||
|  |  | ||||||
|     def releaseDevices(self): |     def releaseDevices(self): | ||||||
|         for fd in self.iDevices: |         for fd in self.iDevices: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user