summaryrefslogtreecommitdiffhomepage
path: root/src/rinput.c
diff options
context:
space:
mode:
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,