improve device detection

This commit is contained in:
Chrys 2018-04-01 14:36:06 +02:00
parent 01acd81e7b
commit f32de79204
4 changed files with 5 additions and 7 deletions

View File

@ -225,7 +225,7 @@ class fenrirManager():
self.environment['runtime']['eventManager'].stopMainEventLoop() self.environment['runtime']['eventManager'].stopMainEventLoop()
self.environment['runtime']['outputManager'].presentText(_("Quit Fenrir"), soundIcon='ScreenReaderOff', interrupt=True) self.environment['runtime']['outputManager'].presentText(_("Quit Fenrir"), soundIcon='ScreenReaderOff', interrupt=True)
self.environment['runtime']['eventManager'].cleanEventQueue() self.environment['runtime']['eventManager'].cleanEventQueue()
time.sleep(1) time.sleep(0.6)
for currManager in self.environment['general']['managerList']: for currManager in self.environment['general']['managerList']:
if self.environment['runtime'][currManager]: if self.environment['runtime'][currManager]:
self.environment['runtime'][currManager].shutdown() self.environment['runtime'][currManager].shutdown()

View File

@ -11,8 +11,8 @@ generalData = {
'tutorialMode': False, 'tutorialMode': False,
'currUser':'', 'currUser':'',
'prevUser':'', 'prevUser':'',
'managerList':['processManager', 'punctuationManager', 'byteManager', 'cursorManager', 'applicationManager', 'commandManager' 'managerList':[ 'punctuationManager', 'byteManager', 'cursorManager', 'applicationManager', 'commandManager'
, 'screenManager', 'inputManager','outputManager', 'helpManager', 'memoryManager', 'eventManager', 'debug'], , 'screenManager', 'inputManager','outputManager', 'helpManager', 'memoryManager', 'eventManager','processManager', 'debug'],
'commandFolderList':['commands','onKeyInput', 'onByteInput', 'onCursorChange', 'onScreenUpdate','onScreenChanged','onHeartBeat', 'onPlugInputDevice' 'commandFolderList':['commands','onKeyInput', 'onByteInput', 'onCursorChange', 'onScreenUpdate','onScreenChanged','onHeartBeat', 'onPlugInputDevice'
,'onApplicationChange','onSwitchApplicationProfile','help',], ,'onApplicationChange','onSwitchApplicationProfile','help',],
} }

View File

@ -24,7 +24,6 @@ class inputManager():
self.env = environment self.env = environment
self.env['runtime']['settingsManager'].loadDriver(\ self.env['runtime']['settingsManager'].loadDriver(\
self.env['runtime']['settingsManager'].getSetting('keyboard', 'driver'), 'inputDriver') self.env['runtime']['settingsManager'].getSetting('keyboard', 'driver'), 'inputDriver')
self.updateInputDevices()
# init LEDs with current state # init LEDs with current state
self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getLedState() self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getLedState()
self.env['input']['oldNumLock'] = self.env['input']['newNumLock'] self.env['input']['oldNumLock'] = self.env['input']['newNumLock']

View File

@ -52,6 +52,7 @@ class driver(inputDriver):
global _evdevAvailableError global _evdevAvailableError
self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR)
return return
self.updateInputDevices()
if _udevAvailable: if _udevAvailable:
self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev) self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev)
else: else:
@ -61,14 +62,12 @@ class driver(inputDriver):
context = pyudev.Context() context = pyudev.Context()
monitor = pyudev.Monitor.from_netlink(context) monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by(subsystem='input') monitor.filter_by(subsystem='input')
# wait until start process finished
time.sleep(8)
monitor.start() monitor.start()
while active.value: while active.value:
devices = monitor.poll(2) devices = monitor.poll(2)
if devices: if devices:
while monitor.poll(0.2): while monitor.poll(0.2):
time.sleep(0.1) time.sleep(0.2)
eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None}) eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None})
return time.time() return time.time()
def plugInputDeviceWatchdogTimer(self, active): def plugInputDeviceWatchdogTimer(self, active):