When a controller is plugged in and focus is NULL then set focus to the first button

This commit is contained in:
Devlrxxh 2026-03-06 18:55:03 +01:00
parent 17eb80c685
commit fef25bed9c
2 changed files with 34 additions and 0 deletions

View file

@ -239,6 +239,7 @@ UIController::UIController()
m_mouseDraggingSliderId = -1; m_mouseDraggingSliderId = -1;
m_lastHoverMouseX = -1; m_lastHoverMouseX = -1;
m_lastHoverMouseY = -1; m_lastHoverMouseY = -1;
m_wasControllerConnected = false;
m_accumulatedTicks = 0; m_accumulatedTicks = 0;
m_lastUiSfx = 0; m_lastUiSfx = 0;
@ -784,6 +785,38 @@ void UIController::tickInput()
#endif #endif
{ {
#ifdef _WINDOWS64 #ifdef _WINDOWS64
// When a controller is plugged in and focus is NULL then set focus to the first button
{
bool controllerConnected = Win64_IsControllerConnected();
if (controllerConnected && !m_wasControllerConnected)
{
UIScene* pFocusScene = NULL;
for (int grp = 0; grp < eUIGroup_COUNT && !pFocusScene; ++grp)
{
pFocusScene = m_groups[grp]->GetTopScene(eUILayer_Debug);
if (!pFocusScene) pFocusScene = m_groups[grp]->GetTopScene(eUILayer_Tooltips);
if (!pFocusScene) pFocusScene = m_groups[grp]->GetTopScene(eUILayer_Error);
if (!pFocusScene) pFocusScene = m_groups[grp]->GetTopScene(eUILayer_Alert);
if (!pFocusScene) pFocusScene = m_groups[grp]->GetTopScene(eUILayer_Popup);
if (!pFocusScene) pFocusScene = m_groups[grp]->GetTopScene(eUILayer_Fullscreen);
if (!pFocusScene) pFocusScene = m_groups[grp]->GetTopScene(eUILayer_Scene);
}
if (pFocusScene && pFocusScene->getMovie())
{
Iggy* focusMovie = pFocusScene->getMovie();
IggyFocusHandle currentFocus = IGGY_FOCUS_NULL;
IggyFocusableObject focusables[64];
S32 numFocusables = 0;
IggyPlayerGetFocusableObjects(focusMovie, &currentFocus, focusables, 64, &numFocusables);
if (currentFocus == IGGY_FOCUS_NULL && numFocusables > 0)
{
IggyPlayerSetFocusRS(focusMovie, focusables[0].object, 0);
}
}
}
m_wasControllerConnected = controllerConnected;
}
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive()) if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
{ {
UIScene* pScene = NULL; UIScene* pScene = NULL;

View file

@ -166,6 +166,7 @@ private:
int m_mouseDraggingSliderId; int m_mouseDraggingSliderId;
int m_lastHoverMouseX; int m_lastHoverMouseX;
int m_lastHoverMouseY; int m_lastHoverMouseY;
bool m_wasControllerConnected;
//bool m_bSysUIShowing; //bool m_bSysUIShowing;
bool m_bSystemUIShowing; bool m_bSystemUIShowing;
C4JThread *m_reloadSkinThread; C4JThread *m_reloadSkinThread;