src/video/windows/SDL_windowsevents.c
changeset 8976 1a5d959d7b32
parent 8953 dc80dc0bd22e
child 9257 6f41196c2d6b
equal deleted inserted replaced
8975:180271d72b1e 8976:1a5d959d7b32
   451             GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER));
   451             GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER));
   452 
   452 
   453             /* Mouse data */
   453             /* Mouse data */
   454             if (inp.header.dwType == RIM_TYPEMOUSE) {
   454             if (inp.header.dwType == RIM_TYPEMOUSE) {
   455                 if (isRelative) {
   455                 if (isRelative) {
   456                     RAWMOUSE* mouse = &inp.data.mouse;
   456                     RAWMOUSE* rawmouse = &inp.data.mouse;
   457 
   457 
   458                     if ((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) {
   458                     if ((rawmouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) {
   459                         SDL_SendMouseMotion(data->window, 0, 1, (int)mouse->lLastX, (int)mouse->lLastY);
   459                         SDL_SendMouseMotion(data->window, 0, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY);
   460                     } else {
   460                     } else {
   461                         /* synthesize relative moves from the abs position */
   461                         /* synthesize relative moves from the abs position */
   462                         static SDL_Point initialMousePoint;
   462                         static SDL_Point initialMousePoint;
   463                         if (initialMousePoint.x == 0 && initialMousePoint.y == 0) {
   463                         if (initialMousePoint.x == 0 && initialMousePoint.y == 0) {
   464                             initialMousePoint.x = mouse->lLastX;
   464                             initialMousePoint.x = rawmouse->lLastX;
   465                             initialMousePoint.y = mouse->lLastY;
   465                             initialMousePoint.y = rawmouse->lLastY;
   466                         }
   466                         }
   467 
   467 
   468                         SDL_SendMouseMotion(data->window, 0, 1, (int)(mouse->lLastX-initialMousePoint.x), (int)(mouse->lLastY-initialMousePoint.y) );
   468                         SDL_SendMouseMotion(data->window, 0, 1, (int)(rawmouse->lLastX-initialMousePoint.x), (int)(rawmouse->lLastY-initialMousePoint.y) );
   469 
   469 
   470                         initialMousePoint.x = mouse->lLastX;
   470                         initialMousePoint.x = rawmouse->lLastX;
   471                         initialMousePoint.y = mouse->lLastY;
   471                         initialMousePoint.y = rawmouse->lLastY;
   472                     }
   472                     }
   473                     WIN_CheckRawMouseButtons( mouse->usButtonFlags, data );
   473                     WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data);
   474                 } else if (isCapture) {
   474                 } else if (isCapture) {
   475                     /* we check for where Windows thinks the system cursor lives in this case, so we don't really lose mouse accel, etc. */
   475                     /* we check for where Windows thinks the system cursor lives in this case, so we don't really lose mouse accel, etc. */
   476                     POINT pt;
   476                     POINT pt;
   477                     HWND hwnd = data->hwnd;
       
   478                     GetCursorPos(&pt);
   477                     GetCursorPos(&pt);
   479                     if (WindowFromPoint(pt) != hwnd) {  /* if in the window, WM_MOUSEMOVE, etc, will cover it. */
   478                     if (WindowFromPoint(pt) != hwnd) {  /* if in the window, WM_MOUSEMOVE, etc, will cover it. */
   480                         ScreenToClient(data->hwnd, &pt);
   479                         ScreenToClient(hwnd, &pt);
   481                         SDL_SendMouseMotion(data->window, 0, 0, (int) pt.x, (int) pt.y);
   480                         SDL_SendMouseMotion(data->window, 0, 0, (int) pt.x, (int) pt.y);
   482                         SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT);
   481                         SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT);
   483                         SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT);
   482                         SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT);
   484                         SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE);
   483                         SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE);
   485                         SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_XBUTTON1) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X1);
   484                         SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_XBUTTON1) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X1);
   890     case WM_NCHITTEST:
   889     case WM_NCHITTEST:
   891         {
   890         {
   892             SDL_Window *window = data->window;
   891             SDL_Window *window = data->window;
   893             if (window->hit_test) {
   892             if (window->hit_test) {
   894                 POINT winpoint = { (int) LOWORD(lParam), (int) HIWORD(lParam) };
   893                 POINT winpoint = { (int) LOWORD(lParam), (int) HIWORD(lParam) };
   895                 if (ScreenToClient(data->hwnd, &winpoint)) {
   894                 if (ScreenToClient(hwnd, &winpoint)) {
   896                     const SDL_Point point = { (int) winpoint.x, (int) winpoint.y };
   895                     const SDL_Point point = { (int) winpoint.x, (int) winpoint.y };
   897                     const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
   896                     const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
   898                     switch (rc) {
   897                     switch (rc) {
   899                         case SDL_HITTEST_DRAGGABLE: return HTCAPTION;
   898                         case SDL_HITTEST_DRAGGABLE: return HTCAPTION;
   900                         case SDL_HITTEST_RESIZE_TOPLEFT: return HTTOPLEFT;
   899                         case SDL_HITTEST_RESIZE_TOPLEFT: return HTTOPLEFT;
   903                         case SDL_HITTEST_RESIZE_RIGHT: return HTRIGHT;
   902                         case SDL_HITTEST_RESIZE_RIGHT: return HTRIGHT;
   904                         case SDL_HITTEST_RESIZE_BOTTOMRIGHT: return HTBOTTOMRIGHT;
   903                         case SDL_HITTEST_RESIZE_BOTTOMRIGHT: return HTBOTTOMRIGHT;
   905                         case SDL_HITTEST_RESIZE_BOTTOM: return HTBOTTOM;
   904                         case SDL_HITTEST_RESIZE_BOTTOM: return HTBOTTOM;
   906                         case SDL_HITTEST_RESIZE_BOTTOMLEFT: return HTBOTTOMLEFT;
   905                         case SDL_HITTEST_RESIZE_BOTTOMLEFT: return HTBOTTOMLEFT;
   907                         case SDL_HITTEST_RESIZE_LEFT: return HTLEFT;
   906                         case SDL_HITTEST_RESIZE_LEFT: return HTLEFT;
       
   907                         case SDL_HITTEST_NORMAL: return HTCLIENT;
   908                     }
   908                     }
   909                 }
   909                 }
   910                 /* If we didn't return, this will call DefWindowProc below. */
   910                 /* If we didn't return, this will call DefWindowProc below. */
   911             }
   911             }
   912         }
   912         }