From cd75b0ce0ae7333119fbe2b5739ac049d4cbfe43 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 21 Dec 2006 11:44:39 -0200 Subject: Added a small utility to allow see/edit IR tables From: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/Makefile | 2 +- v4l2-apps/util/keytable.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 v4l2-apps/util/keytable.c (limited to 'v4l2-apps/util') diff --git a/v4l2-apps/util/Makefile b/v4l2-apps/util/Makefile index 8555ef5b6..8c0277a6a 100644 --- a/v4l2-apps/util/Makefile +++ b/v4l2-apps/util/Makefile @@ -6,7 +6,7 @@ binaries = v4l2-ctl .PHONY: all clean install qv4l2 -all: $(binaries) qv4l2 +all: $(binaries) qv4l2 keytable clean:: rm -f $(binaries) diff --git a/v4l2-apps/util/keytable.c b/v4l2-apps/util/keytable.c new file mode 100644 index 000000000..f908f6065 --- /dev/null +++ b/v4l2-apps/util/keytable.c @@ -0,0 +1,67 @@ +/* keytable.c - This program allows checking/replacing keys at IR + + Copyright (C) 2006 Mauro Carvalho Chehab + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include + +void prtcode (int *codes) +{ + if (isprint (codes[1])) + printf("scancode %d = '%c' (0x%02x)\n", codes[0], codes[1], codes[1]); + else + printf("scancode %d = 0x%02x\n", codes[0], codes[1]); +} + +int main (int argc, char *argv[]) +{ + int fd; + unsigned int i; + int codes[2]; + + if (argc!=2 && argc!=4) { + printf ("usage: %s to get table; or\n" + " %s \n",*argv,*argv); + return -1; + } + + if ((fd = open(argv[1], O_RDONLY)) < 0) { + perror("Couldn't open input device"); + return(-1); + } + + if (argc==2) { + /* Get scancode table */ + for (i=0;i<256;i++) { + codes[0] = i; + if(ioctl(fd, EVIOCGKEYCODE, codes)==0) + prtcode(codes); +// else perror ("EVIOGCKEYCODE"); + } + } else { + codes[0] = (unsigned) strtol(argv[2], NULL, 0); + codes[1] = (unsigned) strtol(argv[3], NULL, 0); + + if(ioctl(fd, EVIOCSKEYCODE, codes)) + perror ("EVIOCSKEYCODE"); + + if(ioctl(fd, EVIOCGKEYCODE, codes)==0) + prtcode(codes); + } + + return 0; +} -- cgit v1.2.3