initial evdev driver

This commit is contained in:
chrys 2016-09-13 00:05:29 +02:00
parent 0abd37f3f4
commit efeb9b884a
5 changed files with 19 additions and 45 deletions

View File

@ -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()

View File

@ -5,7 +5,7 @@ input = {
'currInput': {},
'prevInput': {},
'currEvent': None,
'firstEvent': None
'firstEvent': None,
'firstEvent': None,
'currShortcutString': '',
'consumeKey': False,

View File

@ -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):

View File

@ -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)

View File

@ -16,38 +16,14 @@ class input():
def shutdown(self, environment):
return environment
def getInput(self, environment):
try:
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
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 = None
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
print(len(list(r)))
if r != []:
for fd in r:
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: