mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
Fallback if mouse or keyboard interface is not working.
Problems with tablets on Windows.
This commit is contained in:
parent
c4978651fa
commit
af7fb86427
@ -102,7 +102,10 @@ static bool dinput_init_context(void)
|
||||
static void *dinput_init(void)
|
||||
{
|
||||
if (!dinput_init_context())
|
||||
{
|
||||
RARCH_ERR("Failed to start DirectInput driver.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct dinput_input *di = (struct dinput_input*)calloc(1, sizeof(*di));
|
||||
if (!di)
|
||||
@ -112,47 +115,47 @@ static void *dinput_init(void)
|
||||
if (FAILED(IDirectInput8_CreateDevice(g_ctx, GUID_SysKeyboard, &di->keyboard, NULL)))
|
||||
{
|
||||
RARCH_ERR("Failed to create keyboard device.\n");
|
||||
goto error;
|
||||
di->keyboard = NULL;
|
||||
}
|
||||
|
||||
if (FAILED(IDirectInput8_CreateDevice(g_ctx, GUID_SysMouse, &di->mouse, NULL)))
|
||||
{
|
||||
RARCH_ERR("Failed to create mouse device.\n");
|
||||
goto error;
|
||||
di->mouse = NULL;
|
||||
}
|
||||
#else
|
||||
if (FAILED(IDirectInput8_CreateDevice(g_ctx, &GUID_SysKeyboard, &di->keyboard, NULL)))
|
||||
{
|
||||
RARCH_ERR("Failed to create keyboard device.\n");
|
||||
goto error;
|
||||
di->keyboard = NULL;
|
||||
}
|
||||
if (FAILED(IDirectInput8_CreateDevice(g_ctx, &GUID_SysMouse, &di->mouse, NULL)))
|
||||
{
|
||||
RARCH_ERR("Failed to create mouse device.\n");
|
||||
goto error;
|
||||
di->mouse = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (di->keyboard)
|
||||
{
|
||||
IDirectInputDevice8_SetDataFormat(di->keyboard, &c_dfDIKeyboard);
|
||||
IDirectInputDevice8_SetCooperativeLevel(di->keyboard,
|
||||
(HWND)driver.video_window, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
|
||||
IDirectInputDevice8_Acquire(di->keyboard);
|
||||
}
|
||||
|
||||
if (di->mouse)
|
||||
{
|
||||
IDirectInputDevice8_SetDataFormat(di->mouse, &c_dfDIMouse2);
|
||||
IDirectInputDevice8_SetCooperativeLevel(di->mouse, (HWND)driver.video_window,
|
||||
DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
|
||||
IDirectInputDevice8_Acquire(di->mouse);
|
||||
}
|
||||
|
||||
input_init_keyboard_lut(rarch_key_map_dinput);
|
||||
di->joypad = input_joypad_init_driver(g_settings.input.joypad_driver);
|
||||
|
||||
return di;
|
||||
|
||||
error:
|
||||
RARCH_ERR("Failed to start DirectInput driver.\n");
|
||||
dinput_destroy_context();
|
||||
free(di);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void dinput_poll(void *data)
|
||||
@ -160,15 +163,21 @@ static void dinput_poll(void *data)
|
||||
struct dinput_input *di = (struct dinput_input*)data;
|
||||
|
||||
memset(di->state, 0, sizeof(di->state));
|
||||
if (di->keyboard)
|
||||
{
|
||||
if (FAILED(IDirectInputDevice8_GetDeviceState(di->keyboard, sizeof(di->state), di->state)))
|
||||
{
|
||||
IDirectInputDevice8_Acquire(di->keyboard);
|
||||
if (FAILED(IDirectInputDevice8_GetDeviceState(di->keyboard, sizeof(di->state), di->state)))
|
||||
memset(di->state, 0, sizeof(di->state));
|
||||
}
|
||||
}
|
||||
|
||||
if (di->mouse)
|
||||
{
|
||||
DIMOUSESTATE2 mouse_state;
|
||||
memset(&mouse_state, 0, sizeof(mouse_state));
|
||||
|
||||
if (FAILED(IDirectInputDevice8_GetDeviceState(di->mouse, sizeof(mouse_state), &mouse_state)))
|
||||
{
|
||||
IDirectInputDevice8_Acquire(di->mouse);
|
||||
@ -188,6 +197,7 @@ static void dinput_poll(void *data)
|
||||
ScreenToClient((HWND)driver.video_window, &point);
|
||||
di->mouse_x = point.x;
|
||||
di->mouse_y = point.y;
|
||||
}
|
||||
|
||||
input_joypad_poll(di->joypad);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user