src/video/win32/SDL_win32events.c
changeset 4465 3e69e077cb95
parent 4429 faa9fc8e7f67
child 4470 a5878b271b74
     1.1 --- a/src/video/win32/SDL_win32events.c	Sun May 09 19:55:28 2010 -0700
     1.2 +++ b/src/video/win32/SDL_win32events.c	Sun May 09 20:47:22 2010 -0700
     1.3 @@ -58,12 +58,6 @@
     1.4  #define WM_INPUT 0x00ff
     1.5  #endif
     1.6  
     1.7 -extern HCTX *g_hCtx;
     1.8 -extern HANDLE *mice;
     1.9 -extern int total_mice;
    1.10 -extern int tablet;
    1.11 -int pressure = 0;               /* the pressure reported by the tablet */
    1.12 -
    1.13  static WPARAM
    1.14  RemapVKEY(WPARAM wParam, LPARAM lParam)
    1.15  {
    1.16 @@ -104,8 +98,6 @@
    1.17  WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    1.18  {
    1.19      SDL_WindowData *data;
    1.20 -    RAWINPUT *raw;
    1.21 -    PACKET packet;
    1.22      LRESULT returnCode = -1;
    1.23  
    1.24      /* Send a SDL_SYSWMEVENT if the application wants them */
    1.25 @@ -142,35 +134,6 @@
    1.26  
    1.27      switch (msg) {
    1.28  
    1.29 -    case WT_PACKET:
    1.30 -        {
    1.31 -            /* if we receive such data we need to update the pressure */
    1.32 -            SDL_VideoData *videodata = data->videodata;
    1.33 -            if (videodata->wintabDLL
    1.34 -                && videodata->WTPacket((HCTX) lParam, (UINT) wParam, &packet)) {
    1.35 -                SDL_ChangeEnd(tablet, (int) packet.pkCursor);
    1.36 -                pressure = (int) packet.pkNormalPressure;
    1.37 -            }
    1.38 -        }
    1.39 -        break;
    1.40 -
    1.41 -    case WT_PROXIMITY:
    1.42 -        {
    1.43 -            /* checking where the proximity message showed up */
    1.44 -            int h_context = LOWORD(lParam);
    1.45 -            POINT point;
    1.46 -            GetCursorPos(&point);
    1.47 -            ScreenToClient(hwnd, &point);
    1.48 -
    1.49 -            /* are we in proximity or out of proximity */
    1.50 -            if (h_context == 0) {
    1.51 -                SDL_SendProximity(tablet, point.x, point.y, SDL_PROXIMITYOUT);
    1.52 -            } else {
    1.53 -                SDL_SendProximity(tablet, point.x, point.y, SDL_PROXIMITYIN);
    1.54 -            }
    1.55 -        }
    1.56 -        break;
    1.57 -
    1.58      case WM_SHOWWINDOW:
    1.59          {
    1.60              if (wParam) {
    1.61 @@ -183,13 +146,9 @@
    1.62  
    1.63      case WM_ACTIVATE:
    1.64          {
    1.65 -            int index;
    1.66 -            SDL_Keyboard *keyboard;
    1.67              BOOL minimized;
    1.68  
    1.69              minimized = HIWORD(wParam);
    1.70 -            index = data->videodata->keyboard;
    1.71 -            keyboard = SDL_GetKeyboard(index);
    1.72              if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
    1.73                  SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
    1.74                  SDL_SendWindowEvent(data->window,
    1.75 @@ -200,13 +159,13 @@
    1.76                                          SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
    1.77                  }
    1.78  #endif
    1.79 -                if (keyboard && keyboard->focus != data->window) {
    1.80 -                    SDL_SetKeyboardFocus(index, data->window);
    1.81 +                if (SDL_GetKeyboardFocus() != data->window) {
    1.82 +                    SDL_SetKeyboardFocus(data->window);
    1.83                  }
    1.84                  /* FIXME: Update keyboard state */
    1.85              } else {
    1.86 -                if (keyboard && keyboard->focus == data->window) {
    1.87 -                    SDL_SetKeyboardFocus(index, 0);
    1.88 +                if (SDL_GetKeyboardFocus() == data->window) {
    1.89 +                    SDL_SetKeyboardFocus(NULL);
    1.90                  }
    1.91                  if (minimized) {
    1.92                      SDL_SendWindowEvent(data->window,
    1.93 @@ -217,124 +176,22 @@
    1.94          returnCode = 0;
    1.95          break;
    1.96  
    1.97 -/* WinCE has no RawInput, so we use the classic mouse events.
    1.98 -   In classic Win32 this is done by WM_INPUT
    1.99 - */
   1.100 -#ifdef _WIN32_WCE
   1.101      case WM_MOUSEMOVE:
   1.102 -        SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
   1.103 +        SDL_SendMouseMotion(0, LOWORD(lParam), HIWORD(lParam));
   1.104          break;
   1.105  
   1.106      case WM_LBUTTONDOWN:
   1.107 -        SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
   1.108 -        SDL_SendMouseButton(0, SDL_PRESSED, SDL_BUTTON_LEFT);
   1.109 +        SDL_SendMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT);
   1.110          break;
   1.111  
   1.112      case WM_LBUTTONUP:
   1.113 -        SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
   1.114 -        SDL_SendMouseButton(0, SDL_RELEASED, SDL_BUTTON_LEFT);
   1.115 +        SDL_SendMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT);
   1.116          break;
   1.117 -#else /* _WIN32_WCE */
   1.118 -
   1.119 -    case WM_INPUT:             /* mouse events */
   1.120 -        {
   1.121 -            LPBYTE lpb;
   1.122 -            const RAWINPUTHEADER *header;
   1.123 -            int index = -1;
   1.124 -            int i;
   1.125 -            int size = 0;
   1.126 -            const RAWMOUSE *raw_mouse = NULL;
   1.127 -            POINT point;
   1.128 -            USHORT flags;
   1.129 -            int w, h;
   1.130 -
   1.131 -            /* we're collecting raw data to be able to identify the mouse (if there are several) */
   1.132 -            GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size,
   1.133 -                            sizeof(RAWINPUTHEADER));
   1.134 -            lpb = SDL_stack_alloc(BYTE, size);
   1.135 -            GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size,
   1.136 -                            sizeof(RAWINPUTHEADER));
   1.137 -            raw = (RAWINPUT *) lpb;
   1.138 -            header = &raw->header;
   1.139 -            flags = raw->data.mouse.usButtonFlags;
   1.140 -
   1.141 -            /* we're checking which mouse generated the event */
   1.142 -            for (i = 0; i < total_mice; ++i) {
   1.143 -                if (mice[i] == header->hDevice) {
   1.144 -                    index = i;
   1.145 -                    break;
   1.146 -                }
   1.147 -            }
   1.148 -            if (index < 0) {
   1.149 -                /* New mouse?  Should we dynamically update mouse list? */
   1.150 -                returnCode = 0;
   1.151 -                break;
   1.152 -            }
   1.153 -
   1.154 -            GetCursorPos(&point);
   1.155 -            ScreenToClient(hwnd, &point);
   1.156 -
   1.157 -            SDL_GetWindowSize(data->window, &w, &h);
   1.158 -            if (point.x >= 0 && point.y >= 0 && point.x < w && point.y < h) {
   1.159 -                SDL_SetMouseFocus(index, data->window);
   1.160 -            } else {
   1.161 -                SDL_SetMouseFocus(index, 0);
   1.162 -                /* FIXME: Should we be doing anything else here? */
   1.163 -                break;
   1.164 -            }
   1.165 -
   1.166 -            /* if the message was sent by a tablet we have to send also pressure */
   1.167 -            if (index == tablet) {
   1.168 -                SDL_SendMouseMotion(index, 0, point.x, point.y, pressure);
   1.169 -            } else {
   1.170 -                SDL_SendMouseMotion(index, 0, point.x, point.y, 0);
   1.171 -            }
   1.172 -            /* we're sending mouse buttons messages to check up if sth changed */
   1.173 -            if (flags & RI_MOUSE_LEFT_BUTTON_DOWN) {
   1.174 -                SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_LEFT);
   1.175 -            } else if (flags & RI_MOUSE_LEFT_BUTTON_UP) {
   1.176 -                SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_LEFT);
   1.177 -            }
   1.178 -            if (flags & RI_MOUSE_MIDDLE_BUTTON_DOWN) {
   1.179 -                SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_MIDDLE);
   1.180 -            } else if (flags & RI_MOUSE_MIDDLE_BUTTON_UP) {
   1.181 -                SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_MIDDLE);
   1.182 -            }
   1.183 -            if (flags & RI_MOUSE_RIGHT_BUTTON_DOWN) {
   1.184 -                SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_RIGHT);
   1.185 -            } else if (flags & RI_MOUSE_RIGHT_BUTTON_UP) {
   1.186 -                SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_RIGHT);
   1.187 -            }
   1.188 -            if (flags & RI_MOUSE_BUTTON_4_DOWN) {
   1.189 -                SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_X1);
   1.190 -            } else if (flags & RI_MOUSE_BUTTON_4_UP) {
   1.191 -                SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_X1);
   1.192 -            }
   1.193 -            if (flags & RI_MOUSE_BUTTON_5_DOWN) {
   1.194 -                SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_X2);
   1.195 -            } else if (flags & RI_MOUSE_BUTTON_5_UP) {
   1.196 -                SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_X2);
   1.197 -            }
   1.198 -            if (flags & RI_MOUSE_WHEEL) {
   1.199 -                SDL_SendMouseWheel(index, 0,
   1.200 -                                   (short) raw->data.mouse.usButtonData);
   1.201 -            }
   1.202 -            SDL_stack_free(lpb);
   1.203 -        }
   1.204 -        returnCode = 0;
   1.205 -        break;
   1.206 -#endif /* _WIN32_WCE */
   1.207  
   1.208      case WM_MOUSELEAVE:
   1.209          {
   1.210 -            int i;
   1.211 -
   1.212 -            for (i = 0; i < SDL_GetNumMice(); ++i) {
   1.213 -                SDL_Mouse *mouse = SDL_GetMouse(i);
   1.214 -
   1.215 -                if (mouse->focus == data->window) {
   1.216 -                    SDL_SetMouseFocus(i, 0);
   1.217 -                }
   1.218 +            if (SDL_GetMouseFocus() == data->window) {
   1.219 +                SDL_SetMouseFocus(NULL);
   1.220              }
   1.221          }
   1.222          returnCode = 0;
   1.223 @@ -343,15 +200,12 @@
   1.224      case WM_SYSKEYDOWN:
   1.225      case WM_KEYDOWN:
   1.226          {
   1.227 -            int index;
   1.228 -
   1.229              /* Ignore repeated keys */
   1.230              if (lParam & REPEATED_KEYMASK) {
   1.231                  returnCode = 0;
   1.232                  break;
   1.233              }
   1.234  
   1.235 -            index = data->videodata->keyboard;
   1.236              wParam = RemapVKEY(wParam, lParam);
   1.237              switch (wParam) {
   1.238              case VK_CONTROL:
   1.239 @@ -388,7 +242,7 @@
   1.240                  break;
   1.241              }
   1.242              if (wParam < 256) {
   1.243 -                SDL_SendKeyboardKey(index, SDL_PRESSED,
   1.244 +                SDL_SendKeyboardKey(SDL_PRESSED,
   1.245                                      data->videodata->key_layout[wParam]);
   1.246              }
   1.247          }
   1.248 @@ -398,9 +252,6 @@
   1.249      case WM_SYSKEYUP:
   1.250      case WM_KEYUP:
   1.251          {
   1.252 -            int index;
   1.253 -
   1.254 -            index = data->videodata->keyboard;
   1.255              wParam = RemapVKEY(wParam, lParam);
   1.256              switch (wParam) {
   1.257              case VK_CONTROL:
   1.258 @@ -441,11 +292,11 @@
   1.259              if (wParam == VK_SNAPSHOT
   1.260                  && SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PRINTSCREEN] ==
   1.261                  SDL_RELEASED) {
   1.262 -                SDL_SendKeyboardKey(index, SDL_PRESSED,
   1.263 +                SDL_SendKeyboardKey(SDL_PRESSED,
   1.264                                      data->videodata->key_layout[wParam]);
   1.265              }
   1.266              if (wParam < 256) {
   1.267 -                SDL_SendKeyboardKey(index, SDL_RELEASED,
   1.268 +                SDL_SendKeyboardKey(SDL_RELEASED,
   1.269                                      data->videodata->key_layout[wParam]);
   1.270              }
   1.271          }
   1.272 @@ -470,14 +321,14 @@
   1.273                  text[2] = 0x80 | (char) (wParam & 0x3F);
   1.274                  text[3] = '\0';
   1.275              }
   1.276 -            SDL_SendKeyboardText(data->videodata->keyboard, text);
   1.277 +            SDL_SendKeyboardText(text);
   1.278          }
   1.279          returnCode = 0;
   1.280          break;
   1.281  
   1.282      case WM_INPUTLANGCHANGE:
   1.283          {
   1.284 -            WIN_UpdateKeymap(data->videodata->keyboard);
   1.285 +            WIN_UpdateKeymap();
   1.286          }
   1.287          returnCode = 1;
   1.288          break;