From 9d94e1bd45835f87973fccdfcdbfa84fc1cadaa6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 29 May 2006 00:17:24 +0000 Subject: 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 --- src/i_video.c | 28 +++++++++++++++++++--------- src/i_video.h | 3 ++- src/m_misc.c | 5 +++-- 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 #include @@ -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 #include @@ -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 -- cgit v1.2.3