Make the 'raw' versions the generic function for the message loop

callback - this way it's reused for SDL2 input driver too
This commit is contained in:
twinaphex 2020-08-28 02:55:39 +02:00
parent 15cb55e0bb
commit 4d1cfa9c41
10 changed files with 21 additions and 57 deletions

View File

@ -923,9 +923,7 @@ static LRESULT CALLBACK wnd_proc_common(
return 0;
}
/* XP and higher */
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
static LRESULT CALLBACK wnd_proc_common_raw_internal(HWND hwnd,
static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd,
UINT message, WPARAM wparam, LPARAM lparam)
{
LRESULT ret;
@ -1014,7 +1012,6 @@ static LRESULT CALLBACK wnd_proc_common_raw_internal(HWND hwnd,
return DefWindowProc(hwnd, message, wparam, lparam);
}
#endif
#ifdef HAVE_DINPUT
static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
@ -1116,8 +1113,7 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
#if defined(HAVE_D3D) || defined (HAVE_D3D10) || defined (HAVE_D3D11) || defined (HAVE_D3D12)
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
LRESULT CALLBACK wnd_proc_d3d_raw(HWND hwnd, UINT message,
LRESULT CALLBACK wnd_proc_d3d_common(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam)
{
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
@ -1131,9 +1127,8 @@ LRESULT CALLBACK wnd_proc_d3d_raw(HWND hwnd, UINT message,
return 0;
}
return wnd_proc_common_raw_internal(hwnd, message, wparam, lparam);
return wnd_proc_common_internal(hwnd, message, wparam, lparam);
}
#endif
#ifdef HAVE_DINPUT
LRESULT CALLBACK wnd_proc_d3d_dinput(HWND hwnd, UINT message,
@ -1176,8 +1171,7 @@ LRESULT CALLBACK wnd_proc_wgl_dinput(HWND hwnd, UINT message,
}
#endif
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
LRESULT CALLBACK wnd_proc_wgl_raw(HWND hwnd, UINT message,
LRESULT CALLBACK wnd_proc_wgl_common(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam)
{
LRESULT ret;
@ -1191,10 +1185,9 @@ LRESULT CALLBACK wnd_proc_wgl_raw(HWND hwnd, UINT message,
return 0;
}
return wnd_proc_common_raw_internal(hwnd, message, wparam, lparam);
return wnd_proc_common_internal(hwnd, message, wparam, lparam);
}
#endif
#endif
#ifdef HAVE_VULKAN
#ifdef HAVE_DINPUT
@ -1215,8 +1208,7 @@ LRESULT CALLBACK wnd_proc_vk_dinput(HWND hwnd, UINT message,
}
#endif
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
LRESULT CALLBACK wnd_proc_vk_raw(HWND hwnd, UINT message,
LRESULT CALLBACK wnd_proc_vk_common(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam)
{
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
@ -1229,10 +1221,9 @@ LRESULT CALLBACK wnd_proc_vk_raw(HWND hwnd, UINT message,
return 0;
}
return wnd_proc_common_raw_internal(hwnd, message, wparam, lparam);
return wnd_proc_common_internal(hwnd, message, wparam, lparam);
}
#endif
#endif
#ifdef HAVE_GDI
#ifdef HAVE_DINPUT
@ -1285,8 +1276,7 @@ LRESULT CALLBACK wnd_proc_gdi_dinput(HWND hwnd, UINT message,
}
#endif
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
LRESULT CALLBACK wnd_proc_gdi_raw(HWND hwnd, UINT message,
LRESULT CALLBACK wnd_proc_gdi_common(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam)
{
LRESULT ret;
@ -1331,10 +1321,9 @@ LRESULT CALLBACK wnd_proc_gdi_raw(HWND hwnd, UINT message,
#endif
}
return wnd_proc_common_raw_internal(hwnd, message, wparam, lparam);
return wnd_proc_common_internal(hwnd, message, wparam, lparam);
}
#endif
#endif
bool win32_window_create(void *data, unsigned style,
RECT *mon_rect, unsigned width,

View File

@ -125,27 +125,27 @@ float win32_get_refresh_rate(void *data);
#if defined(HAVE_D3D8) || defined(HAVE_D3D9) || defined (HAVE_D3D10) || defined (HAVE_D3D11) || defined (HAVE_D3D12)
LRESULT CALLBACK wnd_proc_d3d_dinput(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
LRESULT CALLBACK wnd_proc_d3d_raw(HWND hwnd, UINT message,
LRESULT CALLBACK wnd_proc_d3d_common(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
#endif
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
LRESULT CALLBACK wnd_proc_wgl_dinput(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
LRESULT CALLBACK wnd_proc_wgl_raw(HWND hwnd, UINT message,
LRESULT CALLBACK wnd_proc_wgl_common(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
#endif
#if defined(HAVE_VULKAN)
LRESULT CALLBACK wnd_proc_vk_dinput(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
LRESULT CALLBACK wnd_proc_vk_raw(HWND hwnd, UINT message,
LRESULT CALLBACK wnd_proc_vk_common(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
#endif
LRESULT CALLBACK wnd_proc_gdi_dinput(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
LRESULT CALLBACK wnd_proc_gdi_raw(HWND hwnd, UINT message,
LRESULT CALLBACK wnd_proc_gdi_common(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
#ifdef _XBOX

View File

@ -621,14 +621,11 @@ static void *d3d10_gfx_init(const video_info_t* video,
#endif
#ifdef HAVE_MONITOR
win32_monitor_init();
wndclass.lpfnWndProc = wnd_proc_d3d_common;
#ifdef HAVE_DINPUT
if (string_is_equal(settings->arrays.input_driver, "dinput"))
wndclass.lpfnWndProc = wnd_proc_d3d_dinput;
#endif
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
if (string_is_equal(settings->arrays.input_driver, "raw"))
wndclass.lpfnWndProc = wnd_proc_d3d_raw;
#endif
#ifdef HAVE_WINDOW
win32_window_init(&wndclass, true, NULL);
#endif

View File

@ -656,14 +656,11 @@ static void *d3d11_gfx_init(const video_info_t* video,
#endif
#ifdef HAVE_MONITOR
win32_monitor_init();
wndclass.lpfnWndProc = wnd_proc_d3d_common;
#ifdef HAVE_DINPUT
if (string_is_equal(settings->arrays.input_driver, "dinput"))
wndclass.lpfnWndProc = wnd_proc_d3d_dinput;
#endif
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
if (string_is_equal(settings->arrays.input_driver, "raw"))
wndclass.lpfnWndProc = wnd_proc_d3d_raw;
#endif
#ifdef HAVE_WINDOW
win32_window_init(&wndclass, true, NULL);
#endif

View File

@ -913,14 +913,11 @@ static void *d3d12_gfx_init(const video_info_t* video,
#endif
#ifdef HAVE_MONITOR
win32_monitor_init();
wndclass.lpfnWndProc = wnd_proc_d3d_common;
#ifdef HAVE_DINPUT
if (string_is_equal(settings->arrays.input_driver, "dinput"))
wndclass.lpfnWndProc = wnd_proc_d3d_dinput;
#endif
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
if (string_is_equal(settings->arrays.input_driver, "raw"))
wndclass.lpfnWndProc = wnd_proc_d3d_raw;
#endif
#ifdef HAVE_WINDOW
win32_window_init(&wndclass, true, NULL);
#endif

View File

@ -1148,13 +1148,10 @@ static bool d3d8_init_internal(d3d8_video_t *d3d,
#ifdef HAVE_WINDOW
memset(&d3d->windowClass, 0, sizeof(d3d->windowClass));
d3d->windowClass.lpfnWndProc = wnd_proc_d3d_common;
#ifdef HAVE_DINPUT
if (string_is_equal(settings->arrays.input_driver, "dinput"))
d3d->windowClass.lpfnWndProc = wnd_proc_d3d_dinput;
#endif
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
if (string_is_equal(settings->arrays.input_driver, "raw"))
d3d->windowClass.lpfnWndProc = wnd_proc_d3d_raw;
#endif
win32_window_init(&d3d->windowClass, true, NULL);
#endif

View File

@ -1158,13 +1158,10 @@ static bool d3d9_init_internal(d3d9_video_t *d3d,
#ifdef HAVE_WINDOW
memset(&d3d->windowClass, 0, sizeof(d3d->windowClass));
d3d->windowClass.lpfnWndProc = wnd_proc_d3d_common;
#ifdef HAVE_DINPUT
if (string_is_equal(settings->arrays.input_driver, "dinput"))
d3d->windowClass.lpfnWndProc = wnd_proc_d3d_dinput;
#endif
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
if (string_is_equal(settings->arrays.input_driver, "raw"))
d3d->windowClass.lpfnWndProc = wnd_proc_d3d_raw;
#endif
win32_window_init(&d3d->windowClass, true, NULL);
#endif

View File

@ -91,15 +91,11 @@ static bool gfx_ctx_gdi_init(void)
win32_window_reset();
win32_monitor_init();
wndclass.lpfnWndProc = wnd_proc_gdi_common;
#ifdef HAVE_DINPUT
if (string_is_equal(settings->arrays.input_driver, "dinput"))
wndclass.lpfnWndProc = wnd_proc_gdi_dinput;
#endif
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
if (string_is_equal(settings->arrays.input_driver, "raw"))
wndclass.lpfnWndProc = wnd_proc_gdi_raw;
#endif
if (!win32_window_init(&wndclass, true, NULL))
return false;
return true;

View File

@ -218,13 +218,10 @@ static void *gfx_ctx_w_vk_init(void *video_driver)
{
settings_t *settings = config_get_ptr();
wndclass.lpfnWndProc = wnd_proc_vk_common;
#ifdef HAVE_DINPUT
if (string_is_equal(settings->arrays.input_driver, "dinput"))
wndclass.lpfnWndProc = wnd_proc_vk_dinput;
#endif
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
if (string_is_equal(settings->arrays.input_driver, "raw"))
wndclass.lpfnWndProc = wnd_proc_vk_raw;
#endif
}
if (!win32_window_init(&wndclass, true, NULL))

View File

@ -633,13 +633,10 @@ static void *gfx_ctx_wgl_init(void *video_driver)
{
settings_t *settings = config_get_ptr();
wndclass.lpfnWndProc = wnd_proc_wgl_common;
#ifdef HAVE_DINPUT
if (string_is_equal(settings->arrays.input_driver, "dinput"))
wndclass.lpfnWndProc = wnd_proc_wgl_dinput;
#endif
#if _WIN32_WINNT >= 0x0501 && defined(HAVE_WINRAWINPUT)
if (string_is_equal(settings->arrays.input_driver, "raw"))
wndclass.lpfnWndProc = wnd_proc_wgl_raw;
#endif
}