X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Finput.c;h=e3cf071d077d6fed8a20e9a0512d92894682cfd7;hb=3d792006acf30d67362146f9f448f753064a6fcf;hp=f26e125e840d9153900571de5d29b18c6378e189;hpb=8e77275edade55d89b0723a60ab4ef1e2ec288de;p=libpicofe.git diff --git a/common/input.c b/common/input.c index f26e125..e3cf071 100644 --- a/common/input.c +++ b/common/input.c @@ -530,7 +530,7 @@ const char *in_get_key_name(int dev_id, int keycode) return xname; } -int in_bind_key(int dev_id, int keycode, int bind_type, int mask, int force_unbind) +int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbind) { int ret, count; in_dev_t *dev; @@ -567,6 +567,24 @@ int in_bind_key(int dev_id, int keycode, int bind_type, int mask, int force_unbi return 0; } +void in_unbind_all(int dev_id, int act_mask, int bind_type) +{ + int i, count; + in_dev_t *dev; + + if (dev_id < 0 || dev_id >= IN_MAX_DEVS || bind_type >= IN_BINDTYPE_COUNT) + return; + + dev = &in_devices[dev_id]; + count = dev->key_count; + + if (dev->binds == NULL) + return; + + for (i = 0; i < count; i++) + dev->binds[IN_BIND_OFFS(i, bind_type)] &= ~act_mask; +} + /* returns device id, or -1 on error */ int in_config_parse_dev(const char *name) { @@ -700,7 +718,7 @@ void in_config_end(void) int i; for (i = 0; i < IN_MAX_DEVS; i++) { - int n, ret, count, *binds, *def_binds; + int n, t, ret, count, *binds, *def_binds; in_dev_t *dev = &in_devices[i]; if (dev->binds == NULL) @@ -710,9 +728,18 @@ void in_config_end(void) binds = dev->binds; def_binds = binds + count * IN_BINDTYPE_COUNT; - for (n = 0; n < count * IN_BINDTYPE_COUNT; n++) - if (binds[n] == -1) - binds[n] = def_binds[n]; + for (n = 0; n < count; n++) { + int is_default = 1; + for (t = 0; t < IN_BINDTYPE_COUNT; t++) + if (binds[IN_BIND_OFFS(n, t)] == -1) + binds[IN_BIND_OFFS(n, t)] = 0; + else + is_default = 0; + + if (is_default) + for (t = 0; t < IN_BINDTYPE_COUNT; t++) + binds[IN_BIND_OFFS(n, t)] = def_binds[IN_BIND_OFFS(n, t)]; + } if (dev->drv_data == NULL) continue;