diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index a21d965f02..17ffce2e28 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -76,7 +76,6 @@ struct dinput_input LPDIRECTINPUTDEVICE8 keyboard; LPDIRECTINPUTDEVICE8 mouse; const input_device_driver_t *joypad; - uintptr_t window_ptr; uint8_t state[256]; int window_pos_x; @@ -170,27 +169,24 @@ static void *dinput_init(const char *joypad_driver) di->mouse = NULL; } - di->window_ptr = video_driver_window_get(); - if (di->keyboard) { IDirectInputDevice8_SetDataFormat(di->keyboard, &c_dfDIKeyboard); IDirectInputDevice8_SetCooperativeLevel(di->keyboard, - (HWND)di->window_ptr, - DISCL_NONEXCLUSIVE | DISCL_FOREGROUND); + (HWND)video_driver_window_get(), DISCL_NONEXCLUSIVE | DISCL_FOREGROUND); IDirectInputDevice8_Acquire(di->keyboard); } if (di->mouse) { IDirectInputDevice8_SetDataFormat(di->mouse, &c_dfDIMouse2); - IDirectInputDevice8_SetCooperativeLevel(di->mouse, (HWND)di->window_ptr, + IDirectInputDevice8_SetCooperativeLevel(di->mouse, (HWND)video_driver_window_get(), DISCL_NONEXCLUSIVE | DISCL_FOREGROUND); IDirectInputDevice8_Acquire(di->mouse); } input_keymaps_init_keyboard_lut(rarch_key_map_dinput); - di->joypad = input_joypad_init_driver(joypad_driver, di); + di->joypad = input_joypad_init_driver(joypad_driver, di); return di; } @@ -251,7 +247,7 @@ static void dinput_poll(void *data) /* No simple way to get absolute coordinates * for RETRO_DEVICE_POINTER. Just use Win32 APIs. */ GetCursorPos(&point); - ScreenToClient((HWND)di->window_ptr, &point); + ScreenToClient((HWND)video_driver_window_get(), &point); di->mouse_x = point.x; di->mouse_y = point.y; } @@ -779,14 +775,13 @@ static int16_t dinput_input_state(void *data, /* Stores x/y in client coordinates. */ static void dinput_pointer_store_pos( - struct dinput_input *di, struct pointer_status *pointer, WPARAM lParam) { POINT point; point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); - ScreenToClient((HWND)di->window_ptr, &point); + ScreenToClient((HWND)video_driver_window_get(), &point); pointer->pointer_x = point.x; pointer->pointer_y = point.y; } @@ -882,7 +877,7 @@ bool dinput_handle_message(void *data, } new_pointer->pointer_id = GET_POINTERID_WPARAM(wParam); - dinput_pointer_store_pos(di, new_pointer, lParam); + dinput_pointer_store_pos(new_pointer, lParam); dinput_add_pointer(di, new_pointer); return true; } @@ -897,7 +892,7 @@ bool dinput_handle_message(void *data, int pointer_id = GET_POINTERID_WPARAM(wParam); struct pointer_status *pointer = dinput_find_pointer(di, pointer_id); if (pointer) - dinput_pointer_store_pos(di, pointer, lParam); + dinput_pointer_store_pos(pointer, lParam); return true; } case WM_DEVICECHANGE: @@ -975,7 +970,7 @@ static void dinput_grab_mouse(void *data, bool state) IDirectInputDevice8_Unacquire(di->mouse); IDirectInputDevice8_SetCooperativeLevel(di->mouse, - (HWND)di->window_ptr, + (HWND)video_driver_window_get(), state ? (DISCL_EXCLUSIVE | DISCL_FOREGROUND) : (DISCL_NONEXCLUSIVE | DISCL_FOREGROUND));