removed support for SDL 1.2
authorHolger Schemel <info@artsoft.org>
Wed, 14 Nov 2018 22:30:20 +0000 (23:30 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 14 Nov 2018 22:30:20 +0000 (23:30 +0100)
16 files changed:
src/Makefile
src/config.c
src/events.c
src/events.h
src/files.c
src/init.c
src/libgame/misc.c
src/libgame/sdl.c
src/libgame/sdl.h
src/libgame/system.c
src/libgame/system.h
src/main.c
src/main.h
src/network.c
src/screens.c
src/tools.c

index 0f98d356035c7cb823d146003df6ddd29906c9bc..0c195c0c65eca673a680d9900ab323a860508675 100644 (file)
@@ -58,26 +58,19 @@ endif
 # configuring target
 # -----------------------------------------------------------------------------
 
-ifndef TARGET                          # auto-detect compiling for SDL or SDL2
+ifndef TARGET                          # auto-detect compiling for SDL2
   SDL_VERSION := $(shell sdl2-config --version 2> /dev/null)
   ifdef SDL_VERSION
     TARGET = sdl2
   else
-    SDL_VERSION := $(shell sdl-config --version 2> /dev/null)
-    ifdef SDL_VERSION
-      TARGET = sdl
-    else
-      $(error SDL/SDL2 library not found)
-    endif
+    $(error SDL2 library not found)
   endif
 endif
 
 # $(info Using SDL version $(SDL_VERSION) [TARGET == $(TARGET)])
 
 ifeq ($(TARGET),sdl)                   # compiling for SDL target
-SYS_CFLAGS = -DTARGET_SDL $(shell sdl-config --cflags)
-SDL_LIBS = -lSDL_image -lSDL_mixer -lSDL_net
-SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl-config --libs)
+  $(error SDL library version 1.2 not supported anymore)
 endif
 
 ifeq ($(TARGET),sdl2)                  # compiling for SDL2 target
index f5c47238b47dee4d66aa6d60f1d6cd6925402bb5..8c4f1b5a8602e10069126e582d721b170f419b8a 100644 (file)
@@ -99,8 +99,6 @@ char *getWindowTitleString(void)
 
   checked_free(window_title_string);
 
-#if defined(TARGET_SDL2)
-
 #ifdef DEBUG
   window_title_string = checked_malloc(strlen(getProgramInitString()) + 20 +
                                       strlen(getSourceDateString()) + 2 + 1);
@@ -122,23 +120,6 @@ char *getWindowTitleString(void)
   else
     sprintf(window_title_string, "%s",
            getProgramInitString());
-#endif
-
-#else
-
-#ifdef DEBUG
-  window_title_string = checked_malloc(strlen(getProgramInitString()) + 1 +
-                                      strlen(getSourceDateString()) + 2 + 1);
-
-  sprintf(window_title_string, "%s [%s]",
-         getProgramInitString(), getSourceDateString());
-#else
-  window_title_string = checked_malloc(strlen(getProgramInitString()) + 1);
-
-  sprintf(window_title_string, "%s",
-         getProgramInitString());
-#endif
-
 #endif
 
   return window_title_string;
index 5a3d0ca8c3bf75653ddfb5bdbc0877cda6d586a4..7e1f293f9b067cf5792ac4385f1e24a708a3e8b4 100644 (file)
@@ -56,13 +56,11 @@ static int FilterEvents(const Event *event)
 {
   MotionEvent *motion;
 
-#if defined(TARGET_SDL2)
   // skip repeated key press events if keyboard auto-repeat is disabled
   if (event->type == EVENT_KEYPRESS &&
       event->key.repeat &&
       !keyrepeat_status)
     return 0;
-#endif
 
   if (event->type == EVENT_BUTTONPRESS ||
       event->type == EVENT_BUTTONRELEASE)
@@ -185,7 +183,6 @@ static void HandleEvents(void)
        HandleMotionEvent((MotionEvent *) &event);
        break;
 
-#if defined(TARGET_SDL2)
       case EVENT_WHEELMOTION:
        HandleWheelEvent((WheelEvent *) &event);
        break;
@@ -210,7 +207,6 @@ static void HandleEvents(void)
       case SDL_APP_DIDENTERFOREGROUND:
        HandlePauseResumeEvent((PauseResumeEvent *) &event);
        break;
-#endif
 
       case EVENT_KEYPRESS:
       case EVENT_KEYRELEASE:
@@ -253,8 +249,6 @@ void HandleOtherEvents(Event *event)
       HandleClientMessageEvent((ClientMessageEvent *) event);
       break;
 
-#if defined(TARGET_SDL)
-#if defined(TARGET_SDL2)
     case SDL_CONTROLLERBUTTONDOWN:
     case SDL_CONTROLLERBUTTONUP:
       // for any game controller button event, disable overlay buttons
@@ -266,7 +260,6 @@ void HandleOtherEvents(Event *event)
     case SDL_CONTROLLERDEVICEADDED:
     case SDL_CONTROLLERDEVICEREMOVED:
     case SDL_CONTROLLERAXISMOTION:
-#endif
     case SDL_JOYAXISMOTION:
     case SDL_JOYBUTTONDOWN:
     case SDL_JOYBUTTONUP:
@@ -276,7 +269,6 @@ void HandleOtherEvents(Event *event)
     case SDL_SYSWMEVENT:
       HandleWindowManagerEvent(event);
       break;
-#endif
 
     default:
       break;
@@ -349,7 +341,6 @@ void EventLoop(void)
 
 void ClearAutoRepeatKeyEvents(void)
 {
-#if defined(TARGET_SDL2)
   while (PendingEvent())
   {
     Event next_event;
@@ -363,7 +354,6 @@ void ClearAutoRepeatKeyEvents(void)
     else
       break;
   }
-#endif
 }
 
 void ClearEventQueue(void)
@@ -382,12 +372,10 @@ void ClearEventQueue(void)
        ClearPlayerAction();
        break;
 
-#if defined(TARGET_SDL2)
       case SDL_CONTROLLERBUTTONUP:
        HandleJoystickEvent(&event);
        ClearPlayerAction();
        break;
-#endif
 
       default:
        HandleOtherEvents(&event);
@@ -467,12 +455,10 @@ void SleepWhileUnmapped(void)
        key_joystick_mapping = 0;
        break;
 
-#if defined(TARGET_SDL2)
       case SDL_CONTROLLERBUTTONUP:
        HandleJoystickEvent(&event);
        key_joystick_mapping = 0;
        break;
-#endif
 
       case EVENT_MAPNOTIFY:
        window_unmapped = FALSE;
@@ -540,8 +526,6 @@ void HandleMotionEvent(MotionEvent *event)
   HandleButton(event->x, event->y, button_status, button_status);
 }
 
-#if defined(TARGET_SDL2)
-
 void HandleWheelEvent(WheelEvent *event)
 {
   int button_nr;
@@ -1037,8 +1021,6 @@ void HandleFingerEvent(FingerEvent *event)
     HandleFingerEvent_WipeGestures(event);
 }
 
-#endif
-
 static void HandleButtonOrFinger_WipeGestures_MM(int mx, int my, int button)
 {
   static int old_mx = 0, old_my = 0;
@@ -1398,8 +1380,6 @@ static void HandleButtonOrFinger(int mx, int my, int button)
   }
 }
 
-#if defined(TARGET_SDL2)
-
 static boolean checkTextInputKeyModState(void)
 {
   // when playing, only handle raw key events and ignore text input
@@ -1448,8 +1428,6 @@ void HandlePauseResumeEvent(PauseResumeEvent *event)
   }
 }
 
-#endif
-
 void HandleKeyEvent(KeyEvent *event)
 {
   int key_status = (event->type == EVENT_KEYPRESS ? KEY_PRESSED : KEY_RELEASED);
@@ -1483,13 +1461,9 @@ void HandleKeyEvent(KeyEvent *event)
 
   HandleKeyModState(keymod, key_status);
 
-#if defined(TARGET_SDL2)
   // only handle raw key input without text modifier keys pressed
   if (!checkTextInputKeyModState())
     HandleKey(key, key_status);
-#else
-  HandleKey(key, key_status);
-#endif
 }
 
 void HandleFocusEvent(FocusChangeEvent *event)
@@ -1540,9 +1514,7 @@ void HandleClientMessageEvent(ClientMessageEvent *event)
 
 void HandleWindowManagerEvent(Event *event)
 {
-#if defined(TARGET_SDL)
   SDLHandleWindowManagerEvent(event);
-#endif
 }
 
 void HandleButton(int mx, int my, int button, int button_nr)
@@ -1884,13 +1856,11 @@ void HandleKey(Key key, int key_status)
   int joy = 0;
   int i;
 
-#if defined(TARGET_SDL2)
   // map special keys (media keys / remote control buttons) to default keys
   if (key == KSYM_PlayPause)
     key = KSYM_space;
   else if (key == KSYM_Select)
     key = KSYM_Return;
-#endif
 
   HandleSpecialGameControllerKeys(key, key_status);
 
@@ -2471,7 +2441,6 @@ void HandleJoystick(void)
 
 void HandleSpecialGameControllerButtons(Event *event)
 {
-#if defined(TARGET_SDL2)
   int key_status;
   Key key;
 
@@ -2504,12 +2473,10 @@ void HandleSpecialGameControllerButtons(Event *event)
   }
 
   HandleKey(key, key_status);
-#endif
 }
 
 void HandleSpecialGameControllerKeys(Key key, int key_status)
 {
-#if defined(TARGET_SDL2)
 #if defined(KSYM_Rewind) && defined(KSYM_FastForward)
   int button = SDL_CONTROLLER_BUTTON_INVALID;
 
@@ -2534,7 +2501,6 @@ void HandleSpecialGameControllerKeys(Key key, int key_status)
     HandleJoystickEvent(&event);
   }
 #endif
-#endif
 }
 
 boolean DoKeysymAction(int keysym)
index 3234877318cb54c6333c6d5981a5650ec8f52c0c..47a86c5673aa073d34bfb9402ea217d99a04f833 100644 (file)
@@ -26,13 +26,11 @@ void SleepWhileUnmapped(void);
 void HandleExposeEvent(ExposeEvent *);
 void HandleButtonEvent(ButtonEvent *);
 void HandleMotionEvent(MotionEvent *);
-#if defined(TARGET_SDL2)
 void HandleWheelEvent(WheelEvent *);
 void HandleWindowEvent(WindowEvent *);
 void HandleFingerEvent(FingerEvent *);
 void HandleTextEvent(TextEvent *);
 void HandlePauseResumeEvent(PauseResumeEvent *);
-#endif
 void HandleKeysDebug(Key);
 void HandleKeyEvent(KeyEvent *);
 void HandleFocusEvent(FocusChangeEvent *);
index b5c92b98f5033e4b3fce32cc156f645d6b6bdf2a..322c5165a91ec4641555ca84aadc4b35e6e32c25 100644 (file)
@@ -11043,7 +11043,6 @@ void ConvertLevels(void)
 
 void CreateLevelSketchImages(void)
 {
-#if defined(TARGET_SDL)
   Bitmap *bitmap1;
   Bitmap *bitmap2;
   int i;
@@ -11099,7 +11098,6 @@ void CreateLevelSketchImages(void)
   Error(ERR_INFO, "%d normal and small images created", NUM_FILE_ELEMENTS);
 
   CloseAllAndExit(0);
-#endif
 }
 
 
@@ -11109,7 +11107,6 @@ void CreateLevelSketchImages(void)
 
 void CreateCustomElementImages(char *directory)
 {
-#if defined(TARGET_SDL)
   char *src_basename = "RocksCE-template.ilbm";
   char *dst_basename = "RocksCE.bmp";
   char *src_filename = getPath2(directory, src_basename);
@@ -11201,5 +11198,4 @@ void CreateCustomElementImages(char *directory)
   FreeBitmap(bitmap);
 
   CloseAllAndExit(0);
-#endif
 }
index 3ab46d0f1b2b54e31265149df4209e1dcc6b3016..3f060862a525d58b3a7c8c6d94cbed331db9f1f5 100644 (file)
@@ -6194,16 +6194,13 @@ void CloseAllAndExit(int exit_value)
 
   FreeAllImages();
 
-#if defined(TARGET_SDL)
-#if defined(TARGET_SDL2)
   // !!! TODO !!!
   // set a flag to tell the network server thread to quit and wait for it
   // using SDL_WaitThread()
-#else
-  if (network_server)  // terminate network server
-    SDL_KillThread(server_thread);
-#endif
-#endif
+  //
+  // Code used with SDL 1.2:
+  // if (network_server)       // terminate network server
+  //   SDL_KillThread(server_thread);
 
   CloseVideoDisplay();
   ClosePlatformDependentStuff();
index da88de962284c3897e3e6bbde4aacf51fda3fa62..5daeffcefb3d000f26a856153fb75b23f18b5342 100644 (file)
@@ -1552,10 +1552,6 @@ static void translate_keyname(Key *keysym, char **x11name, char **name, int mode
     { KSYM_Meta_R,     "XK_Meta_R",            "right meta" },
     { KSYM_Alt_L,      "XK_Alt_L",             "left alt" },
     { KSYM_Alt_R,      "XK_Alt_R",             "right alt" },
-#if !defined(TARGET_SDL2)
-    { KSYM_Super_L,    "XK_Super_L",           "left super" },  // Win-L
-    { KSYM_Super_R,    "XK_Super_R",           "right super" }, // Win-R
-#endif
     { KSYM_Mode_switch,        "XK_Mode_switch",       "mode switch" }, // Alt-R
     { KSYM_Multi_key,  "XK_Multi_key",         "multi key" },   // Ctrl-R
 
@@ -1569,7 +1565,6 @@ static void translate_keyname(Key *keysym, char **x11name, char **name, int mode
     { KSYM_Page_Up,    "XK_Page_Up",           "page up" },
     { KSYM_Page_Down,  "XK_Page_Down",         "page down" },
 
-#if defined(TARGET_SDL2)
     { KSYM_Select,     "XK_Select",            "select" },
     { KSYM_Menu,       "XK_Menu",              "menu" },        // menu key
     { KSYM_Back,       "XK_Back",              "back" },        // back key
@@ -1577,7 +1572,6 @@ static void translate_keyname(Key *keysym, char **x11name, char **name, int mode
 #if defined(PLATFORM_ANDROID)
     { KSYM_Rewind,     "XK_Rewind",            "rewind" },
     { KSYM_FastForward,        "XK_FastForward",       "fast forward" },
-#endif
 #endif
 
     // ASCII 0x20 to 0x40 keys (except numbers)
@@ -1628,7 +1622,6 @@ static void translate_keyname(Key *keysym, char **x11name, char **name, int mode
     { KSYM_udiaeresis, "XK_udiaeresis",        "u umlaut" },
     { KSYM_ssharp,     "XK_ssharp",            "sharp s" },
 
-#if defined(TARGET_SDL2)
     // special (non-ASCII) keys (UTF-8, for reverse mapping only)
     { KSYM_degree,     "XK_degree",            "\xc2\xb0" },
     { KSYM_Adiaeresis, "XK_Adiaeresis",        "\xc3\x84" },
@@ -1641,9 +1634,7 @@ static void translate_keyname(Key *keysym, char **x11name, char **name, int mode
 
     // other keys (for reverse mapping only)
     { KSYM_space,      "XK_space",             " " },
-#endif
 
-#if defined(TARGET_SDL2)
     // keypad keys are not in numerical order in SDL2
     { KSYM_KP_0,       "XK_KP_0",              "keypad 0" },
     { KSYM_KP_1,       "XK_KP_1",              "keypad 1" },
@@ -1655,7 +1646,6 @@ static void translate_keyname(Key *keysym, char **x11name, char **name, int mode
     { KSYM_KP_7,       "XK_KP_7",              "keypad 7" },
     { KSYM_KP_8,       "XK_KP_8",              "keypad 8" },
     { KSYM_KP_9,       "XK_KP_9",              "keypad 9" },
-#endif
 
     // end-of-array identifier
     { 0,                NULL,                  NULL }
@@ -1674,10 +1664,6 @@ static void translate_keyname(Key *keysym, char **x11name, char **name, int mode
       sprintf(name_buffer, "%c", 'a' + (char)(key - KSYM_a));
     else if (key >= KSYM_0 && key <= KSYM_9)
       sprintf(name_buffer, "%c", '0' + (char)(key - KSYM_0));
-#if !defined(TARGET_SDL2)
-    else if (key >= KSYM_KP_0 && key <= KSYM_KP_9)
-      sprintf(name_buffer, "keypad %c", '0' + (char)(key - KSYM_KP_0));
-#endif
     else if (key >= KSYM_FKEY_FIRST && key <= KSYM_FKEY_LAST)
       sprintf(name_buffer, "F%d", (int)(key - KSYM_FKEY_FIRST + 1));
     else if (key == KSYM_UNDEFINED)
@@ -1713,10 +1699,6 @@ static void translate_keyname(Key *keysym, char **x11name, char **name, int mode
       sprintf(name_buffer, "XK_%c", 'a' + (char)(key - KSYM_a));
     else if (key >= KSYM_0 && key <= KSYM_9)
       sprintf(name_buffer, "XK_%c", '0' + (char)(key - KSYM_0));
-#if !defined(TARGET_SDL2)
-    else if (key >= KSYM_KP_0 && key <= KSYM_KP_9)
-      sprintf(name_buffer, "XK_KP_%c", '0' + (char)(key - KSYM_KP_0));
-#endif
     else if (key >= KSYM_FKEY_FIRST && key <= KSYM_FKEY_LAST)
       sprintf(name_buffer, "XK_F%d", (int)(key - KSYM_FKEY_FIRST + 1));
     else if (key == KSYM_UNDEFINED)
@@ -1794,15 +1776,6 @@ static void translate_keyname(Key *keysym, char **x11name, char **name, int mode
       else if (c >= '0' && c <= '9')
        key = KSYM_0 + (Key)(c - '0');
     }
-#if !defined(TARGET_SDL2)
-    else if (strPrefix(name_ptr, "XK_KP_") && strlen(name_ptr) == 7)
-    {
-      char c = name_ptr[6];
-
-      if (c >= '0' && c <= '9')
-       key = KSYM_KP_0 + (Key)(c - '0');
-    }
-#endif
     else if (strPrefix(name_ptr, "XK_F") && strlen(name_ptr) <= 6)
     {
       char c1 = name_ptr[4];
index bdbe5a4b60eb3399427e993f59ccfc7c7ca727f7..a4fc6fa09d0d6c6465606f2ef808c40e209e013e 100644 (file)
 // ============================================================================
 
 // SDL internal variables
-#if defined(TARGET_SDL2)
 static SDL_Window *sdl_window = NULL;
 static SDL_Renderer *sdl_renderer = NULL;
 static SDL_Texture *sdl_texture_stream = NULL;
 static SDL_Texture *sdl_texture_target = NULL;
 static boolean fullscreen_enabled = FALSE;
-#endif
-
 static boolean limit_screen_updates = FALSE;
 
 
@@ -114,7 +111,6 @@ static void UpdateScreenExt(SDL_Rect *rect, boolean with_frame_delay)
     rect = NULL;
   }
 
-#if defined(TARGET_SDL2)
   SDL_Texture *sdl_texture = sdl_texture_stream;
 
   // deactivate use of target texture if render targets are not supported
@@ -216,23 +212,14 @@ static void UpdateScreenExt(SDL_Rect *rect, boolean with_frame_delay)
 #if defined(USE_TOUCH_INPUT_OVERLAY)
   // draw overlay graphics for touch device input, if needed
   DrawTouchInputOverlay();
-#endif
-
 #endif
 
   // global synchronization point of the game to align video frame delay
   if (with_frame_delay)
     WaitUntilDelayReached(&video.frame_delay, video.frame_delay_value);
 
-#if defined(TARGET_SDL2)
- // show render target buffer on screen
+  // show render target buffer on screen
   SDL_RenderPresent(sdl_renderer);
-#else  // TARGET_SDL
-  if (rect)
-    SDL_UpdateRects(screen, 1, rect);
-  else
-    SDL_UpdateRect(screen, 0, 0, 0, 0);
-#endif
 }
 
 static void UpdateScreen_WithFrameDelay(SDL_Rect *rect)
@@ -286,16 +273,10 @@ static void SDLSetWindowIcon(char *basename)
   SDL_SetColorKey(surface, SET_TRANSPARENT_PIXEL,
                  SDL_MapRGB(surface->format, 0x00, 0x00, 0x00));
 
-#if defined(TARGET_SDL2)
   SDL_SetWindowIcon(sdl_window, surface);
-#else
-  SDL_WM_SetIcon(surface, NULL);
-#endif
 #endif
 }
 
-#if defined(TARGET_SDL2)
-
 static boolean equalSDLPixelFormat(SDL_PixelFormat *format1,
                                   SDL_PixelFormat *format2)
 {
@@ -389,74 +370,6 @@ boolean SDLSetNativeSurface(SDL_Surface **surface)
   return TRUE;
 }
 
-#else
-
-static Pixel SDLGetColorKey(SDL_Surface *surface)
-{
-  if ((surface->flags & SDL_SRCCOLORKEY) == 0)
-    return -1;
-
-  return surface->format->colorkey;
-}
-
-static boolean SDLHasColorKey(SDL_Surface *surface)
-{
-  return (SDLGetColorKey(surface) != -1);
-}
-
-static boolean SDLHasAlpha(SDL_Surface *surface)
-{
-  return ((surface->flags & SDL_SRCALPHA) != 0);
-}
-
-static void SDLSetAlpha(SDL_Surface *surface, boolean set, int alpha)
-{
-  SDL_SetAlpha(surface, (set ? SDL_SRCALPHA : 0), alpha);
-}
-
-SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface)
-{
-  SDL_Surface *new_surface;
-
-  if (surface == NULL)
-    return NULL;
-
-  if (!video.initialized)
-    new_surface = SDL_ConvertSurface(surface, surface->format, SURFACE_FLAGS);
-  else if (SDLHasAlpha(surface))
-    new_surface = SDL_DisplayFormatAlpha(surface);
-  else
-    new_surface = SDL_DisplayFormat(surface);
-
-  if (new_surface == NULL)
-    Error(ERR_EXIT, "%s() failed: %s",
-         (video.initialized ? "SDL_DisplayFormat" : "SDL_ConvertSurface"),
-         SDL_GetError());
-
-  return new_surface;
-}
-
-boolean SDLSetNativeSurface(SDL_Surface **surface)
-{
-  SDL_Surface *new_surface;
-
-  if (surface == NULL ||
-      *surface == NULL ||
-      !video.initialized)
-    return FALSE;
-
-  new_surface = SDLGetNativeSurface(*surface);
-
-  SDL_FreeSurface(*surface);
-
-  *surface = new_surface;
-
-  return TRUE;
-}
-
-#endif
-
-#if defined(TARGET_SDL2)
 static SDL_Texture *SDLCreateTextureFromSurface(SDL_Surface *surface)
 {
   if (program.headless)
@@ -470,11 +383,9 @@ static SDL_Texture *SDLCreateTextureFromSurface(SDL_Surface *surface)
 
   return texture;
 }
-#endif
 
 void SDLCreateBitmapTextures(Bitmap *bitmap)
 {
-#if defined(TARGET_SDL2)
   if (bitmap == NULL)
     return;
 
@@ -485,12 +396,10 @@ void SDLCreateBitmapTextures(Bitmap *bitmap)
 
   bitmap->texture        = SDLCreateTextureFromSurface(bitmap->surface);
   bitmap->texture_masked = SDLCreateTextureFromSurface(bitmap->surface_masked);
-#endif
 }
 
 void SDLFreeBitmapTextures(Bitmap *bitmap)
 {
-#if defined(TARGET_SDL2)
   if (bitmap == NULL)
     return;
 
@@ -501,28 +410,19 @@ void SDLFreeBitmapTextures(Bitmap *bitmap)
 
   bitmap->texture = NULL;
   bitmap->texture_masked = NULL;
-#endif
 }
 
 void SDLInitVideoDisplay(void)
 {
-#if !defined(TARGET_SDL2)
-  if (!strEqual(setup.system.sdl_videodriver, ARG_DEFAULT))
-    SDL_putenv(getStringCat2("SDL_VIDEODRIVER=", setup.system.sdl_videodriver));
-
-  SDL_putenv("SDL_VIDEO_CENTERED=1");
-#endif
-
   // initialize SDL video
   if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
     Error(ERR_EXIT, "SDL_InitSubSystem() failed: %s", SDL_GetError());
 
   // set default SDL depth
-#if !defined(TARGET_SDL2)
-  video.default_depth = SDL_GetVideoInfo()->vfmt->BitsPerPixel;
-#else
   video.default_depth = 32;    // (how to determine video depth in SDL2?)
-#endif
+  //
+  // Code used with SDL 1.2:
+  // video.default_depth = SDL_GetVideoInfo()->vfmt->BitsPerPixel;
 }
 
 static void SDLInitVideoBuffer_VideoBuffer(boolean fullscreen)
@@ -535,13 +435,8 @@ static void SDLInitVideoBuffer_VideoBuffer(boolean fullscreen)
 
   SDLSetScreenRenderingMode(setup.screen_rendering_mode);
 
-#if defined(TARGET_SDL2)
   // SDL 2.0: support for (desktop) fullscreen mode available
   video.fullscreen_available = TRUE;
-#else
-  // SDL 1.2: no support for fullscreen mode in R'n'D anymore
-  video.fullscreen_available = FALSE;
-#endif
 
   // open SDL video output device (window or fullscreen mode)
   if (!SDLSetVideoMode(fullscreen))
@@ -588,15 +483,9 @@ static boolean SDLCreateScreen(boolean fullscreen)
 {
   SDL_Surface *new_surface = NULL;
 
-#if defined(TARGET_SDL2)
   int surface_flags_window     = SURFACE_FLAGS | SDL_WINDOW_RESIZABLE;
   int surface_flags_fullscreen = SURFACE_FLAGS | SDL_WINDOW_FULLSCREEN_DESKTOP;
-#else
-  int surface_flags_window     = SURFACE_FLAGS;
-  int surface_flags_fullscreen = SURFACE_FLAGS;        // (no fullscreen in SDL 1.2)
-#endif
 
-#if defined(TARGET_SDL2)
 #if 1
   int renderer_flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
 #else
@@ -608,7 +497,6 @@ static boolean SDLCreateScreen(boolean fullscreen)
 #endif
 
   SDLSetScreenSizeAndOffsets(video.width, video.height);
-#endif
 
   int width  = video.width;
   int height = video.height;
@@ -621,8 +509,6 @@ static boolean SDLCreateScreen(boolean fullscreen)
   video.window_width  = screen_width;
   video.window_height = screen_height;
 
-#if defined(TARGET_SDL2)
-
   // store if initial screen mode is fullscreen mode when changing screen size
   video.fullscreen_initial = fullscreen;
 
@@ -713,42 +599,9 @@ static boolean SDLCreateScreen(boolean fullscreen)
     Error(ERR_WARN, "SDL_CreateWindow() failed: %s", SDL_GetError());
   }
 
-#else  // TARGET_SDL
-
-  if (gfx.final_screen_bitmap == NULL)
-    gfx.final_screen_bitmap = CreateBitmapStruct();
-
-  gfx.final_screen_bitmap->width = width;
-  gfx.final_screen_bitmap->height = height;
-
-  gfx.final_screen_bitmap->surface =
-    SDL_SetVideoMode(width, height, video.depth, surface_flags);
-
-  if (gfx.final_screen_bitmap->surface != NULL)
-  {
-    new_surface =
-      SDL_CreateRGBSurface(surface_flags, width, height, video.depth, 0,0,0, 0);
-
-    if (new_surface == NULL)
-      Error(ERR_WARN, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
-
-#if 0
-    new_surface = gfx.final_screen_bitmap->surface;
-    gfx.final_screen_bitmap = NULL;
-#endif
-
-  }
-  else
-  {
-    Error(ERR_WARN, "SDL_SetVideoMode() failed: %s", SDL_GetError());
-  }
-#endif
-
-#if defined(TARGET_SDL2)
   // store fullscreen state ("video.fullscreen_enabled" may not reflect this!)
   if (new_surface != NULL)
     fullscreen_enabled = fullscreen;
-#endif
 
   if (backbuffer == NULL)
     backbuffer = CreateBitmapStruct();
@@ -805,9 +658,7 @@ boolean SDLSetVideoMode(boolean fullscreen)
     }
   }
 
-#if defined(TARGET_SDL2)
   SDLRedrawWindow();                   // map window
-#endif
 
 #ifdef DEBUG
 #if defined(PLATFORM_WIN32)
@@ -821,20 +672,13 @@ boolean SDLSetVideoMode(boolean fullscreen)
     boolean wminfo_success = FALSE;
 
     SDL_VERSION(&wminfo.version);
-#if defined(TARGET_SDL2)
+
     if (sdl_window)
       wminfo_success = SDL_GetWindowWMInfo(sdl_window, &wminfo);
-#else
-    wminfo_success = (SDL_GetWMInfo(&wminfo) == 1);
-#endif
 
     if (wminfo_success)
     {
-#if defined(TARGET_SDL2)
       hwnd = wminfo.info.win.window;
-#else
-      hwnd = wminfo.window;
-#endif
 
       DragAcceptFiles(hwnd, TRUE);
     }
@@ -847,17 +691,12 @@ boolean SDLSetVideoMode(boolean fullscreen)
 
 void SDLSetWindowTitle(void)
 {
-#if defined(TARGET_SDL2)
   if (sdl_window == NULL)
     return;
 
   SDL_SetWindowTitle(sdl_window, program.window_title);
-#else
-  SDL_WM_SetCaption(program.window_title, program.window_title);
-#endif
 }
 
-#if defined(TARGET_SDL2)
 void SDLSetWindowScaling(int window_scaling_percent)
 {
   if (sdl_window == NULL)
@@ -998,11 +837,8 @@ void SDLSetScreenProperties(void)
   SDLSetScreenSizeForRenderer(video.screen_width, video.screen_height);
 }
 
-#endif
-
 void SDLSetScreenRenderingMode(char *screen_rendering_mode)
 {
-#if defined(TARGET_SDL2)
   video.screen_rendering_mode =
     (strEqual(screen_rendering_mode, STR_SPECIAL_RENDERING_BITMAP) ?
      SPECIAL_RENDERING_BITMAP :
@@ -1010,14 +846,10 @@ void SDLSetScreenRenderingMode(char *screen_rendering_mode)
      SPECIAL_RENDERING_TARGET:
      strEqual(screen_rendering_mode, STR_SPECIAL_RENDERING_DOUBLE) ?
      SPECIAL_RENDERING_DOUBLE : SPECIAL_RENDERING_OFF);
-#else
-  video.screen_rendering_mode = SPECIAL_RENDERING_BITMAP;
-#endif
 }
 
 void SDLSetScreenVsyncMode(char *vsync_mode)
 {
-#if defined(TARGET_SDL2)
   int interval =
     (strEqual(vsync_mode, STR_VSYNC_MODE_NORMAL)   ? VSYNC_MODE_NORMAL :
      strEqual(vsync_mode, STR_VSYNC_MODE_ADAPTIVE) ? VSYNC_MODE_ADAPTIVE :
@@ -1027,7 +859,6 @@ void SDLSetScreenVsyncMode(char *vsync_mode)
   // if adaptive vsync requested, but not supported, retry with normal vsync
   if (result == -1 && interval == VSYNC_MODE_ADAPTIVE)
     SDL_GL_SetSwapInterval(VSYNC_MODE_NORMAL);
-#endif
 }
 
 void SDLRedrawWindow(void)
@@ -1062,7 +893,6 @@ void SDLFreeBitmapPointers(Bitmap *bitmap)
   bitmap->surface = NULL;
   bitmap->surface_masked = NULL;
 
-#if defined(TARGET_SDL2)
   if (bitmap->texture)
     SDL_DestroyTexture(bitmap->texture);
   if (bitmap->texture_masked)
@@ -1070,7 +900,6 @@ void SDLFreeBitmapPointers(Bitmap *bitmap)
 
   bitmap->texture = NULL;
   bitmap->texture_masked = NULL;
-#endif
 }
 
 void SDLCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap,
@@ -1104,7 +933,6 @@ void SDLBlitTexture(Bitmap *bitmap,
                    int src_x, int src_y, int width, int height,
                    int dst_x, int dst_y, int mask_mode)
 {
-#if defined(TARGET_SDL2)
   SDL_Texture *texture;
   SDL_Rect src_rect;
   SDL_Rect dst_rect;
@@ -1126,7 +954,6 @@ void SDLBlitTexture(Bitmap *bitmap,
   dst_rect.h = height;
 
   SDL_RenderCopy(sdl_renderer, texture, &src_rect, &dst_rect);
-#endif
 }
 
 void SDLFillRectangle(Bitmap *dst_bitmap, int x, int y, int width, int height,
@@ -2515,11 +2342,6 @@ void SDLOpenAudio(void)
   if (program.headless)
     return;
 
-#if !defined(TARGET_SDL2)
-  if (!strEqual(setup.system.sdl_audiodriver, ARG_DEFAULT))
-    SDL_putenv(getStringCat2("SDL_AUDIODRIVER=", setup.system.sdl_audiodriver));
-#endif
-
   if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
   {
     Error(ERR_WARN, "SDL_InitSubSystem() failed: %s", SDL_GetError());
@@ -2575,17 +2397,9 @@ void SDLHandleWindowManagerEvent(Event *event)
   SDL_SysWMEvent *syswmevent = (SDL_SysWMEvent *)event;
   SDL_SysWMmsg *syswmmsg = (SDL_SysWMmsg *)(syswmevent->msg);
 
-#if defined(TARGET_SDL2)
   if (syswmmsg->msg.win.msg == WM_DROPFILES)
-#else
-  if (syswmmsg->msg == WM_DROPFILES)
-#endif
   {
-#if defined(TARGET_SDL2)
     HDROP hdrop = (HDROP)syswmmsg->msg.win.wParam;
-#else
-    HDROP hdrop = (HDROP)syswmmsg->wParam;
-#endif
     int i, num_files;
 
     printf("::: SDL_SYSWMEVENT:\n");
@@ -2602,11 +2416,7 @@ void SDLHandleWindowManagerEvent(Event *event)
       printf("::: - '%s'\n", buffer);
     }
 
-#if defined(TARGET_SDL2)
     DragFinish((HDROP)syswmmsg->msg.win.wParam);
-#else
-    DragFinish((HDROP)syswmmsg->wParam);
-#endif
   }
 #endif
 #endif
@@ -2617,11 +2427,7 @@ void SDLHandleWindowManagerEvent(Event *event)
 // joystick functions
 // ============================================================================
 
-#if defined(TARGET_SDL2)
 static void *sdl_joystick[MAX_PLAYERS];                // game controller or joystick
-#else
-static SDL_Joystick *sdl_joystick[MAX_PLAYERS];        // only joysticks supported
-#endif
 static int sdl_js_axis_raw[MAX_PLAYERS][2];
 static int sdl_js_axis[MAX_PLAYERS][2];
 static int sdl_js_button[MAX_PLAYERS][2];
@@ -2647,25 +2453,17 @@ boolean SDLOpenJoystick(int nr)
   if (nr < 0 || nr >= MAX_PLAYERS)
     return FALSE;
 
-#if defined(TARGET_SDL2)
   sdl_is_controller[nr] = SDL_IsGameController(nr);
-#else
-  sdl_is_controller[nr] = FALSE;
-#endif
 
 #if DEBUG_JOYSTICKS
   Error(ERR_DEBUG, "opening joystick %d (%s)",
        nr, (sdl_is_controller[nr] ? "game controller" : "joystick"));
 #endif
 
-#if defined(TARGET_SDL2)
   if (sdl_is_controller[nr])
     sdl_joystick[nr] = SDL_GameControllerOpen(nr);
   else
     sdl_joystick[nr] = SDL_JoystickOpen(nr);
-#else
-  sdl_joystick[nr] = SDL_JoystickOpen(nr);
-#endif
 
   return (sdl_joystick[nr] != NULL);
 }
@@ -2679,14 +2477,10 @@ void SDLCloseJoystick(int nr)
   Error(ERR_DEBUG, "closing joystick %d", nr);
 #endif
 
-#if defined(TARGET_SDL2)
   if (sdl_is_controller[nr])
     SDL_GameControllerClose(sdl_joystick[nr]);
   else
     SDL_JoystickClose(sdl_joystick[nr]);
-#else
-  SDL_JoystickClose(sdl_joystick[nr]);
-#endif
 
   sdl_joystick[nr] = NULL;
 }
@@ -2696,23 +2490,15 @@ boolean SDLCheckJoystickOpened(int nr)
   if (nr < 0 || nr >= MAX_PLAYERS)
     return FALSE;
 
-#if defined(TARGET_SDL2)
   return (sdl_joystick[nr] != NULL ? TRUE : FALSE);
-#else
-  return (SDL_JoystickOpened(nr) ? TRUE : FALSE);
-#endif
 }
 
 static void setJoystickAxis(int nr, int axis_id_raw, int axis_value)
 {
-#if defined(TARGET_SDL2)
   int axis_id = (axis_id_raw == SDL_CONTROLLER_AXIS_LEFTX ||
                 axis_id_raw == SDL_CONTROLLER_AXIS_RIGHTX ? 0 :
                 axis_id_raw == SDL_CONTROLLER_AXIS_LEFTY ||
                 axis_id_raw == SDL_CONTROLLER_AXIS_RIGHTY ? 1 : -1);
-#else
-  int axis_id = axis_id_raw % 2;
-#endif
 
   if (nr < 0 || nr >= MAX_PLAYERS)
     return;
@@ -2731,7 +2517,6 @@ static void setJoystickAxis(int nr, int axis_id_raw, int axis_value)
 
 static void setJoystickButton(int nr, int button_id_raw, int button_state)
 {
-#if defined(TARGET_SDL2)
   int button_id = (button_id_raw == SDL_CONTROLLER_BUTTON_A ||
                   button_id_raw == SDL_CONTROLLER_BUTTON_X ||
                   button_id_raw == SDL_CONTROLLER_BUTTON_LEFTSHOULDER ||
@@ -2756,9 +2541,6 @@ static void setJoystickButton(int nr, int button_id_raw, int button_state)
       button_id_raw == SDL_CONTROLLER_BUTTON_DPAD_UP ||
       button_id_raw == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
     sdl_js_axis_raw[nr][0] = sdl_js_axis_raw[nr][1] = -1;
-#else
-  int button_id = button_id_raw % 2;
-#endif
 
   if (nr < 0 || nr >= MAX_PLAYERS)
     return;
@@ -2773,7 +2555,6 @@ void HandleJoystickEvent(Event *event)
 {
   switch(event->type)
   {
-#if defined(TARGET_SDL2)
     case SDL_CONTROLLERDEVICEADDED:
 #if DEBUG_JOYSTICKS
       Error(ERR_DEBUG, "SDL_CONTROLLERDEVICEADDED: device %d added",
@@ -2819,7 +2600,6 @@ void HandleJoystickEvent(Event *event)
                        event->cbutton.button,
                        FALSE);
       break;
-#endif
 
     case SDL_JOYAXISMOTION:
       if (sdl_is_controller[event->jaxis.which])
@@ -2872,32 +2652,25 @@ void SDLInitJoysticks(void)
 {
   static boolean sdl_joystick_subsystem_initialized = FALSE;
   boolean print_warning = !sdl_joystick_subsystem_initialized;
-#if defined(TARGET_SDL2)
   char *mappings_file_base = getPath2(options.conf_directory,
                                      GAMECONTROLLER_BASENAME);
   char *mappings_file_user = getPath2(getUserGameDataDir(),
                                      GAMECONTROLLER_BASENAME);
   int num_mappings;
-#endif
   int i;
 
   if (!sdl_joystick_subsystem_initialized)
   {
     sdl_joystick_subsystem_initialized = TRUE;
 
-#if defined(TARGET_SDL2)
     SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
 
     if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) < 0)
-#else
-    if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
-#endif
     {
       Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
       return;
     }
 
-#if defined(TARGET_SDL2)
     num_mappings = SDL_GameControllerAddMappingsFromFile(mappings_file_base);
 
     // the included game controller base mappings should always be found
@@ -2942,7 +2715,6 @@ void SDLInitJoysticks(void)
       Error(ERR_INFO, "- joystick %d (%s): '%s'",
            i, type, (name ? name : "(Unknown)"));
     }
-#endif
 #endif
   }
 
index 58434681112f608d782529a098675d8e4c0f403d..4f9ced82a7cc193a6a2561c01b0cf9631f9af740 100644 (file)
 
 // definitions needed for "system.c"
 
-#if defined(TARGET_SDL2)
 #define SURFACE_FLAGS          (0)
-#else
-#define SURFACE_FLAGS          (SDL_SWSURFACE)
-#endif
 
-#if defined(TARGET_SDL2)
 #define SET_TRANSPARENT_PIXEL  (SDL_TRUE)
 #define UNSET_TRANSPARENT_PIXEL        (SDL_FALSE)
-#else
-#define SET_TRANSPARENT_PIXEL  (SDL_SRCCOLORKEY)
-#define UNSET_TRANSPARENT_PIXEL        (0)
-#endif
 
 // system dependent definitions
 
-#if defined(TARGET_SDL2)
 #define TARGET_STRING          "SDL2"
-#else
-#define TARGET_STRING          "SDL"
-#endif
 
 #if defined(PLATFORM_ANDROID)
 #define WINDOW_SCALING_STATUS  WINDOW_SCALING_NOT_AVAILABLE
 #define FULLSCREEN_STATUS      FULLSCREEN_AVAILABLE
-#elif defined(TARGET_SDL2)
+#else
 #define WINDOW_SCALING_STATUS  WINDOW_SCALING_AVAILABLE
 #define FULLSCREEN_STATUS      FULLSCREEN_AVAILABLE
-#else  // SDL 1.2
-#define WINDOW_SCALING_STATUS  WINDOW_SCALING_NOT_AVAILABLE
-#define FULLSCREEN_STATUS      FULLSCREEN_AVAILABLE
 #endif
 
 #define CURSOR_MAX_WIDTH       32
@@ -68,24 +52,17 @@ typedef struct SDLSurfaceInfo       DrawWindow;
 typedef Uint32                 Pixel;
 typedef SDL_Cursor            *Cursor;
 
-#if defined(TARGET_SDL2)
 typedef SDL_Keycode            Key;
 typedef SDL_Keymod             KeyMod;
-#else
-typedef SDLKey                 Key;
-typedef unsigned int           KeyMod;
-#endif
 
 typedef SDL_Event              Event;
 typedef SDL_MouseButtonEvent   ButtonEvent;
 typedef SDL_MouseMotionEvent   MotionEvent;
-#if defined(TARGET_SDL2)
 typedef SDL_MouseWheelEvent    WheelEvent;
 typedef SDL_TouchFingerEvent   FingerEvent;
 typedef SDL_TextInputEvent     TextEvent;
 typedef SDL_Event              PauseResumeEvent;
 typedef SDL_WindowEvent                WindowEvent;
-#endif
 typedef SDL_KeyboardEvent      KeyEvent;
 typedef SDL_Event              ExposeEvent;
 typedef SDL_Event              FocusChangeEvent;
@@ -101,10 +78,8 @@ struct SDLSurfaceInfo
   int width, height;
   SDL_Surface *surface;
   SDL_Surface *surface_masked;
-#if defined(TARGET_SDL2)
   SDL_Texture *texture;
   SDL_Texture *texture_masked;
-#endif
 };
 
 struct MouseCursorInfo
@@ -127,13 +102,11 @@ struct MouseCursorInfo
 #define EVENT_BUTTONPRESS      SDL_MOUSEBUTTONDOWN
 #define EVENT_BUTTONRELEASE    SDL_MOUSEBUTTONUP
 #define EVENT_MOTIONNOTIFY     SDL_MOUSEMOTION
-#if defined(TARGET_SDL2)
 #define        EVENT_WHEELMOTION       SDL_MOUSEWHEEL
 #define        EVENT_FINGERPRESS       SDL_FINGERDOWN
 #define EVENT_FINGERRELEASE    SDL_FINGERUP
 #define EVENT_FINGERMOTION     SDL_FINGERMOTION
 #define EVENT_TEXTINPUT                SDL_TEXTINPUT
-#endif
 #define EVENT_KEYPRESS         SDL_KEYDOWN
 #define EVENT_KEYRELEASE       SDL_KEYUP
 #define EVENT_EXPOSE           SDL_USEREVENT + 0
@@ -172,20 +145,11 @@ struct MouseCursorInfo
 #define KSYM_Control_L         SDLK_LCTRL
 #define KSYM_Control_R         SDLK_RCTRL
 
-#if defined(TARGET_SDL2)
 #define KSYM_Meta_L            SDLK_LGUI
 #define KSYM_Meta_R            SDLK_RGUI
-#else
-#define KSYM_Meta_L            SDLK_LMETA
-#define KSYM_Meta_R            SDLK_RMETA
-#endif
 
 #define KSYM_Alt_L             SDLK_LALT
 #define KSYM_Alt_R             SDLK_RALT
-#if !defined(TARGET_SDL2)
-#define KSYM_Super_L           SDLK_LSUPER
-#define KSYM_Super_R           SDLK_RSUPER
-#endif
 #define KSYM_Mode_switch       SDLK_MODE
 #define KSYM_Multi_key         SDLK_RCTRL
 
@@ -198,7 +162,6 @@ struct MouseCursorInfo
 #define KSYM_Page_Up           SDLK_PAGEUP
 #define KSYM_Page_Down         SDLK_PAGEDOWN
 
-#if defined(TARGET_SDL2)
 #define KSYM_Select            SDLK_SELECT
 #define KSYM_Menu              SDLK_MENU
 #define KSYM_Back              SDLK_AC_BACK
@@ -207,20 +170,13 @@ struct MouseCursorInfo
 #define KSYM_Rewind            SDLK_AUDIOREWIND
 #define KSYM_FastForward       SDLK_AUDIOFASTFORWARD
 #endif
-#endif
 
 #define KSYM_space             SDLK_SPACE
 #define KSYM_exclam            SDLK_EXCLAIM
 #define KSYM_quotedbl          SDLK_QUOTEDBL
 #define KSYM_numbersign                SDLK_HASH
 #define KSYM_dollar            SDLK_DOLLAR
-
-#if defined(TARGET_SDL2)
 #define KSYM_percent           SDLK_PERCENT
-#else
-#define KSYM_percent           37                      // undefined in SDL
-#endif
-
 #define KSYM_ampersand         SDLK_AMPERSAND
 #define KSYM_apostrophe                SDLK_QUOTE
 #define KSYM_parenleft         SDLK_LEFTPAREN
@@ -253,7 +209,6 @@ struct MouseCursorInfo
 #define KSYM_braceright                KSYM_UNDEFINED          // undefined
 #define KSYM_asciitilde                KSYM_UNDEFINED          // undefined
 
-#if defined(TARGET_SDL2)
 #define KSYM_degree            176
 #define KSYM_Adiaeresis                196
 #define KSYM_Odiaeresis                214
@@ -262,16 +217,6 @@ struct MouseCursorInfo
 #define KSYM_odiaeresis                246
 #define KSYM_udiaeresis                252
 #define KSYM_ssharp            223
-#else
-#define KSYM_degree            SDLK_WORLD_16
-#define KSYM_Adiaeresis                SDLK_WORLD_36
-#define KSYM_Odiaeresis                SDLK_WORLD_54
-#define KSYM_Udiaeresis                SDLK_WORLD_60
-#define KSYM_adiaeresis                SDLK_WORLD_68
-#define KSYM_odiaeresis                SDLK_WORLD_86
-#define KSYM_udiaeresis                SDLK_WORLD_92
-#define KSYM_ssharp            SDLK_WORLD_63
-#endif
 
 #ifndef SDLK_A
 #define SDLK_A                 65
@@ -367,7 +312,6 @@ struct MouseCursorInfo
 #define KSYM_8                 SDLK_8
 #define KSYM_9                 SDLK_9
 
-#if defined(TARGET_SDL2)
 #define KSYM_KP_0              SDLK_KP_0
 #define KSYM_KP_1              SDLK_KP_1
 #define KSYM_KP_2              SDLK_KP_2
@@ -378,18 +322,6 @@ struct MouseCursorInfo
 #define KSYM_KP_7              SDLK_KP_7
 #define KSYM_KP_8              SDLK_KP_8
 #define KSYM_KP_9              SDLK_KP_9
-#else
-#define KSYM_KP_0              SDLK_KP0
-#define KSYM_KP_1              SDLK_KP1
-#define KSYM_KP_2              SDLK_KP2
-#define KSYM_KP_3              SDLK_KP3
-#define KSYM_KP_4              SDLK_KP4
-#define KSYM_KP_5              SDLK_KP5
-#define KSYM_KP_6              SDLK_KP6
-#define KSYM_KP_7              SDLK_KP7
-#define KSYM_KP_8              SDLK_KP8
-#define KSYM_KP_9              SDLK_KP9
-#endif
 
 #define KSYM_F1                        SDLK_F1
 #define KSYM_F2                        SDLK_F2
@@ -413,15 +345,8 @@ struct MouseCursorInfo
 #define KMOD_Shift_R           KMOD_RSHIFT
 #define KMOD_Control_L         KMOD_LCTRL
 #define KMOD_Control_R         KMOD_RCTRL
-
-#if defined(TARGET_SDL2)
 #define KMOD_Meta_L            KMOD_LGUI
 #define KMOD_Meta_R            KMOD_RGUI
-#else
-#define KMOD_Meta_L            KMOD_LMETA
-#define KMOD_Meta_R            KMOD_RMETA
-#endif
-
 #define KMOD_Alt_L             KMOD_LALT
 #define KMOD_Alt_R             KMOD_RALT
 
@@ -436,9 +361,7 @@ struct MouseCursorInfo
                                 KMOD_Meta    | \
                                 KMOD_Alt)
 
-#if defined(TARGET_SDL2)
 #define KMOD_TextInput         (KMOD_Shift | KMOD_Alt_R)
-#endif
 
 // SDL function definitions
 
@@ -447,7 +370,6 @@ SDL_Surface *SDLGetNativeSurface(SDL_Surface *);
 void SDLCreateBitmapTextures(Bitmap *);
 void SDLFreeBitmapTextures(Bitmap *);
 
-#if defined(TARGET_SDL2)
 SDL_Surface *SDL_DisplayFormat(SDL_Surface *);
 void SDLSetWindowScaling(int);
 void SDLSetWindowScalingQuality(char *);
@@ -456,7 +378,6 @@ void SDLSetDisplaySize(void);
 void SDLSetScreenSizeAndOffsets(int, int);
 void SDLSetScreenSizeForRenderer(int, int);
 void SDLSetScreenProperties(void);
-#endif
 
 void SDLSetScreenRenderingMode(char *);
 void SDLSetScreenVsyncMode(char *);
index 702a86bc05e2f0881638fef4c38f0ef992b13644..0b9be20e1b4cd209e2bc51ac20aa80bac9140c7e 100644 (file)
@@ -55,9 +55,7 @@ DrawBuffer           *drawto = NULL;
 int                    button_status = MB_NOT_PRESSED;
 boolean                        motion_status = FALSE;
 int                    wheel_steps = DEFAULT_WHEEL_STEPS;
-#if defined(TARGET_SDL2)
 boolean                        keyrepeat_status = TRUE;
-#endif
 
 int                    redraw_mask = REDRAW_NONE;
 
@@ -179,11 +177,7 @@ void InitPlatformDependentStuff(void)
 
   OpenLogFiles();
 
-#if defined(TARGET_SDL2)
-  int sdl_init_flags = SDL_INIT_EVENTS      | SDL_INIT_NOPARACHUTE;
-#else
-  int sdl_init_flags = SDL_INIT_EVENTTHREAD | SDL_INIT_NOPARACHUTE;
-#endif
+  int sdl_init_flags = SDL_INIT_EVENTS | SDL_INIT_NOPARACHUTE;
 
   if (SDL_Init(sdl_init_flags) < 0)
     Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
@@ -252,9 +246,7 @@ void InitGfxWindowInfo(int win_xsize, int win_ysize)
   {
     ReCreateBitmap(&gfx.background_bitmap, win_xsize, win_ysize);
 
-#if defined(TARGET_SDL2)
     ReCreateBitmap(&gfx.final_screen_bitmap, win_xsize, win_ysize);
-#endif
 
     ReCreateBitmap(&gfx.fade_bitmap_backup, win_xsize, win_ysize);
     ReCreateBitmap(&gfx.fade_bitmap_source, win_xsize, win_ysize);
@@ -536,9 +528,7 @@ void InitVideoDisplay(void)
     return;
 
   SDLInitVideoDisplay();
-#if defined(TARGET_SDL2)
   SDLSetDisplaySize();
-#endif
 }
 
 void CloseVideoDisplay(void)
@@ -810,7 +800,6 @@ void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap,
   src_x += dst_x - dst_x_unclipped;
   src_y += dst_y - dst_y_unclipped;
 
-#if defined(TARGET_SDL2)
   // !!! 2013-12-11: An "old friend" is back. Same bug in SDL2 2.0.1 !!!
   // !!! 2009-03-30: Fixed by using self-compiled, patched SDL.dll !!!
   /* (This bug still exists in the actual (as of 2009-06-15) version 1.2.13,
@@ -857,7 +846,6 @@ void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap,
 
     return;
   }
-#endif
 
   sysCopyArea(src_bitmap, dst_bitmap,
              src_x, src_y, width, height, dst_x, dst_y, BLIT_OPAQUE);
@@ -1093,23 +1081,12 @@ Pixel GetPixelFromRGBcompact(Bitmap *bitmap, unsigned int color)
 
 void KeyboardAutoRepeatOn(void)
 {
-#if defined(TARGET_SDL2)
   keyrepeat_status = TRUE;
-#else
-  SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2,
-                     SDL_DEFAULT_REPEAT_INTERVAL / 2);
-  SDL_EnableUNICODE(1);
-#endif
 }
 
 void KeyboardAutoRepeatOff(void)
 {
-#if defined(TARGET_SDL2)
   keyrepeat_status = FALSE;
-#else
-  SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
-  SDL_EnableUNICODE(0);
-#endif
 }
 
 boolean SetVideoMode(boolean fullscreen)
@@ -1637,11 +1614,7 @@ void WaitEvent(Event *event)
 
 void PeekEvent(Event *event)
 {
-#if defined(TARGET_SDL2)
   SDL_PeepEvents(event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
-#else
-  SDL_PeepEvents(event, 1, SDL_PEEKEVENT, SDL_ALLEVENTS);
-#endif
 }
 
 void CheckQuitEvent(void)
@@ -1652,26 +1625,8 @@ void CheckQuitEvent(void)
 
 Key GetEventKey(KeyEvent *event, boolean with_modifiers)
 {
-#if defined(TARGET_SDL2)
   // key up/down events in SDL2 do not return text characters anymore
   return event->keysym.sym;
-#else
-
-#if ENABLE_UNUSED_CODE
-  printf("unicode == '%d', sym == '%d', mod == '0x%04x'\n",
-        (int)event->keysym.unicode,
-        (int)event->keysym.sym,
-        (int)SDL_GetModState());
-#endif
-
-  if (with_modifiers &&
-      event->keysym.unicode > 0x0000 &&
-      event->keysym.unicode < 0x2000)
-    return event->keysym.unicode;
-  else
-    return event->keysym.sym;
-
-#endif
 }
 
 KeyMod HandleKeyModState(Key key, int key_status)
@@ -1739,7 +1694,6 @@ KeyMod GetKeyModStateFromEvents(void)
 
 void StartTextInput(int x, int y, int width, int height)
 {
-#if defined(TARGET_SDL2)
 #if defined(HAS_SCREEN_KEYBOARD)
   SDL_StartTextInput();
 
@@ -1750,12 +1704,10 @@ void StartTextInput(int x, int y, int width, int height)
     video.shifted_up = TRUE;
   }
 #endif
-#endif
 }
 
 void StopTextInput(void)
 {
-#if defined(TARGET_SDL2)
 #if defined(HAS_SCREEN_KEYBOARD)
   SDL_StopTextInput();
 
@@ -1766,7 +1718,6 @@ void StopTextInput(void)
     video.shifted_up = FALSE;
   }
 #endif
-#endif
 }
 
 boolean CheckCloseWindowEvent(ClientMessageEvent *event)
index f2ac0c1d73dd976f0f54227521917dde7b59699b..b82b7e8acc5655fd2d644e9f572caee7118dff46 100644 (file)
 #define STR_SPECIAL_RENDERING_TARGET   "target_texture_only"
 #define STR_SPECIAL_RENDERING_DOUBLE   "stream_and_target_texture"
 
-#if defined(TARGET_SDL2)
 #define STR_SPECIAL_RENDERING_DEFAULT  STR_SPECIAL_RENDERING_DOUBLE
-#else
-#define STR_SPECIAL_RENDERING_DEFAULT  STR_SPECIAL_RENDERING_BITMAP
-#endif
 
 #define SPECIAL_RENDERING_OFF          0
 #define SPECIAL_RENDERING_BITMAP       1
 #define SPECIAL_RENDERING_TARGET       2
 #define SPECIAL_RENDERING_DOUBLE       3
 
-#if defined(TARGET_SDL2)
 #define SPECIAL_RENDERING_DEFAULT      SPECIAL_RENDERING_DOUBLE
-#else
-#define SPECIAL_RENDERING_DEFAULT      SPECIAL_RENDERING_BITMAP
-#endif
 
 // values for vertical screen retrace synchronization (vsync)
 #define STR_VSYNC_MODE_OFF             "off"
@@ -1642,9 +1634,7 @@ extern DrawBuffer        *drawto;
 extern int                     button_status;
 extern boolean                 motion_status;
 extern int                     wheel_steps;
-#if defined(TARGET_SDL2)
 extern boolean                 keyrepeat_status;
-#endif
 
 extern int                     redraw_mask;
 
index 109e88d0e6e09f49b1cd6cc2de744d716af83725..d36c3f2aca056ddf14f08af9ca1e93498a54aac3 100644 (file)
@@ -33,11 +33,8 @@ int                  game_status = -1;
 boolean                        game_status_last_screen = -1;
 boolean                        level_editor_test_game = FALSE;
 boolean                        network_playing = FALSE;
-
-#if defined(TARGET_SDL)
 boolean                        network_server = FALSE;
 SDL_Thread            *server_thread;
-#endif
 
 int                    key_joystick_mapping = 0;
 
index 5a6268d95fa41d0196881b571c12b031edee4051..9b6ffeccbd9745c597782db9a612f862484155d2 100644 (file)
@@ -3548,11 +3548,8 @@ extern int                       game_status;
 extern boolean                 game_status_last_screen;
 extern boolean                 level_editor_test_game;
 extern boolean                 network_playing;
-
-#if defined(TARGET_SDL)
 extern boolean                 network_server;
 extern SDL_Thread             *server_thread;
-#endif
 
 extern int                     key_joystick_mapping;
 
index 2730c7b01967842e533a1e2a5b26df25323e93b1..6c1f4c6de4d1bd5d91674188fed45a725eb845cb 100644 (file)
@@ -188,12 +188,9 @@ static void StartNetworkServer(int port)
   static int p;
 
   p = port;
-#if defined(TARGET_SDL2)
+
   server_thread = SDL_CreateThread(NetworkServerThread,
                                   "NetworkServerThread", &p);
-#else
-  server_thread = SDL_CreateThread(NetworkServerThread, &p);
-#endif
   network_server = TRUE;
 }
 
index 06732b87cbd5c27a1d136d822151801cfed8d568..567fbf163b6888a491a75b71a45330427308591f 100644 (file)
@@ -3601,12 +3601,8 @@ static void DrawInfoScreen_Version(void)
   SDL_version sdl_version_compiled;
   const SDL_version *sdl_version_linked;
   int driver_name_len = 10;
-#if defined(TARGET_SDL2)
   SDL_version sdl_version_linked_ext;
   const char *driver_name = NULL;
-#else
-  char driver_name[driver_name_len];
-#endif
 
   SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
 
@@ -3657,12 +3653,8 @@ static void DrawInfoScreen_Version(void)
   ystart += ystep_head;
 
   SDL_VERSION(&sdl_version_compiled);
-#if defined(TARGET_SDL2)
   SDL_GetVersion(&sdl_version_linked_ext);
   sdl_version_linked = &sdl_version_linked_ext;
-#else
-  sdl_version_linked = SDL_Linked_Version();
-#endif
 
   DrawTextF(xstart1, ystart, font_text, "SDL");
   DrawTextF(xstart2, ystart, font_text, "%d.%d.%d",
@@ -3722,22 +3714,14 @@ static void DrawInfoScreen_Version(void)
   DrawTextF(xstart3, ystart, font_head, "Used");
   ystart += ystep_head;
 
-#if defined(TARGET_SDL2)
   driver_name = getStringCopyNStatic(SDL_GetVideoDriver(0), driver_name_len);
-#else
-  SDL_VideoDriverName(driver_name, driver_name_len);
-#endif
 
   DrawTextF(xstart1, ystart, font_text, "SDL_VideoDriver");
   DrawTextF(xstart2, ystart, font_text, "%s", setup.system.sdl_videodriver);
   DrawTextF(xstart3, ystart, font_text, "%s", driver_name);
   ystart += ystep_line;
 
-#if defined(TARGET_SDL2)
   driver_name = getStringCopyNStatic(SDL_GetAudioDriver(0), driver_name_len);
-#else
-  SDL_AudioDriverName(driver_name, driver_name_len);
-#endif
 
   DrawTextF(xstart1, ystart, font_text, "SDL_AudioDriver");
   DrawTextF(xstart2, ystart, font_text, "%s", setup.system.sdl_audiodriver);
@@ -5216,7 +5200,6 @@ static void execSetupGraphics(void)
   if (check_game_speed)
     ModifyGameSpeedIfNeeded();
 
-#if defined(TARGET_SDL2)
   // window scaling may have changed at this point
   ToggleFullscreenOrChangeWindowScalingIfNeeded();
 
@@ -5229,7 +5212,6 @@ static void execSetupGraphics(void)
 
   // screen vsync mode may have changed at this point
   SDLSetScreenVsyncMode(setup.vsync_mode);
-#endif
 }
 
 static void execSetupChooseWindowSize(void)
@@ -6218,7 +6200,7 @@ static struct TokenInfo setup_info_editor[] =
 
 static struct TokenInfo setup_info_graphics[] =
 {
-#if defined(TARGET_SDL2) && !defined(PLATFORM_ANDROID)
+#if !defined(PLATFORM_ANDROID)
   { TYPE_SWITCH,       &setup.fullscreen,      "Fullscreen:"           },
   { TYPE_ENTER_LIST,   execSetupChooseWindowSize, "Window Scaling:"    },
   { TYPE_STRING,       &window_size_text,      ""                      },
@@ -7383,7 +7365,6 @@ void CustomizeKeyboard(int player_nr)
 
 static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick)
 {
-#if defined(TARGET_SDL2)
   static boolean bitmaps_initialized = FALSE;
   boolean screen_initialized = FALSE;
   static Bitmap *controller, *button, *axis_x, *axis_y;
@@ -7729,9 +7710,6 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick)
   while (NextValidEvent(&event));
 
   return success;
-#else
-  return TRUE;
-#endif
 }
 
 static int ConfigureJoystickMain(int player_nr)
@@ -7895,19 +7873,13 @@ static boolean ConfigureVirtualButtonsMain(void)
 
            // press 'Enter' to keep the existing key binding
            if (key == KSYM_Return ||
-#if defined(TARGET_SDL2)
                key == KSYM_Menu ||
-#endif
                key == KSYM_space)
            {
              step_nr++;
            }
-           else if (key == KSYM_BackSpace
-#if defined(TARGET_SDL2)
-                    ||
-                    key == KSYM_Back
-#endif
-                    )
+           else if (key == KSYM_BackSpace ||
+                    key == KSYM_Back)
            {
              if (step_nr == 0)
              {
@@ -7996,7 +7968,6 @@ static boolean ConfigureVirtualButtonsMain(void)
          }
          break;
 
-#if defined(TARGET_SDL2)
        case SDL_WINDOWEVENT:
          HandleWindowEvent((WindowEvent *) &event);
 
@@ -8019,7 +7990,6 @@ static boolean ConfigureVirtualButtonsMain(void)
        case SDL_APP_DIDENTERFOREGROUND:
          HandlePauseResumeEvent((PauseResumeEvent *) &event);
          break;
-#endif
 
         default:
          HandleOtherEvents(&event);
index 5adfc32580e8e5a1526bead2df82da0fa7dc05f0..b2668d026ae34c8e02ce56f9d5785ac0fe3aaec1 100644 (file)
@@ -4205,9 +4205,7 @@ void WaitForEventToContinue(void)
       {
        case EVENT_BUTTONRELEASE:
        case EVENT_KEYPRESS:
-#if defined(TARGET_SDL2)
         case SDL_CONTROLLERBUTTONDOWN:
-#endif
         case SDL_JOYBUTTONDOWN:
          still_wait = FALSE;
          break;
@@ -4344,7 +4342,6 @@ static int RequestHandleEvents(unsigned int req_state)
            break;
          }
 
-#if defined(TARGET_SDL2)
          case SDL_WINDOWEVENT:
            HandleWindowEvent((WindowEvent *) &event);
            break;
@@ -4355,7 +4352,6 @@ static int RequestHandleEvents(unsigned int req_state)
          case SDL_APP_DIDENTERFOREGROUND:
            HandlePauseResumeEvent((PauseResumeEvent *) &event);
            break;
-#endif
 
          case EVENT_KEYPRESS:
          {
@@ -4370,25 +4366,21 @@ static int RequestHandleEvents(unsigned int req_state)
 
              case KSYM_Return:
              case KSYM_y:
-#if defined(TARGET_SDL2)
              case KSYM_Y:
              case KSYM_Select:
              case KSYM_Menu:
 #if defined(KSYM_Rewind)
              case KSYM_Rewind:         // for Amazon Fire TV remote
-#endif
 #endif
                result = 1;
                break;
 
              case KSYM_Escape:
              case KSYM_n:
-#if defined(TARGET_SDL2)
              case KSYM_N:
              case KSYM_Back:
 #if defined(KSYM_FastForward)
              case KSYM_FastForward:    // for Amazon Fire TV remote
-#endif
 #endif
                result = 0;
                break;
@@ -4443,7 +4435,6 @@ static int RequestHandleEvents(unsigned int req_state)
            ClearPlayerAction();
            break;
 
-#if defined(TARGET_SDL2)
          case SDL_CONTROLLERBUTTONDOWN:
            switch (event.cbutton.button)
            {
@@ -4503,7 +4494,6 @@ static int RequestHandleEvents(unsigned int req_state)
            HandleJoystickEvent(&event);
            ClearPlayerAction();
            break;
-#endif
 
          default:
            HandleOtherEvents(&event);
@@ -9297,7 +9287,6 @@ void ToggleFullscreenOrChangeWindowScalingIfNeeded(void)
   if (!change_window_scaling_percent && !video.fullscreen_available)
     return;
 
-#if defined(TARGET_SDL2)
   if (change_window_scaling_percent)
   {
     SDLSetWindowScaling(setup.window_scaling_percent);
@@ -9313,7 +9302,6 @@ void ToggleFullscreenOrChangeWindowScalingIfNeeded(void)
 
     return;
   }
-#endif
 
   if (change_fullscreen ||
       change_window_scaling_percent)