fix enable/disable commands
This commit is contained in:
@ -41,56 +41,3 @@ class inputManager():
|
||||
currShortcutStringList = sorted(currShortcutStringList)
|
||||
return str(currShortcutStringList)[1:-1].replace(" ","").replace("'","")
|
||||
|
||||
def loadShortcuts(self, environment, kbConfigPath='../../config/keyboard/desktop.kb'):
|
||||
kbConfig = open(kbConfigPath,"r")
|
||||
while(True):
|
||||
line = kbConfig.readline()
|
||||
if not line:
|
||||
break
|
||||
line = line.replace('\n','')
|
||||
if line.replace(" ","").startswith("#"):
|
||||
continue
|
||||
if line.split('#')[0].count("=") != 1:
|
||||
continue
|
||||
sepLine = line.split('#')[0].split('=')
|
||||
commandString = sepLine[1]
|
||||
keys = sepLine[0].replace(" ","").split(',')
|
||||
currShortcut = []
|
||||
validKeyString = True
|
||||
for key in keys:
|
||||
if len(key) < 3:
|
||||
validKeyString = False
|
||||
break
|
||||
if not key[0] in ['0','1','2']:
|
||||
validKeyString = False
|
||||
break
|
||||
if key[1] != '-':
|
||||
validKeyString = False
|
||||
break
|
||||
if key[2:] != '':
|
||||
keyInt = self.getCodeForKeyID(key[2:])
|
||||
else:
|
||||
validKeyString = False
|
||||
break
|
||||
if keyInt == 0:
|
||||
validKeyString = False
|
||||
break
|
||||
if not validKeyString:
|
||||
break
|
||||
else:
|
||||
currShortcut.append(key[0] + '-' + str(keyInt))
|
||||
if validKeyString:
|
||||
keyString = ''
|
||||
for k in sorted(currShortcut):
|
||||
if keyString != '':
|
||||
keyString += ','
|
||||
keyString += k
|
||||
environment['bindings'][keyString] = commandString
|
||||
kbConfig.close()
|
||||
return environment
|
||||
|
||||
def getCodeForKeyID(self, keyID):
|
||||
try:
|
||||
return evdev.ecodes.ecodes[keyID.upper()]
|
||||
except:
|
||||
return 0
|
||||
|
@ -72,6 +72,10 @@ class settingsManager():
|
||||
environment['settings'].read(settingConfigPath)
|
||||
return environment
|
||||
|
||||
def setSetting(self, environment, section, setting, value):
|
||||
environment['settings'].set(section, setting, value)
|
||||
return environment
|
||||
|
||||
def getSetting(self, environment, section, setting):
|
||||
value = ''
|
||||
try:
|
||||
@ -81,7 +85,7 @@ class settingsManager():
|
||||
return value
|
||||
|
||||
def getSettingAsInt(self, environment, section, setting):
|
||||
value = ''
|
||||
value = 0
|
||||
try:
|
||||
value = environment['settings'].getint(section, setting)
|
||||
except:
|
||||
@ -89,14 +93,14 @@ class settingsManager():
|
||||
return value
|
||||
|
||||
def getSettingAsFloat(self, environment, section, setting):
|
||||
value = ''
|
||||
value = 0.0
|
||||
try:
|
||||
value = environment['settings'].getfloat(section, setting)
|
||||
except:
|
||||
value = self.settings[section][setting]
|
||||
return value
|
||||
def getSettingAsBool(self, environment, section, setting):
|
||||
value = ''
|
||||
value = False
|
||||
try:
|
||||
value = environment['settings'].getboolean(section, setting)
|
||||
except:
|
||||
|
Reference in New Issue
Block a user