From: notaz Date: Mon, 8 Nov 2010 21:07:38 +0000 (+0000) Subject: input: add in_get_key_code X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d166ceb6d17f24797cbef591451fbfacfc8ec0c2;p=libpicofe.git input: add in_get_key_code git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@902 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/common/input.c b/common/input.c index a6d331e..7a0a23f 100644 --- a/common/input.c +++ b/common/input.c @@ -608,6 +608,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; diff --git a/common/input.h b/common/input.h index 8fbf6e7..4f4bfbc 100644 --- a/common/input.h +++ b/common/input.h @@ -106,6 +106,7 @@ int in_config_bind_key(int dev_id, const char *key, int binds, int bind_type); void in_config_end(void); int in_get_config(int dev_id, int what, void *val); int in_set_config(int dev_id, int what, const void *val, int size); +int in_get_key_code(int dev_id, const char *key_name); int in_name_to_id(const char *dev_name); int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbind); void in_unbind_all(int dev_id, int act_mask, int bind_type);