예제 #1
0
	bool InputState::Update()
	{
		bool result = false;
		_backspacePressed = false;
		_text = "";

		_wheelAmount = 0;

		SDL_Event e;
		while (SDL_PollEvent(&e) != 0)
		{
			if (e.type == SDL_QUIT)
				result = true;
			else if (e.type == SDL_MOUSEBUTTONDOWN)
				HandleMouseButtonDown(e);
			else if (e.type == SDL_MOUSEBUTTONUP)
				HandleMouseButtonUp(e);
			else if (e.type == SDL_MOUSEWHEEL)
				HandleMouseWheel(e);
			else if (e.type == SDL_TEXTINPUT)
				HandleText(e);
			else if (e.type == SDL_KEYDOWN)
				HandleKeyboard(e);
		}

		int mousex, mousey;

		SDL_GetMouseState(&mousex, &mousey);

		_mousePosition = glm::vec2(float(mousex), _windowSize.y - float(mousey));

		return result;
	}
예제 #2
0
파일: Input.cpp 프로젝트: subr3v/s-engine
void FInput::HandleMessage(MSG Message)
{
	char MessageKey = Message.wParam;
	switch (Message.message)
	{
	case WM_KEYDOWN:
		if (bKeysDown[MessageKey] == false)
		{
			bKeysDown[MessageKey] = bKeysPressed[MessageKey] = true;
		}
		break;
	case WM_KEYUP:
		bKeysDown[MessageKey] = bKeysPressed[MessageKey] = false;
		break;
	case WM_RBUTTONDOWN:
		HandleMouseButtonDown(MouseButton::Right);
		break;
	case WM_MBUTTONDOWN:
		HandleMouseButtonDown(MouseButton::Middle);
		break;
	case WM_LBUTTONDOWN:
		HandleMouseButtonDown(MouseButton::Left);
		break;
	case WM_RBUTTONUP:
		HandleMouseButtonUp(MouseButton::Right);
		break;
	case WM_MBUTTONUP:
		HandleMouseButtonUp(MouseButton::Middle);
		break;
	case WM_LBUTTONUP:
		HandleMouseButtonUp(MouseButton::Left);
		break;
	case WM_MOUSEMOVE:
		MouseX = LOWORD(Message.lParam);
		MouseY = HIWORD(Message.lParam);
		break;
	case WM_CHAR:
		if (CurrentTextCount < kMaxCharTextBuffer && Message.wParam > 0 && Message.wParam < 0x10000)
		{
			InputTextBuffer[CurrentTextCount++] = (u8)Message.wParam;
		}
	default:
		break;
	}
}
예제 #3
0
// Returns true if parent needs to be redrawn
bool Envelope::MouseEvent(wxMouseEvent & event, wxRect & r,
                          double h, double pps, bool dB,
                          float zoomMin, float zoomMax)
{
   if (event.ButtonDown() && mButton == wxMOUSE_BTN_NONE)
      return HandleMouseButtonDown( event, r, h, pps,dB,
                                    zoomMin, zoomMax);
   if (event.Dragging() && mDragPoint >= 0)
      return HandleDragging( event, r, h, pps,dB,
                             zoomMin, zoomMax);
   if (event.ButtonUp() && event.GetButton() == mButton)
      return HandleMouseButtonUp( event, r, h, pps, dB,
                                  zoomMin, zoomMax);
   return false;
}