v4l-utils: report rc protocol while testing
PATCH 1/1 v4l-utils: report rc protocol while testing
If you have a remote and want to see what protocol it uses, simply run the following. That's enough to write a new keymap.
./ir-keytable -p rc-5,nec,rc-6,jvc,sony,sanyo,sharp,xmp -t Testing events. Please, press CTRL-C to abort. 1474415431.689685: event type EV_MSC(0x04): protocol = RC_TYPE_RC6_MCE 1474415431.689685: event type EV_MSC(0x04): scancode = 0x800f040e 1474415431.689685: event type EV_SYN(0x00). 1474415443.857071: event type EV_MSC(0x04): protocol = RC_TYPE_RC5 1474415443.857071: event type EV_MSC(0x04): scancode = 0x1e0f 1474415443.857071: event type EV_SYN(0x00).
--- utils/keytable/Makefile.am | 7 +++++++ utils/keytable/keytable.c | 6 ++++++ utils/keytable/parse.h | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+)
utils/keytable/Makefile.am +7 -0
@@ -59,6 +59,13 @@ sync-with-kernel: >> $(srcdir)/parse.h @printf "\t{ NULL, 0}\n};\n" >> $(srcdir)/parse.h + @printf "struct parse_event rc_type_events[] = {\n" >> $(srcdir)/parse.h + @more $(KERNEL_DIR)/usr/include/linux/input-event-codes.h | perl -n \ + -e 'if (m/^\#define\s+(RC_TYPE_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) ' \ + -e '{ printf "\t{\"%s\", %s},\n",$$1,$$2; }' \ + >> $(srcdir)/parse.h + @printf "\t{ NULL, 0}\n};\n" >> $(srcdir)/parse.h + @-mkdir -p $(srcdir)/rc_keymaps @-rm $(srcdir)/rc_keymaps/* @-cp $(srcdir)/rc_keymaps_userspace/* $(srcdir)/rc_keymaps/
utils/keytable/keytable.c +6 -0
@@ -55,6 +55,10 @@ struct input_keymap_entry_v2 {#define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry_v2)#endif +#ifndef MSC_RC_TYPE +#define MSC_RC_TYPE 6 +#endif +struct keytable_entry {u_int32_t scancode;u_int32_t keycode;
@@ -1294,6 +1298,8 @@ static void test_event(int fd)case EV_MSC :if (ev[i].code ==MSC_SCAN )printf (_ (": scancode = 0x%02x\n" ), ev[i].value); +else if (ev[i].code ==MSC_RC_TYPE ) +printf (_ (": protocol = %s\n" ),get_event_name (rc_type_events, ev[i].value));else printf(_(": code = %s(0x%02x), value = %d\n"), get_event_name(msc_events, ev[i].code),
utils/keytable/parse.h +26 -0
@@ -25,6 +25,7 @@ struct parse_event msc_events[] = { {"MSC_RAW", 0x03}, {"MSC_SCAN", 0x04}, {"MSC_TIMESTAMP", 0x05}, + {"MSC_RC_TYPE", 0x06}, {"MSC_MAX", 0x07}, { NULL, 0} };
@@ -639,3 +640,28 @@ struct parse_event abs_events[] = { {"ABS_MAX", 0x3f}, { NULL, 0} }; +struct parse_event rc_type_events[] = { + {"RC_TYPE_UNKNOWN" ,0 }, + {"RC_TYPE_OTHER" ,1 }, + {"RC_TYPE_RC5" ,2 }, + {"RC_TYPE_RC5X" ,3 }, + {"RC_TYPE_RC5_SZ" ,4 }, + {"RC_TYPE_JVC" ,5 }, + {"RC_TYPE_SONY12" ,6 }, + {"RC_TYPE_SONY15" ,7 }, + {"RC_TYPE_SONY20" ,8 }, + {"RC_TYPE_NEC" ,9 }, + {"RC_TYPE_NECX" ,10 }, + {"RC_TYPE_NEC32" ,11 }, + {"RC_TYPE_SANYO" ,12 }, + {"RC_TYPE_MCE_KBD" ,13 }, + {"RC_TYPE_RC6_0" ,14 }, + {"RC_TYPE_RC6_6A_20" ,15 }, + {"RC_TYPE_RC6_6A_24" ,16 }, + {"RC_TYPE_RC6_6A_32" ,17 }, + {"RC_TYPE_RC6_MCE" ,18 }, + {"RC_TYPE_SHARP" ,19 }, + {"RC_TYPE_XMP" ,20 }, + {"RC_TYPE_CEC" ,21 }, + {NULL ,0 } +};
Signature · 1 line
2.7.4
Em Wed, 21 Sep 2016 10:54:23 +0100
Sean Young <[email protected]> escreveu:
Quoted 42 lines
If you have a remote and want to see what protocol it uses, simply run the following. That's enough to write a new keymap.
./ir-keytable -p rc-5,nec,rc-6,jvc,sony,sanyo,sharp,xmp -t Testing events. Please, press CTRL-C to abort. 1474415431.689685: event type
EV_MSC(0x04): protocol =RC_TYPE_RC6_MCE1474415431.689685: event typeEV_MSC(0x04): scancode =0x800f040e1474415431.689685: event typeEV_SYN(0x00). 1474415443.857071: event typeEV_MSC(0x04): protocol =RC_TYPE_RC51474415443.857071: event typeEV_MSC(0x04): scancode =0x1e0f1474415443.857071: event typeEV_SYN(0x00).Signed-off-by Sean Young <[email protected]>--- utils/keytable/Makefile.am | 7 +++++++ utils/keytable/keytable.c | 6 ++++++ utils/keytable/parse.h | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+)utils/keytable/Makefile.am +7
-0@@ -59,6 +59,13 @@ sync-with-kernel: >> $(srcdir)/parse.h @printf "\t{ NULL, 0}\n};\n" >> $(srcdir)/parse.h + @printf "struct parse_event rc_type_events[] = {\n" >> $(srcdir)/parse.h + @more $(KERNEL_DIR)/usr/include/linux/input-event-codes.h | perl -n \ + -e 'if (m/^\#define\s+(RC_TYPE_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) ' \ + -e '{ printf "\t{\"%s\", %s},\n",$$1,$$2; }' \ + >> $(srcdir)/parse.h + @printf "\t{ NULL, 0}\n};\n" >> $(srcdir)/parse.h + @-mkdir -p $(srcdir)/rc_keymaps @-rm $(srcdir)/rc_keymaps/* @-cp $(srcdir)/rc_keymaps_userspace/* $(srcdir)/rc_keymaps/utils/keytable/keytable.c +0
-0
utils/keytable/keytable.c struct input_keymap_entry_v2 { · line 61
Quoted 7 lines
utils/keytable/keytable.c +4
-0@@ -55,6 +55,10 @@ struct input_keymap_entry_v2 {#define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry_v2)#endif +#ifndef MSC_RC_TYPE +#define MSC_RC_TYPE 6 +#endif +
No. The way we do is that we always include the needed Kernel header with the features, via "make sync-with-kernel". See the README.
Quoted 41 lines
utils/keytable/keytable.c +2
-0struct keytable_entry {u_int32_t scancode;u_int32_t keycode;@@ -1294,6 +1298,8 @@ static void test_event(int fd)case EV_MSC :if (ev[i].code ==MSC_SCAN )printf (_ (": scancode = 0x%02x\n" ), ev[i].value); +else if (ev[i].code ==MSC_RC_TYPE ) +printf (_ (": protocol = %s\n" ),get_event_name (rc_type_events, ev[i].value));else printf(_(": code = %s(0x%02x), value = %d\n"), get_event_name(msc_events, ev[i].code),utils/keytable/parse.h +14
-0@@ -25,6 +25,7 @@ struct parse_event msc_events[] = { {"MSC_RAW", 0x03}, {"MSC_SCAN", 0x04}, {"MSC_TIMESTAMP", 0x05}, + {"MSC_RC_TYPE", 0x06}, {"MSC_MAX", 0x07}, { NULL, 0} };@@ -639,3 +640,28 @@ struct parse_event abs_events[] = { {"ABS_MAX", 0x3f}, { NULL, 0} }; +struct parse_event rc_type_events[] = { + {"RC_TYPE_UNKNOWN" ,0 }, + {"RC_TYPE_OTHER" ,1 }, + {"RC_TYPE_RC5" ,2 }, + {"RC_TYPE_RC5X" ,3 }, + {"RC_TYPE_RC5_SZ" ,4 }, + {"RC_TYPE_JVC" ,5 }, + {"RC_TYPE_SONY12" ,6 }, + {"RC_TYPE_SONY15" ,7 }, + {"RC_TYPE_SONY20" ,8 }, + {"RC_TYPE_NEC" ,9 }, + {"RC_TYPE_NECX" ,10 }, + {"RC_TYPE_NEC32" ,11 },
utils/keytable/parse.h struct parse_event abs_events[] = { · line 665
Quoted 10 lines
utils/keytable/parse.h +10
-0+ {"RC_TYPE_SANYO", 12}, + {"RC_TYPE_MCE_KBD", 13}, + {"RC_TYPE_RC6_0", 14}, + {"RC_TYPE_RC6_6A_20", 15}, + {"RC_TYPE_RC6_6A_24", 16}, + {"RC_TYPE_RC6_6A_32", 17}, + {"RC_TYPE_RC6_MCE", 18}, + {"RC_TYPE_SHARP", 19}, + {"RC_TYPE_XMP", 20}, + {"RC_TYPE_CEC", 21},
Don't hardcode the numbers here. Instead, include the file and use it.
You'll need to patch the main Makefile, in order to copy this header via "make sync-with-kernel" target.
utils/keytable/parse.h struct parse_event abs_events[] = { · line 667
Quoted 2 lines
utils/keytable/parse.h +2
-0+ { NULL, 0} +};
Thanks,
Mauro