initial evdev driver
This commit is contained in:
parent
0abd37f3f4
commit
efeb9b884a
@ -20,25 +20,22 @@ for fd in iDevices:
|
||||
# dev.info.bustype,
|
||||
# '/dev/uinput'
|
||||
)
|
||||
dev.grab()
|
||||
|
||||
|
||||
i = 0
|
||||
while i < 100:
|
||||
while i < 1000:
|
||||
r, w, x = select(iDevices, [], [])
|
||||
if r != []:
|
||||
i += 1
|
||||
for fd in r:
|
||||
for event in iDevices[fd].read():
|
||||
if event.code != 30: # a
|
||||
uDevices[fd].write_event(event)
|
||||
uDevices[fd].syn()
|
||||
#print('Devicename:'+ devices[fd].name + ' Devicepath:' + devices[fd].fn + ' Events:' + str(devices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value))
|
||||
print('Devicename:'+ iDevices[fd].name + ' Devicepath:' + iDevices[fd].fn + ' Events:' + str(iDevices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value))
|
||||
else:
|
||||
print('this key is consumed')
|
||||
break
|
||||
break
|
||||
|
||||
for fd in iDevices:
|
||||
iDevices[fd].ungrab()
|
||||
iDevices[fd].close()
|
||||
uDevices[fd].close()
|
||||
|
||||
|
@ -5,7 +5,7 @@ input = {
|
||||
'currInput': {},
|
||||
'prevInput': {},
|
||||
'currEvent': None,
|
||||
'firstEvent': None
|
||||
'firstEvent': None,
|
||||
'firstEvent': None,
|
||||
'currShortcutString': '',
|
||||
'consumeKey': False,
|
||||
|
@ -12,7 +12,10 @@ class inputManager():
|
||||
return environment
|
||||
def proceedInputEvent(self, environment):
|
||||
timeout = True
|
||||
environment, timeout = environment['runtime']['inputDriver'].getInput(environment)
|
||||
event = environment['runtime']['inputDriver'].getInput(environment)
|
||||
if event:
|
||||
timeout = False
|
||||
print(event)
|
||||
return environment, timeout
|
||||
|
||||
def grabDevices(self, environment):
|
||||
|
@ -29,7 +29,7 @@ class fenrir():
|
||||
self.shutdown()
|
||||
|
||||
def handleProcess(self):
|
||||
#self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvent(self.environment)
|
||||
self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvent(self.environment)
|
||||
timeout = True
|
||||
try:
|
||||
self.environment = self.environment['runtime']['screenManager'].update(self.environment)
|
||||
|
@ -16,38 +16,14 @@ class input():
|
||||
def shutdown(self, environment):
|
||||
return environment
|
||||
def getInput(self, environment):
|
||||
|
||||
try:
|
||||
event = None
|
||||
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
|
||||
print(len(list(r)))
|
||||
if r != []:
|
||||
timeout = False
|
||||
for fd in r:
|
||||
for event in self.iDevices[fd].read():
|
||||
if self.isFenrirKey(environment, event):
|
||||
environment['input']['consumeKey'] = not environment['input']['keyForeward'] and not environment['generalInformation']['suspend']
|
||||
if self.isConsumeKeypress(environment):
|
||||
self.writeUInput(self.uDevices[fd], event,environment)
|
||||
keyString = ''
|
||||
if self.isFenrirKey(environment, event):
|
||||
keyString = 'FENRIR'
|
||||
else:
|
||||
keyString = str(event.code)
|
||||
if event.type == evdev.ecodes.EV_KEY:
|
||||
if event.value != 0:
|
||||
environment['input']['currShortcut'][keyString] = 1 #event.value
|
||||
else:
|
||||
try:
|
||||
del(environment['input']['currShortcut'][keyString])
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
environment['runtime']['debug'].writeDebugOut(environment,"Error while inputHandling",debug.debugLevel.ERROR)
|
||||
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
|
||||
self.releaseDevices()
|
||||
time.sleep(0.01)
|
||||
|
||||
|
||||
return environment, timeout
|
||||
event = self.iDevices[fd].read_one()
|
||||
return event
|
||||
return None
|
||||
|
||||
def writeUInput(self, uDevice, event,environment):
|
||||
uDevice.write_event(event)
|
||||
@ -58,8 +34,6 @@ class input():
|
||||
self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()}
|
||||
|
||||
def grabDevices(self):
|
||||
# if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices'):
|
||||
# return
|
||||
for fd in self.iDevices:
|
||||
dev = self.iDevices[fd]
|
||||
cap = dev.capabilities()
|
||||
@ -73,7 +47,7 @@ class input():
|
||||
#dev.info.bustype,
|
||||
#'/dev/uinput'
|
||||
)
|
||||
#dev.grab()
|
||||
dev.grab()
|
||||
|
||||
def releaseDevices(self):
|
||||
for fd in self.iDevices:
|
||||
|
Loading…
Reference in New Issue
Block a user