diff --git a/SourceX/controls/game_controls.cpp b/SourceX/controls/game_controls.cpp index 3b0bab320..5aab92c2a 100644 --- a/SourceX/controls/game_controls.cpp +++ b/SourceX/controls/game_controls.cpp @@ -20,8 +20,6 @@ DWORD translate_controller_button_to_key(ControllerButton controller_button) return questlog ? DVL_VK_SPACE : DVL_VK_ESCAPE; case ControllerButton::BUTTON_B: // Right button return sgpCurrentMenu || stextflag || questlog ? DVL_VK_RETURN : DVL_VK_SPACE; - case ControllerButton::BUTTON_X: // Left button - return 'X'; case ControllerButton::BUTTON_Y: // Top button return DVL_VK_RETURN; case ControllerButton::BUTTON_LEFTSTICK: @@ -69,6 +67,12 @@ bool GetGameAction(const SDL_Event &event, GameAction *action) if (!ctrl_event.up) *action = GameAction(GameActionType::SECONDARY_ACTION); return true; + case ControllerButton::BUTTON_X: // Left button + if (InGameMenu()) + break; // Map to keyboard key + if (!ctrl_event.up) + *action = GameAction(GameActionType::CAST_SPELL); + return true; case ControllerButton::BUTTON_A: // Bottom button if (InGameMenu()) break; // Map to keyboard key diff --git a/SourceX/controls/game_controls.h b/SourceX/controls/game_controls.h index 8a91422dd..6e7131423 100644 --- a/SourceX/controls/game_controls.h +++ b/SourceX/controls/game_controls.h @@ -10,6 +10,7 @@ enum class GameActionType { USE_MANA_POTION, PRIMARY_ACTION, // Talk to towners, click on inv items, attack, etc. SECONDARY_ACTION, // Open chests, doors, pickup items. + CAST_SPELL, TOGGLE_INVENTORY, TOGGLE_CHARACTER_INFO, TOGGLE_QUICK_SPELL_MENU, diff --git a/SourceX/miniwin/misc_msg.cpp b/SourceX/miniwin/misc_msg.cpp index b3fdb925e..eeac83094 100644 --- a/SourceX/miniwin/misc_msg.cpp +++ b/SourceX/miniwin/misc_msg.cpp @@ -361,6 +361,16 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter case GameActionType::SECONDARY_ACTION: performSecondaryAction(); break; + case GameActionType::CAST_SPELL: + if (pcurs >= CURSOR_FIRSTITEM && invflag) + // Drop item so that it does not get destroyed. + DropItemBeforeTrig(); + if (!invflag && !talkflag) + // Cast the spell. + RightMouseDown(); + // Close active menu if any / stop walking. + PressEscKey(); + break; case GameActionType::TOGGLE_QUICK_SPELL_MENU: ShowCursor(); lpMsg->message = DVL_WM_KEYDOWN;