src/video/windows/SDL_windowsevents.c
changeset 6350 19545983ac76
parent 6138 4c64952a58fb
child 6430 48d519500f7e
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Mon Jul 02 08:37:48 2012 -0400
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Tue Jul 03 23:52:02 2012 -0400
     1.3 @@ -173,6 +173,24 @@
     1.4                  if (SDL_GetKeyboardFocus() != data->window) {
     1.5                      SDL_SetKeyboardFocus(data->window);
     1.6                  }
     1.7 +
     1.8 +				if(SDL_GetMouse()->relative_mode) {
     1.9 +					LONG cx, cy;
    1.10 +					RECT rect;
    1.11 +					GetWindowRect(hwnd, &rect);
    1.12 +
    1.13 +					cx = (rect.left + rect.right) / 2;
    1.14 +					cy = (rect.top + rect.bottom) / 2;
    1.15 +
    1.16 +					/* Make an absurdly small clip rect */
    1.17 +					rect.left = cx-1;
    1.18 +					rect.right = cx+1;
    1.19 +					rect.top = cy-1;
    1.20 +					rect.bottom = cy+1;
    1.21 +
    1.22 +					ClipCursor(&rect);
    1.23 +				}
    1.24 +
    1.25                  /*
    1.26                   * FIXME: Update keyboard state
    1.27                   */
    1.28 @@ -191,6 +209,8 @@
    1.29          break;
    1.30  
    1.31  	case WM_MOUSEMOVE:
    1.32 +		if(SDL_GetMouse()->relative_mode)
    1.33 +			break;
    1.34  #ifdef _WIN32_WCE
    1.35          /* transform coords for VGA, WVGA... */
    1.36          {
    1.37 @@ -208,6 +228,25 @@
    1.38          SDL_SendMouseMotion(data->window, 0, LOWORD(lParam), HIWORD(lParam));
    1.39          break;
    1.40  
    1.41 +	case WM_INPUT:
    1.42 +	{
    1.43 +		HRAWINPUT hRawInput = (HRAWINPUT)lParam;
    1.44 +		RAWINPUT inp;
    1.45 +		UINT size = sizeof(inp);
    1.46 +		GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER));
    1.47 +
    1.48 +		/* Mouse data */
    1.49 +		if(inp.header.dwType == RIM_TYPEMOUSE)
    1.50 +		{
    1.51 +			RAWMOUSE* mouse = &inp.data.mouse;
    1.52 +
    1.53 +			if((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE)
    1.54 +				SDL_SendMouseMotion(data->window, 1, (int)mouse->lLastX, (int)mouse->lLastY);
    1.55 +
    1.56 +		}
    1.57 +		break;
    1.58 +	}
    1.59 +
    1.60      case WM_LBUTTONDOWN:
    1.61          SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.62          break;