remove environment parameter and pass it via initialisation
This commit is contained in:
@ -19,32 +19,34 @@ class driver():
|
||||
self.ledDevices = {}
|
||||
|
||||
def initialize(self, environment):
|
||||
self.getInputDevices(environment)
|
||||
def shutdown(self, environment):
|
||||
self.env = environment
|
||||
self.getInputDevices()
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getInputEvent(self, environment):
|
||||
def getInputEvent(self):
|
||||
event = None
|
||||
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
|
||||
r, w, x = select(self.iDevices, [], [], self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay'))
|
||||
if r != []:
|
||||
for fd in r:
|
||||
event = self.iDevices[fd].read_one()
|
||||
environment['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])
|
||||
return environment['runtime']['inputDriver'].mapEvent(environment, event)
|
||||
self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])
|
||||
return self.env['runtime']['inputDriver'].mapEvent(event)
|
||||
return None
|
||||
|
||||
def writeEventBuffer(self, environment):
|
||||
for iDevice, uDevice, event in environment['input']['eventBuffer']:
|
||||
self.writeUInput(environment, uDevice, event)
|
||||
self.clearEventBuffer(environment)
|
||||
def writeEventBuffer(self):
|
||||
for iDevice, uDevice, event in self.env['input']['eventBuffer']:
|
||||
self.writeUInput(uDevice, event)
|
||||
self.clearEventBuffer()
|
||||
|
||||
def clearEventBuffer(self, environment):
|
||||
del environment['input']['eventBuffer'][:]
|
||||
def clearEventBuffer(self):
|
||||
del self.env['input']['eventBuffer'][:]
|
||||
|
||||
def writeUInput(self, environment, uDevice, event):
|
||||
def writeUInput(self, uDevice, event):
|
||||
uDevice.write_event(event)
|
||||
uDevice.syn()
|
||||
|
||||
def getInputDevices(self, environment):
|
||||
def getInputDevices(self):
|
||||
# 3 pos absolute
|
||||
# 2 pos relative
|
||||
# 17 LEDs
|
||||
@ -55,7 +57,7 @@ class driver():
|
||||
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, event):
|
||||
if not event:
|
||||
return None
|
||||
mEvent = inputEvent.inputEvent
|
||||
@ -70,7 +72,7 @@ class driver():
|
||||
print(e)
|
||||
return None
|
||||
|
||||
def getNumlock(self,environment):
|
||||
def getNumlock(self):
|
||||
if self.ledDevices == {}:
|
||||
return True
|
||||
if self.ledDevices == None:
|
||||
@ -79,7 +81,7 @@ class driver():
|
||||
return 0 in dev.leds()
|
||||
return True
|
||||
|
||||
def getCapslock(self,environment):
|
||||
def getCapslock(self):
|
||||
if self.ledDevices == {}:
|
||||
return False
|
||||
if self.ledDevices == None:
|
||||
@ -88,7 +90,7 @@ class driver():
|
||||
return 1 in dev.leds()
|
||||
return False
|
||||
|
||||
def getScrollLock(self,environment):
|
||||
def getScrollLock(self):
|
||||
if self.ledDevices == {}:
|
||||
return False
|
||||
if self.ledDevices == None:
|
||||
@ -97,7 +99,7 @@ class driver():
|
||||
return 2 in dev.leds()
|
||||
return False
|
||||
|
||||
def grabDevices(self, environment):
|
||||
def grabDevices(self):
|
||||
for fd in self.iDevices:
|
||||
dev = self.iDevices[fd]
|
||||
cap = dev.capabilities()
|
||||
@ -113,7 +115,7 @@ class driver():
|
||||
)
|
||||
dev.grab()
|
||||
|
||||
def releaseDevices(self, environment):
|
||||
def releaseDevices(self):
|
||||
for fd in self.iDevices:
|
||||
try:
|
||||
self.iDevices[fd].ungrab()
|
||||
|
Reference in New Issue
Block a user