Browse Source

Added Mouse scroll as axis.

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 10 years ago
parent
commit
b98584957c
3 changed files with 8 additions and 3 deletions
  1. +1
    -0
      src/input/input.cpp
  2. +3
    -3
      src/input/input.h
  3. +4
    -0
      src/platform/sdl/sdlinput.cpp

+ 1
- 0
src/input/input.cpp View File

@@ -72,6 +72,7 @@ InputDeviceInternal* InputDeviceInternal::CreateStandardMouse()


mouse->AddAxis("X"); mouse->AddAxis("X");
mouse->AddAxis("Y"); mouse->AddAxis("Y");
mouse->AddAxis("Scroll");


mouse->AddCursor("Cursor"); mouse->AddCursor("Cursor");




+ 3
- 3
src/input/input.h View File

@@ -100,11 +100,11 @@ private:
static Array<InputDevice*> devices; static Array<InputDevice*> devices;


template <typename T> template <typename T>
int GetItemIndex(const char* name, const Array<String, T>& Array) const
int GetItemIndex(const char* name, const Array<String, T>& 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 i;
} }
return -1; return -1;


+ 4
- 0
src/platform/sdl/sdlinput.cpp View File

@@ -179,6 +179,8 @@ void SdlInputData::Tick(float seconds)
} }
# endif # endif


m_mouse->SetAxis(2, 0);

/* Handle keyboard and WM events */ /* Handle keyboard and WM events */
SDL_Event event; SDL_Event event;
while (SDL_PollEvent(&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) if (event.button.button != SDL_BUTTON_WHEELUP && event.button.button != SDL_BUTTON_WHEELDOWN)
m_mouse->SetKey(event.button.button - 1, event.type == SDL_MOUSEBUTTONDOWN); 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 // TODO: mouse wheel as axis
break; break;
} }


Loading…
Cancel
Save