ref: 050589ae8afe1b26f684d2aa7bc41fc58e9c655d
parent: 9377317f548b91431caa9dbd26b998c141bb0a4d
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Thu Dec 28 16:54:52 EST 2023
m_raw: use callbacks
--- a/unix/in.c
+++ b/unix/in.c
@@ -7,7 +7,7 @@
static cvar_t m_windowed = {"m_windowed", "1", true};
static cvar_t m_filter = {"m_filter", "0", true};
static cvar_t m_raw = {"m_raw", "1", true};
-static int mouseon, oldmwin, focuslost, oldraw = -1;
+static int mouseon, oldmwin, focuslost;
static float dx, dy, olddx, olddy;
static int mbuttons[] = {
@@ -113,6 +113,12 @@
{
}
+static void
+m_raw_cb(cvar_t *var)
+{
+ SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, var->value > 0 ? "0" : "1");
+}
+
void
IN_Move(usercmd_t *cmd)
{
@@ -119,11 +125,6 @@
if(!mouseon)
return;
- if(oldraw != (int)m_raw.value){
- oldraw = m_raw.value;
- SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, oldraw ? "0" : "1");
- }
-
if(m_filter.value){
dx = (dx + olddx) * 0.5;
dy = (dy + olddy) * 0.5;
@@ -169,6 +170,7 @@
void
IN_Init(void)
{
+ m_raw.cb = m_raw_cb;
Cvar_RegisterVariable(&m_windowed);
Cvar_RegisterVariable(&m_filter);
Cvar_RegisterVariable(&m_raw);