fill numlock, scroll and capslock state information

This commit is contained in:
chrys 2016-09-18 03:22:54 +02:00
parent 58075e05d4
commit b588957fb0
3 changed files with 51 additions and 8 deletions

View File

@ -13,6 +13,8 @@ input = {
'lastInputTime':time.time(), 'lastInputTime':time.time(),
'oldNumLock': True, 'oldNumLock': True,
'newNumLock':True, 'newNumLock':True,
'oldScrollLock': True,
'newScrollLock':True,
'oldCapsLock':False, 'oldCapsLock':False,
'newCapsLock':False 'newCapsLock':False
} }

View File

@ -18,12 +18,13 @@ 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) event = environment['runtime']['inputDriver'].getInput(environment)
mEvent = environment['runtime']['inputDriver'].mapEvent(environment, event) mEvent = environment['runtime']['inputDriver'].mapEvent(environment, event)
if mEvent and event: if mEvent and event:
if mEvent['EventValue'] == 0: if mEvent['EventValue'] == 0:
return True return True
timeout = False timeout = False
if mEvent['EventState'] == 0: if mEvent['EventState'] == 0:
if self.isFenrirKey(environment, mEvent): if self.isFenrirKey(environment, mEvent):
@ -40,8 +41,13 @@ class inputManager():
elif mEvent['EventState'] == 2: elif mEvent['EventState'] == 2:
pass pass
else: else:
pass pass
print(environment['input']['currInput']) environment['input']['oldNumLock'] = environment['input']['newNumLock']
environment['input']['newNumLock'] = environment['runtime']['inputDriver'].getNumlock(environment)
environment['input']['oldCapsLock'] = environment['input']['newCapsLock']
environment['input']['newCapsLock'] = environment['runtime']['inputDriver'].getCapslock(environment)
environment['input']['oldScrollLock'] = environment['input']['newScrollLock']
environment['input']['newScrollLock'] = environment['runtime']['inputDriver'].getScrollLock(environment)
environment['input']['lastInputTime'] = time.time() environment['input']['lastInputTime'] = time.time()
environment['input']['shortcutRepeat'] = 1 environment['input']['shortcutRepeat'] = 1
return timeout return timeout

View File

@ -12,9 +12,10 @@ class driver():
def __init__(self): def __init__(self):
self.iDevices = {} self.iDevices = {}
self.uDevices = {} self.uDevices = {}
self.getInputDevices() self.ledDevices = {}
def initialize(self, environment): def initialize(self, environment):
pass self.getInputDevices()
def shutdown(self, environment): def shutdown(self, environment):
pass pass
def getInput(self, environment): def getInput(self, environment):
@ -31,9 +32,16 @@ class driver():
uDevice.syn() uDevice.syn()
def getInputDevices(self): def getInputDevices(self):
# 3 pos absolute
# 2 pos relative
# 17 LEDs
# 1 Keys
# we try to filter out mices and other stuff here
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() and not 3 in dev.capabilities() and not 2 in dev.capabilities()}
self.ledDevices = map(evdev.InputDevice, (evdev.list_devices()))
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()}
def mapEvent(self,environment, event): def mapEvent(self,environment, event):
if not event: if not event:
return None return None
@ -48,7 +56,34 @@ class driver():
except Exception as e: except Exception as e:
print(e) print(e)
return None return None
def getNumlock(self,environment):
if self.ledDevices == {}:
return True
if self.ledDevices == None:
return True
for fd, dev in self.ledDevices.items():
return 0 in dev.leds()
return True
def getCapslock(self,environment):
if self.ledDevices == {}:
return False
if self.ledDevices == None:
return False
for fd, dev in self.ledDevices.items():
return 1 in dev.leds()
return False
def getScrollLock(self,environment):
if self.ledDevices == {}:
return False
if self.ledDevices == None:
return False
for fd, dev in self.ledDevices.items():
return 2 in dev.leds()
return False
def grabDevices(self): def grabDevices(self):
for fd in self.iDevices: for fd in self.iDevices:
dev = self.iDevices[fd] dev = self.iDevices[fd]