initial working input command chain
This commit is contained in:
parent
09320092bc
commit
75db6ac58f
@ -5,7 +5,7 @@ from core import runtime
|
|||||||
from core import screenData
|
from core import screenData
|
||||||
from core import generalInformation
|
from core import generalInformation
|
||||||
from core import commands
|
from core import commands
|
||||||
from core import input
|
from core import inputEvent
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
'screenData': screenData.screenData,
|
'screenData': screenData.screenData,
|
||||||
@ -15,7 +15,7 @@ environment = {
|
|||||||
'commands': commands.commands,
|
'commands': commands.commands,
|
||||||
'commandInfo': commands.commandInfo,
|
'commandInfo': commands.commandInfo,
|
||||||
'commandBuffer': commands.commandBuffer,
|
'commandBuffer': commands.commandBuffer,
|
||||||
'input': input.input,
|
'input': inputEvent.input,
|
||||||
'soundIcons': {},
|
'soundIcons': {},
|
||||||
'bindings': {},
|
'bindings': {},
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ input = {
|
|||||||
'prevInput': [],
|
'prevInput': [],
|
||||||
'prevDeepestInput': [],
|
'prevDeepestInput': [],
|
||||||
'currEvent': None,
|
'currEvent': None,
|
||||||
'firstEvent': None,
|
'eventBuffer': None,
|
||||||
'shortcutRepeat': 0,
|
'shortcutRepeat': 1,
|
||||||
'fenrirKey': ['82'],
|
'fenrirKey': ['KEY_KP0'],
|
||||||
'keyForeward': False,
|
'keyForeward': False,
|
||||||
'lastInputTime':time.time(),
|
'lastInputTime':time.time(),
|
||||||
'oldNumLock': True,
|
'oldNumLock': True,
|
||||||
@ -20,6 +20,7 @@ input = {
|
|||||||
inputEvent = {
|
inputEvent = {
|
||||||
'EventName': '',
|
'EventName': '',
|
||||||
'EventValue': '',
|
'EventValue': '',
|
||||||
'EventTime': time.time(),
|
'EventSec': 0,
|
||||||
|
'EventUsec': 0,
|
||||||
'EventState': 0,
|
'EventState': 0,
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
from utils import debug
|
from utils import debug
|
||||||
|
from core import inputEvent
|
||||||
|
|
||||||
class inputManager():
|
class inputManager():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -18,13 +19,30 @@ class inputManager():
|
|||||||
def proceedInputEvent(self, environment):
|
def proceedInputEvent(self, environment):
|
||||||
timeout = True
|
timeout = True
|
||||||
event = environment['runtime']['inputDriver'].getInput(environment)
|
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
|
timeout = False
|
||||||
environment['input']['firstEvent'] = event
|
if mEvent['EventState'] == 0:
|
||||||
environment['input']['currEvent'] = event
|
if self.isFenrirKey(environment, mEvent):
|
||||||
#if not
|
environment['input']['currInput'].remove('KEY_FENRIR')
|
||||||
#print(event)
|
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
|
return timeout
|
||||||
|
|
||||||
def grabDevices(self, environment):
|
def grabDevices(self, environment):
|
||||||
@ -55,14 +73,16 @@ class inputManager():
|
|||||||
shortcut = []
|
shortcut = []
|
||||||
shortcut.append(environment['input']['shortcutRepeat'])
|
shortcut.append(environment['input']['shortcutRepeat'])
|
||||||
shortcut.append(sorted(environment['input']['prevInput']))
|
shortcut.append(sorted(environment['input']['prevInput']))
|
||||||
|
return str(shortcut)
|
||||||
|
|
||||||
def getPrevShortcut(self, environment):
|
def getCurrShortcut(self, environment):
|
||||||
shortcut = []
|
shortcut = []
|
||||||
shortcut.append(environment['input']['shortcutRepeat'])
|
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):
|
def isFenrirKey(self,environment, mEvent):
|
||||||
return str(event.code) in environment['input']['fenrirKey']
|
return str(mEvent['EventName']) in environment['input']['fenrirKey']
|
||||||
|
|
||||||
def getCommandForShortcut(self, environment, shortcut):
|
def getCommandForShortcut(self, environment, shortcut):
|
||||||
shortcut = shortcut.upper()
|
shortcut = shortcut.upper()
|
||||||
|
@ -34,25 +34,28 @@ class fenrir():
|
|||||||
|
|
||||||
def handleProcess(self):
|
def handleProcess(self):
|
||||||
timeout = self.environment['runtime']['inputManager'].proceedInputEvent(self.environment)
|
timeout = self.environment['runtime']['inputManager'].proceedInputEvent(self.environment)
|
||||||
timeout = True
|
|
||||||
try:
|
try:
|
||||||
self.environment['runtime']['screenManager'].update(self.environment)
|
self.environment['runtime']['screenManager'].update(self.environment)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
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 (self.environment['input']['keyForeward'] or timeout):
|
if not timeout:
|
||||||
#currShortcut = self.environment['runtime']['inputManager'].getCurrShortcut(self.environment)
|
self.prepareCommand()
|
||||||
shortcut = "[1, ['KEY_FENRIR', 'KEY_T']]"
|
|
||||||
command = self.environment['runtime']['inputManager'].getCommandForShortcut(self.environment, shortcut)
|
|
||||||
print(command)
|
|
||||||
#self.environment['runtime']['commandManager'].queueCommand(self.environment, command)
|
|
||||||
if not timeout:
|
|
||||||
self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput')
|
self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput')
|
||||||
self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
||||||
if not self.environment['input']['keyForeward']:
|
self.handleCommands()
|
||||||
self.handleCommands()
|
|
||||||
|
|
||||||
|
def prepareCommand(self):
|
||||||
|
if self.environment['input']['keyForeward']:
|
||||||
|
return
|
||||||
|
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut(self.environment)
|
||||||
|
command = self.environment['runtime']['inputManager'].getCommandForShortcut(self.environment, shortcut)
|
||||||
|
print(command)
|
||||||
|
self.environment['runtime']['commandManager'].queueCommand(self.environment, command)
|
||||||
|
|
||||||
def handleCommands(self):
|
def handleCommands(self):
|
||||||
|
if self.environment['input']['keyForeward']:
|
||||||
|
return
|
||||||
if self.environment['runtime']['commandManager'].isCommandQueued(self.environment):
|
if self.environment['runtime']['commandManager'].isCommandQueued(self.environment):
|
||||||
self.environment['runtime']['commandManager'].executeCommand(self.environment, self.environment['commandInfo']['currCommand'], 'commands')
|
self.environment['runtime']['commandManager'].executeCommand(self.environment, self.environment['commandInfo']['currCommand'], 'commands')
|
||||||
|
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
import evdev
|
import evdev
|
||||||
from evdev import InputDevice, UInput
|
from evdev import InputDevice, UInput
|
||||||
from select import select
|
|
||||||
import time
|
import time
|
||||||
|
from select import select
|
||||||
|
|
||||||
|
from core import inputEvent
|
||||||
from utils import debug
|
from utils import debug
|
||||||
|
|
||||||
class driver():
|
class driver():
|
||||||
@ -32,11 +34,20 @@ class driver():
|
|||||||
self.iDevices = map(evdev.InputDevice, (evdev.list_devices()))
|
self.iDevices = map(evdev.InputDevice, (evdev.list_devices()))
|
||||||
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 mapEvent(self, event):
|
def mapEvent(self,environment, event):
|
||||||
|
if not event:
|
||||||
|
return None
|
||||||
|
mEvent = inputEvent.inputEvent
|
||||||
try:
|
try:
|
||||||
return evdev.ecodes.ecodes[keyID.upper()]
|
mEvent['EventName'] = evdev.ecodes.keys[event.code].upper()
|
||||||
except:
|
mEvent['EventValue'] = event.code
|
||||||
return 0
|
mEvent['EventSec'] = event.sec
|
||||||
|
mEvent['EventUsec'] = event.usec
|
||||||
|
mEvent['EventState'] = event.value
|
||||||
|
return mEvent
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
return None
|
||||||
|
|
||||||
def grabDevices(self):
|
def grabDevices(self):
|
||||||
for fd in self.iDevices:
|
for fd in self.iDevices:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user