diff options
author | albeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-06-12 10:39:04 +0000 |
---|---|---|
committer | albeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-06-12 10:39:04 +0000 |
commit | 86a87de5906e26bb12e07d1fe0a4b0bf466cbd76 (patch) | |
tree | b4bad3ae545578a641323a95a9acac5b96e916ab /input | |
parent | 30097784c0b5b3772fba718a0925eeea7caaf9f8 (diff) | |
download | mpv-86a87de5906e26bb12e07d1fe0a4b0bf466cbd76.tar.bz2 mpv-86a87de5906e26bb12e07d1fe0a4b0bf466cbd76.tar.xz |
Add support for hex key code in input.conf
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6395 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'input')
-rw-r--r-- | input/input.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/input/input.c b/input/input.c index 8a5fab5ef3..0c6aff2210 100644 --- a/input/input.c +++ b/input/input.c @@ -11,6 +11,7 @@ #include <sys/types.h> #include <sys/time.h> #include <fcntl.h> +#include <ctype.h> #include "input.h" #include "mouse.h" @@ -963,7 +964,7 @@ mp_cmd_clone(mp_cmd_t* cmd) { return ret; } -static char key_str[2]; +static char key_str[12]; static char* mp_input_get_key_name(int key) { @@ -974,21 +975,25 @@ mp_input_get_key_name(int key) { return key_names[i].name; } - if(key >> 8 == 0) { - snprintf(key_str,2,"%c",(char)key); + if(isascii(key)) { + snprintf(key_str,12,"%c",(char)key); return key_str; } - return NULL; + // Print the hex key code + snprintf(key_str,12,"%#-8x",key); + return key_str; + } static int mp_input_get_key_from_name(char* name) { - int i,ret = 0; - if(strlen(name) == 1) { // Direct key code - (char)ret = name[0]; + int i,ret = 0,len = strlen(name); + if(len == 1) { // Direct key code + ret = (unsigned char)name[0]; return ret; - } + } else if(len > 2 && strncasecmp("0x",name,2) == 0) + return strtol(name,NULL,16); for(i = 0; key_names[i].name != NULL; i++) { if(strcasecmp(key_names[i].name,name) == 0) |