Commit Graph
7 Commits
Author SHA1 Message Date
Brues b05c15ffa7 input: evict GetMouseButtonClicked so it reads nil outside a handler
Previously g_lastButton persisted as the last click forever. Modern
WoW returns the button only while a mouse handler is running and nil
otherwise (verified in 3.3.5: GetMouseButtonClicked pushes a
frame-manager field [mgr+0x1234] that is set before a mouse handler
dispatches and cleared after, so it is nil when null).

We cannot bracket the handler the same way: WoW dispatches the
frame-script mouse handlers deferred from the WH_GETMESSAGE pump, so
eviction is time-based via the existing per-frame WorldTick. The
button is still captured on each WM button message; EvictTick clears
it after a couple of quiet ticks with nothing held. A held button
keeps it (OnDragStart still reads it) and it survives the whole frame
its click lands in, so multiple addons hooking one OnClick all see it,
avoiding the multi-reader hole a consume-on-read latch would have.

Verified in-game: value matches the GLOBAL_MOUSE_DOWN button arg inside
a handler, and reads nil once clicks settle.
2026-07-13 23:41:33 -05:00
Brues 4daf6b9364 input: add GetMouseButtonClicked()
Returns the button name of the most recent mouse-button message
("LeftButton"/.../"Button5"), or nil before any click. Rides the
existing WH_GETMESSAGE stream in GlobalMouse that already backs
GLOBAL_MOUSE_DOWN/UP and IsMouseButtonDown, so no engine hook is
needed: g_lastButton is captured on every press/release, and the
Script fn pushes it (null tail-jumps to pushnil for the "no click
yet" case).

The hook runs at message-dequeue, synchronously before the engine
dispatches the click to the Lua handler, so the value reflects the
button of the handler currently running (and is readable from nested
helpers where arg1 isn't in scope). Not cleared between events -- no
"handler ended" signal in the 1.12 stream -- so outside a mouse
handler it returns the last-clicked button rather than nil; documented.
2026-07-13 19:02:51 -05:00
Brues d9102bae3b Relicense source headers from LGPL to GPL v3
The repo was internally inconsistent: the LICENSE file is GPL v3 but every
src/ header carried the LGPL v3 notice and the README said "LGPL v3 or
later". LGPL was also the wrong fit — this is an injected mod plus a
bundled addon, not a library other code links against, so LGPL's linking
exception buys nothing.

It's also required: src/voicechat/Tts.cpp is ported from awesome_wotlk's
VoiceChat.cpp, which is GPL v3, and a derivative of GPL code cannot be
relicensed under more permissive terms. Dependencies stay compatible —
MinHook (BSD-2) and the nampower-mirrored packet shapes (BSD) are
GPL-compatible, and SAPI is covered by the system-library exception.

Swept "GNU Lesser General Public License" -> "GNU General Public License"
across all 257 src/ headers and changed the README license line to match
the GPL v3 LICENSE file. Comment-only; no build impact.
2026-06-29 16:38:16 -05:00
Brues ad83eb9575 IsMouseButtonDown
Adds the modern (2.0.1+) query function backed by the same
WH_GETMESSAGE hook stream that drives GLOBAL_MOUSE_DOWN/UP — state
flips at the exact same point the events fire. Accepts the 1..5 ID
form, the "LeftButton".."Button5" name form, or no arg for "any
button held".
2026-05-30 22:36:30 -05:00
Brues 2397b683f3 GLOBAL_MOUSE_*: switch from polling to WH_GETMESSAGE hook
Mirrors the thread-message-hook pattern in Input::Modifier. The hook
catches WM_*BUTTON{DOWN,UP} on the engine's main thread before
dispatch, which:
  - is event-driven (zero work when idle) vs ~5 GetAsyncKeyState +
    GetWindowThreadProcessId calls per WorldTick
  - scopes naturally to WoW's message queue, so the foreground-window
    check is no longer needed
  - catches sub-frame down+up pairs the poll would miss

XBUTTON side-key distinction now comes from GET_XBUTTON_WPARAM
instead of the separate VK_XBUTTON1/2 codes.
2026-05-16 22:33:14 -05:00
Brues 60147989bb Collapse Event::Custom::Fire_* into one variadic template
The six per-arity helpers (Fire_None / Fire_D / Fire_DD / Fire_DDD /
Fire_SD / Fire_S) all wrapped the same FUN_FIRE_EVENT engine call
with the same eventID<0 early-out — only the format string and arg
list differed. Collapsing into a single template Fire(eventID, fmt,
args...) keeps the printf-style format at the call site and frees us
from adding a new per-arity overload for each new event shape.
2026-05-16 22:05:07 -05:00
Brues 96a4edaaa1 Fixed _TURNING and added GLOBAL_MOUSE_ 2026-05-14 12:52:22 -05:00