This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/v4l-utils.git tree:
Subject: ir-keytable: Improve cleans by using EVIOSKEYCODE_V2 Author: Mauro Carvalho Chehab <[email protected]> Date: Tue Jan 25 10:25:01 2011 -0200 The new input protocol version found on kernels 2.6.37+ provide a better way to cleanup the table codes. Instead of having to do a big for to cleanup the entire scancode space, it just deletes the already existing keycodes. Signed-off-by: Mauro Carvalho Chehab <[email protected]> utils/keytable/keytable.c | 66 ++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 60 insertions(+), 6 deletions(-) --- http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=546f11df6b68021549541da8698b2c2a7068c6ef diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c index 354de06..21cd5c2 100644 --- a/utils/keytable/keytable.c +++ b/utils/keytable/keytable.c @@ -21,6 +21,7 @@ #include <string.h> #include <linux/input.h> #include <sys/ioctl.h> +#include <sys/types.h> #include <dirent.h> #include <argp.h> @@ -29,8 +30,23 @@ /* Default place where the keymaps will be stored */ #define CFGDIR "/etc/rc_keymaps" +struct input_keymap_entry_v2 { +#define KEYMAP_BY_INDEX (1 << 0) + u_int8_t flags; + u_int8_t len; + u_int16_t index; + u_int32_t keycode; + u_int8_t scancode[32]; +}; + +#ifndef EVIOCGKEYCODE_V2 +#define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry_v2) +#define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry_v2) +#endif + struct keytable { int codes[2]; + struct input_keymap_entry_v2 keymap; struct keytable *next; }; @@ -127,7 +143,8 @@ static int test = 0; static enum ir_protocols ch_proto = 0; struct keytable keys = { - {0, 0}, NULL + .codes = {0, 0}, + .next = NULL }; @@ -136,6 +153,11 @@ struct cfgfile cfg = { }; /* + * Stores the input layer protocol version + */ +static int input_protocol_version; + +/* * Values that are read only via sysfs node */ static int sysfs = 0; @@ -1086,18 +1108,48 @@ static int set_proto(struct rc_device *rc_dev) return rc; } +static int get_input_protocol_version(int fd) +{ + if (ioctl(fd, EVIOCGVERSION, &input_protocol_version) < 0) { + fprintf(stderr, + "Unable to query evdev protocol version: %s\n", + strerror(errno)); + return errno; + } + if (debug) + fprintf(stderr, "Input Protocol version: 0x%08x\n", + input_protocol_version); + + return 0; +} + static void clear_table(int fd) { int i, j; int codes[2]; + struct input_keymap_entry_v2 entry; /* Clears old table */ - for (j = 0; j < 256; j++) { - for (i = 0; i < 256; i++) { - codes[0] = (j << 8) | i; - codes[1] = KEY_RESERVED; - ioctl(fd, EVIOCSKEYCODE, codes); + if (input_protocol_version < 0x10001) { + for (j = 0; j < 256; j++) { + for (i = 0; i < 256; i++) { + codes[0] = (j << 8) | i; + codes[1] = KEY_RESERVED; + ioctl(fd, EVIOCSKEYCODE, codes); + } } + } else { + memset(&entry, '\0', sizeof(entry)); + i = 0; + do { + entry.flags = KEYMAP_BY_INDEX; + entry.keycode = KEY_RESERVED; + entry.index = 0; + + i++; + if (debug) + fprintf(stderr, "Deleting entry %d\n", i); + } while (ioctl(fd, EVIOCSKEYCODE_V2, &entry) == 0); } } @@ -1320,6 +1372,8 @@ int main(int argc, char *argv[]) } if (dev_from_class) free(devname); + if (get_input_protocol_version(fd)) + return -1; /* * First step: clear, if --clear is specified _______________________________________________ linuxtv-commits mailing list [email protected] http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
