summaryrefslogtreecommitdiff
path: root/src
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
parent7a7d32b65ebe2235d946247765102fd428e1ab5a (diff)
Extend ‘m_autosens’ to specify default FOV.
Diffstat (limited to 'src')
-rw-r--r--src/client/client.h1
-rw-r--r--src/client/entities.c1
-rw-r--r--src/client/input.c23
-rw-r--r--src/client/view.c2
4 files changed, 23 insertions, 4 deletions
diff --git a/src/client/client.h b/src/client/client.h
index eaf8f87..f342383 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -223,6 +223,7 @@ typedef struct client_state_s {
refdef_t refdef;
float fov_x; // interpolated
+ float fov_y; // derived from fov_x assuming 4/3 aspect ratio
int lightlevel;
vec3_t v_forward, v_right, v_up; // set when refdef.angles is set
diff --git a/src/client/entities.c b/src/client/entities.c
index 2c79b3b..fc461b0 100644
--- a/src/client/entities.c
+++ b/src/client/entities.c
@@ -1193,6 +1193,7 @@ void CL_CalcViewValues(void)
// interpolate field of view
cl.fov_x = lerp_client_fov(ops->fov, ps->fov, lerp);
+ cl.fov_y = V_CalcFov(cl.fov_x, 4, 3);
// don't interpolate blend color
Vector4Copy(ps->blend, cl.refdef.blend);
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);
}
/*
diff --git a/src/client/view.c b/src/client/view.c
index b9669e1..ed5b840 100644
--- a/src/client/view.c
+++ b/src/client/view.c
@@ -426,7 +426,7 @@ void V_RenderView(void)
// adjust for non-4/3 screens
if (cl_adjustfov->integer) {
- cl.refdef.fov_y = V_CalcFov(cl.fov_x, 4, 3);
+ cl.refdef.fov_y = cl.fov_y;
cl.refdef.fov_x = V_CalcFov(cl.refdef.fov_y, cl.refdef.height, cl.refdef.width);
} else {
cl.refdef.fov_x = cl.fov_x;