diff options
author | Ray Strode <halfline@gmail.com> | 2023-12-04 23:11:52 +0000 |
---|---|---|
committer | Ray Strode <halfline@gmail.com> | 2023-12-04 23:11:52 +0000 |
commit | 6b5bd35a0e353259b318ab5c675569f98644cc22 (patch) | |
tree | 94620ae9e8ceafb03d82f648c7c94ff97d190486 | |
parent | ceb5576650d21dc0186042a4fbe41af98c365b75 (diff) | |
parent | c2decd9fcffae355bf52be2b50ad340eb83f3620 (diff) |
Merge branch 'input-device-debug' into 'main'
ply-input-device: Handle SYN events
See merge request plymouth/plymouth!253
-rw-r--r-- | src/libply-splash-core/ply-input-device.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/libply-splash-core/ply-input-device.c b/src/libply-splash-core/ply-input-device.c index b0b75b93..db826ab9 100644 --- a/src/libply-splash-core/ply-input-device.c +++ b/src/libply-splash-core/ply-input-device.c @@ -159,8 +159,23 @@ on_input (ply_input_device_t *input_device) { struct input_event ev; int rc; + unsigned int flags; ply_buffer_t *input_buffer = ply_buffer_new (); + static enum { PLY_INPUT_DEVICE_DEBUG_UNKNOWN = -1, + PLY_INPUT_DEVICE_DEBUG_DISABLED, + PLY_INPUT_DEVICE_DEBUG_ENABLED } debug_key_events = PLY_INPUT_DEVICE_DEBUG_UNKNOWN; + + if (debug_key_events == PLY_INPUT_DEVICE_DEBUG_UNKNOWN) { + if (ply_kernel_command_line_has_argument ("plymouth.debug-input-devices")) { + ply_trace ("WARNING: Input device debugging enabled. Passwords will be in log!"); + debug_key_events = PLY_INPUT_DEVICE_DEBUG_ENABLED; + } else { + ply_trace ("Input device debugging disabled"); + debug_key_events = PLY_INPUT_DEVICE_DEBUG_DISABLED; + } + } + flags = LIBEVDEV_READ_FLAG_NORMAL; for (;;) { ply_key_direction_t key_state; enum xkb_key_direction xkb_key_direction; @@ -168,9 +183,26 @@ on_input (ply_input_device_t *input_device) xkb_keysym_t symbol; enum xkb_state_component updated_state; - rc = libevdev_next_event (input_device->dev, LIBEVDEV_READ_FLAG_NORMAL, &ev); - if (rc != LIBEVDEV_READ_STATUS_SUCCESS) + rc = libevdev_next_event (input_device->dev, flags, &ev); + + if (rc == LIBEVDEV_READ_STATUS_SYNC) { + ply_trace ("Input device %s has backlog of events", libevdev_get_name (input_device->dev)); + flags = LIBEVDEV_READ_FLAG_SYNC; + continue; + } else if (rc == LIBEVDEV_READ_STATUS_SUCCESS && flags == LIBEVDEV_READ_FLAG_SYNC) { + ply_trace ("Input device %s event backlog has been processed", libevdev_get_name (input_device->dev)); + flags = LIBEVDEV_READ_FLAG_NORMAL; + } else if (rc != LIBEVDEV_READ_STATUS_SUCCESS) { break; + } + + if (debug_key_events == PLY_INPUT_DEVICE_DEBUG_ENABLED) { + ply_trace ("Received event from input device %s, type=%s code=%s value=%d.", + libevdev_get_name (input_device->dev), + libevdev_event_type_get_name (ev.type), + libevdev_event_code_get_name (ev.type, ev.code), + ev.value); + } if (!libevdev_event_is_type (&ev, EV_KEY)) continue; @@ -208,6 +240,7 @@ on_input (ply_input_device_t *input_device) updated_state = xkb_state_update_key (input_device->keyboard_state, keycode, xkb_key_direction); if ((updated_state & XKB_STATE_LEDS) != 0) { + ply_trace ("Keyboard indicator lights need update"); input_device->leds_state_invalid = true; ply_trigger_pull (input_device->leds_changed_trigger, input_device); } |