Update inputManager.py
This commit is contained in:
parent
4fd69bfe2d
commit
a251e5c466
@ -31,34 +31,19 @@ class inputManager():
|
|||||||
def proceedInputEvent(self, environment):
|
def proceedInputEvent(self, environment):
|
||||||
timeout = True
|
timeout = True
|
||||||
mEvent = environment['runtime']['inputDriver'].getInput(environment)
|
mEvent = environment['runtime']['inputDriver'].getInput(environment)
|
||||||
|
mEvent['EventName'] = self.convertEventName(mEvent['EventName'])
|
||||||
if mEvent:
|
if mEvent:
|
||||||
if mEvent['EventValue'] == 0:
|
if mEvent['EventValue'] == 0:
|
||||||
return True
|
return True
|
||||||
timeout = False
|
timeout = False
|
||||||
if mEvent['EventState'] == 0:
|
if mEvent['EventState'] == 0:
|
||||||
if self.isFenrirKey(environment, mEvent):
|
if mEvent['EventName'] in environment['input']['currInput']:
|
||||||
environment['input']['currInput'].remove('KEY_FENRIR')
|
|
||||||
elif mEvent['EventName'] in ['KEY_RIGHTCTRL','KEY_LEFTCTRL'] :
|
|
||||||
environment['input']['currInput'].remove('KEY_CTRL')
|
|
||||||
elif mEvent['EventName'] in ['KEY_RIGHTSHIFT','KEY_LEFTSHIFT'] :
|
|
||||||
environment['input']['currInput'].remove('KEY_SHIFT')
|
|
||||||
else:
|
|
||||||
environment['input']['currInput'].remove(mEvent['EventName'])
|
environment['input']['currInput'].remove(mEvent['EventName'])
|
||||||
environment['input']['currInput'] = sorted(environment['input']['currInput'])
|
environment['input']['currInput'] = sorted(environment['input']['currInput'])
|
||||||
elif mEvent['EventState'] == 1:
|
elif mEvent['EventState'] == 1:
|
||||||
if self.isFenrirKey(environment, mEvent):
|
if not mEvent['EventName'] in environment['input']['currInput']:
|
||||||
if not self.isFenrirKeyPressed(environment):
|
environment['input']['currInput'].append(mEvent['EventName'])
|
||||||
environment['input']['currInput'].append('KEY_FENRIR')
|
environment['input']['currInput'] = sorted(environment['input']['currInput'])
|
||||||
elif mEvent['EventName'] in ['KEY_RIGHTCTRL','KEY_LEFTCTRL'] :
|
|
||||||
if not 'KEY_CTRL' in environment['input']['currInput']:
|
|
||||||
environment['input']['currInput'].append('KEY_CTRL')
|
|
||||||
elif mEvent['EventName'] in ['KEY_RIGHTSHIFT','KEY_LEFTSHIFT'] :
|
|
||||||
if not 'KEY_SHIFT' in environment['input']['currInput']:
|
|
||||||
environment['input']['currInput'].append('KEY_SHIFT')
|
|
||||||
else:
|
|
||||||
if not mEvent['EventName'] in environment['input']['currInput']:
|
|
||||||
environment['input']['currInput'].append(mEvent['EventName'])
|
|
||||||
environment['input']['currInput'] = sorted(environment['input']['currInput'])
|
|
||||||
elif mEvent['EventState'] == 2:
|
elif mEvent['EventState'] == 2:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -79,7 +64,24 @@ class inputManager():
|
|||||||
|
|
||||||
def releaseDevices(self, environment):
|
def releaseDevices(self, environment):
|
||||||
environment['runtime']['inputDriver'].releaseDevices(environment)
|
environment['runtime']['inputDriver'].releaseDevices(environment)
|
||||||
|
|
||||||
|
def convertEventName(self, eventName):
|
||||||
|
if eventName == 'KEY_LEFTCTRL':
|
||||||
|
eventName == 'KEY_CTRL'
|
||||||
|
elif eventName == 'KEY_RIGHTCTRL':
|
||||||
|
eventName = 'KEY_CTRL'
|
||||||
|
elif eventName == 'KEY_LEFTSHIFT':
|
||||||
|
eventName = 'KEY_SHIFT'
|
||||||
|
elif eventName == 'KEY_RIGHTSHIFT':
|
||||||
|
eventName = 'KEY_SHIFT'
|
||||||
|
elif eventName == 'KEY_LEFTALT':
|
||||||
|
eventName = 'KEY_ALT'
|
||||||
|
elif eventName == 'KEY_RIGHTALT':
|
||||||
|
eventName = 'KEY_ALT'
|
||||||
|
if self.isFenrirKey(environment, eventName):
|
||||||
|
eventName = 'KEY_FENRIR'
|
||||||
|
return eventName
|
||||||
|
|
||||||
def isConsumeInput(self, environment):
|
def isConsumeInput(self, environment):
|
||||||
return environment['runtime']['commandManager'].isCommandQueued(environment) and \
|
return environment['runtime']['commandManager'].isCommandQueued(environment) and \
|
||||||
not environment['input']['keyForeward']
|
not environment['input']['keyForeward']
|
||||||
@ -119,8 +121,8 @@ class inputManager():
|
|||||||
shortcut.append(sorted(environment['input']['currInput']))
|
shortcut.append(sorted(environment['input']['currInput']))
|
||||||
return str(shortcut)
|
return str(shortcut)
|
||||||
|
|
||||||
def isFenrirKey(self,environment, mEvent):
|
def isFenrirKey(self,environment, eventName):
|
||||||
return str(mEvent['EventName']) in environment['input']['fenrirKey']
|
return eventName in environment['input']['fenrirKey']
|
||||||
|
|
||||||
def getCommandForShortcut(self, environment, shortcut):
|
def getCommandForShortcut(self, environment, shortcut):
|
||||||
shortcut = shortcut.upper()
|
shortcut = shortcut.upper()
|
||||||
|
Loading…
Reference in New Issue
Block a user