X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=linux%2Fin_evdev.c;h=3f30970eefa8f08ea156b0bee260e69f244c1245;hb=4db02226eb3c80f49f5c412f7718c437c5e817fc;hp=c61506125322bc150671cab4629fc32e5f1f4fe6;hpb=705bdf63669b4703c79b10342b21acc97a14107c;p=libpicofe.git diff --git a/linux/in_evdev.c b/linux/in_evdev.c index c615061..3f30970 100644 --- a/linux/in_evdev.c +++ b/linux/in_evdev.c @@ -1,10 +1,11 @@ /* - * (C) Gražvydas "notaz" Ignotas, 2008-2010 + * (C) Gražvydas "notaz" Ignotas, 2008-2012 * * 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. + * - MAME license. * See the COPYING file in the top-level directory. */ @@ -19,7 +20,7 @@ #include #include -#include "../common/input.h" +#include "../input.h" #include "in_evdev.h" #define MAX_ABS_DEVS 8 @@ -559,9 +560,10 @@ static const struct { #define KEY_PBTN_MAP_SIZE (sizeof(key_pbtn_map) / sizeof(key_pbtn_map[0])) -static int in_evdev_menu_translate(void *drv_data, int keycode) +static int in_evdev_menu_translate(void *drv_data, int keycode, char *charcode) { in_evdev_t *dev = drv_data; + int ret = 0; int i; if (keycode < 0) @@ -578,12 +580,25 @@ static int in_evdev_menu_translate(void *drv_data, int keycode) } else { - for (i = 0; i < KEY_PBTN_MAP_SIZE; i++) - if (key_pbtn_map[i].key == keycode) - return key_pbtn_map[i].pbtn; + for (i = 0; i < KEY_PBTN_MAP_SIZE; i++) { + if (key_pbtn_map[i].key == keycode) { + ret = key_pbtn_map[i].pbtn; + break; + } + } + + if (charcode != NULL && (unsigned int)keycode < KEY_CNT && + in_evdev_keys[keycode] != NULL && in_evdev_keys[keycode][1] == 0) + { + char c = in_evdev_keys[keycode][0]; + if ('A' <= c && c <= 'Z') + c = 'a' + c - 'A'; + ret |= PBTN_CHAR; + *charcode = c; + } } - return 0; + return ret; } /* remove binds of missing keys, count remaining ones */