make fenrir key configurable
This commit is contained in:
parent
b4f01f76f0
commit
794abf26e3
@ -1,4 +1,3 @@
|
||||
1-KEY_KP0=fenrirKey
|
||||
#1-KEY_LEFTCTRL=shut_up
|
||||
1-KEY_RIGHTCTRL=shut_up
|
||||
1-KEY_KP8=curr_line
|
||||
|
@ -1,5 +1,3 @@
|
||||
|
||||
1-KEY_CAPSLOCK=fenrirKey
|
||||
#1-KEY_LEFTCTRL=shut_up
|
||||
1-KEY_RIGHTCTRL=shut_up
|
||||
1-KEY_I=curr_line
|
||||
|
@ -1,21 +1,20 @@
|
||||
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
|
||||
1-FENRIR,1-KEY_RIGHTCTRL=shut_up
|
||||
1-FENRIR,1-KEY_KP8=curr_line
|
||||
1-FENRIR,1-KEY_KP7=prev_line
|
||||
1-FENRIR,1-KEY_KP9=next_line
|
||||
1-FENRIR,1-KEY_KP5=curr_word
|
||||
1-FENRIR,1-KEY_KP4=prev_word
|
||||
1-FENRIR,1-KEY_KP6=next_word
|
||||
1-FENRIR,1-KEY_KP2=curr_char
|
||||
1-FENRIR,1-KEY_KP1=prev_char
|
||||
1-FENRIR,1-KEY_KP3=next_char
|
||||
1-FENRIR,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
|
||||
1-FENRIR,1-KEY_F2=toggle_braille
|
||||
1-FENRIR,1-KEY_F3=toggle_sound
|
||||
1-FENRIR,1-KEY_F4=toggle_speech
|
||||
#=toggle_output
|
||||
#=toggle_autoRead
|
||||
#=quit_fenrir
|
||||
|
@ -6,12 +6,12 @@ volume=1.0
|
||||
|
||||
[speech]
|
||||
enabled=True
|
||||
driver=espeak
|
||||
driver=speechd
|
||||
rate=0.75
|
||||
pitch=0.5
|
||||
module=espeak
|
||||
voice=en-us
|
||||
language=en-us
|
||||
voice=de
|
||||
language=de
|
||||
volume=1.0
|
||||
autoReadIncomming=True
|
||||
|
||||
@ -27,8 +27,8 @@ screenUpdateDelay=0.4
|
||||
device=all
|
||||
grabDevices=True
|
||||
ignoreShortcuts=False
|
||||
keyboardLayout=desktop
|
||||
charEcho=False
|
||||
keyboardLayout=test
|
||||
charEcho=True
|
||||
charDeleteEcho=True
|
||||
wordEcho=True
|
||||
interruptOnKeyPress=False
|
||||
@ -36,3 +36,4 @@ interruptOnKeyPress=False
|
||||
[general]
|
||||
debugLevel=0
|
||||
punctuationLevel=1
|
||||
fenrirKeys=KEY_KP0
|
||||
|
@ -1,38 +0,0 @@
|
||||
[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
|
@ -36,3 +36,4 @@ interruptOnKeyPress=False
|
||||
[general]
|
||||
debugLevel=0
|
||||
punctuationLevel=1
|
||||
fenrirKeys=KEY_KP0
|
||||
|
@ -2,5 +2,4 @@
|
||||
|
||||
generalInformation = {
|
||||
'running': True,
|
||||
'consumeKey': False,
|
||||
}
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
input = {
|
||||
'currShortcut': {},
|
||||
'currShortcutString': ''
|
||||
'currShortcutString': '',
|
||||
'consumeKey': False,
|
||||
'fenrirKey': ['82'],
|
||||
'keyForeward': False,
|
||||
}
|
||||
|
||||
|
@ -19,25 +19,31 @@ class inputManager():
|
||||
timeout = False
|
||||
for fd in r:
|
||||
for event in self.iDevices[fd].read():
|
||||
if event.code == 82: # a
|
||||
environment['generalInformation']['consumeKey'] = True
|
||||
if not environment['generalInformation']['consumeKey']:
|
||||
if self.isFenrirKey(environment, event): # a
|
||||
environment['input']['consumeKey'] = not environment['input']['keyForeward']
|
||||
if not environment['input']['consumeKey']:
|
||||
self.uDevices[fd].write_event(event)
|
||||
self.uDevices[fd].syn()
|
||||
time.sleep(0.01)
|
||||
else:
|
||||
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'][str(event.code)] = 1 #event.value
|
||||
environment['input']['currShortcut'][keyString] = 1 #event.value
|
||||
else:
|
||||
try:
|
||||
del(environment['input']['currShortcut'][str(event.code)])
|
||||
del(environment['input']['currShortcut'][keyString])
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
self.freeDevices()
|
||||
time.sleep(0.01)
|
||||
environment['input']['currShortcutString'] = self.getShortcutString(environment)
|
||||
environment['generalInformation']['consumeKey'] = environment['input']['currShortcut'] != {}
|
||||
environment['input']['consumeKey'] = environment['input']['currShortcut'] != {} and environment['input']['consumeKey']
|
||||
environment['input']['keyForeward'] = environment['input']['keyForeward'] and environment['input']['currShortcut'] == {}
|
||||
return environment, timeout
|
||||
|
||||
def getShortcutString(self, environment):
|
||||
@ -45,10 +51,12 @@ class inputManager():
|
||||
return ''
|
||||
currShortcutStringList = []
|
||||
for key in environment['input']['currShortcut']:
|
||||
currShortcutStringList.append("%s-%s" % (environment['input']['currShortcut'][key], key))
|
||||
currShortcutStringList.append("%s-%s" % (environment['input']['currShortcut'][key], key))
|
||||
currShortcutStringList = sorted(currShortcutStringList)
|
||||
return str(currShortcutStringList)[1:-1].replace(" ","").replace("'","")
|
||||
|
||||
def isFenrirKey(self,environment, event):
|
||||
return str(event.code) in environment['input']['fenrirKey']
|
||||
|
||||
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()}
|
||||
@ -57,7 +65,6 @@ class inputManager():
|
||||
dev = self.iDevices[fd]
|
||||
cap = dev.capabilities()
|
||||
del cap[0]
|
||||
print(dev.name)
|
||||
self.uDevices[fd] = UInput(
|
||||
cap,
|
||||
dev.name,
|
||||
|
@ -32,6 +32,7 @@ settings = {
|
||||
'keyboardLayout': "desktop",
|
||||
'debugLevel': debug.debugLevel.DEACTIVE,
|
||||
'punctuationLevel': 1,
|
||||
'fenrirKeys':['82'],
|
||||
},
|
||||
'keyboard':{
|
||||
'device':"all",
|
||||
|
@ -30,6 +30,7 @@ class settingsManager():
|
||||
keys = sepLine[0].replace(" ","").split(',')
|
||||
currShortcut = []
|
||||
validKeyString = True
|
||||
keyIdent = ''
|
||||
for key in keys:
|
||||
if len(key) < 3:
|
||||
validKeyString = False
|
||||
@ -41,24 +42,28 @@ class settingsManager():
|
||||
validKeyString = False
|
||||
break
|
||||
if key[2:] != '':
|
||||
keyInt = self.getCodeForKeyID(key[2:])
|
||||
if key[2:] == 'FENRIR':
|
||||
keyIdent= 'FENRIR'
|
||||
else:
|
||||
keyInt = self.getCodeForKeyID(key[2:])
|
||||
keyIdent = str(keyInt)
|
||||
else:
|
||||
validKeyString = False
|
||||
break
|
||||
if keyInt == 0:
|
||||
if keyIdent == '':
|
||||
validKeyString = False
|
||||
break
|
||||
break
|
||||
if not validKeyString:
|
||||
break
|
||||
else:
|
||||
currShortcut.append(key[0] + '-' + str(keyInt))
|
||||
currShortcut.append(key[0] + '-' + keyIdent)
|
||||
if validKeyString:
|
||||
keyString = ''
|
||||
for k in sorted(currShortcut):
|
||||
if keyString != '':
|
||||
keyString += ','
|
||||
keyString += k
|
||||
environment['bindings'][keyString] = commandString
|
||||
environment['bindings'][keyString] = commandString
|
||||
kbConfig.close()
|
||||
return environment
|
||||
|
||||
@ -165,7 +170,20 @@ class settingsManager():
|
||||
spec.loader.exec_module(driver_mod)
|
||||
environment['runtime']['screenDriver'] = driver_mod.screen()
|
||||
return environment
|
||||
|
||||
def setFenrirKeys(self, environment, keys):
|
||||
keyList = keys.split(',')
|
||||
for key in keyList:
|
||||
keyID = self.keyIDasString( key)
|
||||
if keyID != '':
|
||||
if not keyID in environment['input']['fenrirKey']:
|
||||
environment['input']['fenrirKey'].append(keyID)
|
||||
return environment
|
||||
def keyIDasString(self, key):
|
||||
try:
|
||||
KeyID = self.getCodeForKeyID(key)
|
||||
return str(KeyID)
|
||||
except:
|
||||
return ''
|
||||
def initFenrirConfig(self):
|
||||
return self.reInitFenrirConfig(environment.environment)
|
||||
|
||||
@ -175,6 +193,7 @@ class settingsManager():
|
||||
environment['runtime']['inputManager'] = inputManager.inputManager()
|
||||
environment['runtime']['outputManager'] = outputManager.outputManager()
|
||||
environment = environment['runtime']['settingsManager'].loadSettings(environment)
|
||||
environment = self.setFenrirKeys(environment, self.getSetting(environment, 'general','fenrirKeys'))
|
||||
if not os.path.exists(self.getSetting(environment, 'keyboard','keyboardLayout')):
|
||||
if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout')):
|
||||
self.setSetting(environment, 'keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout'))
|
||||
@ -205,4 +224,4 @@ class settingsManager():
|
||||
environment = environment['runtime']['settingsManager'].loadSoundDriver(environment,\
|
||||
environment['runtime']['settingsManager'].getSetting(environment,'sound', 'driver'))
|
||||
return environment
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user