mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-07 16:38:45 -10:00
input: one function starts the input driver for a Windows window
Which input driver a Windows window gets - raw input if that is the setting and it starts, DirectInput otherwise; XInput or the uwp driver on UWP; XInput on Xbox - was written out four times in the video code, drivers' names and all: in the Vulkan context, in the WGL context, in d3d_input_driver() for the Direct3D drivers, and in the GDI driver. It is input_driver_init_windows() in input/ now and the four call it. It is called from where they were, inside a video driver's init, so on the same thread as before: with threaded video that is the video thread, where a raw input window has to be made for its messages to arrive. This does not change which thread starts the input driver. Two of the copies had a wrong argument, and those two behave differently now: - Direct3D 9 (both drivers) passed the joypad driver's name where the input driver's name was wanted, so the comparison with "raw" never matched and D3D9 always got DirectInput whatever the input driver setting said. The window procedure, which goes by the setting, was meanwhile routing messages for raw input. D3D9 now gets the driver the setting names, like every other video driver. - GDI passed the input driver's name where the joypad driver's name was wanted, so the joypad driver was looked up as "raw" or "dinput". It is started by its own setting now. The three file-level variables that kept the DirectInput handle (dinput_vk, dinput_wgl, dinput_gdi) were written and never read; they go. Compiled for Windows with mingw: the Vulkan and WGL contexts, GDI, d3d_common.c, d3d10.c and input_driver.c. d3d11.c and d3d12.c do not compile with the headers here before or after this, and d3d8.c and the two d3d9 files were not tried; in all five the change is the same one line as in d3d10.c. Not run on Windows.
This commit is contained in:
1 parent
80875ecefb
commit
7c3b82c232
13 files changed
+84
-158
No files matched your search
@@ -44,47 +44,3 @@ int32_t d3d_translate_filter(unsigned type)
|
||||
return (int32_t)D3D_TEXTURE_FILTER_POINT;
|
||||
}
|
||||
|
||||
void d3d_input_driver(const char* input_name, const char* joypad_name,
|
||||
input_driver_t** input, void** input_data)
|
||||
{
|
||||
#if defined(__WINRT__)
|
||||
/* Plain xinput is supported on UWP, but it
|
||||
* supports joypad only (uwp driver was added later) */
|
||||
if (string_is_equal(input_name, "xinput"))
|
||||
{
|
||||
void *xinput = input_driver_init_wrap(&input_xinput, joypad_name);
|
||||
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
|
||||
*input_data = xinput;
|
||||
}
|
||||
else
|
||||
{
|
||||
void *uwp = input_driver_init_wrap(&input_uwp, joypad_name);
|
||||
*input = uwp ? (input_driver_t*)&input_uwp : NULL;
|
||||
*input_data = uwp;
|
||||
}
|
||||
#elif defined(_XBOX)
|
||||
void *xinput = input_driver_init_wrap(&input_xinput, joypad_name);
|
||||
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
|
||||
*input_data = xinput;
|
||||
#else
|
||||
#if _WIN32_WINNT >= 0x0501
|
||||
#ifdef HAVE_WINRAWINPUT
|
||||
/* winraw only available since XP */
|
||||
if (string_is_equal(input_name, "raw"))
|
||||
{
|
||||
*input_data = input_driver_init_wrap(&input_winraw, joypad_name);
|
||||
if (*input_data)
|
||||
{
|
||||
*input = &input_winraw;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
*input_data = input_driver_init_wrap(&input_dinput, joypad_name);
|
||||
*input = *input_data ? &input_dinput : NULL;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -66,9 +66,6 @@ typedef struct
|
||||
|
||||
int32_t d3d_translate_filter(unsigned type);
|
||||
|
||||
void d3d_input_driver(const char* input_name,
|
||||
const char* joypad_name, input_driver_t** input, void** input_data);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
+2
-1
@@ -2299,7 +2299,8 @@ static void *d3d10_gfx_init(const video_info_t* video,
|
||||
goto error;
|
||||
}
|
||||
|
||||
d3d_input_driver(settings->arrays.input_driver, settings->arrays.input_joypad_driver, input, input_data);
|
||||
input_driver_init_windows(settings->arrays.input_joypad_driver,
|
||||
input, input_data);
|
||||
|
||||
if (!d3d10_init_swapchain(d3d10,
|
||||
VIDEO_SCALE_W(d3d10->vp.full_dims),
|
||||
|
||||
+2
-1
@@ -3584,7 +3584,8 @@ static void *d3d11_gfx_init(const video_info_t* video,
|
||||
goto error;
|
||||
}
|
||||
|
||||
d3d_input_driver(settings->arrays.input_driver, settings->arrays.input_joypad_driver, input, input_data);
|
||||
input_driver_init_windows(settings->arrays.input_joypad_driver,
|
||||
input, input_data);
|
||||
|
||||
#ifdef __WINRT__
|
||||
DXGICreateFactory2(&d3d11->factory);
|
||||
|
||||
+2
-2
@@ -5019,8 +5019,8 @@ static void *d3d12_gfx_init(const video_info_t* video,
|
||||
else
|
||||
d3d12->flags &= ~D3D12_ST_FLAG_VSYNC;
|
||||
|
||||
d3d_input_driver(settings->arrays.input_driver,
|
||||
settings->arrays.input_joypad_driver, input, input_data);
|
||||
input_driver_init_windows(settings->arrays.input_joypad_driver,
|
||||
input, input_data);
|
||||
|
||||
d3d12_init_base(d3d12);
|
||||
|
||||
|
||||
+2
-1
@@ -2473,7 +2473,8 @@ static bool d3d8_init_internal(d3d8_video_t *d3d,
|
||||
if (!d3d8_initialize(d3d, &d3d->video_info))
|
||||
return false;
|
||||
|
||||
d3d_input_driver(settings->arrays.input_driver, settings->arrays.input_joypad_driver, input, input_data);
|
||||
input_driver_init_windows(settings->arrays.input_joypad_driver,
|
||||
input, input_data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3858,8 +3858,8 @@ static bool d3d9_cg_init_internal(d3d9_video_t *d3d,
|
||||
if (!d3d9_cg_initialize(d3d, &d3d->video_info))
|
||||
return false;
|
||||
|
||||
d3d_input_driver(settings->arrays.input_joypad_driver,
|
||||
settings->arrays.input_joypad_driver, input, input_data);
|
||||
input_driver_init_windows(settings->arrays.input_joypad_driver,
|
||||
input, input_data);
|
||||
|
||||
{
|
||||
char version_str[128];
|
||||
|
||||
@@ -7195,8 +7195,8 @@ static bool d3d9_hlsl_init_internal(d3d9_video_t *d3d,
|
||||
if (!d3d9_hlsl_initialize(d3d, &d3d->video_info))
|
||||
return false;
|
||||
|
||||
d3d_input_driver(settings->arrays.input_joypad_driver,
|
||||
settings->arrays.input_joypad_driver, input, input_data);
|
||||
input_driver_init_windows(settings->arrays.input_joypad_driver,
|
||||
input, input_data);
|
||||
|
||||
{
|
||||
char version_str[128];
|
||||
|
||||
+2
-32
@@ -103,7 +103,6 @@ typedef struct gdi_texture
|
||||
|
||||
|
||||
HDC win32_gdi_hdc;
|
||||
static void *dinput_gdi;
|
||||
|
||||
/* Forward declarations for static helpers used across the display
|
||||
* driver / video driver / font driver sections. */
|
||||
@@ -2366,36 +2365,6 @@ static bool gfx_ctx_gdi_set_video_mode(
|
||||
return true;
|
||||
}
|
||||
|
||||
static void gfx_ctx_gdi_input_driver(
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
#if _WIN32_WINNT >= 0x0501
|
||||
#ifdef HAVE_WINRAWINPUT
|
||||
/* winraw only available since XP */
|
||||
if (string_is_equal(settings->arrays.input_driver, "raw"))
|
||||
{
|
||||
*input_data = input_driver_init_wrap(&input_winraw, settings->arrays.input_driver);
|
||||
if (*input_data)
|
||||
{
|
||||
*input = &input_winraw;
|
||||
dinput_gdi = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
dinput_gdi = input_driver_init_wrap(&input_dinput, settings->arrays.input_driver);
|
||||
*input = dinput_gdi ? &input_dinput : NULL;
|
||||
#else
|
||||
dinput_gdi = NULL;
|
||||
*input = NULL;
|
||||
#endif
|
||||
*input_data = dinput_gdi;
|
||||
}
|
||||
|
||||
static void gdi_create(gdi_t *gdi)
|
||||
{
|
||||
char os[64] = {0};
|
||||
@@ -2494,7 +2463,8 @@ static void *gdi_init(const video_info_t *video,
|
||||
RARCH_LOG("[GDI] Using resolution %ux%u.\n",
|
||||
VIDEO_SCALE_W(temp_dims), VIDEO_SCALE_H(temp_dims));
|
||||
|
||||
gfx_ctx_gdi_input_driver(input, input_data);
|
||||
input_driver_init_windows(
|
||||
config_get_ptr()->arrays.input_joypad_driver, input, input_data);
|
||||
|
||||
|
||||
RARCH_LOG("[GDI] Init complete.\n");
|
||||
|
||||
@@ -58,7 +58,6 @@ typedef struct gfx_ctx_w_vk_data
|
||||
|
||||
/* TODO/FIXME - static globals */
|
||||
gfx_ctx_vulkan_data_t win32_vk;
|
||||
static void *dinput_vk = NULL;
|
||||
int win32_vk_interval = 0;
|
||||
|
||||
/* FORWARD DECLARATIONS */
|
||||
@@ -264,30 +263,7 @@ static void gfx_ctx_w_vk_input_driver(void *data,
|
||||
const char *joypad_name,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
#if _WIN32_WINNT >= 0x0501
|
||||
#ifdef HAVE_WINRAWINPUT
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *input_driver = settings->arrays.input_driver;
|
||||
|
||||
/* winraw only available since XP */
|
||||
if (string_is_equal(input_driver, "raw"))
|
||||
{
|
||||
*input_data = input_driver_init_wrap(&input_winraw, joypad_name);
|
||||
if (*input_data)
|
||||
{
|
||||
*input = &input_winraw;
|
||||
dinput_vk = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
dinput_vk = input_driver_init_wrap(&input_dinput, joypad_name);
|
||||
*input = dinput_vk ? &input_dinput : NULL;
|
||||
*input_data = dinput_vk;
|
||||
#endif
|
||||
input_driver_init_windows(joypad_name, input, input_data);
|
||||
}
|
||||
|
||||
static enum gfx_ctx_api gfx_ctx_w_vk_get_api(void *data) { return GFX_CTX_VULKAN_API; }
|
||||
|
||||
@@ -152,7 +152,6 @@ static uint8_t wgl_flags;
|
||||
#ifdef HAVE_EGL
|
||||
static egl_ctx_data_t win32_egl;
|
||||
#endif
|
||||
static void *dinput_wgl = NULL;
|
||||
static unsigned win32_major = 0;
|
||||
static unsigned win32_minor = 0;
|
||||
static int win32_interval = 0;
|
||||
@@ -700,50 +699,7 @@ static void gfx_ctx_wgl_input_driver(void *data,
|
||||
const char *joypad_name,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
#if _WIN32_WINNT >= 0x0501
|
||||
#ifdef HAVE_WINRAWINPUT
|
||||
const char *input_driver = settings->arrays.input_driver;
|
||||
|
||||
/* winraw only available since XP */
|
||||
if (string_is_equal(input_driver, "raw"))
|
||||
{
|
||||
*input_data = input_driver_init_wrap(&input_winraw, joypad_name);
|
||||
if (*input_data)
|
||||
{
|
||||
*input = &input_winraw;
|
||||
dinput_wgl = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
dinput_wgl = input_driver_init_wrap(&input_dinput, joypad_name);
|
||||
*input = dinput_wgl ? &input_dinput : NULL;
|
||||
*input_data = dinput_wgl;
|
||||
#elif defined(__WINRT__)
|
||||
/* Plain xinput is supported on UWP, but it
|
||||
* supports joypad only (uwp driver was added later) */
|
||||
if (string_is_equal(settings->arrays.input_driver, "xinput"))
|
||||
{
|
||||
void* xinput = input_driver_init_wrap(&input_xinput, joypad_name);
|
||||
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
|
||||
*input_data = xinput;
|
||||
}
|
||||
else
|
||||
{
|
||||
void* uwp = input_driver_init_wrap(&input_uwp, joypad_name);
|
||||
*input = uwp ? (input_driver_t*)&input_uwp : NULL;
|
||||
*input_data = uwp;
|
||||
}
|
||||
#elif defined(_XBOX)
|
||||
void* xinput = input_driver_init_wrap(&input_xinput, joypad_name);
|
||||
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
|
||||
*input_data = xinput;
|
||||
#endif
|
||||
input_driver_init_windows(joypad_name, input, input_data);
|
||||
}
|
||||
|
||||
static enum gfx_ctx_api gfx_ctx_wgl_get_api(void *data) { return win32_api; }
|
||||
|
||||
@@ -6585,6 +6585,69 @@ bool input_driver_grab_mouse_for_video(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined(_XBOX) || defined(__WINRT__)
|
||||
/* Starts the input driver for a window of the Windows family, from the
|
||||
* input driver setting: raw input if that is what is configured and it
|
||||
* starts, DirectInput otherwise; on UWP plain XInput or the uwp
|
||||
* driver; on Xbox XInput.
|
||||
*
|
||||
* The video code had this four times - the Vulkan and WGL contexts,
|
||||
* the Direct3D drivers' d3d_input_driver(), GDI - each with the
|
||||
* drivers' names in it, and two of them with a wrong argument (see
|
||||
* the callers' history). It is still called from where they were, a
|
||||
* video driver's init, and so on the thread that init runs on: with
|
||||
* threaded video that is the video thread, which is where a raw input
|
||||
* window has to be made for its messages to reach it (see
|
||||
* winraw_input.c). Which thread starts the input driver is not
|
||||
* changed by having this here. */
|
||||
void input_driver_init_windows(const char *joypad_name,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
#if defined(__WINRT__)
|
||||
/* Plain xinput is supported on UWP, but it
|
||||
* supports joypad only (uwp driver was added later) */
|
||||
if (string_is_equal(config_get_ptr()->arrays.input_driver, "xinput"))
|
||||
{
|
||||
void *xinput = input_driver_init_wrap(&input_xinput, joypad_name);
|
||||
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
|
||||
*input_data = xinput;
|
||||
}
|
||||
else
|
||||
{
|
||||
void *uwp = input_driver_init_wrap(&input_uwp, joypad_name);
|
||||
*input = uwp ? (input_driver_t*)&input_uwp : NULL;
|
||||
*input_data = uwp;
|
||||
}
|
||||
#elif defined(_XBOX)
|
||||
void *xinput = input_driver_init_wrap(&input_xinput, joypad_name);
|
||||
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
|
||||
*input_data = xinput;
|
||||
#else
|
||||
*input = NULL;
|
||||
*input_data = NULL;
|
||||
#if _WIN32_WINNT >= 0x0501
|
||||
#ifdef HAVE_WINRAWINPUT
|
||||
/* winraw only available since XP */
|
||||
if (string_is_equal(config_get_ptr()->arrays.input_driver, "raw"))
|
||||
{
|
||||
*input_data = input_driver_init_wrap(&input_winraw, joypad_name);
|
||||
if (*input_data)
|
||||
{
|
||||
*input = &input_winraw;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
*input_data = input_driver_init_wrap(&input_dinput, joypad_name);
|
||||
*input = *input_data ? &input_dinput : NULL;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
bool video_driver_init_input(
|
||||
input_driver_t *tmp,
|
||||
settings_t *settings,
|
||||
|
||||
@@ -858,6 +858,11 @@ float input_driver_get_sensor(
|
||||
|
||||
uint64_t input_driver_get_capabilities(void);
|
||||
|
||||
#if defined(_WIN32) || defined(_XBOX) || defined(__WINRT__)
|
||||
void input_driver_init_windows(const char *joypad_name,
|
||||
input_driver_t **input, void **input_data);
|
||||
#endif
|
||||
|
||||
/* For the video driver: see input_driver.c. */
|
||||
uint32_t input_driver_get_flags(void);
|
||||
input_driver_t *input_driver_get_current(void);
|
||||
|
||||
Reference in new issue
Block a user