fill numlock, scroll and capslock state information
This commit is contained in:
parent
58075e05d4
commit
b588957fb0
@ -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
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ 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)
|
||||||
@ -41,7 +42,12 @@ class inputManager():
|
|||||||
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
|
||||||
|
@ -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,8 +32,15 @@ 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:
|
||||||
@ -49,6 +57,33 @@ class driver():
|
|||||||
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]
|
||||||
|
Loading…
Reference in New Issue
Block a user