fix typos

This commit is contained in:
chrys 2016-09-21 18:07:28 +02:00
parent 5f77198e80
commit 9c571ba032
2 changed files with 31 additions and 29 deletions

View File

@ -13,48 +13,48 @@ class inputManager():
pass pass
def initialize(self, environment): def initialize(self, environment):
environment['runtime']['settingsManager'].loadDriver(environment,\ environment['runtime']['settingsManager'].loadDriver(environment,\
environment['runtime']['settingsManager'].getSetting(environment,'keyboard', 'driver'), 'inputDriver') environment['runtime']['settingsManager'].getSetting(environment,'keyboard', 'driver'), 'inputDriver')
# init LEDs with current state # init LEDs with current state
environment['input']['newNumLock'] = environment['runtime']['inputDriver'].getNumlock(environment) environment['input']['newNumLock'] = environment['runtime']['inputDriver'].getNumlock(environment)
environment['input']['oldNumLock'] = environment['input']['newNumLock'] environment['input']['oldNumLock'] = environment['input']['newNumLock']
environment['input']['newCapsLock'] = environment['runtime']['inputDriver'].getCapslock(environment) environment['input']['newCapsLock'] = environment['runtime']['inputDriver'].getCapslock(environment)
environment['input']['oldCapsLock'] = environment['input']['newCapsLock'] environment['input']['oldCapsLock'] = environment['input']['newCapsLock']
environment['input']['newScrollLock'] = environment['runtime']['inputDriver'].getScrollLock(environment) environment['input']['newScrollLock'] = environment['runtime']['inputDriver'].getScrollLock(environment)
environment['input']['oldScrollLock'] = environment['input']['newScrollLock'] environment['input']['oldScrollLock'] = environment['input']['newScrollLock']
self.grabDevices(environment) self.grabDevices(environment)
def shutdown(self, environment): def shutdown(self, environment):
environment['runtime']['inputManager'].releaseDevices(environment) environment['runtime']['inputManager'].releaseDevices(environment)
if environment['runtime']['inputDriver']: if environment['runtime']['inputDriver']:
environment['runtime']['inputDriver'].shutdown(environment) environment['runtime']['inputDriver'].shutdown(environment)
del environment['runtime']['inputDriver'] del environment['runtime']['inputDriver']
def getInputEvent(self, environment): def getInputEvent(self, environment):
eventReceived = False eventReceived = False
mEvent = environment['runtime']['inputDriver'].getInput(environment) mEvent = environment['runtime']['inputDriver'].getInputEvent(environment)
mEvent['EventName'] = self.convertEventName(mEvent['EventName'])
if mEvent: if mEvent:
mEvent['EventName'] = self.convertEventName(environment, mEvent['EventName'])
if mEvent['EventValue'] == 0: if mEvent['EventValue'] == 0:
return False return False
eventReceived = True eventReceived = True
if mEvent['EventState'] == 0: if mEvent['EventState'] == 0:
if mEvent['EventName'] in environment['input']['currInput']: if mEvent['EventName'] in environment['input']['currInput']:
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 not mEvent['EventName'] in environment['input']['currInput']: if not mEvent['EventName'] in environment['input']['currInput']:
environment['input']['currInput'].append(mEvent['EventName']) environment['input']['currInput'].append(mEvent['EventName'])
environment['input']['currInput'] = sorted(environment['input']['currInput']) environment['input']['currInput'] = sorted(environment['input']['currInput'])
elif mEvent['EventState'] == 2: elif mEvent['EventState'] == 2:
pass pass
else: else:
pass pass
environment['input']['oldNumLock'] = environment['input']['newNumLock'] environment['input']['oldNumLock'] = environment['input']['newNumLock']
environment['input']['newNumLock'] = environment['runtime']['inputDriver'].getNumlock(environment) environment['input']['newNumLock'] = environment['runtime']['inputDriver'].getNumlock(environment)
environment['input']['oldCapsLock'] = environment['input']['newCapsLock'] environment['input']['oldCapsLock'] = environment['input']['newCapsLock']
environment['input']['newCapsLock'] = environment['runtime']['inputDriver'].getCapslock(environment) environment['input']['newCapsLock'] = environment['runtime']['inputDriver'].getCapslock(environment)
environment['input']['oldScrollLock'] = environment['input']['newScrollLock'] environment['input']['oldScrollLock'] = environment['input']['newScrollLock']
environment['input']['newScrollLock'] = environment['runtime']['inputDriver'].getScrollLock(environment) environment['input']['newScrollLock'] = environment['runtime']['inputDriver'].getScrollLock(environment)
environment['input']['lastInputTime'] = time.time() environment['input']['lastInputTime'] = time.time()
environment['input']['shortcutRepeat'] = 1 environment['input']['shortcutRepeat'] = 1
return eventReceived return eventReceived
@ -66,7 +66,9 @@ class inputManager():
def releaseDevices(self, environment): def releaseDevices(self, environment):
environment['runtime']['inputDriver'].releaseDevices(environment) environment['runtime']['inputDriver'].releaseDevices(environment)
def convertEventName(self, eventName): def convertEventName(self, environment, eventName):
if not eventName:
return ''
if eventName == 'KEY_LEFTCTRL': if eventName == 'KEY_LEFTCTRL':
eventName == 'KEY_CTRL' eventName == 'KEY_CTRL'
elif eventName == 'KEY_RIGHTCTRL': elif eventName == 'KEY_RIGHTCTRL':
@ -80,18 +82,18 @@ class inputManager():
elif eventName == 'KEY_RIGHTALT': elif eventName == 'KEY_RIGHTALT':
eventName = 'KEY_ALT' eventName = 'KEY_ALT'
if self.isFenrirKey(environment, eventName): if self.isFenrirKey(environment, eventName):
eventName = 'KEY_FENRIR' eventName = 'KEY_FENRIR'
return eventName 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']
#and #and
# not (environment['input']['keyForeward'] or \ # not (environment['input']['keyForeward'] or \
# environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices')) # environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices'))
def clearEventBuffer(self, environment): def clearEventBuffer(self, environment):
environment['runtime']['inputDriver'].clearEventBuffer(environment) environment['runtime']['inputDriver'].clearEventBuffer(environment)
def writeEventBuffer(self, environment): def writeEventBuffer(self, environment):
try: try:
@ -99,7 +101,8 @@ class inputManager():
except Exception as e: except Exception as e:
print(e) print(e)
environment['runtime']['debug'].writeDebugOut(environment,"Error while writeUInput",debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(environment,"Error while writeUInput",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment, str(e),debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(environment, str(e),debug.debugLevel.ERROR)
def isFenrirKeyPressed(self, environment): def isFenrirKeyPressed(self, environment):
return 'KEY_FENRIR' in environment['input']['currInput'] return 'KEY_FENRIR' in environment['input']['currInput']
@ -133,4 +136,3 @@ class inputManager():
def shortcutExists(self, environment, shortcut): def shortcutExists(self, environment, shortcut):
return( str(shortcut).upper() in environment['bindings']) return( str(shortcut).upper() in environment['bindings'])

View File

@ -22,7 +22,7 @@ class driver():
self.getInputDevices(environment) self.getInputDevices(environment)
def shutdown(self, environment): def shutdown(self, environment):
pass pass
def getInput(self, environment): def getInputEvent(self, environment):
event = None event = None
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'))
if r != []: if r != []: