initial but unfinished key consumation
This commit is contained in:
parent
205222c99e
commit
b4f01f76f0
21
config/keyboard/test.conf
Normal file
21
config/keyboard/test.conf
Normal file
@ -0,0 +1,21 @@
|
||||
1-KEY_KP0=fenrirKey
|
||||
#1-KEY_LEFTCTRL=shut_up
|
||||
1-KEY_KP0,1-KEY_RIGHTCTRL=shut_up
|
||||
1-KEY_KP0,1-KEY_KP8=curr_line
|
||||
1-KEY_KP0,1-KEY_KP7=prev_line
|
||||
1-KEY_KP0,1-KEY_KP9=next_line
|
||||
1-KEY_KP0,1-KEY_KP5=curr_word
|
||||
1-KEY_KP0,1-KEY_KP4=prev_word
|
||||
1-KEY_KP0,1-KEY_KP6=next_word
|
||||
1-KEY_KP0,1-KEY_KP2=curr_char
|
||||
1-KEY_KP0,1-KEY_KP1=prev_char
|
||||
1-KEY_KP0,1-KEY_KP3=next_char
|
||||
1-KEY_KP0,1-KEY_KPDOT=exit_review
|
||||
#=curr_screen
|
||||
#=last_incomming
|
||||
1-KEY_KP0,1-KEY_F2=toggle_braille
|
||||
1-KEY_KP0,1-KEY_F3=toggle_sound
|
||||
1-KEY_KP0,1-KEY_F4=toggle_speech
|
||||
#=toggle_output
|
||||
#=toggle_autoRead
|
||||
#=quit_fenrir
|
@ -6,12 +6,12 @@ volume=1.0
|
||||
|
||||
[speech]
|
||||
enabled=True
|
||||
driver=speechd
|
||||
driver=espeak
|
||||
rate=0.75
|
||||
pitch=0.5
|
||||
module=espeak
|
||||
voice=de
|
||||
language=de
|
||||
voice=en-us
|
||||
language=en-us
|
||||
volume=1.0
|
||||
autoReadIncomming=True
|
||||
|
||||
@ -28,7 +28,7 @@ device=all
|
||||
grabDevices=True
|
||||
ignoreShortcuts=False
|
||||
keyboardLayout=desktop
|
||||
charEcho=True
|
||||
charEcho=False
|
||||
charDeleteEcho=True
|
||||
wordEcho=True
|
||||
interruptOnKeyPress=False
|
||||
|
38
config/settings/settings.conf.chrys
Normal file
38
config/settings/settings.conf.chrys
Normal file
@ -0,0 +1,38 @@
|
||||
[sound]
|
||||
enabled=True
|
||||
driver=sox
|
||||
theme=default
|
||||
volume=1.0
|
||||
|
||||
[speech]
|
||||
enabled=True
|
||||
driver=speechd
|
||||
rate=0.75
|
||||
pitch=0.5
|
||||
module=espeak
|
||||
voice=de
|
||||
language=de
|
||||
volume=1.0
|
||||
autoReadIncomming=True
|
||||
|
||||
[braille]
|
||||
enabled=False
|
||||
layout=en
|
||||
|
||||
[screen]
|
||||
driver=linux
|
||||
screenUpdateDelay=0.4
|
||||
|
||||
[keyboard]
|
||||
device=all
|
||||
grabDevices=True
|
||||
ignoreShortcuts=False
|
||||
keyboardLayout=test
|
||||
charEcho=True
|
||||
charDeleteEcho=True
|
||||
wordEcho=True
|
||||
interruptOnKeyPress=False
|
||||
|
||||
[general]
|
||||
debugLevel=0
|
||||
punctuationLevel=1
|
38
config/settings/settings.conf.orig
Normal file
38
config/settings/settings.conf.orig
Normal file
@ -0,0 +1,38 @@
|
||||
[sound]
|
||||
enabled=True
|
||||
driver=sox
|
||||
theme=default
|
||||
volume=1.0
|
||||
|
||||
[speech]
|
||||
enabled=True
|
||||
driver=espeak
|
||||
rate=0.75
|
||||
pitch=0.5
|
||||
module=espeak
|
||||
voice=en-us
|
||||
language=en-us
|
||||
volume=1.0
|
||||
autoReadIncomming=True
|
||||
|
||||
[braille]
|
||||
enabled=False
|
||||
layout=en
|
||||
|
||||
[screen]
|
||||
driver=linux
|
||||
screenUpdateDelay=0.4
|
||||
|
||||
[keyboard]
|
||||
device=all
|
||||
grabDevices=True
|
||||
ignoreShortcuts=False
|
||||
keyboardLayout=desktop
|
||||
charEcho=False
|
||||
charDeleteEcho=True
|
||||
wordEcho=True
|
||||
interruptOnKeyPress=False
|
||||
|
||||
[general]
|
||||
debugLevel=0
|
||||
punctuationLevel=1
|
@ -5,37 +5,46 @@ from select import select
|
||||
import time
|
||||
|
||||
iDevices = map(evdev.InputDevice, (evdev.list_devices()))
|
||||
iDevices = {dev.fd: dev for dev in iDevices if dev.fn in ['/dev/input/event18']}
|
||||
iDevices = {dev.fd: dev for dev in iDevices if 1 in dev.capabilities()}
|
||||
uDevices = {}
|
||||
for fd in iDevices:
|
||||
dev = iDevices[fd]
|
||||
dev.capabilities()
|
||||
uDevices[fd] = UInput()
|
||||
dev.grab()
|
||||
|
||||
# dev.capabilities(),
|
||||
# dev.name,
|
||||
# dev.info.vendor,
|
||||
cap = dev.capabilities()
|
||||
del cap[0]
|
||||
uDevices[fd] = UInput(
|
||||
cap,
|
||||
dev.name,
|
||||
dev.info.vendor,
|
||||
# dev.info.product,
|
||||
# dev.version,
|
||||
# dev.info.bustype,
|
||||
# '/dev/uinput'
|
||||
# )
|
||||
# '/dev/uinput'
|
||||
)
|
||||
dev.grab()
|
||||
|
||||
|
||||
i = 0
|
||||
while i < 10:
|
||||
while i < 100:
|
||||
r, w, x = select(iDevices, [], [])
|
||||
if r != []:
|
||||
i += 1
|
||||
for fd in r:
|
||||
for event in iDevices[fd].read():
|
||||
if event.code != 30:
|
||||
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))
|
||||
else:
|
||||
print('this key is consumed')
|
||||
|
||||
for fd in iDevices:
|
||||
iDevices[fd].ungrab()
|
||||
iDevices[fd].close()
|
||||
uDevices[fd].close()
|
||||
|
||||
|
||||
iDevices.clear()
|
||||
uDevices.clear()
|
||||
|
||||
|
||||
|
@ -2,4 +2,5 @@
|
||||
|
||||
generalInformation = {
|
||||
'running': True,
|
||||
'consumeKey': False,
|
||||
}
|
||||
|
@ -1,35 +1,43 @@
|
||||
#!/bin/python
|
||||
|
||||
import evdev
|
||||
from evdev import InputDevice
|
||||
from evdev import InputDevice, UInput
|
||||
from select import select
|
||||
import time
|
||||
|
||||
class inputManager():
|
||||
def __init__(self):
|
||||
self.devices = map(evdev.InputDevice, (evdev.list_devices()))
|
||||
self.devices = {dev.fd: dev for dev in self.devices}
|
||||
#for dev in self.devices.values(): print(dev)
|
||||
self.iDevices = {}
|
||||
self.uDevices = {}
|
||||
self.getDevices()
|
||||
|
||||
def getKeyPressed(self, environment):
|
||||
timeout = True
|
||||
try:
|
||||
r, w, x = select(self.devices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
|
||||
environment['runtime']['globalLock'].acquire(True)
|
||||
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.devices[fd].read():
|
||||
if event.type == evdev.ecodes.EV_KEY:
|
||||
if event.value != 0:
|
||||
environment['input']['currShortcut'][str(event.code)] = 1 #event.value
|
||||
else:
|
||||
try:
|
||||
del(environment['input']['currShortcut'][str(event.code)])
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
for event in self.iDevices[fd].read():
|
||||
if event.code == 82: # a
|
||||
environment['generalInformation']['consumeKey'] = True
|
||||
if not environment['generalInformation']['consumeKey']:
|
||||
self.uDevices[fd].write_event(event)
|
||||
self.uDevices[fd].syn()
|
||||
time.sleep(0.01)
|
||||
else:
|
||||
if event.type == evdev.ecodes.EV_KEY:
|
||||
if event.value != 0:
|
||||
environment['input']['currShortcut'][str(event.code)] = 1 #event.value
|
||||
else:
|
||||
try:
|
||||
del(environment['input']['currShortcut'][str(event.code)])
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
self.freeDevices()
|
||||
environment['input']['currShortcutString'] = self.getShortcutString(environment)
|
||||
environment['generalInformation']['consumeKey'] = environment['input']['currShortcut'] != {}
|
||||
return environment, timeout
|
||||
|
||||
def getShortcutString(self, environment):
|
||||
@ -41,3 +49,45 @@ class inputManager():
|
||||
currShortcutStringList = sorted(currShortcutStringList)
|
||||
return str(currShortcutStringList)[1:-1].replace(" ","").replace("'","")
|
||||
|
||||
def getDevices(self):
|
||||
self.iDevices = map(evdev.InputDevice, (evdev.list_devices()))
|
||||
self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()}
|
||||
|
||||
for fd in self.iDevices:
|
||||
dev = self.iDevices[fd]
|
||||
cap = dev.capabilities()
|
||||
del cap[0]
|
||||
print(dev.name)
|
||||
self.uDevices[fd] = UInput(
|
||||
cap,
|
||||
dev.name,
|
||||
dev.info.vendor
|
||||
# dev.info.product,
|
||||
# dev.version,
|
||||
# dev.info.bustype,
|
||||
# '/dev/uinput'
|
||||
)
|
||||
dev.grab()
|
||||
|
||||
def freeDevices(self):
|
||||
for fd in self.iDevices:
|
||||
try:
|
||||
self.iDevices[fd].ungrab()
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
self.iDevices[fd].close()
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
self.uDevices[fd].close()
|
||||
except:
|
||||
pass
|
||||
|
||||
self.iDevices.clear()
|
||||
self.uDevices.clear()
|
||||
|
||||
def __del__(self):
|
||||
self.freeDevices()
|
||||
|
||||
|
||||
|
@ -37,14 +37,11 @@ class fenrir():
|
||||
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
||||
if self.environment['commandInfo']['currCommand'] != '':
|
||||
self.handleCommands()
|
||||
self.environment['runtime']['globalLock'].release()
|
||||
|
||||
def updateScreen(self):
|
||||
return
|
||||
self.environment['runtime']['globalLock'].acquire(True)
|
||||
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment,'updateScreen')
|
||||
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
||||
self.environment['runtime']['globalLock'].release()
|
||||
time.sleep(0.5)
|
||||
|
||||
def handleCommands(self):
|
||||
@ -61,6 +58,8 @@ class fenrir():
|
||||
self.environment['runtime']['soundDriver'].shutdown()
|
||||
if self.environment['runtime']['speechDriver'] != None:
|
||||
self.environment['runtime']['speechDriver'].shutdown()
|
||||
self.environment['runtime']['inputManager'].freeDevices()
|
||||
|
||||
def captureSignal(self, siginit, frame):
|
||||
self.shutdownRequest()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user