From f30619d597a58fbfbffc367c13770df19f34da0d Mon Sep 17 00:00:00 2001 From: NOTPIES Date: Tue, 3 Mar 2026 20:04:29 -0300 Subject: [PATCH] add choicetask input support for kbm --- .../Common/Tutorial/ChoiceTask.cpp | 31 +++++++++++++++++-- .../Common/Tutorial/ControllerTask.cpp | 12 +++++++ Minecraft.Client/Common/Tutorial/InfoTask.cpp | 20 +++++++++++- Minecraft.Client/KeyboardMouseInput.h | 2 ++ Minecraft.Client/Minecraft.cpp | 2 +- 5 files changed, 63 insertions(+), 4 deletions(-) diff --git a/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp b/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp index c03166b..e4747bd 100644 --- a/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp +++ b/Minecraft.Client/Common/Tutorial/ChoiceTask.cpp @@ -8,6 +8,20 @@ #include "ChoiceTask.h" #include "..\..\..\Minecraft.World\Material.h" +#ifdef _WINDOWS64 +#include "..\..\KeyboardMouseInput.h" + +static int ActionToVK(int action) +{ + switch (action) + { + case ACTION_MENU_A: return KeyboardMouseInput::KEY_CONFIRM; + case ACTION_MENU_B: return KeyboardMouseInput::KEY_CANCEL; + default: return 0; + } +} +#endif + ChoiceTask::ChoiceTask(Tutorial *tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/, int iConfirmMapping /*= 0*/, int iCancelMapping /*= 0*/, eTutorial_CompletionAction cancelAction /*= e_Tutorial_Completion_None*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) @@ -51,11 +65,24 @@ bool ChoiceTask::isCompleted() // If the player is under water then allow all keypresses so they can jump out if( pMinecraft->localplayers[tutorial->getPad()]->isUnderLiquid(Material::water) ) return false; - if(!m_bConfirmMappingComplete && InputManager.GetValue(pMinecraft->player->GetXboxPad(), m_iConfirmMapping) > 0 ) + int xboxPad = pMinecraft->player->GetXboxPad(); +#ifdef _WINDOWS64 + if(!m_bConfirmMappingComplete && + (InputManager.GetValue(xboxPad, m_iConfirmMapping) > 0 + || g_KBMInput.IsKeyDown(ActionToVK(m_iConfirmMapping)))) +#else + if(!m_bConfirmMappingComplete && InputManager.GetValue(xboxPad, m_iConfirmMapping) > 0 ) +#endif { m_bConfirmMappingComplete = true; } - if(!m_bCancelMappingComplete && InputManager.GetValue(pMinecraft->player->GetXboxPad(), m_iCancelMapping) > 0 ) +#ifdef _WINDOWS64 + if(!m_bCancelMappingComplete && + (InputManager.GetValue(xboxPad, m_iCancelMapping) > 0 + || g_KBMInput.IsKeyDown(ActionToVK(m_iCancelMapping)))) +#else + if(!m_bCancelMappingComplete && InputManager.GetValue(xboxPad, m_iCancelMapping) > 0 ) +#endif { m_bCancelMappingComplete = true; } diff --git a/Minecraft.Client/Common/Tutorial/ControllerTask.cpp b/Minecraft.Client/Common/Tutorial/ControllerTask.cpp index c5fe071..d518736 100644 --- a/Minecraft.Client/Common/Tutorial/ControllerTask.cpp +++ b/Minecraft.Client/Common/Tutorial/ControllerTask.cpp @@ -7,6 +7,10 @@ #include "TutorialConstraints.h" #include "ControllerTask.h" +#ifdef _WINDOWS64 +#include "..\..\KeyboardMouseInput.h" +#endif + ControllerTask::ControllerTask(Tutorial *tutorial, int descriptionId, bool enablePreCompletion, bool showMinimumTime, int mappings[], unsigned int mappingsLength, int iCompletionMaskA[], int iCompletionMaskACount, int iSouthpawMappings[], unsigned int uiSouthpawMappingsCount) : TutorialTask( tutorial, descriptionId, enablePreCompletion, NULL, showMinimumTime ) @@ -66,7 +70,11 @@ bool ControllerTask::isCompleted() } else { +#ifdef _WINDOWS64 + bAllComplete = true; +#else bAllComplete = false; +#endif } } iCurrent++; @@ -87,7 +95,11 @@ bool ControllerTask::isCompleted() } else { +#ifdef _WINDOWS64 + bAllComplete = true; +#else bAllComplete = false; +#endif } } iCurrent++; diff --git a/Minecraft.Client/Common/Tutorial/InfoTask.cpp b/Minecraft.Client/Common/Tutorial/InfoTask.cpp index 5330841..874a9b0 100644 --- a/Minecraft.Client/Common/Tutorial/InfoTask.cpp +++ b/Minecraft.Client/Common/Tutorial/InfoTask.cpp @@ -8,6 +8,20 @@ #include "InfoTask.h" #include "..\..\..\Minecraft.World\Material.h" +#ifdef _WINDOWS64 +#include "..\..\KeyboardMouseInput.h" + +static int ActionToVK(int action) +{ + switch (action) + { + case ACTION_MENU_A: return KeyboardMouseInput::KEY_CONFIRM; + case ACTION_MENU_B: return KeyboardMouseInput::KEY_CANCEL; + default: return 0; + } +} +#endif + InfoTask::InfoTask(Tutorial *tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/, int iMapping /*= 0*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) : TutorialTask( tutorial, descriptionId, false, NULL, true, false, false ) @@ -65,12 +79,16 @@ bool InfoTask::isCompleted() bool current = (*it).second; if(!current) { +#ifdef _WINDOWS64 + if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0 || g_KBMInput.IsKeyDown(ActionToVK((*it).first)) ) +#else if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0 ) +#endif { (*it).second = true; bAllComplete=true; } - else + if (!(*it).second) { bAllComplete = false; } diff --git a/Minecraft.Client/KeyboardMouseInput.h b/Minecraft.Client/KeyboardMouseInput.h index 10aa709..d1e1613 100644 --- a/Minecraft.Client/KeyboardMouseInput.h +++ b/Minecraft.Client/KeyboardMouseInput.h @@ -23,6 +23,8 @@ public: static const int KEY_DROP = 'Q'; static const int KEY_CRAFTING = VK_TAB; static const int KEY_CRAFTING_ALT = 'R'; + static const int KEY_CONFIRM = VK_RETURN; + static const int KEY_CANCEL = VK_ESCAPE; static const int KEY_PAUSE = VK_ESCAPE; static const int KEY_THIRD_PERSON = VK_F5; static const int KEY_DEBUG_INFO = VK_F3; diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index fe3b1b2..fce577f 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -1504,7 +1504,7 @@ void Minecraft::run_middle() } // Utility keys always work regardless of KBM active state - if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_PAUSE)) + if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_PAUSE) && !ui.IsTutorialVisible(i)) { localplayers[i]->ullButtonsPressed|=1LL<