X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Finput.c;h=7bbb39c1ffd6d331d08b330d0cb698e6c618614f;hb=b7c7cd5d463187f209ce669b77694c9c7007b223;hp=182e9fb26042a1697ea192d8aa4dcbd6292d0985;hpb=e9b2926437ccf6b630cf79e00ed98f7934201c20;p=libpicofe.git diff --git a/common/input.c b/common/input.c index 182e9fb..7bbb39c 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 @@ -355,9 +365,6 @@ int in_update_keycode(int *dev_id_out, int *is_down_out, int timeout_ms) drv = &DRV(in_devices[dev_id].drv_id); result = drv->update_keycode(in_devices[dev_id].drv_data, &is_down); - - /* update_keycode() might return -1 when some not interesting - * event happened, like sync event for evdev. */ if (result >= 0) break; @@ -370,7 +377,7 @@ int in_update_keycode(int *dev_id_out, int *is_down_out, int timeout_ms) } } - if (result == -1) + if (result < 0) return -1; finish: /* keep track of menu key state, to allow mixing @@ -611,6 +618,28 @@ const char *in_get_key_name(int dev_id, int keycode) return xname; } +int in_get_key_code(int dev_id, const char *key_name) +{ + in_dev_t *dev; + int i; + + if (dev_id < 0) /* want last used dev? */ + dev_id = menu_last_used_dev; + + if (dev_id < 0 || dev_id >= IN_MAX_DEVS) + return -1; + + dev = &in_devices[dev_id]; + if (dev->key_names == NULL) + return -1; + + for (i = 0; i < dev->key_count; i++) + if (dev->key_names[i] && strcasecmp(dev->key_names[i], key_name) == 0) + return i; + + return -1; +} + int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbind) { int ret, count;