src/video/windows/SDL_windowsevents.c
changeset 6782 582d35419e8a
parent 6682 a0cbe4e5a07a
child 6788 036f53f2f5aa
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Sun Dec 30 19:05:50 2012 -0800
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Mon Dec 31 09:30:15 2012 -0800
     1.3 @@ -221,6 +221,10 @@
     1.4  		HRAWINPUT hRawInput = (HRAWINPUT)lParam;
     1.5  		RAWINPUT inp;
     1.6  		UINT size = sizeof(inp);
     1.7 +
     1.8 +		if(!SDL_GetMouse()->relative_mode)
     1.9 +			break;
    1.10 +
    1.11  		GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER));
    1.12  
    1.13  		/* Mouse data */
    1.14 @@ -229,8 +233,24 @@
    1.15  			RAWMOUSE* mouse = &inp.data.mouse;
    1.16  
    1.17  			if((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE)
    1.18 +			{
    1.19  				SDL_SendMouseMotion(data->window, 1, (int)mouse->lLastX, (int)mouse->lLastY);
    1.20 +			}
    1.21 +			else
    1.22 +			{
    1.23 +				// synthesize relative moves from the abs position
    1.24 +				static SDL_Point initialMousePoint;
    1.25 +				if ( initialMousePoint.x == 0 && initialMousePoint.y == 0 )
    1.26 +				{
    1.27 +					initialMousePoint.x = mouse->lLastX;
    1.28 +					initialMousePoint.y = mouse->lLastY;
    1.29 +				}
    1.30  
    1.31 +				SDL_SendMouseMotion(data->window, 1, (int)(mouse->lLastX-initialMousePoint.x), (int)(mouse->lLastY-initialMousePoint.y) );
    1.32 +
    1.33 +				initialMousePoint.x = mouse->lLastX;
    1.34 +				initialMousePoint.y = mouse->lLastY;
    1.35 +			}
    1.36  		}
    1.37  		break;
    1.38  	}