File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -582,6 +582,8 @@ static int16_t xinput_joypad_state_func(
582582static void xinput_joypad_poll (void )
583583{
584584 int i ;
585+ bool has_active_ports = false;
586+
585587 /* Hotplugging detection: scanning one port at a time every few frames,
586588 * to avoid polling overload and framerate drops. */
587589 xinput_poll_counter ++ ;
@@ -611,13 +613,27 @@ static void xinput_joypad_poll(void)
611613 xinput_hotplug_index = (xinput_hotplug_index + 1 ) % 4 ;
612614 }
613615
616+ for (i = 0 ; i < 4 ; ++ i )
617+ {
618+ if (xinput_active_port [i ])
619+ has_active_ports = true;
620+ }
621+
614622 for (i = 0 ; i < 4 ; ++ i )
615623 {
616624 DWORD status ;
617625 bool success , new_connected ;
618626 xinput_joypad_state * state ;
627+ /* On UWP, controllers may become available after initialization.
628+ * If no ports are currently active, we need to poll all ports
629+ * to catch any late arriving controllers. */
630+ #ifdef __WINRT__
631+ if (!xinput_active_port [i ] && has_active_ports )
632+ continue ;
633+ #else
619634 if (!xinput_active_port [i ])
620635 continue ;
636+ #endif
621637
622638 state = & g_xinput_states [i ];
623639 status = g_XInputGetStateEx (i , & state -> xstate );
Original file line number Diff line number Diff line change @@ -351,6 +351,7 @@ static int16_t xinput_joypad_state_func(
351351static void xinput_joypad_poll (void )
352352{
353353 int i ;
354+ bool has_active_ports = false;
354355
355356 /* Hotplugging detection: scanning one port at a time every few frames,
356357 * to avoid polling overload and framerate drops. */
@@ -381,13 +382,27 @@ static void xinput_joypad_poll(void)
381382 xinput_hotplug_index = (xinput_hotplug_index + 1 ) % 4 ;
382383 }
383384
385+ for (i = 0 ; i < 4 ; ++ i )
386+ {
387+ if (xinput_active_port [i ])
388+ has_active_ports = true;
389+ }
390+
384391 for (i = 0 ; i < 4 ; ++ i )
385392 {
386393 DWORD status ;
387394 bool success , new_connected ;
388395 xinput_joypad_state * state ;
396+ /* On UWP, controllers may become available after initialization.
397+ * If no ports are currently active, we need to poll all ports
398+ * to catch any late arriving controllers. */
399+ #ifdef __WINRT__
400+ if (!xinput_active_port [i ] && has_active_ports )
401+ continue ;
402+ #else
389403 if (!xinput_active_port [i ])
390404 continue ;
405+ #endif
391406
392407 state = & g_xinput_states [i ];
393408 status = g_XInputGetStateEx (i , & state -> xstate );
You can’t perform that action at this time.
0 commit comments