summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--src/i_video.c44
-rw-r--r--src/m_misc.c8
3 files changed, 39 insertions, 16 deletions
diff --git a/NEWS b/NEWS
index 940aa52d..aa0cfe29 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+ Mouse acceleration code to emulate the behaviour of old
+ DOS mouse drivers (thanks to Toke for information about
+ this and suggestions)
Lock surfaces properly when we have to (fixes crash under
Windows 98)
diff --git a/src/i_video.c b/src/i_video.c
index f3b38d7c..50c95e95 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_video.c 105 2005-09-14 21:55:47Z fraggle $
+// $Id: i_video.c 111 2005-09-17 20:50:46Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.27 2005/09/17 20:50:46 fraggle
+// Mouse acceleration code to emulate old DOS drivers
+//
// Revision 1.26 2005/09/14 21:55:47 fraggle
// Lock surfaces properly when we have to (fixes crash under Windows 98)
//
@@ -118,31 +121,29 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: i_video.c 105 2005-09-14 21:55:47Z fraggle $";
+rcsid[] = "$Id: i_video.c 111 2005-09-17 20:50:46Z fraggle $";
-#include <ctype.h>
#include <SDL.h>
+#include <ctype.h>
+#include <math.h>
#include "config.h"
-#include "w_wad.h"
-#include "z_zone.h"
+#include "doomdef.h"
#include "doomstat.h"
+#include "d_main.h"
#include "i_system.h"
-#include "v_video.h"
#include "m_argv.h"
#include "m_swap.h"
-#include "d_main.h"
#include "s_sound.h"
#include "sounds.h"
-
-#include "doomdef.h"
+#include "v_video.h"
+#include "w_wad.h"
+#include "z_zone.h"
extern void M_QuitDOOM();
static SDL_Surface *screen;
-#define POINTER_WARP_COUNTDOWN 1
-
// palette
static SDL_Color palette[256];
static boolean palette_to_set;
@@ -177,6 +178,15 @@ 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
+//
+// TODO: See what is a sensible default value for this
+
+float mouse_acceleration = 1.5;
+
static boolean MouseShouldBeGrabbed()
{
// if the window doesnt have focus, never grab it
@@ -418,7 +428,13 @@ static int MouseButtonState(void)
return result;
}
-boolean mousemoved = false;
+static int AccelerateMouse(int val)
+{
+ if (val < 0)
+ return -AccelerateMouse(-val);
+
+ return (int) pow(val, mouse_acceleration);
+}
void I_GetEvent(void)
{
@@ -457,8 +473,8 @@ void I_GetEvent(void)
case SDL_MOUSEMOTION:
event.type = ev_mouse;
event.data1 = MouseButtonState();
- event.data2 = sdlevent.motion.xrel * 8;
- event.data3 = -sdlevent.motion.yrel * 8;
+ event.data2 = AccelerateMouse(sdlevent.motion.xrel);
+ event.data3 = -AccelerateMouse(sdlevent.motion.yrel);
D_PostEvent(&event);
break;
case SDL_MOUSEBUTTONDOWN:
diff --git a/src/m_misc.c b/src/m_misc.c
index 563d0522..95d13738 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: m_misc.c 110 2005-09-17 20:25:56Z fraggle $
+// $Id: m_misc.c 111 2005-09-17 20:50:46Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -23,6 +23,9 @@
//
//
// $Log$
+// Revision 1.12 2005/09/17 20:50:46 fraggle
+// Mouse acceleration code to emulate old DOS drivers
+//
// Revision 1.11 2005/09/17 20:25:56 fraggle
// Set the default values for variables in their initialisers. Remove the
// "defaultvalue" parameter and associated code from the configuration
@@ -75,7 +78,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: m_misc.c 110 2005-09-17 20:25:56Z fraggle $";
+rcsid[] = "$Id: m_misc.c 111 2005-09-17 20:50:46Z fraggle $";
#include <stdio.h>
#include <stdlib.h>
@@ -363,6 +366,7 @@ static default_t extra_defaults_list[] =
{"fullscreen", &fullscreen},
{"screenmultiply", &screenmultiply},
{"novert", &novert},
+ {"mouse_acceleration", &mouse_acceleration, DEFAULT_FLOAT},
};
static default_collection_t extra_defaults =