예제 #1
0
void Mouse::handleMsg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    RAWINPUT *pRaw = 0;
    UINT size = TEMP_BUFFER_SIZE;
	POINT p;

    switch (msg)
    {
    default:
        break;

    case WM_INPUT:
        GetRawInputData(reinterpret_cast<HRAWINPUT>(lParam), RID_INPUT,
            m_tempBuffer, &size, sizeof(RAWINPUTHEADER));

        pRaw = reinterpret_cast<RAWINPUT*>(m_tempBuffer);

        if (pRaw->header.dwType == RIM_TYPEMOUSE)
        {
            m_xPosRelative = static_cast<float>(pRaw->data.mouse.lLastX);
            m_yPosRelative = static_cast<float>(pRaw->data.mouse.lLastY);

            if (m_enableFiltering)
            {
                performMouseFiltering(m_xPosRelative, m_yPosRelative);

                m_xPosRelative = m_filtered[0];
                m_yPosRelative = m_filtered[1];

                performMouseSmoothing(m_xPosRelative, m_yPosRelative);

                m_xPosRelative = m_filtered[0];
                m_yPosRelative = m_filtered[1];
            }
        }

        break;

    case WM_MOUSEMOVE:
        m_xPosAbsolute = static_cast<int>(static_cast<short>(LOWORD(lParam)));
        m_yPosAbsolute = static_cast<int>(static_cast<short>(HIWORD(lParam)));
        break;

    case WM_MOUSEWHEEL:
        m_wheelDelta += static_cast<int>(static_cast<int>(wParam) >> 16);
        break;
    }
}
예제 #2
0
void TgcD3dInput::updateMouse()
{
	DirectInput::MouseState &mouseState = mouseDevice.CurrentMouseState;
	memcpy(previousMouseButtonsState,currentMouseButtonsState,sizeof(currentMouseButtonsState));
	memcpy(currentMouseButtonsState,mouseState.GetMouseButtons(),sizeof(currentMouseButtonsState));
	
	//Hacer copia del estado actual
	//Array.Copy(currentMouseButtonsState, previousMouseButtonsState, currentMouseButtonsState.Length);
	
	//Actualizar estado de cada boton
	//byte[] mouseStateButtons = mouseState.GetMouseButtons();
	//currentMouseButtonsState[(int)MouseButtons.BUTTON_LEFT] = mouseStateButtons[(int)MouseButtons.BUTTON_LEFT] != 0;
	//currentMouseButtonsState[(int)MouseButtons.BUTTON_MIDDLE] = mouseStateButtons[(int)MouseButtons.BUTTON_MIDDLE] != 0;
	//currentMouseButtonsState[(int)MouseButtons.BUTTON_RIGHT] = mouseStateButtons[(int)MouseButtons.BUTTON_RIGHT] != 0;
	
	
	//Mouse X, Y relative
	if (enableMouseFiltering)
	{
		performMouseFiltering(mouseState.X, mouseState.Y);
		performMouseSmoothing(deltaMouseX, deltaMouseY);
	}
	else
	{
		deltaMouseX = mouseState.X;
		deltaMouseY = mouseState.Y;
	}
	
	
	//Mouse Wheel
	if (mouseState.Z > 0)
	{
		deltaMouseWheel = 1.0f;
	}
	else if (mouseState.Z < 0)
	{
		deltaMouseWheel = -1.0f;
	}
	else
	{
		deltaMouseWheel = 0.0f;
	}
}