X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Finput.c;h=5250535500026d669f0f892686fa69ec7a411c89;hb=2e307a073fd703e88a264b86a541dc5c5f3db110;hp=7a0a23f8431d84b93e897bb710a2e08b94d3ed2c;hpb=d166ceb6d17f24797cbef591451fbfacfc8ec0c2;p=libpicofe.git diff --git a/common/input.c b/common/input.c index 7a0a23f..5250535 100644 --- a/common/input.c +++ b/common/input.c @@ -1,3 +1,13 @@ +/* + * (C) Gražvydas "notaz" Ignotas, 2008-2010 + * + * This work is licensed under the terms of any of these licenses + * (at your option): + * - GNU GPL, version 2 or later. + * - GNU LGPL, version 2.1 or later. + * See the COPYING file in the top-level directory. + */ + #include #include #include @@ -667,22 +677,39 @@ int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbi return 0; } -void in_unbind_all(int dev_id, int act_mask, int bind_type) +/* + * Unbind act_mask on binds with type bind_type + * - if dev_id_ < 0, affects all devices + * else only affects dev_id_ + * - if act_mask == -1, unbind all keys + * else only actions in mask + */ +void in_unbind_all(int dev_id_, int act_mask, int bind_type) { + int dev_id = 0, dev_last = IN_MAX_DEVS - 1; int i, count; in_dev_t *dev; - if (dev_id < 0 || dev_id >= IN_MAX_DEVS || bind_type >= IN_BINDTYPE_COUNT) + if (dev_id_ >= 0) + dev_id = dev_last = dev_id_; + + if (bind_type >= IN_BINDTYPE_COUNT) return; - dev = &in_devices[dev_id]; - count = dev->key_count; + for (; dev_id <= dev_last; dev_id++) { + dev = &in_devices[dev_id]; + count = dev->key_count; - if (dev->binds == NULL) - return; + if (dev->binds == NULL) + continue; - for (i = 0; i < count; i++) - dev->binds[IN_BIND_OFFS(i, bind_type)] &= ~act_mask; + if (act_mask != -1) { + for (i = 0; i < count; i++) + dev->binds[IN_BIND_OFFS(i, bind_type)] &= ~act_mask; + } + else + memset(dev->binds, 0, sizeof(dev->binds[0]) * count * IN_BINDTYPE_COUNT); + } } /* returns device id, or -1 on error */