Use last active input device to decide keyboard mode instead of connection state

The keyboard UI mode (on-screen virtual keyboard vs direct text input)
was determined by Win64_IsControllerConnected(), which checks if any
XInput controller is physically plugged in. This meant that even if
the player was actively using mouse and keyboard, the virtual keyboard
would still appear as long as a controller was connected.

Replace the connection check with g_KBMInput.IsKBMActive(), which
tracks the actual last-used input device based on per-frame input
detection. Now the keyboard mode is determined by what the player is
currently using, not what hardware happens to be plugged in.

Affected scenes: CreateWorldMenu (world naming) and LoadOrJoinMenu
(world renaming).
This commit is contained in:
MrTheShy 2026-03-05 21:17:53 +01:00
parent 9ec08e0af8
commit 7ff958e124
2 changed files with 3 additions and 3 deletions

View file

@ -476,7 +476,7 @@ void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId)
{
m_bIgnoreInput=true;
#ifdef _WINDOWS64
if (Win64_IsControllerConnected())
if (!g_KBMInput.IsKBMActive())
{
UIKeyboardInitData kbData;
kbData.title = app.GetString(IDS_CREATE_NEW_WORLD);
@ -488,7 +488,7 @@ void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId)
}
else
{
// PC without controller: edit the name field directly in-place.
// PC with KBM active: edit the name field directly in-place.
m_bIgnoreInput = false; // Don't block input - m_bDirectEditing is the guard
m_worldNameBeforeEdit = m_worldName;
m_bDirectEditing = true;

View file

@ -2394,7 +2394,7 @@ int UIScene_LoadOrJoinMenu::SaveOptionsDialogReturned(void *pParam,int iPad,C4JS
kbData.maxChars = 25;
kbData.callback = &UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback;
kbData.lpParam = pClass;
kbData.pcMode = !Win64_IsControllerConnected();
kbData.pcMode = g_KBMInput.IsKBMActive();
ui.NavigateToScene(pClass->m_iPad, eUIScene_Keyboard, &kbData);
}
#elif defined _DURANGO