summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2005-07-25 20:50:55 +0000
committerSimon Howard2005-07-25 20:50:55 +0000
commit1e30507db78e1361b409cd7e5ca0f231a7c5a016 (patch)
treed7cbfdfff68042c77898f934b17fc201b6f8ba1d /src
parent0f9690eb41e0aecbc6cee2d6c335b9dfbf0e02bf (diff)
downloadchocolate-doom-1e30507db78e1361b409cd7e5ca0f231a7c5a016.tar.gz
chocolate-doom-1e30507db78e1361b409cd7e5ca0f231a7c5a016.tar.bz2
chocolate-doom-1e30507db78e1361b409cd7e5ca0f231a7c5a016.zip
mouse
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 29
Diffstat (limited to 'src')
-rw-r--r--src/i_video.c58
1 files changed, 53 insertions, 5 deletions
diff --git a/src/i_video.c b/src/i_video.c
index 50357883..212855c2 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_video.c 26 2005-07-24 02:14:04Z fraggle $
+// $Id: i_video.c 29 2005-07-25 20:50:55Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.7 2005/07/25 20:50:55 fraggle
+// mouse
+//
// Revision 1.6 2005/07/24 02:14:04 fraggle
// Move to SDL for graphics.
// Translate key scancodes to correct internal format when reading
@@ -50,7 +53,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: i_video.c 26 2005-07-24 02:14:04Z fraggle $";
+rcsid[] = "$Id: i_video.c 29 2005-07-25 20:50:55Z fraggle $";
#include <ctype.h>
#include <SDL.h>
@@ -63,7 +66,7 @@ rcsid[] = "$Id: i_video.c 26 2005-07-24 02:14:04Z fraggle $";
#include "doomdef.h"
-SDL_Surface *screen;
+static SDL_Surface *screen;
#define POINTER_WARP_COUNTDOWN 1
@@ -71,7 +74,6 @@ SDL_Surface *screen;
// This cannot work properly w/o DGA.
// Needs an invisible mouse cursor at least.
boolean grabMouse;
-int doPointerWarp = POINTER_WARP_COUNTDOWN;
// Blocky mode,
// replace each 320x200 pixel with multiply*multiply pixels.
@@ -178,6 +180,21 @@ void I_StartFrame (void)
}
+static int mousebuttonstate(void)
+{
+ Uint8 state = SDL_GetMouseState(NULL, NULL);
+ int result = 0;
+
+ if (state & SDL_BUTTON(1))
+ result |= 1;
+ if (state & SDL_BUTTON(2))
+ result |= 2;
+ if (state & SDL_BUTTON(3))
+ result |= 4;
+
+ return result;
+}
+
static int lastmousex = 0;
static int lastmousey = 0;
boolean mousemoved = false;
@@ -203,6 +220,26 @@ void I_GetEvent(void)
event.data1 = xlatekey(&sdlevent.key.keysym);
D_PostEvent(&event);
break;
+ case SDL_MOUSEMOTION:
+ event.type = ev_mouse;
+ event.data1 = mousebuttonstate();
+ event.data2 = sdlevent.motion.xrel * 8;
+ event.data3 = -sdlevent.motion.yrel * 8;
+ D_PostEvent(&event);
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ event.type = ev_mouse;
+ event.data1 = mousebuttonstate();
+ event.data2 = event.data3 = 0;
+ D_PostEvent(&event);
+ break;
+ case SDL_MOUSEBUTTONUP:
+ event.type = ev_mouse;
+ event.data1 = mousebuttonstate();
+ event.data2 = event.data3 = 0;
+ D_PostEvent(&event);
+ break;
+
#if 0
case ButtonPress:
event.type = ev_mouse;
@@ -487,9 +524,18 @@ void I_SetPalette (byte* palette)
void I_InitGraphics(void)
{
+ int flags = 0;
+
SDL_Init(SDL_INIT_VIDEO);
- screen = SDL_SetVideoMode(SCREENWIDTH, SCREENHEIGHT, 8, 0);
+// flags |= SDL_FULLSCREEN;
+
+ screen = SDL_SetVideoMode(SCREENWIDTH, SCREENHEIGHT, 8, flags);
+
+ if (screen == NULL)
+ {
+ I_Error("Error setting video mode: %s\n", SDL_GetError());
+ }
if (multiply == 1)
screens[0] = (unsigned char *) (screen->pixels);
@@ -497,6 +543,8 @@ void I_InitGraphics(void)
screens[0] = (unsigned char *) malloc (SCREENWIDTH * SCREENHEIGHT);
SDL_EnableUNICODE(1);
+ SDL_ShowCursor(0);
+ SDL_WM_GrabInput(SDL_GRAB_ON);
}