Skip to content

Add right-click-to-command control scheme#2298

Draft
leosnake2208 wants to merge 2 commits into
Phobos-developers:developfrom
leosnake2208:feature/modern-controls
Draft

Add right-click-to-command control scheme#2298
leosnake2208 wants to merge 2 commits into
Phobos-developers:developfrom
leosnake2208:feature/modern-controls

Conversation

@leosnake2208

@leosnake2208 leosnake2208 commented Jul 18, 2026

Copy link
Copy Markdown

Feature

An opt-in control scheme matching modern RTS games:

  • Right mouse button issues orders to the current selection — move, attack, enter, capture, harvest, guard, and so on.
  • Left mouse button only selects, box-selects and self-deploys, and deselects when clicking empty ground.

Special left-click modes are preserved on both buttons: while placing a building, repairing, selling, toggling power, planting a beacon, planning a path, or targeting a superweapon, the left button performs that action and the right button cancels it — exactly as in vanilla. Only mouse behaviour changes; no keyboard hotkeys are rebound.

Config

Gated behind a new user setting, default off:

[Phobos]
RightClickCommand=false  ; boolean

Implementation

The tactical mouse message handler (MouseClass @ 0x6930A0) dispatches window mouse messages through a jump table. RBUTTONUP and LBUTTONUP are two cases of the same function, sharing one stack frame and this.

  • RMB → command (0x693397): the RBUTTONUP handler, past its drag-flag gate, populates the view-relative click point and jumps into the shared LMB-up command dispatch at 0x69323E, so the order flows through the game's own DecideAction → apply path — reusing 100% of the command and network logic (no argument/packet reconstruction). A flag tells the LBUTTONUP hook to let this RMB-issued order pass unmodified.
  • LMB → select/deploy only (0x6931B4, 0x693276): right after DecideAction, any command action is downgraded to Action::None, so the left button only selects/box-selects/deploys. On empty ground a would-be move becomes a deselect (MapClass::UnselectAll). Completed band-selects exit earlier and never reach this point.
  • A special-mode guard (InSpecialLeftClickMode) keeps repair/sell/placement/beacon/planning/superweapon-targeting on their vanilla buttons.

Validated with the repo's check-hooks skill — no conflicts with Phobos or Ares 3.0p1; hook sizes and return targets check out. Built clean (Debug/Release, 0 warnings). The scheme was developed and extensively tested in-game on the CnCNet Yuri's Revenge build.

Notes

  • Net-safe: client-side input mapping only; orders reuse the game's own networked dispatch.
  • Could later be split into finer toggles (RMB-to-command vs LMB-select-only) if that is preferred.

Optional control scheme matching modern RTS games: the right mouse button
issues orders to the current selection, while the left mouse button only
selects/deploys and deselects on empty ground. Reuses the game's own command
dispatch (and network path) by redirecting the RMB-up handler into the shared
LMB-up command dispatch. Special left-click modes (repair/sell/place/beacon/
superweapon/planning) keep their vanilla behaviour.

Gated behind [Phobos] ModernControls (default off).
@Coronia

Coronia commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

rename the tag to RightClickCommand since ModernControl is an ambigious name that can refer to many things

@github-actions

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

Address review feedback (Coronia): "ModernControls" is an ambiguous
name. Rename the INI tag, config field, source file, namespace and
hook names to the clearer "RightClickCommand"; update docs and CREDITS.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@leosnake2208 leosnake2208 changed the title Add modern control scheme (right-click to command) Add right-click-to-command control scheme Jul 19, 2026
@leosnake2208

Copy link
Copy Markdown
Author

Done — renamed the tag to RightClickCommand (and updated the config field, source file, namespace, hook names, docs and CREDITS to match). PR title/body updated too. Thanks!

leosnake2208 added a commit to leosnake2208/Phobos that referenced this pull request Jul 19, 2026
… TypeSelectByMultiClick

Mirror the upstream PR structure in the integrated local build. The single
ModernControls toggle/file is replaced by two, matching PR Phobos-developers#2298 (right-click
to command) and PR Phobos-developers#2297 (multi-click type-select):

- src/Misc/RightClickCommand.cpp  - RMB command + LMB select/deselect,
  gated by [Phobos] -> RightClickCommand
- src/Misc/MultiClickTypeSelect.cpp - double/triple-click type-select,
  gated by [Phobos] -> TypeSelectByMultiClick

Both default true (this is the personal build). The fork-only 250px
double-click radius and selection-group matching are preserved. The two
features share RightClickCommand::RmbCommandInProgress: the RMB redirect
flows through the 0x693290 multi-click hook, which clears the flag and
skips the event, so an RMB order is never miscounted as a left-click.

WASD panning stays separate and always-on (CameraPanWASD.cpp).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Metadorius

Copy link
Copy Markdown
Member

hint: we'd appreciate (even broken) real human English more than an LLM text ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants