Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions input/drivers_joypad/xinput_hybrid_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ static int16_t xinput_joypad_state_func(
static void xinput_joypad_poll(void)
{
int i;
bool has_active_ports = false;

/* Hotplugging detection: scanning one port at a time every few frames,
* to avoid polling overload and framerate drops. */
xinput_poll_counter++;
Expand Down Expand Up @@ -611,13 +613,27 @@ static void xinput_joypad_poll(void)
xinput_hotplug_index = (xinput_hotplug_index + 1) % 4;
}

for (i = 0; i < 4; ++i)
{
if (xinput_active_port[i])
has_active_ports = true;
}

for (i = 0; i < 4; ++i)
{
DWORD status;
bool success, new_connected;
xinput_joypad_state *state;
/* On UWP, controllers may become available after initialization.
* If no ports are currently active, we need to poll all ports
* to catch any late arriving controllers. */
#ifdef __WINRT__
if (!xinput_active_port[i] && has_active_ports)
continue;
#else
if (!xinput_active_port[i])
continue;
#endif

state = &g_xinput_states[i];
status = g_XInputGetStateEx(i, &state->xstate);
Expand Down
15 changes: 15 additions & 0 deletions input/drivers_joypad/xinput_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ static int16_t xinput_joypad_state_func(
static void xinput_joypad_poll(void)
{
int i;
bool has_active_ports = false;

/* Hotplugging detection: scanning one port at a time every few frames,
* to avoid polling overload and framerate drops. */
Expand Down Expand Up @@ -381,13 +382,27 @@ static void xinput_joypad_poll(void)
xinput_hotplug_index = (xinput_hotplug_index + 1) % 4;
}

for (i = 0; i < 4; ++i)
{
if (xinput_active_port[i])
has_active_ports = true;
}

for (i = 0; i < 4; ++i)
{
DWORD status;
bool success, new_connected;
xinput_joypad_state *state;
/* On UWP, controllers may become available after initialization.
* If no ports are currently active, we need to poll all ports
* to catch any late arriving controllers. */
#ifdef __WINRT__
if (!xinput_active_port[i] && has_active_ports)
continue;
#else
if (!xinput_active_port[i])
continue;
#endif

state = &g_xinput_states[i];
status = g_XInputGetStateEx(i, &state->xstate);
Expand Down
Loading