mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-26 04:36:56 +00:00
(DInput) Set a userdata struct for the window message loop properly -
get rid of input_get_data - we no longer need it
This commit is contained in:
parent
fa63ada1d3
commit
8999d6e4a6
@ -1081,12 +1081,14 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
|
||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||
taskbar_is_created = true;
|
||||
#endif
|
||||
#if !defined(_XBOX)
|
||||
{
|
||||
void* input_data = input_get_data();
|
||||
void* input_data = (void*)(LONG_PTR)GetWindowLongPtr(main_window.hwnd, GWLP_USERDATA);
|
||||
if (input_data && dinput_handle_message(input_data,
|
||||
message, wparam, lparam))
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case WM_DROPFILES:
|
||||
case WM_SYSCOMMAND:
|
||||
@ -1432,6 +1434,16 @@ bool win32_get_metrics(void *data,
|
||||
return false;
|
||||
}
|
||||
|
||||
void win32_unset_input_userdata(void)
|
||||
{
|
||||
SetWindowLongPtr(main_window.hwnd, GWLP_USERDATA, 0);
|
||||
}
|
||||
|
||||
void win32_set_input_userdata(void *data)
|
||||
{
|
||||
SetWindowLongPtr(main_window.hwnd, GWLP_USERDATA, (LONG_PTR)data);
|
||||
}
|
||||
|
||||
void win32_monitor_init(void)
|
||||
{
|
||||
win32_common_state_t
|
||||
|
@ -156,6 +156,10 @@ bool win32_load_content_from_gui(const char *szFilename);
|
||||
|
||||
void win32_setup_pixel_format(HDC hdc, bool supports_gl);
|
||||
|
||||
void win32_unset_input_userdata(void);
|
||||
|
||||
void win32_set_input_userdata(void *data);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -45,6 +45,10 @@
|
||||
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#ifndef _XBOX
|
||||
#include "../../gfx/common/win32_common.h"
|
||||
#endif
|
||||
|
||||
#include "../input_keymaps.h"
|
||||
|
||||
#include "../../configuration.h"
|
||||
@ -180,6 +184,10 @@ static void *dinput_init(const char *joypad_driver)
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_dinput);
|
||||
di->joypad = input_joypad_init_driver(joypad_driver, di);
|
||||
|
||||
#ifndef _XBOX
|
||||
win32_set_input_userdata(di);
|
||||
#endif
|
||||
|
||||
return di;
|
||||
}
|
||||
|
||||
@ -943,28 +951,33 @@ static void dinput_free(void *data)
|
||||
struct dinput_input *di = (struct dinput_input*)data;
|
||||
LPDIRECTINPUT8 hold_ctx = g_dinput_ctx;
|
||||
|
||||
if (di)
|
||||
{
|
||||
/* Prevent a joypad driver to kill our context prematurely. */
|
||||
g_dinput_ctx = NULL;
|
||||
if (di->joypad)
|
||||
di->joypad->destroy();
|
||||
g_dinput_ctx = hold_ctx;
|
||||
if (!di)
|
||||
return;
|
||||
|
||||
/* Clear any leftover pointers. */
|
||||
dinput_clear_pointers(di);
|
||||
/* Prevent a joypad driver to kill our context prematurely. */
|
||||
g_dinput_ctx = NULL;
|
||||
if (di->joypad)
|
||||
di->joypad->destroy();
|
||||
|
||||
if (di->keyboard)
|
||||
IDirectInputDevice8_Release(di->keyboard);
|
||||
#ifndef _XBOX
|
||||
win32_unset_input_userdata();
|
||||
#endif
|
||||
|
||||
if (di->mouse)
|
||||
IDirectInputDevice8_Release(di->mouse);
|
||||
g_dinput_ctx = hold_ctx;
|
||||
|
||||
if (di->joypad_driver_name)
|
||||
free(di->joypad_driver_name);
|
||||
/* Clear any leftover pointers. */
|
||||
dinput_clear_pointers(di);
|
||||
|
||||
free(di);
|
||||
}
|
||||
if (di->keyboard)
|
||||
IDirectInputDevice8_Release(di->keyboard);
|
||||
|
||||
if (di->mouse)
|
||||
IDirectInputDevice8_Release(di->mouse);
|
||||
|
||||
if (di->joypad_driver_name)
|
||||
free(di->joypad_driver_name);
|
||||
|
||||
free(di);
|
||||
|
||||
dinput_destroy_context();
|
||||
}
|
||||
|
@ -301,8 +301,6 @@ void *input_driver_get_data(void);
|
||||
|
||||
input_driver_t *input_get_ptr(void);
|
||||
|
||||
void *input_get_data(void);
|
||||
|
||||
void input_driver_set_nonblock_state(void);
|
||||
|
||||
void input_driver_unset_nonblock_state(void);
|
||||
|
@ -23688,12 +23688,6 @@ const char* config_get_input_driver_options(void)
|
||||
return char_list_new_special(STRING_LIST_INPUT_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void *input_get_data(void)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
return p_rarch->current_input_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* input_driver_set_rumble_state:
|
||||
* @port : User number.
|
||||
|
Loading…
x
Reference in New Issue
Block a user