ir-keytable: re-add --device option
PATCH 1/1 ir-keytable: re-add --device option
While --device option doesn't work for enumerating and for RC/LIRC specific control, it is still useful for testing purposes for all kinds of input devices. For example, it can be used to test mouse events:
$ ./utils/keytable/ir-keytable -d /dev/input/event4 -t Testing events. Please, press CTRL-C to abort. 1222738.567737: event type EV_REL(0x02): REL_X (0x0000) value=1 1222738.567737: event type EV_SYN(0x00). 1222738.573742: event type EV_REL(0x02): REL_X (0x0000) value=1 1222738.573742: event type EV_SYN(0x00). 1222738.581738: event type EV_REL(0x02): REL_X (0x0000) value=2 1222738.581738: event type EV_REL(0x02): REL_Y (0x0001) value=1
So, re-add it, but only on test mode.
Partially reverts: 906719e4c573 ("keytable: remove misleading --device argument")
utils/keytable/ir-keytable.1.in +5 -0
@@ -22,6 +22,9 @@ Auto\-load keymaps, based on a configuration file. Only works with \fB\-c\fR, \fB\-\-clear\fR Clears the scancode to keycode mappings. .TP +\fB\-d\fR, \fB\-\-device\fR=\fIDEV\fR +Use specified input device. Works only on test mode. +.TP \fB\-D\fR, \fB\-\-delay\fR=\fIDELAY\fR Sets the delay before repeating a keystroke. .TP
@@ -66,6 +69,8 @@ print the v4l2\-utils version Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options. Options can be combined together. .SS The options arguments are: +.IP \fIDEV\fR +the /dev/input/event* device to control .IP \fISYSDEV\fR the rc device as found at /sys/class/rc .IP \fIKEYMAP\fR
utils/keytable/keytable.c +29 -16
99 lines not on this page · raw message
Thanks,
Mauro
Quoted 14 lines · Mauro Carvalho Chehab
While --device option doesn't work for enumerating and for RC/LIRC specific control, it is still useful for testing purposes for all kinds of input devices. For example, it can be used to test mouse events:
$ ./utils/keytable/ir-keytable -d /dev/input/event4 -t Testing events. Please, press CTRL-C to abort. 1222738.567737: event type EV_REL(0x02): REL_X (0x0000) value=1 1222738.567737: event type EV_SYN(0x00). 1222738.573742: event type EV_REL(0x02): REL_X (0x0000) value=1 1222738.573742: event type EV_SYN(0x00). 1222738.581738: event type EV_REL(0x02): REL_X (0x0000) value=2 1222738.581738: event type EV_REL(0x02): REL_Y (0x0001) value=1
Quoted 1 line
So, re-add it, but only on test mode.
Isn't this the same functionality as evtest(1), but not as complete?
https://cgit.freedesktop.org/evtest/
evtest is packaged for Fedora, Debian, and Ubuntu.
Sean
Quoted 143 lines
Partially reverts:
906719e4c573("keytable: remove misleading --device argument")Signed-off-by Mauro Carvalho Chehab <[email protected]>utils/keytable/ir-keytable.1.in +5
-0@@ -22,6 +22,9 @@ Auto\-load keymaps, based on a configuration file. Only works with \fB\-c\fR, \fB\-\-clear\fR Clears the scancode to keycode mappings. .TP +\fB\-d\fR, \fB\-\-device\fR=\fIDEV\fR +Use specified input device. Works only on test mode. +.TP \fB\-D\fR, \fB\-\-delay\fR=\fIDELAY\fR Sets the delay before repeating a keystroke. .TP@@ -66,6 +69,8 @@ print the v4l2\-utils version Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options. Options can be combined together. .SS The options arguments are: +.IP \fIDEV\fR +the /dev/input/event* device to control .IP \fISYSDEV\fR the rc device as found at /sys/class/rc .IP \fIKEYMAP\fRutils/keytable/keytable.c +29
-16@@ -249,6 +249,7 @@ static const char doc[] = N_("You need to have read permissions on /dev/input for the program to work\n" "\nOn the options below, the arguments are:\n" " SYSDEV - the rc device as found at /sys/class/rc\n" +" DEV - the /dev/input/event* device to control\n" " KEYMAP - a keymap file with protocols and scancode to keycode mappings\n" " SCANKEY - a set of scancode1=keycode1,scancode2=keycode2.. value pairs\n" " PROTOCOL - protocol name (nec, rc-5, rc-6, jvc, sony, sanyo, rc-5-sz, lirc,\n" @@ -267,6 +268,7 @@ static const struct argp_option options[] = { {"sysdev", 's', N_("SYSDEV"), 0, N_("rc device to control, defaults to rc0 if not specified"), 0}, {"test", 't', 0, 0, N_("test if IR is generating events"), 0}, {"read", 'r', 0, 0, N_("reads the current scancode/keycode mapping"), 0}, + {"device", 'd', N_("DEV"), 0, N_("ir device to control"), 0}, {"write", 'w', N_("KEYMAP"), 0, N_("write (adds) the keymap from the specified file"), 0}, {"set-key", 'k', N_("SCANKEY"), 0, N_("Change scan/key pairs"), 0}, {"protocol", 'p', N_("PROTOCOL"), 0, N_("Protocol to enable (the other ones will be disabled). To enable more than one, use the option more than one time"), 0},@@ -285,6 +287,7 @@ static const char args_doc[] = N_("");/* Static vars to store the parameters */ static char *devclass =NULL ; +static char *devicename =NULL ;static int readtable =0 ;static int clear =0 ;int debug =0 ;@@ -551,6 +554,9 @@ static error_t parse_opt(int k, char *arg, struct argp_state *state)if (!p || *p || period <0 )argp_error (state,_ ("Invalid period: %s" ), arg);break ; +case 'd' : + devicename = arg; +break ;case 's' : devclass = arg;break ;@@ -2033,7 +2039,7 @@ int main(int argc, char *argv[])int dev_from_class =0 , write_cnt;int fd;static struct sysfs_names *names; -struct rc_device rc_dev; +struct rc_device rc_dev = { };#ifdef ENABLE_NLS setlocale (LC_ALL ,"" );@@ -2046,6 +2052,11 @@ int main(int argc, char *argv[])if (test_keymap)return 0 ; +if (devicename &&( !test || devclass || clear || readtable || keytable || ch_proto || cfg.next || delay >=0 || period >=0 || bpf_protocol)) { +fprintf (stderr,_ ("device option can be used only for test events\n" )); +return -1 ; + } +/* Just list all devices */ if (!clear && !readtable && !keytable && !ch_proto && !cfg.next && !test && delay <0 && period <0 && !bpf_protocol) {if (show_sysfs_attribs (&rc_dev, devclass))@@ -2061,19 +2072,21 @@ int main(int argc, char *argv[])fprintf (stderr,_ ("Auto-mode can be used only with --read, --verbose and --sysdev options\n" ));return -1 ; } - - names =find_device (devclass); -if (!names) -return -1 ; - rc_dev.sysfs_name = names->name; -if (get_attribs (&rc_dev, names->name)) { +if (!devicename) { + names =find_device (devclass); +if (!names) +return -1 ; + rc_dev.sysfs_name = names->name; +if (get_attribs (&rc_dev, names->name)) { +free_names (names); +return -1 ; + } + names->name =NULL ;free_names (names); -return -1 ; - } - names->name =NULL ; -free_names (names); - dev_from_class++; + devicename = rc_dev.input_name; + dev_from_class++; + }if (cfg.next) {struct cfgfile *cur;@@ -2124,14 +2137,14 @@ int main(int argc, char *argv[]) }if (debug) -fprintf (stderr,_ ("Opening %s\n" ), rc_dev.input_name); - fd =open (rc_dev.input_name,O_RDONLY |O_NONBLOCK ); +fprintf (stderr,_ ("Opening %s\n" ), devicename); + fd =open (devicename,O_RDONLY |O_NONBLOCK );if (fd <0 ) { -perror (rc_dev.input_name); +perror (devicename);return -1 ; }if (dev_from_class) -free (rc_dev.input_name); +free (devicename);if (get_input_protocol_version (fd))return -1 ;Thanks,
Mauro
Em Mon, 7 Sep 2020 15:43:09 +0100
Sean Young <[email protected]> escreveu:
Quoted 15 lines · Mauro Carvalho Chehab
Quoted 14 lines
While --device option doesn't work for enumerating and for RC/LIRC specific control, it is still useful for testing purposes for all kinds of input devices. For example, it can be used to test mouse events:
$ ./utils/keytable/ir-keytable -d /dev/input/event4 -t Testing events. Please, press CTRL-C to abort. 1222738.567737: event type EV_REL(0x02): REL_X (0x0000) value=1 1222738.567737: event type EV_SYN(0x00). 1222738.573742: event type EV_REL(0x02): REL_X (0x0000) value=1 1222738.573742: event type EV_SYN(0x00). 1222738.581738: event type EV_REL(0x02): REL_X (0x0000) value=2 1222738.581738: event type EV_REL(0x02): REL_Y (0x0001) value=1
Quoted 7 lines
Quoted 1 line
So, re-add it, but only on test mode.
Isn't this the same functionality as evtest(1), but not as complete?
https://cgit.freedesktop.org/evtest/
evtest is packaged for Fedora, Debian, and Ubuntu.
No idea. At least on the device I'm testing (Hikey 970), evtest doesn't produce anything when I move my mouse (checking via ssh):
$ sudo evtest No device specified, trying to scan all of /dev/input/event* Available devices: /dev/input/event0: PixArt Dell MS116 USB Optical Mouse Select the device event number [0-0]:
While ir-keytable works fine.
Thanks,
Mauro
Em Mon, 7 Sep 2020 16:58:06 +0200
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 29 lines
Em Mon, 7 Sep 2020 15:43:09 +0100
Sean Young <[email protected]> escreveu:Quoted 15 lines · Mauro Carvalho Chehab
Quoted 14 lines
While --device option doesn't work for enumerating and for RC/LIRC specific control, it is still useful for testing purposes for all kinds of input devices. For example, it can be used to test mouse events:
$ ./utils/keytable/ir-keytable -d /dev/input/event4 -t Testing events. Please, press CTRL-C to abort. 1222738.567737: event type EV_REL(0x02): REL_X (0x0000) value=1 1222738.567737: event type EV_SYN(0x00). 1222738.573742: event type EV_REL(0x02): REL_X (0x0000) value=1 1222738.573742: event type EV_SYN(0x00). 1222738.581738: event type EV_REL(0x02): REL_X (0x0000) value=2 1222738.581738: event type EV_REL(0x02): REL_Y (0x0001) value=1Quoted 7 lines
Quoted 1 line
So, re-add it, but only on test mode.
Isn't this the same functionality as evtest(1), but not as complete?
https://cgit.freedesktop.org/evtest/
evtest is packaged for Fedora, Debian, and Ubuntu.
No idea. At least on the device I'm testing (Hikey 970), evtest doesn't produce anything when I move my mouse (checking via ssh):
Quoted 7 lines
$ sudo evtest No device specified, trying to scan all of /dev/input/event* Available devices: /dev/input/event0: PixArt Dell MS116 USB Optical Mouse Select the device event number [0-0]:While ir-keytable works fine.
Gah! it actually expects a "0" as input, as pressing just <enter> does nothing. crap!
Thanks,
Mauro
Quoted 38 lines · Mauro Carvalho Chehab
Em Mon, 7 Sep 2020 16:58:06 +0200
Mauro Carvalho Chehab <[email protected]> escreveu:Quoted 35 lines
Em Mon, 7 Sep 2020 15:43:09 +0100
Sean Young <[email protected]> escreveu:Quoted 15 lines · Mauro Carvalho Chehab
Quoted 14 lines
While --device option doesn't work for enumerating and for RC/LIRC specific control, it is still useful for testing purposes for all kinds of input devices. For example, it can be used to test mouse events:
$ ./utils/keytable/ir-keytable -d /dev/input/event4 -t Testing events. Please, press CTRL-C to abort. 1222738.567737: event type EV_REL(0x02): REL_X (0x0000) value=1 1222738.567737: event type EV_SYN(0x00). 1222738.573742: event type EV_REL(0x02): REL_X (0x0000) value=1 1222738.573742: event type EV_SYN(0x00). 1222738.581738: event type EV_REL(0x02): REL_X (0x0000) value=2 1222738.581738: event type EV_REL(0x02): REL_Y (0x0001) value=1Quoted 7 lines
Quoted 1 line
So, re-add it, but only on test mode.
Isn't this the same functionality as evtest(1), but not as complete?
https://cgit.freedesktop.org/evtest/
evtest is packaged for Fedora, Debian, and Ubuntu.
No idea. At least on the device I'm testing (Hikey 970), evtest doesn't produce anything when I move my mouse (checking via ssh):
$ sudo evtest No device specified, trying to scan all of /dev/input/event* Available devices: /dev/input/event0: PixArt Dell MS116 USB Optical Mouse Select the device event number [0-0]:
Quoted 4 lines
Quoted 1 line
While ir-keytable works fine.
Gah! it actually expects a "0" as input, as pressing just <enter> does nothing. crap!
You can specify the device on the command line:
$ sudo evtest /dev/input/event6
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x45e product 0x737 version 0x111
Input device name: "PixArt Microsoft USB Optical Mouse"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 272 (BTN_LEFT)
Event code 273 (BTN_RIGHT)
Event code 274 (BTN_MIDDLE)
Event type 2 (EV_REL)
Event code 0 (REL_X)
Event code 1 (REL_Y)
Event code 8 (REL_WHEEL)
Event code 11 (REL_WHEEL_HI_RES)
Event type 4 (EV_MSC)
Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1599502969.368229, type 2 (EV_REL), code 1 (REL_Y), value -3It gives more information about the device than ir-keytable, and it's maintained by Peter Hutterer, the maintainer of libinput.
Having said that, asking for the input device when there is only one is a bit stupid.
Thanks,
Sean