From b98584957c587073810c462601e6f9449591c6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20=E2=80=98Touky=E2=80=99=20Huet?= Date: Sat, 17 May 2014 01:31:03 +0000 Subject: [PATCH] Added Mouse scroll as axis. --- src/input/input.cpp | 1 + src/input/input.h | 6 +++--- src/platform/sdl/sdlinput.cpp | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/input/input.cpp b/src/input/input.cpp index 06c3e1f3..0affb6ec 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -72,6 +72,7 @@ InputDeviceInternal* InputDeviceInternal::CreateStandardMouse() mouse->AddAxis("X"); mouse->AddAxis("Y"); + mouse->AddAxis("Scroll"); mouse->AddCursor("Cursor"); diff --git a/src/input/input.h b/src/input/input.h index 864ddcfa..bdd6e680 100644 --- a/src/input/input.h +++ b/src/input/input.h @@ -100,11 +100,11 @@ private: static Array devices; template - int GetItemIndex(const char* name, const Array& Array) const + int GetItemIndex(const char* name, const Array& array) const { - for (int i = 0; i < Array.Count(); ++i) + for (int i = 0; i < array.Count(); ++i) { - if (Array[i] == name) + if (array[i] == name) return i; } return -1; diff --git a/src/platform/sdl/sdlinput.cpp b/src/platform/sdl/sdlinput.cpp index 2f7bdac1..2f0b9c6b 100644 --- a/src/platform/sdl/sdlinput.cpp +++ b/src/platform/sdl/sdlinput.cpp @@ -179,6 +179,8 @@ void SdlInputData::Tick(float seconds) } # endif + m_mouse->SetAxis(2, 0); + /* Handle keyboard and WM events */ SDL_Event event; while (SDL_PollEvent(&event)) @@ -199,6 +201,8 @@ void SdlInputData::Tick(float seconds) { if (event.button.button != SDL_BUTTON_WHEELUP && event.button.button != SDL_BUTTON_WHEELDOWN) m_mouse->SetKey(event.button.button - 1, event.type == SDL_MOUSEBUTTONDOWN); + else + m_mouse->SetAxis(2, (event.button.button != SDL_BUTTON_WHEELUP) ? (1) : (-1)); // TODO: mouse wheel as axis break; }