src/video/windows/SDL_windowsevents.c
changeset 6945 d97f9251ac3a
parent 6944 e8effbc1a10e
child 6947 18ccf3e4921d
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Wed Feb 27 11:39:41 2013 -0800
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Wed Feb 27 11:39:43 2013 -0800
     1.3 @@ -226,11 +226,26 @@
     1.4  	if ( rawButtons != data->mouse_button_flags )
     1.5  	{
     1.6  		Uint32 mouseFlags = SDL_GetMouseState( NULL, NULL );
     1.7 -		WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_1_DOWN), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
     1.8 -		WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_2_DOWN), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_RIGHT );
     1.9 -		WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_3_DOWN), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_MIDDLE );
    1.10 -		WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_4_DOWN), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
    1.11 -		WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_5_DOWN), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
    1.12 +		if ( (rawButtons & RI_MOUSE_BUTTON_1_DOWN) )
    1.13 +			WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_1_DOWN), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
    1.14 +		if ( (rawButtons & RI_MOUSE_BUTTON_1_UP) )
    1.15 +			WIN_CheckWParamMouseButton(  !(rawButtons & RI_MOUSE_BUTTON_1_UP), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
    1.16 +		if ( (rawButtons & RI_MOUSE_BUTTON_2_DOWN) )
    1.17 +			WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_2_DOWN), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
    1.18 +		if ( (rawButtons & RI_MOUSE_BUTTON_2_UP) )
    1.19 +			WIN_CheckWParamMouseButton(  !(rawButtons & RI_MOUSE_BUTTON_2_UP), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
    1.20 +		if ( (rawButtons & RI_MOUSE_BUTTON_3_DOWN) )
    1.21 +			WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_3_DOWN), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
    1.22 +		if ( (rawButtons & RI_MOUSE_BUTTON_3_UP) )
    1.23 +			WIN_CheckWParamMouseButton(  !(rawButtons & RI_MOUSE_BUTTON_3_UP), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
    1.24 +		if ( (rawButtons & RI_MOUSE_BUTTON_4_DOWN) )
    1.25 +			WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_4_DOWN), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
    1.26 +		if ( (rawButtons & RI_MOUSE_BUTTON_4_UP) )
    1.27 +			WIN_CheckWParamMouseButton(  !(rawButtons & RI_MOUSE_BUTTON_4_UP), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
    1.28 +		if ( (rawButtons & RI_MOUSE_BUTTON_5_DOWN) )
    1.29 +			WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_5_DOWN), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
    1.30 +		if ( (rawButtons & RI_MOUSE_BUTTON_5_UP) )
    1.31 +			WIN_CheckWParamMouseButton(  !(rawButtons & RI_MOUSE_BUTTON_5_UP), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
    1.32  		data->mouse_button_flags = rawButtons;
    1.33  	}
    1.34  }
    1.35 @@ -295,6 +310,9 @@
    1.36  
    1.37              minimized = HIWORD(wParam);
    1.38              if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
    1.39 +				Uint32 mouseFlags;
    1.40 +				SHORT keyState;
    1.41 +
    1.42                  SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
    1.43                  SDL_SendWindowEvent(data->window,
    1.44                                      SDL_WINDOWEVENT_RESTORED, 0, 0);
    1.45 @@ -305,10 +323,23 @@
    1.46                  if (SDL_GetKeyboardFocus() != data->window) {
    1.47                      SDL_SetKeyboardFocus(data->window);
    1.48                  }
    1.49 -				/* mouse buttons may have changed state here, in theory we would need
    1.50 +				/* mouse buttons may have changed state here, we need
    1.51  				to resync them, but we will get a WM_MOUSEMOVE right away which will fix 
    1.52 -				things up
    1.53 +				things up if in non raw mode also
    1.54  				*/
    1.55 +				mouseFlags = SDL_GetMouseState( NULL, NULL );
    1.56 +
    1.57 +				keyState = GetAsyncKeyState( VK_LBUTTON );
    1.58 +				WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
    1.59 +				keyState = GetAsyncKeyState( VK_RBUTTON );
    1.60 +				WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
    1.61 +				keyState = GetAsyncKeyState( VK_MBUTTON );
    1.62 +				WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
    1.63 +				keyState = GetAsyncKeyState( VK_XBUTTON1 );
    1.64 +				WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
    1.65 +				keyState = GetAsyncKeyState( VK_XBUTTON2 );
    1.66 +				WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
    1.67 +				data->mouse_button_flags = 0;
    1.68  
    1.69  				if(SDL_GetMouse()->relative_mode) {
    1.70  					LONG cx, cy;
    1.71 @@ -348,15 +379,16 @@
    1.72  		if( !SDL_GetMouse()->relative_mode )
    1.73  	        SDL_SendMouseMotion(data->window, 0, LOWORD(lParam), HIWORD(lParam));
    1.74  		/* don't break here, fall through to check the wParam like the button presses */
    1.75 +	case WM_LBUTTONUP:
    1.76 +	case WM_RBUTTONUP:
    1.77 +	case WM_MBUTTONUP:
    1.78 +	case WM_XBUTTONUP:
    1.79  	case WM_LBUTTONDOWN:
    1.80 -	case WM_LBUTTONUP:
    1.81  	case WM_RBUTTONDOWN:
    1.82 -	case WM_RBUTTONUP:
    1.83  	case WM_MBUTTONDOWN:
    1.84 -	case WM_MBUTTONUP:
    1.85  	case WM_XBUTTONDOWN:
    1.86 -	case WM_XBUTTONUP:
    1.87 -		WIN_CheckWParamMouseButtons( wParam, data );
    1.88 +		if( !SDL_GetMouse()->relative_mode )
    1.89 +			WIN_CheckWParamMouseButtons( wParam, data );
    1.90  		break;
    1.91  
    1.92  	case WM_INPUT:
    1.93 @@ -394,8 +426,7 @@
    1.94  				initialMousePoint.x = mouse->lLastX;
    1.95  				initialMousePoint.y = mouse->lLastY;
    1.96  			}
    1.97 -			/ * this call doesn't actually work, usButtonFlags gets zero'd if you hold down button 1 and then move the mouse
    1.98 -			WIN_CheckRawMouseButtons( mouse->usButtonFlags, data ); */
    1.99 +			WIN_CheckRawMouseButtons( mouse->usButtonFlags, data ); 
   1.100  		}
   1.101  		break;
   1.102  	}