summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2006-05-29 00:17:24 +0000
committerSimon Howard2006-05-29 00:17:24 +0000
commit9d94e1bd45835f87973fccdfcdbfa84fc1cadaa6 (patch)
treee50267ba27ee4574bd292913b8cae7d86e0ff4e5 /src
parent4d7893a26cbddef166757603e4783f6c5f46acb2 (diff)
downloadchocolate-doom-9d94e1bd45835f87973fccdfcdbfa84fc1cadaa6.tar.gz
chocolate-doom-9d94e1bd45835f87973fccdfcdbfa84fc1cadaa6.tar.bz2
chocolate-doom-9d94e1bd45835f87973fccdfcdbfa84fc1cadaa6.zip
Change the mouse acceleration behavior to accelerate by multiplying by a
linear amount when a threshold is exceeded. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 535
Diffstat (limited to 'src')
-rw-r--r--src/i_video.c28
-rw-r--r--src/i_video.h3
-rw-r--r--src/m_misc.c5
3 files changed, 24 insertions, 12 deletions
diff --git a/src/i_video.c b/src/i_video.c
index acb8af1b..72e4d0f8 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_video.c 532 2006-05-26 15:37:09Z fraggle $
+// $Id: i_video.c 535 2006-05-29 00:17:24Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -175,7 +175,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: i_video.c 532 2006-05-26 15:37:09Z fraggle $";
+rcsid[] = "$Id: i_video.c 535 2006-05-29 00:17:24Z fraggle $";
#include <SDL.h>
#include <ctype.h>
@@ -269,14 +269,17 @@ static int disk_image_w, disk_image_h;
static byte *saved_background;
static boolean window_focused;
-// mouse acceleration
-// We accelerate the mouse by raising the mouse movement values to
-// the power of this value, to simulate the acceleration in DOS
-// mouse drivers
+// Mouse acceleration
//
-// TODO: See what is a sensible default value for this
+// This emulates some of the behavior of DOS mouse drivers by increasing
+// the speed when the mouse is moved fast.
+//
+// The mouse input values are input directly to the game, but when
+// the values exceed the value of mouse_threshold, they are multiplied
+// by mouse_acceleration to increase the speed.
-float mouse_acceleration = 1.5;
+float mouse_acceleration = 2.0;
+int mouse_threshold = 10;
static boolean MouseShouldBeGrabbed()
{
@@ -485,7 +488,14 @@ static int AccelerateMouse(int val)
if (val < 0)
return -AccelerateMouse(-val);
- return (int) pow(((float) val) / mouse_acceleration, mouse_acceleration);
+ if (val > mouse_threshold)
+ {
+ return (val - mouse_threshold) * mouse_acceleration + mouse_threshold;
+ }
+ else
+ {
+ return val;
+ }
}
void I_GetEvent(void)
diff --git a/src/i_video.h b/src/i_video.h
index 3b9b673f..ad48c3a4 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_video.h 532 2006-05-26 15:37:09Z fraggle $
+// $Id: i_video.h 535 2006-05-29 00:17:24Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -66,6 +66,7 @@ extern int screenmultiply;
extern int fullscreen;
extern boolean grabmouse;
extern float mouse_acceleration;
+extern int mouse_threshold;
extern int startup_delay;
#endif
diff --git a/src/m_misc.c b/src/m_misc.c
index 57840604..899fad01 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: m_misc.c 532 2006-05-26 15:37:09Z fraggle $
+// $Id: m_misc.c 535 2006-05-29 00:17:24Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -106,7 +106,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: m_misc.c 532 2006-05-26 15:37:09Z fraggle $";
+rcsid[] = "$Id: m_misc.c 535 2006-05-29 00:17:24Z fraggle $";
#include <stdio.h>
#include <stdlib.h>
@@ -402,6 +402,7 @@ static default_t extra_defaults_list[] =
{"grabmouse", &grabmouse},
{"novert", &novert},
{"mouse_acceleration", &mouse_acceleration, DEFAULT_FLOAT},
+ {"mouse_threshold", &mouse_threshold},
{"show_endoom", &show_endoom},
{"vanilla_savegame_limit", &vanilla_savegame_limit},
#ifdef FEATURE_MULTIPLAYER