summaryrefslogtreecommitdiffhomepage
path: root/src/rinput.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-07-31 16:02:10 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-08-10 22:40:52 +0100
commit5e921bf59373d79d27c322ff86e8b5a37b151e45 (patch)
tree4d40e39543b085ce4c8cb9b1a7b3c0108de680c0 /src/rinput.c
parentc8d7588251fd4fe63ac6afe2a90ca7066c786609 (diff)
Add magical feature codegen system, at long last
Diffstat (limited to 'src/rinput.c')
-rw-r--r--src/rinput.c11
1 files changed, 8 insertions, 3 deletions
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 <stdbool.h>
#include <Windows.h>
#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,