From 1e578f1a50787e95b4f1f4cccc1879212fa5c133 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Fri, 24 Jan 2020 16:31:31 +0100 Subject: [PATCH] Log key count in input test --- repos/dde_linux/run/usb_hid.run | 24 ++++++++++++------------ repos/dde_linux/run/usb_hid_raw.run | 24 ++++++++++++------------ repos/os/src/test/input/test.cc | 6 +++++- repos/ports/run/vbox5_genode_usb_hid.run | 24 ++++++++++++------------ 4 files changed, 41 insertions(+), 37 deletions(-) diff --git a/repos/dde_linux/run/usb_hid.run b/repos/dde_linux/run/usb_hid.run index 3021bb07d..2f9fe5143 100644 --- a/repos/dde_linux/run/usb_hid.run +++ b/repos/dde_linux/run/usb_hid.run @@ -227,22 +227,22 @@ filter_out_color_escape_sequences trim_lines compare_output_to { -[init -> test-input] Input event #0 PRESS KEY_X 65534 -[init -> test-input] Input event #1 RELEASE KEY_X -[init -> test-input] Input event #2 PRESS BTN_LEFT 65534 -[init -> test-input] Input event #3 REL_MOTION -1+0 -[init -> test-input] Input event #4 REL_MOTION +0+1 -[init -> test-input] Input event #5 RELEASE BTN_LEFT +[init -> test-input] Input event #0 PRESS KEY_X 65534 key count: 1 +[init -> test-input] Input event #1 RELEASE KEY_X key count: 0 +[init -> test-input] Input event #2 PRESS BTN_LEFT 65534 key count: 1 +[init -> test-input] Input event #3 REL_MOTION -1+0 key count: 1 +[init -> test-input] Input event #4 REL_MOTION +0+1 key count: 1 +[init -> test-input] Input event #5 RELEASE BTN_LEFT key count: 0 [init -> usb_drv] dev_info: USB disconnect, device [init -> usb_drv] dev_info: new full-speed USB device [init -> usb_drv] dev_info: D L [init -> usb_drv] dev_info: input: USB HID v1.11 Keyboard [D L] [init -> usb_drv] dev_info: D L [init -> usb_drv] dev_info: input: USB HID v1.11 Mouse [D L] -[init -> test-input] Input event #6 PRESS KEY_X 65534 -[init -> test-input] Input event #7 RELEASE KEY_X -[init -> test-input] Input event #8 PRESS BTN_LEFT 65534 -[init -> test-input] Input event #9 REL_MOTION -1+0 -[init -> test-input] Input event #10 REL_MOTION +0+1 -[init -> test-input] Input event #11 RELEASE BTN_LEFT +[init -> test-input] Input event #6 PRESS KEY_X 65534 key count: 1 +[init -> test-input] Input event #7 RELEASE KEY_X key count: 0 +[init -> test-input] Input event #8 PRESS BTN_LEFT 65534 key count: 1 +[init -> test-input] Input event #9 REL_MOTION -1+0 key count: 1 +[init -> test-input] Input event #10 REL_MOTION +0+1 key count: 1 +[init -> test-input] Input event #11 RELEASE BTN_LEFT key count: 0 } diff --git a/repos/dde_linux/run/usb_hid_raw.run b/repos/dde_linux/run/usb_hid_raw.run index 9e076cc4e..7901aba32 100644 --- a/repos/dde_linux/run/usb_hid_raw.run +++ b/repos/dde_linux/run/usb_hid_raw.run @@ -236,20 +236,20 @@ filter_out_color_escape_sequences trim_lines compare_output_to { -[init -> test-input] Input event #0 PRESS KEY_X 65534 -[init -> test-input] Input event #1 RELEASE KEY_X -[init -> test-input] Input event #2 PRESS BTN_LEFT 65534 -[init -> test-input] Input event #3 REL_MOTION -1+0 -[init -> test-input] Input event #4 REL_MOTION +0+1 -[init -> test-input] Input event #5 RELEASE BTN_LEFT +[init -> test-input] Input event #0 PRESS KEY_X 65534 key count: 1 +[init -> test-input] Input event #1 RELEASE KEY_X key count: 0 +[init -> test-input] Input event #2 PRESS BTN_LEFT 65534 key count: 1 +[init -> test-input] Input event #3 REL_MOTION -1+0 key count: 1 +[init -> test-input] Input event #4 REL_MOTION +0+1 key count: 1 +[init -> test-input] Input event #5 RELEASE BTN_LEFT key count: 0 [init -> usb_drv] dev_info: USB disconnect, device [init -> usb_drv] dev_info: new full-speed USB device [init -> usb_hid_drv] dev_info: input: USB HID v1.11 Keyboard [HID 03eb:204d] [init -> usb_hid_drv] dev_info: input: USB HID v1.11 Mouse [HID 03eb:204d] -[init -> test-input] Input event #6 PRESS KEY_X 65534 -[init -> test-input] Input event #7 RELEASE KEY_X -[init -> test-input] Input event #8 PRESS BTN_LEFT 65534 -[init -> test-input] Input event #9 REL_MOTION -1+0 -[init -> test-input] Input event #10 REL_MOTION +0+1 -[init -> test-input] Input event #11 RELEASE BTN_LEFT +[init -> test-input] Input event #6 PRESS KEY_X 65534 key count: 1 +[init -> test-input] Input event #7 RELEASE KEY_X key count: 0 +[init -> test-input] Input event #8 PRESS BTN_LEFT 65534 key count: 1 +[init -> test-input] Input event #9 REL_MOTION -1+0 key count: 1 +[init -> test-input] Input event #10 REL_MOTION +0+1 key count: 1 +[init -> test-input] Input event #11 RELEASE BTN_LEFT key count: 0 } diff --git a/repos/os/src/test/input/test.cc b/repos/os/src/test/input/test.cc index 215c87581..1476f74f1 100644 --- a/repos/os/src/test/input/test.cc +++ b/repos/os/src/test/input/test.cc @@ -25,11 +25,15 @@ struct Main Input::Connection _input { _env }; Signal_handler
_input_sigh { _env.ep(), *this, &Main::_handle_input }; unsigned _event_cnt { 0 }; + int _key_cnt { 0 }; void _handle_input() { _input.for_each_event([&] (Input::Event const &ev) { - log("Input event #", _event_cnt++, "\t", ev); }); + if (ev.press()) ++_key_cnt; + if (ev.release()) --_key_cnt; + log("Input event #", _event_cnt++, "\t", ev, "\tkey count: ", _key_cnt); + }); } Main(Env &env) : _env(env) diff --git a/repos/ports/run/vbox5_genode_usb_hid.run b/repos/ports/run/vbox5_genode_usb_hid.run index 5ffae86a3..5d232ab98 100644 --- a/repos/ports/run/vbox5_genode_usb_hid.run +++ b/repos/ports/run/vbox5_genode_usb_hid.run @@ -288,12 +288,12 @@ filter_out_color_escape_sequences trim_lines compare_output_to { -[init -> log_terminal] [init -> test-input] Input event #0 PRESS KEY_X 65534 -[init -> log_terminal] [init -> test-input] Input event #1 RELEASE KEY_X -[init -> log_terminal] [init -> test-input] Input event #2 PRESS BTN_LEFT 65534 -[init -> log_terminal] [init -> test-input] Input event #3 REL_MOTION -1+0 -[init -> log_terminal] [init -> test-input] Input event #4 REL_MOTION +0+1 -[init -> log_terminal] [init -> test-input] Input event #5 RELEASE BTN_LEFT +[init -> log_terminal] [init -> test-input] Input event #0 PRESS KEY_X 65534 key count: 1 +[init -> log_terminal] [init -> test-input] Input event #1 RELEASE KEY_X key count: 0 +[init -> log_terminal] [init -> test-input] Input event #2 PRESS BTN_LEFT 65534 key count: 1 +[init -> log_terminal] [init -> test-input] Input event #3 REL_MOTION -1+0 key count: 1 +[init -> log_terminal] [init -> test-input] Input event #4 REL_MOTION +0+1 key count: 1 +[init -> log_terminal] [init -> test-input] Input event #5 RELEASE BTN_LEFT key count: 0 [init -> usb_drv] dev_info: USB disconnect, device [init -> log_terminal] [init -> usb_drv] dev_info: USB disconnect, device [init -> usb_drv] dev_info: new full-speed USB device @@ -303,10 +303,10 @@ compare_output_to { [init -> log_terminal] [init -> usb_drv] dev_info: input: USB HID v1.11 Keyboard [D L] [init -> log_terminal] [init -> usb_drv] dev_info: D L [init -> log_terminal] [init -> usb_drv] dev_info: input: USB HID v1.11 Mouse [D L] -[init -> log_terminal] [init -> test-input] Input event #6 PRESS KEY_X 65534 -[init -> log_terminal] [init -> test-input] Input event #7 RELEASE KEY_X -[init -> log_terminal] [init -> test-input] Input event #8 PRESS BTN_LEFT 65534 -[init -> log_terminal] [init -> test-input] Input event #9 REL_MOTION -1+0 -[init -> log_terminal] [init -> test-input] Input event #10 REL_MOTION +0+1 -[init -> log_terminal] [init -> test-input] Input event #11 RELEASE BTN_LEFT +[init -> log_terminal] [init -> test-input] Input event #6 PRESS KEY_X 65534 key count: 1 +[init -> log_terminal] [init -> test-input] Input event #7 RELEASE KEY_X key count: 0 +[init -> log_terminal] [init -> test-input] Input event #8 PRESS BTN_LEFT 65534 key count: 1 +[init -> log_terminal] [init -> test-input] Input event #9 REL_MOTION -1+0 key count: 1 +[init -> log_terminal] [init -> test-input] Input event #10 REL_MOTION +0+1 key count: 1 +[init -> log_terminal] [init -> test-input] Input event #11 RELEASE BTN_LEFT key count: 0 }