From: nerdopolis Date: Thu, 7 Dec 2023 22:25:58 +0000 (-0500) Subject: ply-input-device: Handle the keyboard sequence to change VTs X-Git-Tag: 23.51.283~6^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7215ab126958368020c768d6c1c58af986556fec;p=thirdparty%2Fplymouth.git ply-input-device: Handle the keyboard sequence to change VTs --- diff --git a/src/libply-splash-core/ply-input-device.c b/src/libply-splash-core/ply-input-device.c index 02506090..81a0b7e5 100644 --- a/src/libply-splash-core/ply-input-device.c +++ b/src/libply-splash-core/ply-input-device.c @@ -36,6 +36,7 @@ #include "ply-input-device.h" #include "ply-list.h" #include "ply-logger.h" +#include "ply-terminal.h" #include "ply-trigger.h" #include "ply-utils.h" @@ -62,6 +63,7 @@ struct _ply_input_device struct libevdev *dev; + uint32_t kernel_has_vts : 1; uint32_t leds_state_invalid : 1; }; @@ -149,6 +151,17 @@ apply_key_to_input_buffer (ply_input_device_t *input_device, assert (character_size + 1 == sizeof(character_buf)); ply_buffer_append_bytes (input_buffer, character_buf, character_size); + } else { + xkb_keysym_t keysym; + + if (!input_device->kernel_has_vts) + break; + + keysym = xkb_state_key_get_one_sym (input_device->keyboard_state, keycode); + if (keysym >= XKB_KEY_XF86Switch_VT_1 && keysym <= XKB_KEY_XF86Switch_VT_12) { + int vt_number = keysym - XKB_KEY_XF86Switch_VT_1 + 1; + ply_change_to_vt (vt_number); + } } break; } @@ -339,6 +352,8 @@ ply_input_device_open (struct xkb_context *xkb_context, if (input_device->compose_table) input_device->compose_state = xkb_compose_state_new (input_device->compose_table, XKB_COMPOSE_STATE_NO_FLAGS); + input_device->kernel_has_vts = ply_character_device_exists ("/dev/tty0"); + return input_device; error: