void InputContext::TriggerMouseEvent(MouseEvent &mouse) { emit MouseEventReceived(&mouse); switch(mouse.eventType) { case MouseEvent::MouseMove: emit MouseMove(&mouse); break; case MouseEvent::MouseScroll: emit MouseScroll(&mouse); break; case MouseEvent::MousePressed: switch(mouse.button) { case MouseEvent::LeftButton: emit MouseLeftPressed(&mouse); break; case MouseEvent::RightButton: emit MouseRightPressed(&mouse); break; case MouseEvent::MiddleButton: emit MouseMiddlePressed(&mouse); break; ///\todo XButton1 and XButton2 support? } break; case MouseEvent::MouseReleased: switch(mouse.button) { case MouseEvent::LeftButton: emit MouseLeftReleased(&mouse); break; case MouseEvent::RightButton: emit MouseRightReleased(&mouse); break; case MouseEvent::MiddleButton: emit MouseMiddleReleased(&mouse); break; ///\todo XButton1 and XButton2 support? } break; case MouseEvent::MouseDoubleClicked: emit MouseDoubleClicked(&mouse); break; default: assert(false); break; } }
void SugoiGame::PollEvents() { sr::Event event; while (m_window->PollEvent(event)) { switch (event.type) { case sr::Event::WINDOW_CLOSED: m_window->Close(); break; case sr::Event::KEY_PRESSED: KeyPressed(event.key.keyCode, event.key.alt, event.key.control, event.key.shift, event.key.system); break; case sr::Event::KEY_RELEASED: KeyReleased(event.key.keyCode, event.key.alt, event.key.control, event.key.shift, event.key.system); break; case sr::Event::MOUSE_PRESSED: if (event.mouseClicked.mouseCode == GLFW_MOUSE_BUTTON_1) { MouseLeftPressed(); } else if (event.mouseClicked.mouseCode == GLFW_MOUSE_BUTTON_2) { MouseRightPressed(); } else if (event.mouseClicked.mouseCode == GLFW_MOUSE_BUTTON_3) { MouseMiddlePressed(); } break; case sr::Event::MOUSE_RELEASED: if (event.mouseClicked.mouseCode == GLFW_MOUSE_BUTTON_1) { MouseLeftReleased(event.mouseClicked.x, event.mouseClicked.y); } else if (event.mouseClicked.mouseCode == GLFW_MOUSE_BUTTON_2) { MouseRightReleased(); } else if (event.mouseClicked.mouseCode == GLFW_MOUSE_BUTTON_3) { MouseMiddleReleased(); } break; case sr::Event::MOUSE_MOVED: MouseMoved(event.mouseMoved.x, event.mouseMoved.y); break; case sr::Event::MOUSE_SCROLLED: MouseScroll(event.mouseScrolled.xoffset, event.mouseScrolled.yoffset); break; } } }