ref: 9d94e1bd45835f87973fccdfcdbfa84fc1cadaa6
parent: 4d7893a26cbddef166757603e4783f6c5f46acb2
author: Simon Howard <[email protected]>
date: Sun May 28 20:17:24 EDT 2006
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
--- 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 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 @@
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)
--- 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 fullscreen;
extern boolean grabmouse;
extern float mouse_acceleration;
+extern int mouse_threshold;
extern int startup_delay;
#endif
--- 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 @@
{"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