diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 5c84cf1d7c..43afdc2d59 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -38,7 +38,6 @@ #include "../../frontend/drivers/platform_linux.h" -#include "../../configuration.h" #include "../../runloop.h" static enum gfx_ctx_api android_api = GFX_CTX_NONE; @@ -366,10 +365,10 @@ static bool android_gfx_ctx_set_video_mode(void *data, } static void android_gfx_ctx_input_driver(void *data, + const char *joypad_name, const input_driver_t **input, void **input_data) { - settings_t *settings = config_get_ptr(); - void *androidinput = input_android.init(settings->input.joypad_driver); + void *androidinput = input_android.init(joypad_name); *input = androidinput ? &input_android : NULL; *input_data = androidinput; diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index 60f1dfe2b1..b5412a189f 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -154,7 +154,9 @@ static void gfx_ctx_cgl_destroy(void *data) free(cgl); } -static void gfx_ctx_cgl_input_driver(void *data, const input_driver_t **input, void **input_data) +static void gfx_ctx_cgl_input_driver(void *data, + const char *name, + const input_driver_t **input, void **input_data) { (void)data; (void)input; diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index cf18281938..566869809a 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -588,10 +588,11 @@ static bool cocoagl_gfx_ctx_set_resize(void *data, unsigned width, unsigned heig return false; } -static void cocoagl_gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void cocoagl_gfx_ctx_input_driver(void *data, + const char *name, + const input_driver_t **input, void **input_data) { - (void)data; - *input = NULL; + *input = NULL; *input_data = NULL; } diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index ab1d5b4682..0fb31ad377 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -29,7 +29,6 @@ #include "../drivers/d3d.h" #include "../common/win32_common.h" -#include "../../configuration.h" #include "../../runloop.h" #include "../../verbosity.h" #include "../../ui/ui_companion_driver.h" @@ -182,15 +181,15 @@ static void gfx_ctx_d3d_destroy(void *data) } static void gfx_ctx_d3d_input_driver(void *data, + const char *name, const input_driver_t **input, void **input_data) { - settings_t *settings = config_get_ptr(); #ifdef _XBOX - void *xinput = input_xinput.init(settings->input.joypad_driver); + void *xinput = input_xinput.init(joypad_name); *input = xinput ? (const input_driver_t*)&input_xinput : NULL; *input_data = xinput; #else - dinput = input_dinput.init(settings->input.joypad_driver); + dinput = input_dinput.init(joypad_name); *input = dinput ? &input_dinput : NULL; *input_data = dinput; #endif diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index d2a4b3c282..b8738d3165 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -746,10 +746,10 @@ static void gfx_ctx_drm_destroy(void *data) } static void gfx_ctx_drm_input_driver(void *data, + const char *name, const input_driver_t **input, void **input_data) { - (void)data; - *input = NULL; + *input = NULL; *input_data = NULL; } diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 4a9d9735cd..1b750a3689 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -222,23 +222,22 @@ static bool gfx_ctx_emscripten_bind_api(void *data, static void gfx_ctx_emscripten_input_driver(void *data, + const char *name, const input_driver_t **input, void **input_data) { - (void)data; + void *rwebinput = NULL; - *input = NULL; - *input_data = NULL; + *input = NULL; + *input_data = NULL; #ifndef HAVE_SDL2 - { - void *rwebinput = input_rwebinput.init(); + rwebinput = input_rwebinput.init(); - if (!rwebinput) - return; + if (!rwebinput) + return; - *input = &input_rwebinput; - *input_data = rwebinput; - } + *input = &input_rwebinput; + *input_data = rwebinput; #endif } diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index 36078d774a..f4cf4f63d5 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -79,7 +79,9 @@ static void gfx_ctx_null_destroy(void *data) (void)data; } -static void gfx_ctx_null_input_driver(void *data, const input_driver_t **input, void **input_data) +static void gfx_ctx_null_input_driver(void *data, + const char *name, + const input_driver_t **input, void **input_data) { (void)data; (void)input; diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index ced55e6b33..80276bae10 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -155,10 +155,10 @@ error: } static void gfx_ctx_khr_display_input_driver(void *data, + const char *name, const input_driver_t **input, void **input_data) { - (void)data; - *input = NULL; + *input = NULL; *input_data = NULL; } diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index 475ba08255..de76f06aea 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -226,10 +226,10 @@ error: } static void gfx_ctx_mali_fbdev_input_driver(void *data, + const char *name, const input_driver_t **input, void **input_data) { - (void)data; - *input = NULL; + *input = NULL; *input_data = NULL; } diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index 141b3ad54f..bab164cadc 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -199,10 +199,10 @@ error: } static void gfx_ctx_opendingux_input_driver(void *data, + const char *name, const input_driver_t **input, void **input_data) { - (void)data; - *input = NULL; + *input = NULL; *input_data = NULL; } diff --git a/gfx/drivers_context/osmesa_ctx.c b/gfx/drivers_context/osmesa_ctx.c index 24caa0ab61..f6899ece1b 100644 --- a/gfx/drivers_context/osmesa_ctx.c +++ b/gfx/drivers_context/osmesa_ctx.c @@ -372,9 +372,10 @@ static void osmesa_ctx_swap_buffers(void *data, video_frame_info_t video_info) #endif } -static void osmesa_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void osmesa_ctx_input_driver(void *data, + const char *name, + const input_driver_t **input, void **input_data) { - (void)data; *input = NULL; *input_data = NULL; } diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index 5a63a57054..fa34420ec9 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -339,10 +339,10 @@ static void gfx_ctx_ps3_destroy(void *data) } static void gfx_ctx_ps3_input_driver(void *data, + const char *joypad_name, const input_driver_t **input, void **input_data) { - settings_t *settings = config_get_ptr(); - void *ps3input = input_ps3.init(settings->input.joypad_driver); + void *ps3input = input_ps3.init(joypad_name); *input = ps3input ? &input_ps3 : NULL; *input_data = ps3input; diff --git a/gfx/drivers_context/qnx_ctx.c b/gfx/drivers_context/qnx_ctx.c index 6e3060a904..31ffdbda4b 100644 --- a/gfx/drivers_context/qnx_ctx.c +++ b/gfx/drivers_context/qnx_ctx.c @@ -346,10 +346,10 @@ static bool gfx_ctx_qnx_set_video_mode(void *data, static void gfx_ctx_qnx_input_driver(void *data, + const char *joypad_name, const input_driver_t **input, void **input_data) { - settings_t *settings = config_get_ptr(); - void *qnxinput = input_qnx.init(settings->input.joypad_driver); + void *qnxinput = input_qnx.init(joypad_name); *input = qnxinput ? &input_qnx : NULL; *input_data = qnxinput; diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 2fa338cc1b..50dd0c33a9 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -391,10 +391,11 @@ static void sdl_ctx_swap_buffers(void *data, video_frame_info_t video_info) (void)data; } -static void sdl_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void sdl_ctx_input_driver(void *data, + const char *name, + const input_driver_t **input, void **input_data) { - (void)data; - *input = NULL; + *input = NULL; *input_data = NULL; } diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index d5f9b3f8a3..959b0571e3 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -451,10 +451,10 @@ static void gfx_ctx_vc_destroy(void *data) } static void gfx_ctx_vc_input_driver(void *data, + const char *name, const input_driver_t **input, void **input_data) { - (void)data; - *input = NULL; + *input = NULL; *input_data = NULL; } diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index e85009b642..ac12fc7afa 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -204,10 +204,10 @@ error: } static void gfx_ctx_vivante_input_driver(void *data, + const char *name, const input_driver_t **input, void **input_data) { - (void)data; - *input = NULL; + *input = NULL; *input_data = NULL; } diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 9ec79438e5..a59e99f91c 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -42,7 +42,6 @@ #include "../common/gl_common.h" #endif -#include "../../configuration.h" #include "../../frontend/frontend_driver.h" #include "../../runloop.h" #include "../../input/input_keyboard.h" @@ -1365,13 +1364,18 @@ static void input_wl_free(void *data) wl->joypad->destroy(); } -static bool input_wl_init(void *data) +static bool input_wl_init(void *data, const char *joypad_name) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - settings_t *settings = config_get_ptr(); - wl->joypad = input_joypad_init_driver(settings->input.joypad_driver, wl); + + if (!wl) + return false; + + wl->joypad = input_joypad_init_driver(joypad_name, wl); + if (!wl->joypad) return false; + input_keymaps_init_keyboard_lut(rarch_key_map_linux); return true; } @@ -1455,10 +1459,11 @@ static const input_driver_t input_wayland = { }; static void gfx_ctx_wl_input_driver(void *data, + const char *joypad_name, const input_driver_t **input, void **input_data) { /* Input is heavily tied to the window stuff on Wayland, so just implement the input driver here. */ - if (!input_wl_init(data)) + if (!input_wl_init(data, joypad_name)) { *input = NULL; *input_data = NULL; diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index 00421c303b..fba99cf998 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -559,10 +559,10 @@ error: static void gfx_ctx_wgl_input_driver(void *data, + const char *joypad_name, const input_driver_t **input, void **input_data) { - settings_t *settings = config_get_ptr(); - dinput_wgl = input_dinput.init(settings ? settings->input.joypad_driver : NULL); + dinput_wgl = input_dinput.init(joypad_name); *input = dinput_wgl ? &input_dinput : NULL; *input_data = dinput_wgl; diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 08d53d4d45..897f40b163 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -36,8 +36,6 @@ #endif -#include "../../configuration.h" - #include "../../frontend/frontend_driver.h" #include "../common/gl_common.h" #include "../common/x11_common.h" @@ -877,12 +875,10 @@ error: } static void gfx_ctx_x_input_driver(void *data, + const char *joypad_name, const input_driver_t **input, void **input_data) { - settings_t *settings = config_get_ptr(); - void *xinput = input_x.init(settings->input.joypad_driver); - - (void)data; + void *xinput = input_x.init(joypad_name); *input = xinput ? &input_x : NULL; *input_data = xinput; diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index d89ea1f721..133736d847 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -23,7 +23,6 @@ #include "../../config.h" #endif -#include "../../configuration.h" #include "../../frontend/frontend_driver.h" #include "../common/egl_common.h" @@ -424,12 +423,10 @@ error: static void gfx_ctx_xegl_input_driver(void *data, - const input_driver_t **input, void **input_data) + const char *joypad_name, + const input_driver_t **input, void **input_data) { - settings_t *settings = config_get_ptr(); - void *xinput = input_x.init(settings->input.joypad_driver); - - (void)data; + void *xinput = input_x.init(joypad_name); *input = xinput ? &input_x : NULL; *input_data = xinput; diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index a3acb683a9..f1b114ee61 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -412,10 +412,14 @@ bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics) bool video_context_driver_input_driver(gfx_ctx_input_t *inp) { + settings_t *settings = config_get_ptr(); + const char *joypad_name = settings ? settings->input.joypad_driver : NULL; + if (!current_video_context || !current_video_context->input_driver) return false; current_video_context->input_driver( - video_context_data, inp->input, inp->input_data); + video_context_data, joypad_name, + inp->input, inp->input_data); return true; } diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 27d07c2f2b..3b78e72a0a 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -126,7 +126,7 @@ typedef struct gfx_ctx_driver /* Most video backends will want to use a certain input driver. * Checks for it here. */ - void (*input_driver)(void*, const input_driver_t**, void**); + void (*input_driver)(void*, const char *, const input_driver_t**, void**); /* Wraps whatever gl_proc_address() there is. * Does not take opaque, to avoid lots of ugly wrapper code. */