Skip to content

Mouse support - #73

Draft
AloXado320 wants to merge 1 commit into
flyngmt:masterfrom
AloXado320:mouse
Draft

Mouse support#73
AloXado320 wants to merge 1 commit into
flyngmt:masterfrom
AloXado320:mouse

Conversation

@AloXado320

Copy link
Copy Markdown

Adds mouse support to most menu interfaces in the game, of which some makes sense logically.

Here's the changes in detail:

m_hand (Hand cursor)

  • Render now uses a separate visual position variable so mouse movement feels smooth.

m_tag (Menu table like interface for items and selection entries for it)

  • Each submenu has a table entry check for mouse to interact them seamlessly.
  • Item selection entry highlights the text hovered by mouse.
  • Left/Right click functionality for both table entries and item selection entry.
  • Scroll wheel support for catalog list entries.
  • Adjusted positions from some table entries and set hitboxes for each of them.

m_design (Design menu)

  • Seamlessly change design modes and it's entries depending where you hover the mouse.
  • Interpolation used for pen drawing to prevent missed pixels if the mouse is moved too fast.
  • Safety checks like preventing changing menus while currently drawing and extra spacing for tool menu icons.

m_choice (Dialog choose selection)

  • Simple hover and selection mouse support.

Prazon added a commit to Prazon/ACGC-PC-Together that referenced this pull request Aug 6, 2026
Mouse input for the menu overlays, behind a new MOUSE_INPUT define.
pc_mouse.c samples the mouse once per frame at the end of the SDL event
pump, so every reader in a frame sees the same snapshot: button edges,
wheel movement, motion, and a position mapped into GC screen space with
the pillarbox correction undone. pc_mouse.h stays SDL-free so decomp
translation units can include it, and folds to static inline no-ops when
MOUSE_INPUT is off.

Wired up in four interfaces, all keeping controller parity — whichever
device was used last owns the cursor:

- m_hand_ovl.c: hand renders from a separate visual_pos that eases toward
  the logical slot, so pointer movement stays smooth
- m_tag_ovl.c: hover highlights table slots and submenu options, left
  click = A, right click = B, wheel scrolls the catalog
- m_design_ovl.c: cursor drives the pattern grid, hovering switches
  between tool/grid/palette/canvas areas, strokes interpolate so fast
  drags leave no gaps
- m_choice_main_normal.c_inc: dialogue choices highlight on hover

Fixes applied on top of the draft PR:

- pc_mouse.h defined its disabled-build fallbacks as non-inline functions
  in a header, one with a syntax error; now static inline
- GET_BUTTON_PRESSED/GET_BUTTON_HELD were unparenthesised, so uses inside
  larger && expressions dropped the controller path's guard
- the wheel accumulator was only cleared when a reader consumed it, so one
  scroll outside a menu left pc_mouse_active() true forever
- motion was compared against the position from two frames back
- mTG_mouse_move_func indexed tags[sel_tag_idx] before the bounds check
  mTG_move_func applies; sel_tag_idx is -1 with no tag up
- the design overlay compared ->mode against a mDE_MAIN_MODE_* value from
  a different enum; now ->main_mode_act
- palette and tool modes hand their whole move step to the mouse while it
  is active and only a button press released ownership, leaving the stick
  dead after touching the mouse; stick deflection now releases it too
- added the missing pc_mouse.h includes, named the mouse button constants,
  widened fields holding fractional coords to f32, and tied the per-table
  mouse metadata array to mTG_TABLE_NUM with a size check

Built with build_pc.bat (client and dedicated server link clean).
Not yet exercised in game: the hit boxes are hand-tuned constants from the
draft and several tables fall back to a default box.
Prazon added a commit to Prazon/ACGC-PC-Together that referenced this pull request Aug 6, 2026
Mouse input for the menu overlays, behind a new MOUSE_INPUT define.
pc_mouse.c samples the mouse once per frame at the end of the SDL event
pump, so every reader in a frame sees the same snapshot: button edges,
wheel movement, motion, and a position mapped into GC screen space with
the pillarbox correction undone. pc_mouse.h stays SDL-free so decomp
translation units can include it, and folds to static inline no-ops when
MOUSE_INPUT is off.

Wired up in four interfaces, all keeping controller parity — whichever
device was used last owns the cursor:

- m_hand_ovl.c: hand renders from a separate visual_pos that eases toward
  the logical slot, so pointer movement stays smooth
- m_tag_ovl.c: hover highlights table slots and submenu options, left
  click = A, right click = B, wheel scrolls the catalog
- m_design_ovl.c: cursor drives the pattern grid, hovering switches
  between tool/grid/palette/canvas areas, strokes interpolate so fast
  drags leave no gaps
- m_choice_main_normal.c_inc: dialogue choices highlight on hover

Fixes applied on top of the draft PR:

- pc_mouse.h defined its disabled-build fallbacks as non-inline functions
  in a header, one with a syntax error; now static inline
- GET_BUTTON_PRESSED/GET_BUTTON_HELD were unparenthesised, so uses inside
  larger && expressions dropped the controller path's guard
- the wheel accumulator was only cleared when a reader consumed it, so one
  scroll outside a menu left pc_mouse_active() true forever
- motion was compared against the position from two frames back
- mTG_mouse_move_func indexed tags[sel_tag_idx] before the bounds check
  mTG_move_func applies; sel_tag_idx is -1 with no tag up
- the design overlay compared ->mode against a mDE_MAIN_MODE_* value from
  a different enum; now ->main_mode_act
- palette and tool modes hand their whole move step to the mouse while it
  is active and only a button press released ownership, leaving the stick
  dead after touching the mouse; stick deflection now releases it too
- added the missing pc_mouse.h includes, named the mouse button constants,
  widened fields holding fractional coords to f32, and tied the per-table
  mouse metadata array to mTG_TABLE_NUM with a size check

Built with build_pc.bat (client and dedicated server link clean).
Not yet exercised in game: the hit boxes are hand-tuned constants from the
draft and several tables fall back to a default box.
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.

1 participant