mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
Restore this
This commit is contained in:
parent
d28cadef01
commit
91ef99f9b7
@ -282,8 +282,7 @@ static bool xinput_joypad_init(void *data)
|
|||||||
#if defined(HAVE_DYNAMIC) && !defined(__WINRT__)
|
#if defined(HAVE_DYNAMIC) && !defined(__WINRT__)
|
||||||
dylib_close(g_xinput_dll);
|
dylib_close(g_xinput_dll);
|
||||||
#endif
|
#endif
|
||||||
goto error; /* DLL was loaded but did not contain
|
goto error; /* DLL was loaded but did not contain the correct function. */
|
||||||
the correct function. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Zero out the states. */
|
/* Zero out the states. */
|
||||||
@ -329,8 +328,7 @@ static bool xinput_joypad_init(void *data)
|
|||||||
for (j = 0; j < MAX_USERS; j++)
|
for (j = 0; j < MAX_USERS; j++)
|
||||||
{
|
{
|
||||||
if (xinput_joypad_name(j))
|
if (xinput_joypad_name(j))
|
||||||
RARCH_LOG("[XInput]: Attempting autoconf for \"%s\","
|
RARCH_LOG("[XInput]: Attempting autoconf for \"%s\", user #%u\n", xinput_joypad_name(j), j);
|
||||||
" user #%u\n", xinput_joypad_name(j), j);
|
|
||||||
else
|
else
|
||||||
RARCH_LOG("[XInput]: Attempting autoconf for user #%u\n", j);
|
RARCH_LOG("[XInput]: Attempting autoconf for user #%u\n", j);
|
||||||
|
|
||||||
@ -340,10 +338,8 @@ static bool xinput_joypad_init(void *data)
|
|||||||
int32_t pid = 0;
|
int32_t pid = 0;
|
||||||
#ifdef HAVE_DINPUT
|
#ifdef HAVE_DINPUT
|
||||||
int32_t dinput_index = 0;
|
int32_t dinput_index = 0;
|
||||||
bool success = dinput_joypad_get_vidpid_from_xinput_index(
|
bool success = dinput_joypad_get_vidpid_from_xinput_index((int32_t)pad_index_to_xuser_index(j), (int32_t*)&vid, (int32_t*)&pid,
|
||||||
(int32_t)pad_index_to_xuser_index(j),
|
(int32_t*)&dinput_index);
|
||||||
(int32_t*)&vid, (int32_t*)&pid,
|
|
||||||
(int32_t*)&dinput_index);
|
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
RARCH_LOG("[XInput]: Found VID/PID (%04X/%04X) from DINPUT index %d for \"%s\", user #%u\n",
|
RARCH_LOG("[XInput]: Found VID/PID (%04X/%04X) from DINPUT index %d for \"%s\", user #%u\n",
|
||||||
@ -375,13 +371,14 @@ error:
|
|||||||
|
|
||||||
static bool xinput_joypad_query_pad(unsigned pad)
|
static bool xinput_joypad_query_pad(unsigned pad)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DINPUT
|
|
||||||
int xuser = pad_index_to_xuser_index(pad);
|
int xuser = pad_index_to_xuser_index(pad);
|
||||||
if (xuser == -1)
|
if (xuser > -1)
|
||||||
return dinput_joypad.query_pad(pad);
|
return g_xinput_states[xuser].connected;
|
||||||
pad = xuser;
|
#ifdef HAVE_DINPUT
|
||||||
|
return dinput_joypad.query_pad(pad);
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
return g_xinput_states[pad].connected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xinput_joypad_destroy(void)
|
static void xinput_joypad_destroy(void)
|
||||||
@ -428,17 +425,17 @@ static bool xinput_joypad_button(unsigned port_num, uint16_t joykey)
|
|||||||
{
|
{
|
||||||
uint16_t btn_word = 0;
|
uint16_t btn_word = 0;
|
||||||
unsigned hat_dir = 0;
|
unsigned hat_dir = 0;
|
||||||
#ifdef HAVE_DINPUT
|
|
||||||
int xuser = pad_index_to_xuser_index(port_num);
|
int xuser = pad_index_to_xuser_index(port_num);
|
||||||
|
|
||||||
|
#ifdef HAVE_DINPUT
|
||||||
if (xuser == -1)
|
if (xuser == -1)
|
||||||
return dinput_joypad.button(port_num, joykey);
|
return dinput_joypad.button(port_num, joykey);
|
||||||
port_num = xuser;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!(g_xinput_states[port_num].connected))
|
if (!(g_xinput_states[xuser].connected))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
btn_word = g_xinput_states[port_num].xstate.Gamepad.wButtons;
|
btn_word = g_xinput_states[xuser].xstate.Gamepad.wButtons;
|
||||||
hat_dir = GET_HAT_DIR(joykey);
|
hat_dir = GET_HAT_DIR(joykey);
|
||||||
|
|
||||||
if (hat_dir)
|
if (hat_dir)
|
||||||
@ -466,6 +463,7 @@ static bool xinput_joypad_button(unsigned port_num, uint16_t joykey)
|
|||||||
|
|
||||||
static int16_t xinput_joypad_axis (unsigned port_num, uint32_t joyaxis)
|
static int16_t xinput_joypad_axis (unsigned port_num, uint32_t joyaxis)
|
||||||
{
|
{
|
||||||
|
int xuser;
|
||||||
int16_t val = 0;
|
int16_t val = 0;
|
||||||
int axis = -1;
|
int axis = -1;
|
||||||
bool is_neg = false;
|
bool is_neg = false;
|
||||||
@ -475,31 +473,29 @@ static int16_t xinput_joypad_axis (unsigned port_num, uint32_t joyaxis)
|
|||||||
if (joyaxis == AXIS_NONE)
|
if (joyaxis == AXIS_NONE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
xuser = pad_index_to_xuser_index(port_num);
|
||||||
|
|
||||||
#ifdef HAVE_DINPUT
|
#ifdef HAVE_DINPUT
|
||||||
{
|
if (xuser == -1)
|
||||||
int xuser = pad_index_to_xuser_index(port_num);
|
return dinput_joypad.axis(port_num, joyaxis);
|
||||||
if (xuser == -1)
|
|
||||||
return dinput_joypad.axis(port_num, joyaxis);
|
|
||||||
port_num = xuser;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!(g_xinput_states[port_num].connected))
|
if (!(g_xinput_states[xuser].connected))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* triggers (axes 4,5) cannot be negative */
|
/* triggers (axes 4,5) cannot be negative */
|
||||||
if (AXIS_NEG_GET(joyaxis) <= 3)
|
if (AXIS_NEG_GET(joyaxis) <= 3)
|
||||||
{
|
{
|
||||||
axis = AXIS_NEG_GET(joyaxis);
|
axis = AXIS_NEG_GET(joyaxis);
|
||||||
is_neg = true;
|
is_neg = true;
|
||||||
}
|
}
|
||||||
else if (AXIS_POS_GET(joyaxis) <= 5)
|
else if (AXIS_POS_GET(joyaxis) <= 5)
|
||||||
{
|
{
|
||||||
axis = AXIS_POS_GET(joyaxis);
|
axis = AXIS_POS_GET(joyaxis);
|
||||||
is_pos = true;
|
is_pos = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pad = &(g_xinput_states[port_num].xstate.Gamepad);
|
pad = &(g_xinput_states[xuser].xstate.Gamepad);
|
||||||
|
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
@ -524,13 +520,13 @@ static int16_t xinput_joypad_axis (unsigned port_num, uint32_t joyaxis)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_neg && val > 0)
|
if (is_neg && val > 0)
|
||||||
return 0;
|
val = 0;
|
||||||
else if (is_pos && val < 0)
|
else if (is_pos && val < 0)
|
||||||
return 0;
|
val = 0;
|
||||||
|
|
||||||
/* Clamp to avoid overflow error. */
|
/* Clamp to avoid overflow error. */
|
||||||
if (val == -32768)
|
if (val == -32768)
|
||||||
return -32767;
|
val = -32767;
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@ -543,18 +539,19 @@ static void xinput_joypad_poll(void)
|
|||||||
{
|
{
|
||||||
#ifdef HAVE_DINPUT
|
#ifdef HAVE_DINPUT
|
||||||
if (g_xinput_states[i].connected)
|
if (g_xinput_states[i].connected)
|
||||||
if (g_XInputGetStateEx(i,
|
{
|
||||||
|
if (g_XInputGetStateEx && g_XInputGetStateEx(i,
|
||||||
&(g_xinput_states[i].xstate))
|
&(g_xinput_states[i].xstate))
|
||||||
== ERROR_DEVICE_NOT_CONNECTED)
|
== ERROR_DEVICE_NOT_CONNECTED)
|
||||||
g_xinput_states[i].connected = false;
|
g_xinput_states[i].connected = false;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Normally, dinput handles device insertion/removal for us, but
|
/* Normally, dinput handles device insertion/removal for us, but
|
||||||
* since dinput is not available on UWP we have to do it ourselves */
|
* since dinput is not available on UWP we have to do it ourselves */
|
||||||
/* Also note that on UWP, the controllers are not available on startup
|
/* Also note that on UWP, the controllers are not available on startup
|
||||||
* and are instead 'plugged in' a moment later because Microsoft reasons */
|
* and are instead 'plugged in' a moment later because Microsoft reasons */
|
||||||
/* TODO: This may be bad for performance? */
|
/* TODO: This may be bad for performance? */
|
||||||
bool new_connected = g_XInputGetStateEx(i,
|
bool new_connected = g_XInputGetStateEx && g_XInputGetStateEx(i, &(g_xinput_states[i].xstate)) != ERROR_DEVICE_NOT_CONNECTED;
|
||||||
&(g_xinput_states[i].xstate)) != ERROR_DEVICE_NOT_CONNECTED;
|
|
||||||
if (new_connected != g_xinput_states[i].connected)
|
if (new_connected != g_xinput_states[i].connected)
|
||||||
{
|
{
|
||||||
if (new_connected)
|
if (new_connected)
|
||||||
@ -580,16 +577,16 @@ static void xinput_joypad_poll(void)
|
|||||||
static bool xinput_joypad_rumble(unsigned pad,
|
static bool xinput_joypad_rumble(unsigned pad,
|
||||||
enum retro_rumble_effect effect, uint16_t strength)
|
enum retro_rumble_effect effect, uint16_t strength)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DINPUT
|
|
||||||
int xuser = pad_index_to_xuser_index(pad);
|
int xuser = pad_index_to_xuser_index(pad);
|
||||||
|
|
||||||
if (xuser == -1)
|
if (xuser == -1)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_DINPUT
|
||||||
if (dinput_joypad.set_rumble)
|
if (dinput_joypad.set_rumble)
|
||||||
return dinput_joypad.set_rumble(pad, effect, strength);
|
return dinput_joypad.set_rumble(pad, effect, strength);
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Consider the low frequency (left) motor the "strong" one. */
|
/* Consider the low frequency (left) motor the "strong" one. */
|
||||||
if (effect == RETRO_RUMBLE_STRONG)
|
if (effect == RETRO_RUMBLE_STRONG)
|
||||||
@ -597,6 +594,9 @@ static bool xinput_joypad_rumble(unsigned pad,
|
|||||||
else if (effect == RETRO_RUMBLE_WEAK)
|
else if (effect == RETRO_RUMBLE_WEAK)
|
||||||
g_xinput_rumble_states[xuser].wRightMotorSpeed = strength;
|
g_xinput_rumble_states[xuser].wRightMotorSpeed = strength;
|
||||||
|
|
||||||
|
if (!g_XInputSetState)
|
||||||
|
return false;
|
||||||
|
|
||||||
return (g_XInputSetState(xuser, &g_xinput_rumble_states[xuser])
|
return (g_XInputSetState(xuser, &g_xinput_rumble_states[xuser])
|
||||||
== 0);
|
== 0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user