initial keyboard grab
This commit is contained in:
parent
9fbbfc7e6e
commit
30f579f12b
@ -4,12 +4,11 @@ class command():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
return environment
|
pass
|
||||||
def shutdown(self, environment):
|
def shutdown(self, environment):
|
||||||
return environment
|
pass
|
||||||
def getDescription(self, environment):
|
def getDescription(self, environment):
|
||||||
return 'interrupts the current presentation'
|
return 'interrupts the current presentation'
|
||||||
|
|
||||||
def run(self, environment):
|
def run(self, environment):
|
||||||
environment['runtime']['outputManager'].interruptOutput(environment)
|
environment['runtime']['outputManager'].interruptOutput(environment)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
|
@ -4,23 +4,23 @@ class command():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
return environment
|
pass
|
||||||
def shutdown(self, environment):
|
def shutdown(self, environment):
|
||||||
return environment
|
pass
|
||||||
def getDescription(self, environment):
|
def getDescription(self, environment):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def run(self, environment):
|
def run(self, environment):
|
||||||
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'interruptOnKeyPress'):
|
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'interruptOnKeyPress'):
|
||||||
return environment
|
return
|
||||||
|
if environment['runtime']['inputManager'].noKeyPressed(environment):
|
||||||
|
return
|
||||||
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
|
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
|
||||||
return environment
|
return
|
||||||
# if environment['screenData']['newCursor'] == environment['screenData']['oldCursor'] and\
|
# if environment['screenData']['newCursor'] == environment['screenData']['oldCursor'] and\
|
||||||
# environment['screenData']['newDelta'] == environment['screenData']['oldDelta']:
|
# environment['screenData']['newDelta'] == environment['screenData']['oldDelta']:
|
||||||
# return environment
|
# return environment
|
||||||
if environment['input']['currShortcut'] != '':
|
|
||||||
return environment
|
|
||||||
environment['runtime']['outputManager'].interruptOutput(environment)
|
environment['runtime']['outputManager'].interruptOutput(environment)
|
||||||
return environment
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -4,33 +4,34 @@ class command():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
return environment
|
pass
|
||||||
def shutdown(self, environment):
|
def shutdown(self, environment):
|
||||||
return environment
|
pass
|
||||||
def getDescription(self, environment):
|
def getDescription(self, environment):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def run(self, environment):
|
def run(self, environment):
|
||||||
# TTY Change
|
# TTY Change
|
||||||
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
|
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
|
||||||
return environment
|
return
|
||||||
|
if environment['runtime']['inputManager'].noKeyPressed(environment):
|
||||||
|
return
|
||||||
# detect an change on the screen, we just want to cursor arround, so no change should appear
|
# detect an change on the screen, we just want to cursor arround, so no change should appear
|
||||||
if environment['screenData']['newDelta'] != '':
|
if environment['screenData']['newDelta'] != '':
|
||||||
return environment
|
return
|
||||||
if environment['screenData']['newNegativeDelta'] != '':
|
if environment['screenData']['newNegativeDelta'] != '':
|
||||||
return environment
|
return
|
||||||
# is it a horizontal change?
|
# is it a horizontal change?
|
||||||
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y'] or\
|
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y'] or\
|
||||||
environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']:
|
environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']:
|
||||||
return environment
|
return
|
||||||
|
print('drin')
|
||||||
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']].strip() == '':
|
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']].strip() == '':
|
||||||
pass
|
pass
|
||||||
#environment['runtime']['outputManager'].presentText(environment, "blank",True)
|
#environment['runtime']['outputManager'].presentText(environment, "blank",True)
|
||||||
else:
|
else:
|
||||||
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']],interrupt=True)
|
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']],interrupt=True)
|
||||||
|
|
||||||
return environment
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@ class command():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
return environment
|
pass
|
||||||
def shutdown(self, environment):
|
def shutdown(self, environment):
|
||||||
return environment
|
pass
|
||||||
def getDescription(self, environment):
|
def getDescription(self, environment):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@ -21,8 +21,7 @@ class command():
|
|||||||
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True)
|
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True)
|
||||||
else:
|
else:
|
||||||
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']], True)
|
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']], True)
|
||||||
|
|
||||||
return environment
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ class commandManager():
|
|||||||
environment['commands'][section][command].run(environment)
|
environment['commands'][section][command].run(environment)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
environment['runtime']['debug'].writeDebugOut(environment,"Executing command:" + section + "." + command ,debug.debugLevel.ERROR)
|
environment['runtime']['debug'].writeDebugOut(environment,"Executing command:" + section + "." + command ,debug.debugLevel.ERROR)
|
||||||
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
|
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
|
||||||
self.clearCommandQueued(environment)
|
self.clearCommandQueued(environment)
|
||||||
|
@ -17,7 +17,7 @@ class inputManager():
|
|||||||
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)
|
||||||
@ -25,11 +25,9 @@ class inputManager():
|
|||||||
environment['runtime']['inputDriver'].shutdown(environment)
|
environment['runtime']['inputDriver'].shutdown(environment)
|
||||||
|
|
||||||
def proceedInputEvent(self, environment):
|
def proceedInputEvent(self, environment):
|
||||||
|
|
||||||
timeout = True
|
timeout = True
|
||||||
event = environment['runtime']['inputDriver'].getInput(environment)
|
mEvent = environment['runtime']['inputDriver'].getInput(environment)
|
||||||
mEvent = environment['runtime']['inputDriver'].mapEvent(environment, event)
|
if mEvent:
|
||||||
if mEvent and event:
|
|
||||||
if mEvent['EventValue'] == 0:
|
if mEvent['EventValue'] == 0:
|
||||||
return True
|
return True
|
||||||
timeout = False
|
timeout = False
|
||||||
@ -45,7 +43,7 @@ class inputManager():
|
|||||||
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 self.isFenrirKey(environment, mEvent):
|
||||||
if not 'KEY_FENRIR' in environment['input']['currInput']:
|
if not self.isFenrirKeyPressed(environment):
|
||||||
environment['input']['currInput'].append('KEY_FENRIR')
|
environment['input']['currInput'].append('KEY_FENRIR')
|
||||||
elif mEvent['EventName'] in ['KEY_RIGHTCTRL','KEY_LEFTCTRL'] :
|
elif mEvent['EventName'] in ['KEY_RIGHTCTRL','KEY_LEFTCTRL'] :
|
||||||
if not 'KEY_CTRL' in environment['input']['currInput']:
|
if not 'KEY_CTRL' in environment['input']['currInput']:
|
||||||
@ -76,20 +74,30 @@ class inputManager():
|
|||||||
environment['runtime']['inputDriver'].grabDevices(environment)
|
environment['runtime']['inputDriver'].grabDevices(environment)
|
||||||
|
|
||||||
def releaseDevices(self, environment):
|
def releaseDevices(self, environment):
|
||||||
environment['runtime']['inputDriver'].releaseDevices()
|
environment['runtime']['inputDriver'].releaseDevices(environment)
|
||||||
|
|
||||||
def isConsumeInput(self, environment):
|
def isConsumeInput(self, environment):
|
||||||
return environment['input']['consumeKey'] and \
|
return environment['runtime']['commandManager'].isCommandQueued(environment) and \
|
||||||
not environment['input']['keyForeward'] or \
|
not environment['input']['keyForeward']
|
||||||
not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices')
|
#and
|
||||||
|
# not (environment['input']['keyForeward'] or \
|
||||||
|
# environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices'))
|
||||||
|
|
||||||
|
def clearEventBuffer(self, environment):
|
||||||
|
environment['runtime']['inputDriver'].clearEventBuffer(environment)
|
||||||
|
|
||||||
def passInput(self, environment):
|
def writeEventBuffer(self, environment):
|
||||||
try:
|
try:
|
||||||
environment['runtime']['inputDriver']
|
environment['runtime']['inputDriver'].writeEventBuffer(environment)
|
||||||
except Exception as e:
|
except Exception as 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):
|
||||||
|
return 'KEY_FENRIR' in environment['input']['currInput']
|
||||||
|
|
||||||
|
def noKeyPressed(self, environment):
|
||||||
|
return environment['input']['currInput'] == []
|
||||||
def getPrevDeepestInput(self, environment):
|
def getPrevDeepestInput(self, environment):
|
||||||
shortcut = []
|
shortcut = []
|
||||||
shortcut.append(environment['input']['shortcutRepeat'])
|
shortcut.append(environment['input']['shortcutRepeat'])
|
||||||
|
@ -41,16 +41,23 @@ class fenrir():
|
|||||||
self.environment['runtime']['debug'].writeDebugOut(self.environment, str(e),debug.debugLevel.ERROR)
|
self.environment['runtime']['debug'].writeDebugOut(self.environment, str(e),debug.debugLevel.ERROR)
|
||||||
if not timeout:
|
if not timeout:
|
||||||
self.prepareCommand()
|
self.prepareCommand()
|
||||||
self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput')
|
if not (self.environment['runtime']['inputManager'].isConsumeInput(self.environment) or \
|
||||||
self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
self.environment['runtime']['inputManager'].isFenrirKeyPressed(self.environment)):
|
||||||
|
self.environment['runtime']['inputManager'].writeEventBuffer(self.environment)
|
||||||
|
elif not self.environment['runtime']['commandManager'].isCommandQueued(self.environment) or self.environment['runtime']['inputManager'].noKeyPressed(self.environment):
|
||||||
|
self.environment['runtime']['inputManager'].clearEventBuffer(self.environment)
|
||||||
|
self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput')
|
||||||
|
self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
||||||
|
|
||||||
self.handleCommands()
|
self.handleCommands()
|
||||||
|
|
||||||
def prepareCommand(self):
|
def prepareCommand(self):
|
||||||
if self.environment['input']['keyForeward']:
|
if self.environment['input']['keyForeward']:
|
||||||
return
|
return
|
||||||
|
if time.time() - self.environment['commandInfo']['lastCommandExecutionTime'] < 0.2:
|
||||||
|
return
|
||||||
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut(self.environment)
|
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut(self.environment)
|
||||||
command = self.environment['runtime']['inputManager'].getCommandForShortcut(self.environment, shortcut)
|
command = self.environment['runtime']['inputManager'].getCommandForShortcut(self.environment, shortcut)
|
||||||
print(command)
|
|
||||||
self.environment['runtime']['commandManager'].queueCommand(self.environment, command)
|
self.environment['runtime']['commandManager'].queueCommand(self.environment, command)
|
||||||
|
|
||||||
def handleCommands(self):
|
def handleCommands(self):
|
||||||
|
@ -15,7 +15,7 @@ class driver():
|
|||||||
self.ledDevices = {}
|
self.ledDevices = {}
|
||||||
|
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.getInputDevices()
|
self.getInputDevices(environment)
|
||||||
def shutdown(self, environment):
|
def shutdown(self, environment):
|
||||||
pass
|
pass
|
||||||
def getInput(self, environment):
|
def getInput(self, environment):
|
||||||
@ -24,14 +24,23 @@ class driver():
|
|||||||
if r != []:
|
if r != []:
|
||||||
for fd in r:
|
for fd in r:
|
||||||
event = self.iDevices[fd].read_one()
|
event = self.iDevices[fd].read_one()
|
||||||
return event
|
environment['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])
|
||||||
|
return environment['runtime']['inputDriver'].mapEvent(environment, event)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def writeUInput(self, uDevice, event,environment):
|
def writeEventBuffer(self, environment):
|
||||||
|
for iDevice, uDevice, event in environment['input']['eventBuffer']:
|
||||||
|
self.writeUInput(environment, uDevice, event)
|
||||||
|
self.clearEventBuffer(environment)
|
||||||
|
|
||||||
|
def clearEventBuffer(self, environment):
|
||||||
|
del environment['input']['eventBuffer'][:]
|
||||||
|
|
||||||
|
def writeUInput(self, environment, uDevice, event):
|
||||||
uDevice.write_event(event)
|
uDevice.write_event(event)
|
||||||
uDevice.syn()
|
uDevice.syn()
|
||||||
|
|
||||||
def getInputDevices(self):
|
def getInputDevices(self, environment):
|
||||||
# 3 pos absolute
|
# 3 pos absolute
|
||||||
# 2 pos relative
|
# 2 pos relative
|
||||||
# 17 LEDs
|
# 17 LEDs
|
||||||
@ -84,7 +93,7 @@ class driver():
|
|||||||
return 2 in dev.leds()
|
return 2 in dev.leds()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def grabDevices(self):
|
def grabDevices(self, environment):
|
||||||
for fd in self.iDevices:
|
for fd in self.iDevices:
|
||||||
dev = self.iDevices[fd]
|
dev = self.iDevices[fd]
|
||||||
cap = dev.capabilities()
|
cap = dev.capabilities()
|
||||||
@ -100,7 +109,7 @@ class driver():
|
|||||||
)
|
)
|
||||||
dev.grab()
|
dev.grab()
|
||||||
|
|
||||||
def releaseDevices(self):
|
def releaseDevices(self, environment):
|
||||||
for fd in self.iDevices:
|
for fd in self.iDevices:
|
||||||
try:
|
try:
|
||||||
self.iDevices[fd].ungrab()
|
self.iDevices[fd].ungrab()
|
||||||
|
Loading…
Reference in New Issue
Block a user