mirror of
https://github.com/moparisthebest/uinput-mapper
synced 2025-02-07 10:30:12 -05:00
Configuration now allows modifying the dictionary.
This commit is contained in:
parent
1022db5eaf
commit
8ecdcd1bc1
48
py/configs/example_conf.py
Normal file
48
py/configs/example_conf.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
from cinput import *
|
||||||
|
|
||||||
|
overrule = lambda x: -x*2
|
||||||
|
passthrough = lambda x: x
|
||||||
|
|
||||||
|
config = {
|
||||||
|
EV_REL : {
|
||||||
|
#REL_X : {
|
||||||
|
# 'type' : EV_REL,
|
||||||
|
# 'code' : REL_X,
|
||||||
|
# 'value': overrule
|
||||||
|
#},
|
||||||
|
#REL_Y : {
|
||||||
|
# 'type': EV_REL,
|
||||||
|
# 'code': REL_Y,
|
||||||
|
# 'value' : overrule
|
||||||
|
#},
|
||||||
|
REL_X : {
|
||||||
|
'type' : EV_REL,
|
||||||
|
'code' : REL_X,
|
||||||
|
'value' : lambda x: 0
|
||||||
|
},
|
||||||
|
REL_Y : {
|
||||||
|
'type' : EV_REL,
|
||||||
|
'code' : REL_Y,
|
||||||
|
'value' : lambda x: 0
|
||||||
|
},
|
||||||
|
REL_WHEEL : {
|
||||||
|
'type' : EV_REL,
|
||||||
|
'code' : REL_WHEEL,
|
||||||
|
'value' : lambda x: -x*2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
EV_KEY : {
|
||||||
|
BTN_LEFT : {
|
||||||
|
'type' : EV_KEY,
|
||||||
|
'code' : BTN_LEFT,
|
||||||
|
'value' : passthrough
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def config_merge(c):
|
||||||
|
for k, v in config.iteritems():
|
||||||
|
if k in c:
|
||||||
|
c[k].update(v)
|
||||||
|
else:
|
||||||
|
c[k] = v
|
@ -44,3 +44,20 @@ config = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def config_merge(c):
|
||||||
|
# XXX: We cannot just use update; as it will override everything in say EV_KEY
|
||||||
|
for k, v in config.iteritems():
|
||||||
|
if k in c:
|
||||||
|
c[k].update(v)
|
||||||
|
else:
|
||||||
|
c[k] = v
|
||||||
|
|
||||||
|
# Uncomment this to make touch click too
|
||||||
|
c[EV_KEY][BTN_TOUCH] = {
|
||||||
|
'type' : EV_KEY,
|
||||||
|
'code' : BTN_TOUCH,
|
||||||
|
'value' : lambda x: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
17
py/create.py
17
py/create.py
@ -16,10 +16,6 @@ import optparse
|
|||||||
|
|
||||||
parser = optparse.OptionParser(description='Create input devices. '
|
parser = optparse.OptionParser(description='Create input devices. '
|
||||||
'TODO')
|
'TODO')
|
||||||
#parser.add_option('-c', '--config', type=str, action='append',
|
|
||||||
# default=[],
|
|
||||||
# help='Merge configuration file with default '
|
|
||||||
# 'configuration (allowed to be used multiple times)')
|
|
||||||
parser.add_option('-C', '--compat', action='store_true',
|
parser.add_option('-C', '--compat', action='store_true',
|
||||||
help='Enable compatibility mode; for Python < 2.7')
|
help='Enable compatibility mode; for Python < 2.7')
|
||||||
|
|
||||||
@ -29,19 +25,10 @@ args, cfg = parser.parse_args()
|
|||||||
f = pickle.Unpickler(sys.stdin)
|
f = pickle.Unpickler(sys.stdin)
|
||||||
|
|
||||||
conf = f.load()
|
conf = f.load()
|
||||||
print conf
|
|
||||||
|
|
||||||
for path in cfg:
|
for path in cfg:
|
||||||
config = imp.load_source('', path).config
|
config_merge = imp.load_source('', path).config_merge
|
||||||
|
config_merge(conf)
|
||||||
# XXX: We cannot just use update; as it will override everything in say EV_TE
|
|
||||||
for k, v in config.iteritems():
|
|
||||||
if k in conf:
|
|
||||||
conf[k].update(v)
|
|
||||||
else:
|
|
||||||
conf[k] = v
|
|
||||||
#conf.update(config)
|
|
||||||
print conf
|
|
||||||
|
|
||||||
m = KeyMapper(conf)
|
m = KeyMapper(conf)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user