Controller Manual Aim Improvements #8140
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Controller Manual Aim Improvements
Summary
This PR refactors and improves controller aiming and cursor interaction for DevilutionX, enabling precise manual aiming and consistent cursor-based actions with gamepads. The changes unify gamepad aiming logic, ensure cursor persistence, and guarantee that all attack, spell, and interaction actions respect the controller-placed cursor position.
Technical Changes
1. Unified Gamepad Aiming State
GamepadAimActivestate to track when the player is actively aiming with the right stick or padmapped D-pad.2. Cursor Persistence and Device Switching
GamepadAimActive, preventing premature cursor hiding or device swaps during controller aiming.3. D-pad and Analog Stick Handling
GamepadAimActiveand hides the cursor.4. SecondaryAction Cursor Support
PerformSecondaryAction()to explicitly handle all special cursor states (e.g., Telekinesis, Identify, Repair, etc.) using a manual list.5. Interact and PrimaryAction Patches
Interact()andPerformPrimaryAction()to respect controller aiming state.GamepadAimActiveis true, attacks and primary actions are directed at the cursor position, ensuring consistent targeting for controller users.6. Spell Casting Consistency
PerformSpellAction()so that, when controller aiming is active, the player turns and casts spells (e.g., Firewall, Teleport, Town Portal) at the cursor position.7. Modifier Hints UI
modifier_hints.cppso gamepad modifier hints (menu navigation, hotspell selection) are hidden while manual aiming is active (IsGamepadAimActive()).8. Controller Motion API
controller_motion.hto declare and expose the new gamepad aiming state API (IsGamepadAimActive()and related helpers).9. Minimal Impact on KBM
IsGamepadAimActive()), leaving KBM and general gameplay unaffected.10. QuickCast Targeting Fixes
QuickCast()and related logic to ensure spells cast via quickcast always target the preferred monster when available, even if objects or items are nearby.Usage
Files Modified
Source/controls/controller_motion.cppSource/controls/controller_motion.hSource/controls/plrctrls.cppSource/controls/modifier_hints.cpp