src/video/windib/SDL_dibevents.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/video/windib/SDL_dibevents.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/video/windib/SDL_dibevents.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -43,8 +43,8 @@
     1.4  
     1.5  /* The translation table from a Microsoft VK keysym to a SDL keysym */
     1.6  static SDLKey VK_keymap[SDLK_LAST];
     1.7 -static SDL_keysym *TranslateKey (WPARAM vkey, UINT scancode,
     1.8 -                                 SDL_keysym * keysym, int pressed);
     1.9 +static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode,
    1.10 +                                SDL_keysym * keysym, int pressed);
    1.11  
    1.12  /* Masks for processing the windows KEYDOWN and KEYUP messages */
    1.13  #define REPEATED_KEYMASK	(1<<30)
    1.14 @@ -63,7 +63,7 @@
    1.15  #ifdef _WIN32_WCE
    1.16  
    1.17  WPARAM
    1.18 -rotateKey (WPARAM key, SDL_ScreenOrientation direction)
    1.19 +rotateKey(WPARAM key, SDL_ScreenOrientation direction)
    1.20  {
    1.21      if (direction != SDL_ORIENTATION_LEFT)
    1.22          return key;
    1.23 @@ -87,7 +87,7 @@
    1.24  
    1.25  /* The main Win32 event handler */
    1.26  LRESULT
    1.27 -DIB_HandleMessage (_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    1.28 +DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    1.29  {
    1.30      extern int posted;
    1.31  
    1.32 @@ -104,7 +104,7 @@
    1.33  
    1.34              // Rotate key if necessary
    1.35              if (this->hidden->orientation != SDL_ORIENTATION_UP)
    1.36 -                wParam = rotateKey (wParam, this->hidden->orientation);
    1.37 +                wParam = rotateKey(wParam, this->hidden->orientation);
    1.38  #endif
    1.39              /* Ignore repeated keys */
    1.40              if (lParam & REPEATED_KEYMASK) {
    1.41 @@ -120,12 +120,12 @@
    1.42              case VK_SHIFT:
    1.43                  /* EXTENDED trick doesn't work here */
    1.44                  {
    1.45 -                    Uint8 *state = SDL_GetKeyState (NULL);
    1.46 +                    Uint8 *state = SDL_GetKeyState(NULL);
    1.47                      if (state[SDLK_LSHIFT] == SDL_RELEASED
    1.48 -                        && (GetKeyState (VK_LSHIFT) & 0x8000)) {
    1.49 +                        && (GetKeyState(VK_LSHIFT) & 0x8000)) {
    1.50                          wParam = VK_LSHIFT;
    1.51                      } else if (state[SDLK_RSHIFT] == SDL_RELEASED
    1.52 -                               && (GetKeyState (VK_RSHIFT) & 0x8000)) {
    1.53 +                               && (GetKeyState(VK_RSHIFT) & 0x8000)) {
    1.54                          wParam = VK_RSHIFT;
    1.55                      } else {
    1.56                          /* Probably a key repeat */
    1.57 @@ -150,18 +150,18 @@
    1.58                  m.wParam = wParam;
    1.59                  m.lParam = lParam;
    1.60                  m.time = 0;
    1.61 -                if (TranslateMessage (&m)
    1.62 -                    && PeekMessage (&m, hwnd, 0, WM_USER, PM_NOREMOVE)
    1.63 +                if (TranslateMessage(&m)
    1.64 +                    && PeekMessage(&m, hwnd, 0, WM_USER, PM_NOREMOVE)
    1.65                      && (m.message == WM_CHAR)) {
    1.66 -                    GetMessage (&m, hwnd, 0, WM_USER);
    1.67 +                    GetMessage(&m, hwnd, 0, WM_USER);
    1.68                      wParam = m.wParam;
    1.69                  }
    1.70              }
    1.71  #endif /* NO_GETKEYBOARDSTATE */
    1.72 -            posted = SDL_PrivateKeyboard (SDL_PRESSED,
    1.73 -                                          TranslateKey (wParam,
    1.74 -                                                        HIWORD (lParam),
    1.75 -                                                        &keysym, 1));
    1.76 +            posted = SDL_PrivateKeyboard(SDL_PRESSED,
    1.77 +                                         TranslateKey(wParam,
    1.78 +                                                      HIWORD(lParam),
    1.79 +                                                      &keysym, 1));
    1.80          }
    1.81          return (0);
    1.82  
    1.83 @@ -177,7 +177,7 @@
    1.84  
    1.85              // Rotate key if necessary
    1.86              if (this->hidden->orientation != SDL_ORIENTATION_UP)
    1.87 -                wParam = rotateKey (wParam, this->hidden->orientation);
    1.88 +                wParam = rotateKey(wParam, this->hidden->orientation);
    1.89  #endif
    1.90  
    1.91              switch (wParam) {
    1.92 @@ -190,12 +190,12 @@
    1.93              case VK_SHIFT:
    1.94                  /* EXTENDED trick doesn't work here */
    1.95                  {
    1.96 -                    Uint8 *state = SDL_GetKeyState (NULL);
    1.97 +                    Uint8 *state = SDL_GetKeyState(NULL);
    1.98                      if (state[SDLK_LSHIFT] == SDL_PRESSED
    1.99 -                        && !(GetKeyState (VK_LSHIFT) & 0x8000)) {
   1.100 +                        && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
   1.101                          wParam = VK_LSHIFT;
   1.102                      } else if (state[SDLK_RSHIFT] == SDL_PRESSED
   1.103 -                               && !(GetKeyState (VK_RSHIFT) & 0x8000)) {
   1.104 +                               && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
   1.105                          wParam = VK_RSHIFT;
   1.106                      } else {
   1.107                          /* Probably a key repeat */
   1.108 @@ -212,17 +212,17 @@
   1.109              }
   1.110              /* Windows only reports keyup for print screen */
   1.111              if (wParam == VK_SNAPSHOT
   1.112 -                && SDL_GetKeyState (NULL)[SDLK_PRINT] == SDL_RELEASED) {
   1.113 -                posted = SDL_PrivateKeyboard (SDL_PRESSED,
   1.114 -                                              TranslateKey (wParam,
   1.115 -                                                            HIWORD
   1.116 -                                                            (lParam),
   1.117 -                                                            &keysym, 1));
   1.118 +                && SDL_GetKeyState(NULL)[SDLK_PRINT] == SDL_RELEASED) {
   1.119 +                posted = SDL_PrivateKeyboard(SDL_PRESSED,
   1.120 +                                             TranslateKey(wParam,
   1.121 +                                                          HIWORD
   1.122 +                                                          (lParam),
   1.123 +                                                          &keysym, 1));
   1.124              }
   1.125 -            posted = SDL_PrivateKeyboard (SDL_RELEASED,
   1.126 -                                          TranslateKey (wParam,
   1.127 -                                                        HIWORD (lParam),
   1.128 -                                                        &keysym, 0));
   1.129 +            posted = SDL_PrivateKeyboard(SDL_RELEASED,
   1.130 +                                         TranslateKey(wParam,
   1.131 +                                                      HIWORD(lParam),
   1.132 +                                                      &keysym, 0));
   1.133          }
   1.134          return (0);
   1.135  
   1.136 @@ -242,46 +242,46 @@
   1.137              if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
   1.138                  SDL_SysWMmsg wmmsg;
   1.139  
   1.140 -                SDL_VERSION (&wmmsg.version);
   1.141 +                SDL_VERSION(&wmmsg.version);
   1.142                  wmmsg.hwnd = hwnd;
   1.143                  wmmsg.msg = msg;
   1.144                  wmmsg.wParam = wParam;
   1.145                  wmmsg.lParam = lParam;
   1.146 -                posted = SDL_PrivateSysWMEvent (&wmmsg);
   1.147 +                posted = SDL_PrivateSysWMEvent(&wmmsg);
   1.148  
   1.149                  /* DJM: If the user isn't watching for private
   1.150                     messages in her SDL event loop, then pass it
   1.151                     along to any win32 specific window proc.
   1.152                   */
   1.153              } else if (userWindowProc) {
   1.154 -                return CallWindowProc (userWindowProc, hwnd, msg, wParam,
   1.155 -                                       lParam);
   1.156 +                return CallWindowProc(userWindowProc, hwnd, msg, wParam,
   1.157 +                                      lParam);
   1.158              }
   1.159          }
   1.160          break;
   1.161      }
   1.162 -    return (DefWindowProc (hwnd, msg, wParam, lParam));
   1.163 +    return (DefWindowProc(hwnd, msg, wParam, lParam));
   1.164  }
   1.165  
   1.166  void
   1.167 -DIB_PumpEvents (_THIS)
   1.168 +DIB_PumpEvents(_THIS)
   1.169  {
   1.170      MSG msg;
   1.171  
   1.172 -    while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) {
   1.173 -        if (GetMessage (&msg, NULL, 0, 0) > 0) {
   1.174 -            DispatchMessage (&msg);
   1.175 +    while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
   1.176 +        if (GetMessage(&msg, NULL, 0, 0) > 0) {
   1.177 +            DispatchMessage(&msg);
   1.178          }
   1.179      }
   1.180  }
   1.181  
   1.182  void
   1.183 -DIB_InitOSKeymap (_THIS)
   1.184 +DIB_InitOSKeymap(_THIS)
   1.185  {
   1.186      int i;
   1.187  
   1.188      /* Map the VK keysyms */
   1.189 -    for (i = 0; i < SDL_arraysize (VK_keymap); ++i)
   1.190 +    for (i = 0; i < SDL_arraysize(VK_keymap); ++i)
   1.191          VK_keymap[i] = SDLK_UNKNOWN;
   1.192  
   1.193      VK_keymap[VK_BACK] = SDLK_BACKSPACE;
   1.194 @@ -406,7 +406,7 @@
   1.195  }
   1.196  
   1.197  static SDL_keysym *
   1.198 -TranslateKey (WPARAM vkey, UINT scancode, SDL_keysym * keysym, int pressed)
   1.199 +TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym * keysym, int pressed)
   1.200  {
   1.201      /* Set the keysym information */
   1.202      keysym->scancode = (unsigned char) scancode;
   1.203 @@ -421,10 +421,10 @@
   1.204          BYTE keystate[256];
   1.205          Uint16 wchars[2];
   1.206  
   1.207 -        GetKeyboardState (keystate);
   1.208 +        GetKeyboardState(keystate);
   1.209          if (SDL_ToUnicode
   1.210              ((UINT) vkey, scancode, keystate, wchars,
   1.211 -             sizeof (wchars) / sizeof (wchars[0]), 0) == 1) {
   1.212 +             sizeof(wchars) / sizeof(wchars[0]), 0) == 1) {
   1.213              keysym->unicode = wchars[0];
   1.214          }
   1.215  #endif /* NO_GETKEYBOARDSTATE */
   1.216 @@ -433,27 +433,27 @@
   1.217  }
   1.218  
   1.219  int
   1.220 -DIB_CreateWindow (_THIS)
   1.221 +DIB_CreateWindow(_THIS)
   1.222  {
   1.223 -    char *windowid = SDL_getenv ("SDL_WINDOWID");
   1.224 +    char *windowid = SDL_getenv("SDL_WINDOWID");
   1.225  
   1.226 -    SDL_RegisterApp (NULL, 0, 0);
   1.227 +    SDL_RegisterApp(NULL, 0, 0);
   1.228  
   1.229      SDL_windowid = (windowid != NULL);
   1.230      if (SDL_windowid) {
   1.231  #if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
   1.232          /* wince 2.1 does not have strtol */
   1.233          wchar_t *windowid_t =
   1.234 -            SDL_malloc ((SDL_strlen (windowid) + 1) * sizeof (wchar_t));
   1.235 -        MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, windowid, -1,
   1.236 -                             windowid_t, SDL_strlen (windowid) + 1);
   1.237 -        SDL_Window = (HWND) wcstol (windowid_t, NULL, 0);
   1.238 -        SDL_free (windowid_t);
   1.239 +            SDL_malloc((SDL_strlen(windowid) + 1) * sizeof(wchar_t));
   1.240 +        MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1,
   1.241 +                            windowid_t, SDL_strlen(windowid) + 1);
   1.242 +        SDL_Window = (HWND) wcstol(windowid_t, NULL, 0);
   1.243 +        SDL_free(windowid_t);
   1.244  #else
   1.245 -        SDL_Window = (HWND) SDL_strtoull (windowid, NULL, 0);
   1.246 +        SDL_Window = (HWND) SDL_strtoull(windowid, NULL, 0);
   1.247  #endif
   1.248          if (SDL_Window == NULL) {
   1.249 -            SDL_SetError ("Couldn't get user specified window");
   1.250 +            SDL_SetError("Couldn't get user specified window");
   1.251              return (-1);
   1.252          }
   1.253  
   1.254 @@ -461,46 +461,45 @@
   1.255             window to be handled by SDL.
   1.256           */
   1.257          userWindowProc =
   1.258 -            (WNDPROCTYPE) GetWindowLongPtr (SDL_Window, GWLP_WNDPROC);
   1.259 -        SetWindowLongPtr (SDL_Window, GWLP_WNDPROC, (LONG_PTR) WinMessage);
   1.260 +            (WNDPROCTYPE) GetWindowLongPtr(SDL_Window, GWLP_WNDPROC);
   1.261 +        SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR) WinMessage);
   1.262      } else {
   1.263 -        SDL_Window = CreateWindow (SDL_Appname, SDL_Appname,
   1.264 -                                   (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU
   1.265 -                                    | WS_MINIMIZEBOX), CW_USEDEFAULT,
   1.266 -                                   CW_USEDEFAULT, 0, 0, NULL, NULL,
   1.267 -                                   SDL_Instance, NULL);
   1.268 +        SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
   1.269 +                                  (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU
   1.270 +                                   | WS_MINIMIZEBOX), CW_USEDEFAULT,
   1.271 +                                  CW_USEDEFAULT, 0, 0, NULL, NULL,
   1.272 +                                  SDL_Instance, NULL);
   1.273          if (SDL_Window == NULL) {
   1.274 -            SDL_SetError ("Couldn't create window");
   1.275 +            SDL_SetError("Couldn't create window");
   1.276              return (-1);
   1.277          }
   1.278 -        ShowWindow (SDL_Window, SW_HIDE);
   1.279 +        ShowWindow(SDL_Window, SW_HIDE);
   1.280      }
   1.281  
   1.282      /* JC 14 Mar 2006
   1.283         Flush the message loop or this can cause big problems later
   1.284         Especially if the user decides to use dialog boxes or assert()!
   1.285       */
   1.286 -    WIN_FlushMessageQueue ();
   1.287 +    WIN_FlushMessageQueue();
   1.288  
   1.289      return (0);
   1.290  }
   1.291  
   1.292  void
   1.293 -DIB_DestroyWindow (_THIS)
   1.294 +DIB_DestroyWindow(_THIS)
   1.295  {
   1.296      if (SDL_windowid) {
   1.297 -        SetWindowLongPtr (SDL_Window, GWLP_WNDPROC,
   1.298 -                          (LONG_PTR) userWindowProc);
   1.299 +        SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR) userWindowProc);
   1.300      } else {
   1.301 -        DestroyWindow (SDL_Window);
   1.302 +        DestroyWindow(SDL_Window);
   1.303      }
   1.304 -    SDL_UnregisterApp ();
   1.305 +    SDL_UnregisterApp();
   1.306  
   1.307      /* JC 14 Mar 2006
   1.308         Flush the message loop or this can cause big problems later
   1.309         Especially if the user decides to use dialog boxes or assert()!
   1.310       */
   1.311 -    WIN_FlushMessageQueue ();
   1.312 +    WIN_FlushMessageQueue();
   1.313  }
   1.314  
   1.315  /* vi: set ts=4 sw=4 expandtab: */