summaryrefslogtreecommitdiff
path: root/src/client/input.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2013-03-04 16:50:49 +0400
committerAndrey Nazarov <skuller@skuller.net>2013-03-04 16:50:49 +0400
commitba783822ee4e3aa5b939e9ee875c3e8efec5a422 (patch)
treedbe3f1ff08d9962a07a6766ec2642c01c45303fc /src/client/input.c
parent7a7d32b65ebe2235d946247765102fd428e1ab5a (diff)
Extend ‘m_autosens’ to specify default FOV.
Diffstat (limited to 'src/client/input.c')
-rw-r--r--src/client/input.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/client/input.c b/src/client/input.c
index f69523a..41f9b5f 100644
--- a/src/client/input.c
+++ b/src/client/input.c
@@ -552,6 +552,9 @@ static float CL_KeyState(kbutton_t *key)
//==========================================================================
+static float autosens_x;
+static float autosens_y;
+
/*
================
CL_MouseMove
@@ -596,9 +599,9 @@ static void CL_MouseMove(void)
mx *= speed;
my *= speed;
- if (m_autosens->integer && cl.fov_x >= 1) {
- mx *= cl.fov_x / 90.0f;
- my *= V_CalcFov(cl.fov_x, 4, 3) / 73.739795291688f;
+ if (m_autosens->integer) {
+ mx *= cl.fov_x * autosens_x;
+ my *= cl.fov_y * autosens_y;
}
// add mouse X/Y movement
@@ -746,6 +749,18 @@ void CL_UpdateCmd(int msec)
cl.cmd.angles[2] = ANGLE2SHORT(cl.viewangles[2]);
}
+static void m_autosens_changed(cvar_t *self)
+{
+ float fov;
+
+ if (self->value > 90.0f && self->value <= 179.0f)
+ fov = self->value;
+ else
+ fov = 90.0f;
+
+ autosens_x = 1.0f / fov;
+ autosens_y = 1.0f / V_CalcFov(fov, 4, 3);
+}
/*
============
@@ -822,6 +837,8 @@ void CL_RegisterInput(void)
m_filter = Cvar_Get("m_filter", "0", 0);
m_accel = Cvar_Get("m_accel", "0", 0);
m_autosens = Cvar_Get("m_autosens", "0", 0);
+ m_autosens->changed = m_autosens_changed;
+ m_autosens_changed(m_autosens);
}
/*