From b7fced59e1d1690842f7ac8f286eb89d4c976189 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 25 Sep 2006 18:04:29 +0000 Subject: Add "test controls" mode - for setup.exe in the future. Start straight into the game with no melt effect and display a box showing mouse speed to allow the threshold to be set easily. When escape is pressed, quit straight away. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 662 --- src/g_game.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 131 insertions(+), 3 deletions(-) (limited to 'src/g_game.c') diff --git a/src/g_game.c b/src/g_game.c index 94a56ff8..4b6ec2f2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: g_game.c 641 2006-09-21 11:13:28Z rtc_marine $ +// $Id: g_game.c 662 2006-09-25 18:04:29Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -134,10 +134,11 @@ static const char -rcsid[] = "$Id: g_game.c 641 2006-09-21 11:13:28Z rtc_marine $"; +rcsid[] = "$Id: g_game.c 662 2006-09-25 18:04:29Z fraggle $"; #include #include +#include #include "doomdef.h" #include "doomstat.h" @@ -153,6 +154,7 @@ rcsid[] = "$Id: g_game.c 641 2006-09-21 11:13:28Z rtc_marine $"; #include "m_random.h" #include "i_system.h" #include "i_timer.h" +#include "i_video.h" #include "p_setup.h" #include "p_saveg.h" @@ -260,6 +262,8 @@ byte* demoend; boolean singledemo; // quit after playing a demo from cmdline boolean precache = true; // if true, load all graphics at start + +boolean testcontrols = false; // Invoked by setup to test controls wbstartstruct_t wminfo; // parms for world map / intermission @@ -336,6 +340,7 @@ boolean* joybuttons = &joyarray[1]; // allow [-1] int savegameslot; char savedescription[32]; +int testcontrols_mousespeed; #define BODYQUESIZE 32 @@ -345,6 +350,106 @@ int bodyqueslot; int vanilla_savegame_limit = 1; int vanilla_demo_limit = 1; + +#define MOUSE_SPEED_BOX_WIDTH 16 +#define COLOR_RED 0xb0 +#define COLOR_BLACK 0x00 +#define COLOR_WHITE 0xff + +void G_DrawMouseSpeedBox(void) +{ + extern int usemouse; + int i; + int box_x, box_y; + int original_speed; + int x, y; + int redline_x; + int linelen; + char *lumpname; + int color; + + // If the mouse is turned off or acceleration is turned off, don't + // draw the box at all. + + if (!usemouse || fabs(mouse_acceleration - 1) < 0.01) + { + return; + } + + // Calculate box position + + box_x = SCREENWIDTH - MOUSE_SPEED_BOX_WIDTH * 8; + box_y = SCREENHEIGHT - 9; + + // Draw the box. + + x = box_x; + + for (i=0; iangleturn -= mousex*0x8; + if (mousex == 0) + { + // No movement in the previous frame + + testcontrols_mousespeed = 0; + } + mousex = mousey = 0; if (forward > MAXPLMOVE) @@ -640,6 +752,11 @@ void G_DoLoadLevel (void) sendpause = sendsave = paused = false; memset (mousebuttons, 0, sizeof(mousebuttons)); memset (joybuttons, 0, sizeof(joybuttons)); + + if (testcontrols) + { + players[consoleplayer].message = "Press escape to quit."; + } } @@ -700,7 +817,18 @@ boolean G_Responder (event_t* ev) if (F_Responder (ev)) return true; // finale ate the event } - + + if (testcontrols && ev->type == ev_mouse) + { + // If we are invoked by setup to test the controls, save the + // mouse speed so that we can display it on-screen. + // Perform a low pass filter on this so that the thermometer + // appears to move smoothly. + + testcontrols_mousespeed = ((testcontrols_mousespeed * 2) + + abs(ev->data2)) / 3; + } + switch (ev->type) { case ev_keydown: -- cgit v1.2.3