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')+'/*')
|
commandList = glob.glob(self.env['runtime']['settingsManager'].getSetting('general', 'scriptPath')+'/*')
|
||||||
subCommand = os.path.dirname(os.path.realpath(__main__.__file__)) + '/commands/commands/subprocess.py'
|
subCommand = os.path.dirname(os.path.realpath(__main__.__file__)) + '/commands/commands/subprocess.py'
|
||||||
for command in commandList:
|
for command in commandList:
|
||||||
|
invalid = False
|
||||||
try:
|
try:
|
||||||
fileName, fileExtension = os.path.splitext(command)
|
fileName, fileExtension = os.path.splitext(command)
|
||||||
fileName = fileName.split('/')[-1]
|
fileName = fileName.split('/')[-1]
|
||||||
@ -89,7 +90,13 @@ class commandManager():
|
|||||||
shortcutKeys = []
|
shortcutKeys = []
|
||||||
shortcut = []
|
shortcut = []
|
||||||
for key in keys:
|
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())
|
shortcutKeys.append(key.upper())
|
||||||
|
if invalid:
|
||||||
|
continue
|
||||||
if not 'KEY_SCRIPT' in shortcutKeys:
|
if not 'KEY_SCRIPT' in shortcutKeys:
|
||||||
shortcutKeys.append('KEY_SCRIPT')
|
shortcutKeys.append('KEY_SCRIPT')
|
||||||
shortcut.append(1)
|
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 cursorManager
|
||||||
from core import applicationManager
|
from core import applicationManager
|
||||||
from core import environment
|
from core import environment
|
||||||
|
from core import inputEvent
|
||||||
from core.settings import settings
|
from core.settings import settings
|
||||||
from core import debug
|
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'):
|
def loadShortcuts(self, kbConfigPath=os.path.dirname(os.path.realpath(__main__.__file__)) + '/../../config/keyboard/desktop.conf'):
|
||||||
kbConfig = open(kbConfigPath,"r")
|
kbConfig = open(kbConfigPath,"r")
|
||||||
while(True):
|
while(True):
|
||||||
|
invalid = False
|
||||||
line = kbConfig.readline()
|
line = kbConfig.readline()
|
||||||
if not line:
|
if not line:
|
||||||
break
|
break
|
||||||
@ -52,7 +54,13 @@ class settingsManager():
|
|||||||
try:
|
try:
|
||||||
shortcutRepeat = int(key)
|
shortcutRepeat = int(key)
|
||||||
except:
|
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())
|
shortcutKeys.append(key.upper())
|
||||||
|
if invalid:
|
||||||
|
continue
|
||||||
shortcut.append(shortcutRepeat)
|
shortcut.append(shortcutRepeat)
|
||||||
shortcut.append(sorted(shortcutKeys))
|
shortcut.append(sorted(shortcutKeys))
|
||||||
if len(shortcutKeys) != 1 and not 'KEY_FENRIR' in shortcutKeys:
|
if len(shortcutKeys) != 1 and not 'KEY_FENRIR' in shortcutKeys:
|
||||||
@ -90,6 +98,8 @@ class settingsManager():
|
|||||||
self.env['soundIcons'][soundIcon] = soundIconFile
|
self.env['soundIcons'][soundIcon] = soundIconFile
|
||||||
self.env['runtime']['debug'].writeDebugOut("SoundIcon: " + soundIcon + '.' + soundIconFile, debug.debugLevel.INFO, onAnyLevel=True)
|
self.env['runtime']['debug'].writeDebugOut("SoundIcon: " + soundIcon + '.' + soundIconFile, debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
siConfig.close()
|
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'):
|
def loadDicts(self, dictConfigPath=os.path.dirname(os.path.realpath(__main__.__file__)) + '/../../config/punctuation/default.conf'):
|
||||||
dictConfig = open(dictConfigPath,"r")
|
dictConfig = open(dictConfigPath,"r")
|
||||||
|
@ -6,11 +6,14 @@ import time
|
|||||||
|
|
||||||
devices = map(evdev.InputDevice, (evdev.list_devices()))
|
devices = map(evdev.InputDevice, (evdev.list_devices()))
|
||||||
devices = {dev.fd: dev for dev in devices}
|
devices = {dev.fd: dev for dev in devices}
|
||||||
|
for fd in devices:
|
||||||
|
print('Devicename:'+ devices[fd].name + ' Devicepath:' + devices[fd].fn )
|
||||||
|
|
||||||
while True:
|
#--- log events---
|
||||||
r, w, x = select(devices, [], [])
|
#while True:
|
||||||
if r != []:
|
# r, w, x = select(devices, [], [])
|
||||||
for fd in r:
|
# if r != []:
|
||||||
for event in devices[fd].read():
|
# for fd in r:
|
||||||
print('Devicename:'+ devices[fd].name + ' Devicepath:' + devices[fd].fn + ' Events:' + str(devices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value))
|
# 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