remove unneded ledDevices

This commit is contained in:
chrys 2017-02-26 18:29:03 +01:00
parent 09764feaa8
commit 2186d992a7

View File

@ -22,7 +22,6 @@ class driver():
def __init__(self): def __init__(self):
self.iDevices = {} self.iDevices = {}
self.uDevices = {} self.uDevices = {}
self.ledDevices = {}
self._initialized = False self._initialized = False
def initialize(self, environment): def initialize(self, environment):
@ -38,7 +37,6 @@ class driver():
def shutdown(self): def shutdown(self):
if not self._initialized: if not self._initialized:
return return
self.releaseDevices()
def getInputEvent(self): def getInputEvent(self):
if not self.hasIDevices(): if not self.hasIDevices():
@ -111,21 +109,17 @@ class driver():
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut("Skip Inputdevice : " + dev +' ' + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Skip Inputdevice : " + dev +' ' + str(e),debug.debugLevel.ERROR)
self.iDevices = map(evdev.InputDevice, (readableDevices)) self.iDevices = map(evdev.InputDevice, (readableDevices))
self.ledDevices = map(evdev.InputDevice, (readableDevices))
# 3 pos absolute # 3 pos absolute
# 2 pos relative # 2 pos relative
# 17 LEDs
# 1 Keys # 1 Keys
# we try to filter out mices and other stuff here # we try to filter out mices and other stuff here
if self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'ALL': if self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'ALL':
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()}
self.ledDevices = {dev.fd: dev for dev in self.ledDevices if 1 in dev.capabilities() and 17 in dev.capabilities()}
elif self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'NOMICE': elif self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'NOMICE':
self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()} self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()}
self.ledDevices = {dev.fd: dev for dev in self.ledDevices if 1 in dev.capabilities() and 17 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()}
else: else:
self.iDevices = {dev.fd: dev for dev in self.iDevices if dev.name.upper() in self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper().split(',')} self.iDevices = {dev.fd: dev for dev in self.iDevices if dev.name.upper() in self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper().split(',')}
self.ledDevices = {dev.fd: dev for dev in self.ledDevices if dev.name.upper() in self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper().split(',')}
def mapEvent(self, event): def mapEvent(self, event):
if not self._initialized: if not self._initialized:
@ -144,27 +138,26 @@ class driver():
return None return None
def getLedState(self, led = 0): def getLedState(self, led = 0):
if not self._initialized: if not self.hasIDevices():
return False return False
# 0 = Numlock # 0 = Numlock
# 1 = Capslock # 1 = Capslock
# 2 = Rollen # 2 = Rollen
if self.ledDevices == None: for fd, dev in self.iDevices.items():
return False if led in dev.leds():
if self.ledDevices == {}: return True
return False
for fd, dev in self.ledDevices.items():
return led in dev.leds()
return False return False
def toggleLedState(self, led = 0): def toggleLedState(self, led = 0):
if not self._initialized: if not self.hasIDevices():
return None return False
ledState = self.getLedState(led) ledState = self.getLedState(led)
for i in self.ledDevices: for i in self.iDevices:
if ledState == 1: # 17 LEDs
self.ledDevices[i].set_led(led , 0) if 17 in self.iDevices[i].capabilities():
else: if ledState == 1:
self.ledDevices[i].set_led(led , 1) self.iDevices[i].set_led(led , 0)
else:
self.iDevices[i].set_led(led , 1)
def grabDevices(self): def grabDevices(self):
if not self._initialized: if not self._initialized:
return return
@ -245,6 +238,5 @@ class driver():
def __del__(self): def __del__(self):
if not self._initialized: if not self._initialized:
return return
self.shutdown()