Browse Source

really fixes #8

Wei Mingzhi 9 years ago
parent
commit
bea7d19c9d
2 changed files with 27 additions and 15 deletions
  1. 1 1
      common.h
  2. 26 14
      input.c

+ 1 - 1
common.h

@@ -131,8 +131,8 @@ FILE *MY_fopen(const char *path, const char *mode);
 
 #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) && !defined (__WINPHONE__)

+ 26 - 14
input.c

@@ -113,30 +113,42 @@ PAL_KeyboardEventFilter(
 
       case SDLK_UP:
       case SDLK_KP8:
-         g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-         g_InputState.dir = kDirNorth;
-         g_InputState.dwKeyPress |= kKeyUp;
+         if (gpGlobals->fInBattle || g_InputState.dir != kDirNorth)
+         {
+            g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
+            g_InputState.dir = kDirNorth;
+            g_InputState.dwKeyPress |= kKeyUp;
+         }
          break;
 
       case SDLK_DOWN:
       case SDLK_KP2:
-         g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-         g_InputState.dir = kDirSouth;
-         g_InputState.dwKeyPress |= kKeyDown;
+         if (gpGlobals->fInBattle || g_InputState.dir != kDirSouth)
+         {
+            g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
+            g_InputState.dir = kDirSouth;
+            g_InputState.dwKeyPress |= kKeyDown;
+         }
          break;
 
       case SDLK_LEFT:
       case SDLK_KP4:
-         g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-         g_InputState.dir = kDirWest;
-         g_InputState.dwKeyPress |= kKeyLeft;
+         if (gpGlobals->fInBattle || g_InputState.dir != kDirWest)
+         {
+            g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
+            g_InputState.dir = kDirWest;
+            g_InputState.dwKeyPress |= kKeyLeft;
+         }
          break;
 
-      case SDLK_RIGHT:
-      case SDLK_KP6:
-         g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-         g_InputState.dir = kDirEast;
-         g_InputState.dwKeyPress |= kKeyRight;
+     case SDLK_RIGHT:
+     case SDLK_KP6:
+         if (gpGlobals->fInBattle || g_InputState.dir != kDirEast)
+         {
+            g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
+            g_InputState.dir = kDirEast;
+            g_InputState.dwKeyPress |= kKeyRight;
+         }
          break;
 
 #if defined(DINGOO)