foxygit / doom Log in
commit 3771126689527293eb4ad658b338d7910bf79012
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Mon Oct 26 19:28:12 2009 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Mon Oct 26 19:28:12 2009 +0000

    Initial hacks for compiling under SDL 1.3.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 1726
---
 src/i_video.c        | 24 ++++++++++++++++++++++--
 textscreen/txt_sdl.c | 10 +++++++++-
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/i_video.c b/src/i_video.c
index 062c9c9c..481ee0ea 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -334,7 +334,9 @@ static int TranslateKey(SDL_keysym *sym)

       case SDLK_PAUSE:	return KEY_PAUSE;

+#if !SDL_VERSION_ATLEAST(1, 3, 0)
       case SDLK_EQUALS: return KEY_EQUALS;
+#endif

       case SDLK_MINUS:          return KEY_MINUS;

@@ -347,9 +349,11 @@ static int TranslateKey(SDL_keysym *sym)
 	return KEY_RCTRL;

       case SDLK_LALT:
-      case SDLK_LMETA:
       case SDLK_RALT:
+#if !SDL_VERSION_ATLEAST(1, 3, 0)
+      case SDLK_LMETA:
       case SDLK_RMETA:
+#endif
         return KEY_RALT;

       case SDLK_CAPSLOCK: return KEY_CAPSLOCK;
@@ -420,9 +424,15 @@ void I_StartFrame (void)

 static int MouseButtonState(void)
 {
-    Uint8 state = SDL_GetMouseState(NULL, NULL);
+    Uint8 state;
     int result = 0;

+#if SDL_VERSION_ATLEAST(1, 3, 0)
+    state = SDL_GetMouseState(0, NULL, NULL);
+#else
+    state = SDL_GetMouseState(NULL, NULL);
+#endif
+
     // Note: button "0" is left, button "1" is right,
     // button "2" is middle for Doom.  This is different
     // to how SDL sees things.
@@ -585,7 +595,11 @@ static void CenterMouse(void)
     // Clear any relative movement caused by warping

     SDL_PumpEvents();
+#if SDL_VERSION_ATLEAST(1, 3, 0)
+    SDL_GetRelativeMouseState(0, NULL, NULL);
+#else
     SDL_GetRelativeMouseState(NULL, NULL);
+#endif
 }

 //
@@ -599,7 +613,11 @@ static void I_ReadMouse(void)
     int x, y;
     event_t ev;

+#if SDL_VERSION_ATLEAST(1, 3, 0)
+    SDL_GetRelativeMouseState(0, &x, &y);
+#else
     SDL_GetRelativeMouseState(&x, &y);
+#endif

     if (x != 0 || y != 0)
     {
@@ -1553,7 +1571,9 @@ void I_InitGraphics(void)
     // has to be done before the call to SDL_SetVideoMode.

     I_SetWindowCaption();
+#if !SDL_VERSION_ATLEAST(1, 3, 0)
     I_SetWindowIcon();
+#endif

     // Set the video mode.

diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c
index 0b11aeab..4f8bc2a8 100644
--- a/textscreen/txt_sdl.c
+++ b/textscreen/txt_sdl.c
@@ -285,7 +285,11 @@ void TXT_UpdateScreen(void)

 void TXT_GetMousePosition(int *x, int *y)
 {
+#if SDL_VERSION_ATLEAST(1, 3, 0)
+    SDL_GetMouseState(0, x, y);
+#else
     SDL_GetMouseState(x, y);
+#endif

     *x /= font->w;
     *y /= font->h;
@@ -324,7 +328,9 @@ static int TranslateKey(SDL_keysym *sym)

         case SDLK_PAUSE:       return KEY_PAUSE;

+#if !SDL_VERSION_ATLEAST(1, 3, 0)
         case SDLK_EQUALS:      return KEY_EQUALS;
+#endif

         case SDLK_LSHIFT:
         case SDLK_RSHIFT:
@@ -335,9 +341,11 @@ static int TranslateKey(SDL_keysym *sym)
                                return KEY_RCTRL;

         case SDLK_LALT:
-        case SDLK_LMETA:
         case SDLK_RALT:
+#if !SDL_VERSION_ATLEAST(1, 3, 0)
+        case SDLK_LMETA:
         case SDLK_RMETA:
+#endif
                                return KEY_RALT;

         case SDLK_CAPSLOCK:    return KEY_CAPSLOCK;