Merge branch 'master' of github.com:chrys87/fenrir
This commit is contained in:
commit
2ce5adba82
11
TODO v2.0
11
TODO v2.0
@ -5,9 +5,6 @@ Things needing little knowledge are marked with "(Easy for contribution)". so ju
|
||||
[X] = Done
|
||||
|
||||
Cleanups:
|
||||
- split oldValues := newValues out to helper function
|
||||
[] split it out
|
||||
[] use it in vcsa driver
|
||||
- Migrate *Data.py to classes and use getter/setter (Easy for contribution)
|
||||
[] commandsData.py
|
||||
[] eventData.py
|
||||
@ -20,7 +17,11 @@ Cleanups:
|
||||
[] settingsData -> defaultSettings.py
|
||||
|
||||
General:
|
||||
- make fenrir runable without settingsfile. fallback to defaults
|
||||
- get information already in watchdogs insteed of mainloop (use eventloop to transport)
|
||||
[X] InputDriver
|
||||
[] ScreenDriver
|
||||
[] split oldValues := newValues out to helper function
|
||||
[] move processing of diff to watchdog
|
||||
- imporove attribute handling
|
||||
[] improve attributes_curr_char (Easy for contribution)
|
||||
[] add an attribute sound (Easy for contribution)
|
||||
@ -46,6 +47,8 @@ General:
|
||||
[] select field separator
|
||||
- make it runnable via pypy3 (low priority)
|
||||
[] wrapper script for running Fenrir to check if pypy exists, use python3 as fallback.
|
||||
- make fenrir runnable without root permissions
|
||||
- make fenrir runable without settingsfile. fallback to defaults
|
||||
|
||||
Braille Support:
|
||||
[] brailleFocusMode:
|
||||
|
0
src/fenrir/core/eventData.py
Executable file → Normal file
0
src/fenrir/core/eventData.py
Executable file → Normal file
@ -49,12 +49,16 @@ class fenrirManager():
|
||||
self.environment['runtime']['eventManager'].startMainEventLoop()
|
||||
self.shutdown()
|
||||
def handleInput(self, event):
|
||||
#startTime = time.time()
|
||||
eventReceived = self.environment['runtime']['inputManager'].getInputEvent()
|
||||
#startTime = time.time
|
||||
self.environment['runtime']['debug'].writeDebugOut('DEBUG INPUT fenrirMan:' + str(event),debug.debugLevel.INFO)
|
||||
if not event['Data']:
|
||||
event['Data'] = self.environment['runtime']['inputManager'].getInputEvent()
|
||||
if event['Data']:
|
||||
event['Data']['EventName'] = self.environment['runtime']['inputManager'].convertEventName(event['Data']['EventName'])
|
||||
self.environment['runtime']['inputManager'].handleInputEvent(event['Data'])
|
||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
||||
if eventReceived:
|
||||
|
||||
if True:
|
||||
if self.environment['runtime']['screenManager'].isSuspendingScreen():
|
||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||
else:
|
||||
@ -82,6 +86,7 @@ class fenrirManager():
|
||||
if event['Data'] == '':
|
||||
return
|
||||
command = event['Data']
|
||||
|
||||
if self.environment['runtime']['helpManager'].isTutorialMode():
|
||||
if self.environment['runtime']['commandManager'].commandExists( command, 'help'):
|
||||
self.environment['runtime']['commandManager'].executeCommand( command, 'help')
|
||||
@ -157,6 +162,7 @@ class fenrirManager():
|
||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||
self.environment['runtime']['eventManager'].putToEventQueue(fenrirEventType.ExecuteCommand, self.command)
|
||||
self.command = ''
|
||||
|
||||
def shutdownRequest(self):
|
||||
try:
|
||||
self.environment['runtime']['eventManager'].stopMainEventLoop()
|
||||
|
@ -18,8 +18,11 @@ class inputDriver():
|
||||
self._isInitialized = False
|
||||
def getInputEvent(self):
|
||||
time.sleep(0.05)
|
||||
if not self._initialized:
|
||||
return None
|
||||
def handleInputEvent(self, event):
|
||||
time.sleep(0.05)
|
||||
if not self._initialized:
|
||||
return
|
||||
def writeEventBuffer(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
|
@ -27,26 +27,25 @@ class inputManager():
|
||||
def shutdown(self):
|
||||
self.removeAllDevices()
|
||||
self.env['runtime']['settingsManager'].shutdownDriver('inputDriver')
|
||||
|
||||
def getInputEvent(self):
|
||||
eventReceived = False
|
||||
mEvent = self.env['runtime']['inputDriver'].getInputEvent()
|
||||
if mEvent:
|
||||
mEvent['EventName'] = self.convertEventName(mEvent['EventName'])
|
||||
eventReceived = True
|
||||
return self.env['runtime']['inputDriver'].getInputEvent()
|
||||
def handleInputEvent(self, eventData):
|
||||
self.env['runtime']['debug'].writeDebugOut('DEBUG INPUT inputMan:' + str(eventData),debug.debugLevel.INFO)
|
||||
if not eventData:
|
||||
return
|
||||
self.env['input']['prevInput'] = self.env['input']['currInput'].copy()
|
||||
if mEvent['EventState'] == 0:
|
||||
if mEvent['EventName'] in self.env['input']['currInput']:
|
||||
self.env['input']['currInput'].remove(mEvent['EventName'])
|
||||
if eventData['EventState'] == 0:
|
||||
if eventData['EventName'] in self.env['input']['currInput']:
|
||||
self.env['input']['currInput'].remove(eventData['EventName'])
|
||||
if len(self.env['input']['currInput']) > 1:
|
||||
self.env['input']['currInput'] = sorted(self.env['input']['currInput'])
|
||||
elif len(self.env['input']['currInput']) == 0:
|
||||
self.env['input']['shortcutRepeat'] = 1
|
||||
self.setLedState = self.handleLedStates(mEvent)
|
||||
self.setLedState = self.handleLedStates(eventData)
|
||||
self.lastInputTime = time.time()
|
||||
elif mEvent['EventState'] == 1:
|
||||
if not mEvent['EventName'] in self.env['input']['currInput']:
|
||||
self.env['input']['currInput'].append(mEvent['EventName'])
|
||||
elif eventData['EventState'] == 1:
|
||||
if not eventData['EventName'] in self.env['input']['currInput']:
|
||||
self.env['input']['currInput'].append(eventData['EventName'])
|
||||
if len(self.env['input']['currInput']) > 1:
|
||||
self.env['input']['currInput'] = sorted(self.env['input']['currInput'])
|
||||
if len(self.lastDeepestInput) < len(self.env['input']['currInput']):
|
||||
@ -56,12 +55,11 @@ class inputManager():
|
||||
self.env['input']['shortcutRepeat'] += 1
|
||||
else:
|
||||
self.env['input']['shortcutRepeat'] = 1
|
||||
self.setLedState = self.handleLedStates(mEvent)
|
||||
self.setLedState = self.handleLedStates(eventData)
|
||||
self.lastInputTime = time.time()
|
||||
elif mEvent['EventState'] == 2:
|
||||
elif eventData['EventState'] == 2:
|
||||
self.lastInputTime = time.time()
|
||||
else:
|
||||
pass
|
||||
|
||||
self.env['input']['oldNumLock'] = self.env['input']['newNumLock']
|
||||
self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getLedState()
|
||||
self.env['input']['oldCapsLock'] = self.env['input']['newCapsLock']
|
||||
@ -72,7 +70,6 @@ class inputManager():
|
||||
if self.noKeyPressed():
|
||||
self.env['input']['prevInput'] = []
|
||||
self.setLedState = True
|
||||
return eventReceived
|
||||
|
||||
def handleLedStates(self, mEvent):
|
||||
if not self.setLedState:
|
||||
|
@ -15,8 +15,3 @@ from fenrir.core import debug
|
||||
class driver(inputDriver):
|
||||
def __init__(self):
|
||||
inputDriver.__init__(self)
|
||||
|
||||
def getInputEvent(self):
|
||||
time.sleep(0.1)
|
||||
if not self._initialized:
|
||||
return None
|
||||
|
@ -12,6 +12,7 @@ try:
|
||||
import evdev
|
||||
from evdev import InputDevice, UInput
|
||||
_evdevAvailable = True
|
||||
|
||||
except Exception as e:
|
||||
_evdevAvailableError = str(e)
|
||||
|
||||
@ -60,7 +61,7 @@ class driver(inputDriver):
|
||||
self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev)
|
||||
else:
|
||||
self.env['runtime']['processManager'].addSimpleEventThread(fenrirEventType.PlugInputDevice, self.plugInputDeviceWatchdogTimer)
|
||||
self.env['runtime']['processManager'].addSimpleEventThread(fenrirEventType.KeyboardInput, self.inputWatchdog, {'dev':self.iDevicesFD})
|
||||
self.env['runtime']['processManager'].addCustomEventThread(self.inputWatchdog)
|
||||
def plugInputDeviceWatchdogUdev(self,active , eventQueue):
|
||||
context = pyudev.Context()
|
||||
monitor = pyudev.Monitor.from_netlink(context)
|
||||
@ -70,67 +71,55 @@ class driver(inputDriver):
|
||||
devices = monitor.poll(2)
|
||||
if devices:
|
||||
while monitor.poll(0.5):
|
||||
time.sleep(0.2)
|
||||
time.sleep(0.08)
|
||||
eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None})
|
||||
return time.time()
|
||||
def plugInputDeviceWatchdogTimer(self, active):
|
||||
time.sleep(2.5)
|
||||
return time.time()
|
||||
def inputWatchdog(self,active , params):
|
||||
try:
|
||||
deviceFd = []
|
||||
while self.watchDog.value == 0:
|
||||
if active.value == 0:
|
||||
return
|
||||
r = []
|
||||
while r == []:
|
||||
if active.value == 0:
|
||||
return
|
||||
r, w, x = select(list(params['dev']), [], [], 0.3)
|
||||
self.watchDog.value = 0
|
||||
except:
|
||||
pass
|
||||
def getInputEvent(self):
|
||||
if not self.hasIDevices():
|
||||
self.watchDog.value = 1
|
||||
return None
|
||||
event = None
|
||||
r, w, x = select(self.iDevices, [], [], 0.00001)
|
||||
if r != []:
|
||||
|
||||
def inputWatchdog(self,active , eventQueue):
|
||||
while active.value:
|
||||
r, w, x = select(self.iDevices, [], [], 0.5)
|
||||
for fd in r:
|
||||
event = None
|
||||
foreward = False
|
||||
eventFired = False
|
||||
try:
|
||||
event = self.iDevices[fd].read_one()
|
||||
except:
|
||||
self.removeDevice(fd)
|
||||
self.watchDog.value = 1
|
||||
return None
|
||||
foreward = False
|
||||
while(event):
|
||||
self.env['runtime']['debug'].writeDebugOut('DEBUG INPUT1:' + str(event),debug.debugLevel.INFO)
|
||||
self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])
|
||||
if event.type == evdev.events.EV_KEY:
|
||||
self.env['runtime']['debug'].writeDebugOut('DEBUG INPUT2:' + str(event),debug.debugLevel.INFO)
|
||||
if event.code != 0:
|
||||
self.env['runtime']['debug'].writeDebugOut('DEBUG INPUT3:' + str(event),debug.debugLevel.INFO)
|
||||
currMapEvent = self.mapEvent(event)
|
||||
if not currMapEvent:
|
||||
foreward = True
|
||||
event = self.iDevices[fd].read_one()
|
||||
continue
|
||||
self.env['runtime']['debug'].writeDebugOut('DEBUG INPUT4:' + str(currMapEvent),debug.debugLevel.INFO)
|
||||
if not isinstance(currMapEvent['EventName'], str):
|
||||
foreward = True
|
||||
event = self.iDevices[fd].read_one()
|
||||
continue
|
||||
if not foreward:
|
||||
self.env['runtime']['debug'].writeDebugOut('DEBUG INPUT5:' + str(currMapEvent),debug.debugLevel.INFO)
|
||||
if not foreward or eventFired:
|
||||
if currMapEvent['EventState'] in [0,1,2]:
|
||||
self.watchDog.value = 1
|
||||
return currMapEvent
|
||||
eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()})
|
||||
eventFired = True
|
||||
self.env['runtime']['debug'].writeDebugOut('DEBUG INPUT6:' + str(currMapEvent),debug.debugLevel.INFO)
|
||||
else:
|
||||
if not event.type in [0,1,4]:
|
||||
if not event.type in [0,4]:
|
||||
foreward = True
|
||||
self.env['runtime']['debug'].writeDebugOut('DEBUG INPUT7:' + str(currMapEvent),debug.debugLevel.INFO)
|
||||
|
||||
event = self.iDevices[fd].read_one()
|
||||
if foreward:
|
||||
if foreward and not eventFired:
|
||||
self.writeEventBuffer()
|
||||
self.clearEventBuffer()
|
||||
self.watchDog.value = 1
|
||||
return None
|
||||
|
||||
def handleInputEvent(self, event):
|
||||
return
|
||||
|
||||
def writeEventBuffer(self):
|
||||
if not self._initialized:
|
||||
@ -230,6 +219,7 @@ class driver(inputDriver):
|
||||
mEvent['EventSec'] = event.sec
|
||||
mEvent['EventUsec'] = event.usec
|
||||
mEvent['EventState'] = event.value
|
||||
mEvent['EventType'] = event.type
|
||||
return mEvent
|
||||
except Exception as e:
|
||||
return None
|
||||
|
@ -118,7 +118,7 @@ class driver(screenDriver):
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('getSessionInformation: Maybe no LoginD:' + str(e),debug.debugLevel.ERROR)
|
||||
self.env['screen']['autoIgnoreScreens'] = []
|
||||
self.env['runtime']['debug'].writeDebugOut('getSessionInformation:' + str(self.env['screen']['autoIgnoreScreens']) + ' ' + str(self.env['general']) ,debug.debugLevel.INFO)
|
||||
#self.env['runtime']['debug'].writeDebugOut('getSessionInformation:' + str(self.env['screen']['autoIgnoreScreens']) + ' ' + str(self.env['general']) ,debug.debugLevel.INFO)
|
||||
|
||||
def updateWatchdog(self,active , eventQueue):
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user