浏览代码

Porting to SDL2

Wei Mingzhi 11 年之前
父节点
当前提交
449a3477a4
共有 2 个文件被更改,包括 26 次插入2 次删除
  1. 5 1
      common.h
  2. 21 1
      input.c

+ 5 - 1
common.h

@@ -48,6 +48,7 @@ extern "C"
 #endif
 
 #if SDL_VERSION_ATLEAST(2,0,0)
+
 #define SDLK_KP1     SDLK_KP_1
 #define SDLK_KP2     SDLK_KP_2
 #define SDLK_KP3     SDLK_KP_3
@@ -58,6 +59,9 @@ extern "C"
 #define SDLK_KP8     SDLK_KP_8
 #define SDLK_KP9     SDLK_KP_9
 #define SDLK_KP0     SDLK_KP_0
+
+#define SDL_HWSURFACE     0
+
 #endif
 
 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
@@ -102,8 +106,8 @@ extern "C"
 
 #define PAL_HAS_JOYSTICKS     1
 #ifndef _WIN32_WCE
-#define PAL_ALLOW_KEYREPEAT   1
 #if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
+#define PAL_ALLOW_KEYREPEAT   1
 #define PAL_HAS_CD            1
 #endif
 #if !defined (CYGWIN) && !defined (DINGOO) && !defined (GPH) && !defined (GEKKO)

+ 21 - 1
input.c

@@ -655,7 +655,7 @@ PAL_EventFilter(
 static int SDLCALL
 PAL_EventFilter(
    void                  *userdata,
-   const SDL_Event       *lpEvent
+   SDL_Event             *lpEvent
 )
 #endif
 /*++
@@ -676,12 +676,24 @@ PAL_EventFilter(
 {
    switch (lpEvent->type)
    {
+#if SDL_VERSION_ATLEAST(2,0,0)
+   case SDL_WINDOWEVENT:
+      if (lpEvent->window.event == SDL_WINDOWEVENT_RESIZED)
+      {
+         //
+         // resized the window
+         //
+         VIDEO_Resize(lpEvent->window.data1, lpEvent->window.data2);
+      }
+      break;
+#else
    case SDL_VIDEORESIZE:
       //
       // resized the window
       //
       VIDEO_Resize(lpEvent->resize.w, lpEvent->resize.h);
       break;
+#endif
 
    case SDL_QUIT:
       //
@@ -786,6 +798,13 @@ PAL_ShutdownInput(
 --*/
 {
 #ifdef PAL_HAS_JOYSTICKS
+#if SDL_VERSION_ATLEAST(2,0,0)
+   if (g_pJoy != NULL)
+   {
+      SDL_JoystickClose(g_pJoy);
+      g_pJoy = NULL;
+   }
+#else
    if (SDL_JoystickOpened(0))
    {
       assert(g_pJoy != NULL);
@@ -793,6 +812,7 @@ PAL_ShutdownInput(
       g_pJoy = NULL;
    }
 #endif
+#endif
 }
 
 VOID