Skip to content

Commit 96fcad8

Browse files
committed
Release v5.4: drop IN_MenuMouse raw-mouse hooks
1 parent 48bf1ba commit 96fcad8

12 files changed

Lines changed: 7 additions & 125 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v5.4
4+
5+
- Raw mouse: removed the `IN_MenuMouse` engine hook (SofExe `0x4A420`), Pre/Post callbacks, and `in_menumouse.cpp`. `GetCursorPos` no longer takes a special “real API” path while menu-mouse runs; with raw mouse enabled it always drains pending mickeys and reports the synthetic cursor position like other code paths.
6+
37
## v5.3
48

59
- Raw mouse: if `RegisterRawInputDevices` returns `ERROR_INVALID_PARAMETER` (87) for focus-following registration (`hwndTarget=NULL`), retry once with an explicit same-process top-level HWND (resolved via `cl_hwnd`, window heuristics, or foreground when it belongs to the game process). Non-null `hwndTarget` must be owned by the calling process; comments in `raw_shared.cpp` document that Win32 rule.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.3
1+
5.4

build/generated_detours.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ namespace detour_Sys_SendKeyEvents {
153153
tSys_SendKeyEvents oSys_SendKeyEvents = nullptr;
154154
}
155155

156-
namespace detour_IN_MenuMouse {
157-
tIN_MenuMouse oIN_MenuMouse = nullptr;
158-
}
159-
160156
namespace detour_GetCursorPos {
161157
tGetCursorPos oGetCursorPos = nullptr;
162158
}
@@ -572,17 +568,6 @@ namespace detour_Sys_SendKeyEvents {
572568
}
573569
}
574570

575-
namespace detour_IN_MenuMouse {
576-
ManagerType& GetManager() {
577-
static ManagerType* instance = nullptr;
578-
if (!instance) {
579-
static char storage[sizeof(ManagerType)];
580-
instance = new(storage) ManagerType();
581-
}
582-
return *instance;
583-
}
584-
}
585-
586571
namespace detour_GetCursorPos {
587572
ManagerType& GetManager() {
588573
static ManagerType* instance = nullptr;
@@ -750,17 +735,6 @@ namespace detour_CinematicFreeze {
750735
}
751736
}
752737

753-
namespace detour_IN_MenuMouse {
754-
void __cdecl hkIN_MenuMouse(cvar_t* cvar1, cvar_t* cvar2) {
755-
ManagerType& mgr = GetManager();
756-
if (mgr.GetPreCallbackCount() > 0) mgr.DispatchPre(cvar1, cvar2);
757-
if (oIN_MenuMouse) {
758-
oIN_MenuMouse(cvar1, cvar2);
759-
}
760-
if (mgr.GetPostCallbackCount() > 0) mgr.DispatchPost(cvar1, cvar2);
761-
}
762-
}
763-
764738
// Override hooks (hooks.json override: true)
765739
// Note: Override hooks with custom_detour: true are manually installed at runtime and not generated here
766740
namespace detour_CL_Precache_f {

build/generated_detours.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,33 +1006,6 @@ namespace {
10061006
static AutoDetour_Sys_SendKeyEvents g_AutoDetour_Sys_SendKeyEvents;
10071007
}
10081008

1009-
namespace detour_IN_MenuMouse {
1010-
using tIN_MenuMouse = void(__cdecl*)(cvar_t* cvar1, cvar_t* cvar2);
1011-
extern tIN_MenuMouse oIN_MenuMouse;
1012-
using ManagerType = TypedSharedHookManager<void, cvar_t*, cvar_t*>;
1013-
ManagerType& GetManager();
1014-
1015-
void __cdecl hkIN_MenuMouse(cvar_t* cvar1, cvar_t* cvar2);
1016-
}
1017-
1018-
namespace {
1019-
struct AutoDetour_IN_MenuMouse {
1020-
AutoDetour_IN_MenuMouse() {
1021-
using namespace detour_IN_MenuMouse;
1022-
if (!GetDetourSystem().IsDetourRegistered("IN_MenuMouse")) {
1023-
GetDetourSystem().RegisterDetour(
1024-
reinterpret_cast<void*>(0x0004A420),
1025-
reinterpret_cast<void*>(detour_IN_MenuMouse::hkIN_MenuMouse),
1026-
reinterpret_cast<void**>(&detour_IN_MenuMouse::oIN_MenuMouse),
1027-
"IN_MenuMouse",
1028-
DetourModule::SofExe,
1029-
static_cast<size_t>(0));
1030-
}
1031-
}
1032-
};
1033-
static AutoDetour_IN_MenuMouse g_AutoDetour_IN_MenuMouse;
1034-
}
1035-
10361009
namespace detour_GetCursorPos {
10371010
using tGetCursorPos = BOOL(__stdcall*)(LPPOINT lpPoint);
10381011
extern tGetCursorPos oGetCursorPos;

build/generated_registrations.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ extern void r_blendlightmaps_post_callback();
5656
extern void r_blendlightmaps_pre_callback();
5757
extern void raw_mouse_EarlyStartup();
5858
extern void raw_mouse_RefDllLoaded(char const* name);
59-
extern void raw_mouse_in_menumouse_post(cvar_t* cvar1, cvar_t* cvar2);
60-
extern void raw_mouse_in_menumouse_pre(cvar_t*& cvar1, cvar_t*& cvar2);
6159
extern void scaledCon_EarlyStartup();
6260
extern void scaledHud_RefDllLoaded(char const* name);
6361
extern void scaledUIBase_RefDllLoaded(char const* name);
@@ -161,19 +159,6 @@ inline void RegisterAllFeatureHooks() {
161159
100);
162160
PrintOut(PRINT_LOG, "[RegisterAllFeatureHooks] R_BlendLightmaps post callbacks: %zu\n", mgr.GetPostCallbackCount());
163161
}
164-
detour_IN_MenuMouse::GetManager().RegisterPreCallback(
165-
"raw_mouse", "raw_mouse_in_menumouse_pre",
166-
[](cvar_t*& cvar1, cvar_t*& cvar2) { raw_mouse_in_menumouse_pre(cvar1, cvar2); },
167-
0);
168-
{
169-
auto& mgr = detour_IN_MenuMouse::GetManager();
170-
PrintOut(PRINT_LOG, "[RegisterAllFeatureHooks] IN_MenuMouse manager at 0x%p\n", &mgr);
171-
mgr.RegisterPostCallback(
172-
"raw_mouse", "raw_mouse_in_menumouse_post",
173-
[](cvar_t* cvar1, cvar_t* cvar2) { raw_mouse_in_menumouse_post(cvar1, cvar2); },
174-
0);
175-
PrintOut(PRINT_LOG, "[RegisterAllFeatureHooks] IN_MenuMouse post callbacks: %zu\n", mgr.GetPostCallbackCount());
176-
}
177162
detour_GL_FindImage::GetManager().RegisterPostCallback(
178163
"scaled_ui_base", "gl_findimage_post_callback",
179164
[](void* result, char* filename, int imagetype, char mimap, char allowPicmip) { return gl_findimage_post_callback(result, filename, imagetype, mimap, allowPicmip); },

detours.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -431,18 +431,6 @@ functions:
431431
detour_len: 5
432432
params: []
433433

434-
- name: IN_MenuMouse
435-
module: SofExe
436-
identifier: "0x0004A420"
437-
return_type: void
438-
calling_convention: __cdecl
439-
detour_len: 0
440-
params:
441-
- type: cvar_t*
442-
name: cvar1
443-
- type: cvar_t*
444-
name: cvar2
445-
446434
- name: GetCursorPos
447435
module: Unknown
448436
identifier: "GetCursorPos"

hdr/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
Increment version using: ./increment_version.sh
88
*/
99

10-
#define SOFBUDDY_VERSION "5.3"
10+
#define SOFBUDDY_VERSION "5.4"

src/features/raw_mouse/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ References: MSDN [GetRawInputBuffer](https://learn.microsoft.com/en-us/windows/w
3939
- **Sys_SendKeyEvents** – Replaced entirely: `raw_mouse_consume_deltas()`, then `Sys_SendKeyEvents_Replacement()` (capped pump + frame time). Raw-buffer draining now lives in the `GetCursorPos` path.
4040

4141
## Custom detours
42-
- **SetCursorPos** (patch + GetProcAddress) – When enabled: treat as recenter; set `window_center`, return TRUE without moving OS cursor. Patched at IN_Frame, IN_MouseMove, IN_MenuMouse. When disabled: real SetCursorPos.
42+
- **SetCursorPos** (patch + GetProcAddress) – When enabled: treat as recenter; set `window_center`, return TRUE without moving OS cursor. Patched at IN_Frame, IN_MouseMove. When disabled: real SetCursorPos.
4343

4444
## Technical details
4545
- **Registration:** `raw_mouse_ensure_registered()` clears stale cached targets, resolves a usable game HWND for clip/focus tracking, and separately ensures the process-level raw mouse registration exists. The Win32 registration path always uses `hwndTarget = NULL` for the normal focused-app case, which removes the usual “bad HWND” source of error 87.

src/features/raw_mouse/hooks/getcursorpos.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ BOOL getcursorpos_override_callback(
1616
return original(lpPoint);
1717
}
1818

19-
if (raw_mouse_in_menumouse_scope()) {
20-
SOFBUDDY_ASSERT(original != nullptr);
21-
return original(lpPoint);
22-
}
23-
2419
raw_mouse_drain_pending_raw_for_cursor();
2520

2621
if (!lpPoint) {

src/features/raw_mouse/hooks/hooks.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
[
2-
{
3-
"function": "IN_MenuMouse",
4-
"callback": "raw_mouse_in_menumouse_pre",
5-
"phase": "Pre",
6-
"priority": 0
7-
},
8-
{
9-
"function": "IN_MenuMouse",
10-
"callback": "raw_mouse_in_menumouse_post",
11-
"phase": "Post",
12-
"priority": 0
13-
},
142
{
153
"function": "GetCursorPos",
164
"callback": "getcursorpos_override_callback",

0 commit comments

Comments
 (0)