diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index 7967b6de86..28c4eb5270 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -14,6 +14,7 @@ */ #include +#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -154,9 +155,42 @@ error: } static void gfx_ctx_khr_display_input_driver(void *data, - const char *name, + const char *joypad_name, const input_driver_t **input, void **input_data) { +#ifdef HAVE_X11 + settings_t *settings = config_get_ptr(); + + /* We cannot use the X11 input driver for DRM/KMS */ + if (string_is_equal(settings->arrays.input_driver, "x")) + { +#ifdef HAVE_UDEV + { + /* Try to set it to udev instead */ + void *udev = input_udev.init(joypad_name); + if (udev) + { + *input = &input_udev; + *input_data = udev; + return; + } + } +#endif +#if defined(__linux__) && !defined(ANDROID) + { + /* Try to set it to linuxraw instead */ + void *linuxraw = input_linuxraw.init(joypad_name); + if (linuxraw) + { + *input = &input_linuxraw; + *input_data = linuxraw; + return; + } + } +#endif + } +#endif + *input = NULL; *input_data = NULL; }