From 3bbbeca957d9b738c6206578cb91072a13dd2ce5 Mon Sep 17 00:00:00 2001 From: zoltanvb Date: Sun, 30 Mar 2025 12:55:41 +0200 Subject: [PATCH] Save fallback to linuxraw driver in case of first boot. When no devices can be detected and it is the initial boot, make sure the driver is set to linuxraw, if supported. --- input/drivers/udev_input.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index f34caa6e78..ef5cbf0f12 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -4126,7 +4126,28 @@ static void *udev_input_init(const char *joypad_driver) /* If using KMS and we forgot this, * we could lock ourselves out completely. */ if (!udev->num_devices) + { + settings_t *settings = config_get_ptr(); RARCH_WARN("[udev]: Couldn't open any keyboard, mouse or touchpad. Are permissions set correctly for /dev/input/event* and /run/udev/?\n"); + /* Start screen is not used nowadays, but it still gets true value only + * on first startup without config file, so it should be good to catch + * initial boots without udev devices available. */ +#if defined(__linux__) && !defined(ANDROID) + if (settings->bools.menu_show_start_screen) + { + /* Force fallback to linuxraw. Driver reselection would happen even + * without overwriting input_driver setting, but that would not be saved + * as input driver auto-changes are not stored (due to interlock with + * video context driver), and on next boot user would be stuck with a + * possibly nonworking configuration. + */ + strlcpy(settings->arrays.input_driver, "linuxraw", + sizeof(settings->arrays.input_driver)); + RARCH_WARN("[udev]: First boot and without input devices, forcing fallback to linuxraw.\n"); + goto error; + } +#endif + } input_keymaps_init_keyboard_lut(rarch_key_map_linux);