initial working input command chain
This commit is contained in:
		| @@ -5,7 +5,7 @@ from core import runtime | ||||
| from core import screenData | ||||
| from core import generalInformation | ||||
| from core import commands | ||||
| from core import input | ||||
| from core import inputEvent | ||||
|  | ||||
| environment = { | ||||
| 'screenData': screenData.screenData, | ||||
| @@ -15,7 +15,7 @@ environment = { | ||||
| 'commands': commands.commands, | ||||
| 'commandInfo': commands.commandInfo, | ||||
| 'commandBuffer': commands.commandBuffer, | ||||
| 'input': input.input, | ||||
| 'input': inputEvent.input, | ||||
| 'soundIcons': {}, | ||||
| 'bindings': {}, | ||||
| } | ||||
|   | ||||
| @@ -6,9 +6,9 @@ input = { | ||||
| 'prevInput': [],  | ||||
| 'prevDeepestInput': [],  | ||||
| 'currEvent': None,  | ||||
| 'firstEvent': None, | ||||
| 'shortcutRepeat': 0, | ||||
| 'fenrirKey': ['82'], | ||||
| 'eventBuffer': None, | ||||
| 'shortcutRepeat': 1, | ||||
| 'fenrirKey': ['KEY_KP0'], | ||||
| 'keyForeward': False, | ||||
| 'lastInputTime':time.time(), | ||||
| 'oldNumLock': True, | ||||
| @@ -20,6 +20,7 @@ input = { | ||||
| inputEvent = { | ||||
| 'EventName': '', | ||||
| 'EventValue': '', | ||||
| 'EventTime': time.time(), | ||||
| 'EventSec': 0, | ||||
| 'EventUsec': 0, | ||||
| 'EventState': 0, | ||||
| } | ||||
|   | ||||
| @@ -2,6 +2,7 @@ | ||||
|  | ||||
| import time | ||||
| from utils import debug | ||||
| from core import inputEvent | ||||
|  | ||||
| class inputManager(): | ||||
|     def __init__(self): | ||||
| @@ -18,13 +19,30 @@ class inputManager(): | ||||
|     def proceedInputEvent(self, environment): | ||||
|         timeout = True    	 | ||||
|         event = environment['runtime']['inputDriver'].getInput(environment) | ||||
|         if event: | ||||
|         mEvent = environment['runtime']['inputDriver'].mapEvent(environment, event) | ||||
|         if mEvent and event: | ||||
|             if mEvent['EventValue'] == 0: | ||||
|                 return True         | ||||
|             timeout = False | ||||
|             environment['input']['firstEvent'] = event | ||||
|             environment['input']['currEvent'] = event | ||||
|             #if not  | ||||
|             #print(event) | ||||
|         | ||||
|             if mEvent['EventState'] == 0: | ||||
|                 if self.isFenrirKey(environment, mEvent): | ||||
|                     environment['input']['currInput'].remove('KEY_FENRIR') | ||||
|                 else: | ||||
|                     environment['input']['currInput'].remove(mEvent['EventName']) | ||||
|                 environment['input']['currInput'] = sorted(environment['input']['currInput'])                     | ||||
|             elif mEvent['EventState'] == 1: | ||||
|                 if self.isFenrirKey(environment, mEvent): | ||||
|                     environment['input']['currInput'].append('KEY_FENRIR') | ||||
|                 else:                 | ||||
|                     environment['input']['currInput'].append(mEvent['EventName'])             | ||||
|                 environment['input']['currInput'] = sorted(environment['input']['currInput']) | ||||
|             elif mEvent['EventState'] == 2: | ||||
|                 pass | ||||
|             else: | ||||
|                 pass | ||||
|             print(environment['input']['currInput'])     | ||||
|             environment['input']['lastInputTime'] = time.time() | ||||
|             environment['input']['shortcutRepeat'] = 1 | ||||
|         return timeout | ||||
|      | ||||
|     def grabDevices(self, environment): | ||||
| @@ -55,14 +73,16 @@ class inputManager(): | ||||
|         shortcut = [] | ||||
|         shortcut.append(environment['input']['shortcutRepeat']) | ||||
|         shortcut.append(sorted(environment['input']['prevInput'])) | ||||
|         return str(shortcut) | ||||
|  | ||||
|     def getPrevShortcut(self, environment): | ||||
|     def getCurrShortcut(self, environment): | ||||
|         shortcut = [] | ||||
|         shortcut.append(environment['input']['shortcutRepeat']) | ||||
|         shortcut.append(sorted(environment['input']['prevInput'])) | ||||
|         shortcut.append(sorted(environment['input']['currInput'])) | ||||
|         return str(shortcut) | ||||
|          | ||||
|     def isFenrirKey(self,environment, event): | ||||
|         return str(event.code) in environment['input']['fenrirKey'] | ||||
|     def isFenrirKey(self,environment, mEvent): | ||||
|         return str(mEvent['EventName']) in environment['input']['fenrirKey'] | ||||
|  | ||||
|     def getCommandForShortcut(self, environment, shortcut): | ||||
|         shortcut = shortcut.upper() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user