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]
|
[speech]
|
||||||
enabled=True
|
enabled=True
|
||||||
driver=speechd
|
driver=espeak
|
||||||
rate=0.75
|
rate=0.75
|
||||||
pitch=0.5
|
pitch=0.5
|
||||||
module=espeak
|
module=espeak
|
||||||
voice=de
|
voice=en-us
|
||||||
language=de
|
language=en-us
|
||||||
volume=1.0
|
volume=1.0
|
||||||
autoReadIncomming=True
|
autoReadIncomming=True
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ device=all
|
|||||||
grabDevices=True
|
grabDevices=True
|
||||||
ignoreShortcuts=False
|
ignoreShortcuts=False
|
||||||
keyboardLayout=desktop
|
keyboardLayout=desktop
|
||||||
charEcho=True
|
charEcho=False
|
||||||
charDeleteEcho=True
|
charDeleteEcho=True
|
||||||
wordEcho=True
|
wordEcho=True
|
||||||
interruptOnKeyPress=False
|
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
|
import time
|
||||||
|
|
||||||
iDevices = map(evdev.InputDevice, (evdev.list_devices()))
|
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 = {}
|
uDevices = {}
|
||||||
for fd in iDevices:
|
for fd in iDevices:
|
||||||
dev = iDevices[fd]
|
dev = iDevices[fd]
|
||||||
dev.capabilities()
|
cap = dev.capabilities()
|
||||||
uDevices[fd] = UInput()
|
del cap[0]
|
||||||
dev.grab()
|
uDevices[fd] = UInput(
|
||||||
|
cap,
|
||||||
# dev.capabilities(),
|
dev.name,
|
||||||
# dev.name,
|
dev.info.vendor,
|
||||||
# dev.info.vendor,
|
|
||||||
# dev.info.product,
|
# dev.info.product,
|
||||||
# dev.version,
|
# dev.version,
|
||||||
# dev.info.bustype,
|
# dev.info.bustype,
|
||||||
# '/dev/uinput'
|
# '/dev/uinput'
|
||||||
# )
|
)
|
||||||
|
dev.grab()
|
||||||
|
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while i < 10:
|
while i < 100:
|
||||||
r, w, x = select(iDevices, [], [])
|
r, w, x = select(iDevices, [], [])
|
||||||
if r != []:
|
if r != []:
|
||||||
i += 1
|
i += 1
|
||||||
for fd in r:
|
for fd in r:
|
||||||
for event in iDevices[fd].read():
|
for event in iDevices[fd].read():
|
||||||
if event.code != 30:
|
if event.code != 30: # a
|
||||||
uDevices[fd].write_event(event)
|
uDevices[fd].write_event(event)
|
||||||
uDevices[fd].syn()
|
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:'+ 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:
|
for fd in iDevices:
|
||||||
iDevices[fd].ungrab()
|
iDevices[fd].ungrab()
|
||||||
|
iDevices[fd].close()
|
||||||
|
uDevices[fd].close()
|
||||||
|
|
||||||
|
|
||||||
|
iDevices.clear()
|
||||||
|
uDevices.clear()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
generalInformation = {
|
generalInformation = {
|
||||||
'running': True,
|
'running': True,
|
||||||
|
'consumeKey': False,
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,43 @@
|
|||||||
#!/bin/python
|
#!/bin/python
|
||||||
|
|
||||||
import evdev
|
import evdev
|
||||||
from evdev import InputDevice
|
from evdev import InputDevice, UInput
|
||||||
from select import select
|
from select import select
|
||||||
|
import time
|
||||||
|
|
||||||
class inputManager():
|
class inputManager():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.devices = map(evdev.InputDevice, (evdev.list_devices()))
|
self.iDevices = {}
|
||||||
self.devices = {dev.fd: dev for dev in self.devices}
|
self.uDevices = {}
|
||||||
#for dev in self.devices.values(): print(dev)
|
self.getDevices()
|
||||||
|
|
||||||
def getKeyPressed(self, environment):
|
def getKeyPressed(self, environment):
|
||||||
timeout = True
|
timeout = True
|
||||||
try:
|
try:
|
||||||
r, w, x = select(self.devices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
|
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
|
||||||
environment['runtime']['globalLock'].acquire(True)
|
|
||||||
if r != []:
|
if r != []:
|
||||||
timeout = False
|
timeout = False
|
||||||
for fd in r:
|
for fd in r:
|
||||||
for event in self.devices[fd].read():
|
for event in self.iDevices[fd].read():
|
||||||
if event.type == evdev.ecodes.EV_KEY:
|
if event.code == 82: # a
|
||||||
if event.value != 0:
|
environment['generalInformation']['consumeKey'] = True
|
||||||
environment['input']['currShortcut'][str(event.code)] = 1 #event.value
|
if not environment['generalInformation']['consumeKey']:
|
||||||
else:
|
self.uDevices[fd].write_event(event)
|
||||||
try:
|
self.uDevices[fd].syn()
|
||||||
del(environment['input']['currShortcut'][str(event.code)])
|
time.sleep(0.01)
|
||||||
except:
|
else:
|
||||||
pass
|
if event.type == evdev.ecodes.EV_KEY:
|
||||||
except:
|
if event.value != 0:
|
||||||
pass
|
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['input']['currShortcutString'] = self.getShortcutString(environment)
|
||||||
|
environment['generalInformation']['consumeKey'] = environment['input']['currShortcut'] != {}
|
||||||
return environment, timeout
|
return environment, timeout
|
||||||
|
|
||||||
def getShortcutString(self, environment):
|
def getShortcutString(self, environment):
|
||||||
@ -41,3 +49,45 @@ class inputManager():
|
|||||||
currShortcutStringList = sorted(currShortcutStringList)
|
currShortcutStringList = sorted(currShortcutStringList)
|
||||||
return str(currShortcutStringList)[1:-1].replace(" ","").replace("'","")
|
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')
|
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
||||||
if self.environment['commandInfo']['currCommand'] != '':
|
if self.environment['commandInfo']['currCommand'] != '':
|
||||||
self.handleCommands()
|
self.handleCommands()
|
||||||
self.environment['runtime']['globalLock'].release()
|
|
||||||
|
|
||||||
def updateScreen(self):
|
def updateScreen(self):
|
||||||
return
|
return
|
||||||
self.environment['runtime']['globalLock'].acquire(True)
|
|
||||||
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment,'updateScreen')
|
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment,'updateScreen')
|
||||||
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
||||||
self.environment['runtime']['globalLock'].release()
|
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
def handleCommands(self):
|
def handleCommands(self):
|
||||||
@ -61,6 +58,8 @@ class fenrir():
|
|||||||
self.environment['runtime']['soundDriver'].shutdown()
|
self.environment['runtime']['soundDriver'].shutdown()
|
||||||
if self.environment['runtime']['speechDriver'] != None:
|
if self.environment['runtime']['speechDriver'] != None:
|
||||||
self.environment['runtime']['speechDriver'].shutdown()
|
self.environment['runtime']['speechDriver'].shutdown()
|
||||||
|
self.environment['runtime']['inputManager'].freeDevices()
|
||||||
|
|
||||||
def captureSignal(self, siginit, frame):
|
def captureSignal(self, siginit, frame):
|
||||||
self.shutdownRequest()
|
self.shutdownRequest()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user