add sanity check for valid keys
This commit is contained in:
parent
4fdf58f2f7
commit
707b120cba
File diff suppressed because one or more lines are too long
@ -66,6 +66,7 @@ class commandManager():
|
||||
commandList = glob.glob(self.env['runtime']['settingsManager'].getSetting('general', 'scriptPath')+'/*')
|
||||
subCommand = os.path.dirname(os.path.realpath(__main__.__file__)) + '/commands/commands/subprocess.py'
|
||||
for command in commandList:
|
||||
invalid = False
|
||||
try:
|
||||
fileName, fileExtension = os.path.splitext(command)
|
||||
fileName = fileName.split('/')[-1]
|
||||
@ -89,7 +90,13 @@ class commandManager():
|
||||
shortcutKeys = []
|
||||
shortcut = []
|
||||
for key in keys:
|
||||
if not self.env['runtime']['settingsManager'].isValidKey(key.upper()):
|
||||
self.env['runtime']['debug'].writeDebugOut("invalid key : "+ key.upper() + ' command:' +commandName ,debug.debugLevel.WARNING)
|
||||
invalid = True
|
||||
break
|
||||
shortcutKeys.append(key.upper())
|
||||
if invalid:
|
||||
continue
|
||||
if not 'KEY_SCRIPT' in shortcutKeys:
|
||||
shortcutKeys.append('KEY_SCRIPT')
|
||||
shortcut.append(1)
|
||||
|
File diff suppressed because one or more lines are too long
@ -16,6 +16,7 @@ from core import punctuationManager
|
||||
from core import cursorManager
|
||||
from core import applicationManager
|
||||
from core import environment
|
||||
from core import inputEvent
|
||||
from core.settings import settings
|
||||
from core import debug
|
||||
|
||||
@ -29,6 +30,7 @@ class settingsManager():
|
||||
def loadShortcuts(self, kbConfigPath=os.path.dirname(os.path.realpath(__main__.__file__)) + '/../../config/keyboard/desktop.conf'):
|
||||
kbConfig = open(kbConfigPath,"r")
|
||||
while(True):
|
||||
invalid = False
|
||||
line = kbConfig.readline()
|
||||
if not line:
|
||||
break
|
||||
@ -52,7 +54,13 @@ class settingsManager():
|
||||
try:
|
||||
shortcutRepeat = int(key)
|
||||
except:
|
||||
if not self.isValidKey(key.upper()):
|
||||
self.env['runtime']['debug'].writeDebugOut("invalid key : "+ key.upper() + ' command:' +commandName ,debug.debugLevel.WARNING)
|
||||
invalid = True
|
||||
break
|
||||
shortcutKeys.append(key.upper())
|
||||
if invalid:
|
||||
continue
|
||||
shortcut.append(shortcutRepeat)
|
||||
shortcut.append(sorted(shortcutKeys))
|
||||
if len(shortcutKeys) != 1 and not 'KEY_FENRIR' in shortcutKeys:
|
||||
@ -90,6 +98,8 @@ class settingsManager():
|
||||
self.env['soundIcons'][soundIcon] = soundIconFile
|
||||
self.env['runtime']['debug'].writeDebugOut("SoundIcon: " + soundIcon + '.' + soundIconFile, debug.debugLevel.INFO, onAnyLevel=True)
|
||||
siConfig.close()
|
||||
def isValidKey(self, key):
|
||||
return key in inputEvent.keyNames
|
||||
|
||||
def loadDicts(self, dictConfigPath=os.path.dirname(os.path.realpath(__main__.__file__)) + '/../../config/punctuation/default.conf'):
|
||||
dictConfig = open(dictConfigPath,"r")
|
||||
|
@ -6,11 +6,14 @@ import time
|
||||
|
||||
devices = map(evdev.InputDevice, (evdev.list_devices()))
|
||||
devices = {dev.fd: dev for dev in devices}
|
||||
for fd in devices:
|
||||
print('Devicename:'+ devices[fd].name + ' Devicepath:' + devices[fd].fn )
|
||||
|
||||
while True:
|
||||
r, w, x = select(devices, [], [])
|
||||
if r != []:
|
||||
for fd in r:
|
||||
for event in devices[fd].read():
|
||||
print('Devicename:'+ devices[fd].name + ' Devicepath:' + devices[fd].fn + ' Events:' + str(devices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value))
|
||||
#--- log events---
|
||||
#while True:
|
||||
# r, w, x = select(devices, [], [])
|
||||
# if r != []:
|
||||
# for fd in r:
|
||||
# for event in devices[fd].read():
|
||||
# print('Devicename:'+ devices[fd].name + ' Devicepath:' + devices[fd].fn + ' Events:' + str(devices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user