From 5e921bf59373d79d27c322ff86e8b5a37b151e45 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 31 Jul 2022 16:02:10 +0100 Subject: Add magical feature codegen system, at long last --- src/rinput.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/rinput.c') diff --git a/src/rinput.c b/src/rinput.c index 1b81cf5..a7ad8d8 100644 --- a/src/rinput.c +++ b/src/rinput.c @@ -17,14 +17,16 @@ // NOTE: compiled on Windows only. All Linux Source releases are new enough to // have raw input already. -#include #include #include "con_.h" #include "hook.h" #include "errmsg.h" +#include "feature.h" #include "intdefs.h" +FEATURE("raw mouse input") + // We reimplement m_rawinput by hooking cursor functions in the same way as // RInput (it's way easier than replacing all the mouse-handling internals of // the actual engine). We also take the same window class it does in order to @@ -76,11 +78,14 @@ static int __stdcall hook_SetCursorPos(int x, int y) { return orig_SetCursorPos(x, y); } -bool rinput_init(void) { +PREINIT { if (con_findvar("m_rawinput")) return false; // no need! // create cvar hidden so if we fail to init, setting can still be preserved con_reg(m_rawinput); + return true; +} +INIT { WNDCLASSEXW wc = { .cbSize = sizeof(wc), // cast because inproc is binary-compatible but doesn't use stupid @@ -139,7 +144,7 @@ e0: UnregisterClassW(L"RInput", 0); return false; } -void rinput_end(void) { +END { RAWINPUTDEVICE rd = { .dwFlags = RIDEV_REMOVE, .hwndTarget = 0, -- cgit v1.2.3