From 8f9619e21afa596e847f16f46f353f52da6b8767 Mon Sep 17 00:00:00 2001 From: Xawotihs Date: Mon, 27 Jun 2011 21:18:16 +0000 Subject: [PATCH] Added support for wheel mouse events --- JGE/src/SDLmain.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/JGE/src/SDLmain.cpp b/JGE/src/SDLmain.cpp index 1ee67b543..a8bc06481 100644 --- a/JGE/src/SDLmain.cpp +++ b/JGE/src/SDLmain.cpp @@ -151,8 +151,9 @@ public: void OnMouseDoubleClicked(const SDL_MouseButtonEvent& event); void OnMouseClicked(const SDL_MouseButtonEvent& event); void OnMouseMoved(const SDL_MouseMotionEvent& event); + void OnMouseWheel(int x, int y); - void OnTouchEvent(const SDL_TouchFingerEvent& event); + void OnTouchEvent(const SDL_TouchFingerEvent& event); void OnEvent(SDL_Event* Event) { @@ -201,6 +202,10 @@ public: break; + case SDL_MOUSEWHEEL: + OnMouseWheel(Event->wheel.x, Event->wheel.y); + break; + case SDL_FINGERMOTION: case SDL_FINGERDOWN: case SDL_FINGERUP: @@ -433,6 +438,29 @@ void SdlApp::OnMouseDoubleClicked(const SDL_MouseButtonEvent& event) #endif } +void SdlApp::OnMouseWheel(int x, int y) +{ + if(!x && y) + { // Vertical wheel + if(y > 0) + { + g_engine->HoldKey_NoRepeat(JGE_BTN_UP); + } + else + { + g_engine->HoldKey_NoRepeat(JGE_BTN_DOWN); + } + } + else if(x && !y) + { // Horizontal wheel + g_engine->HoldKey_NoRepeat(JGE_BTN_LEFT); + } + else + { + g_engine->HoldKey_NoRepeat(JGE_BTN_RIGHT); + } +} + void SdlApp::OnMouseClicked(const SDL_MouseButtonEvent& event) { if (event.type == SDL_MOUSEBUTTONDOWN)