Explorar el Código

Added Mouse scroll as axis.

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> hace 10 años
padre
commit
b98584957c
Se han modificado 3 ficheros con 8 adiciones y 3 borrados
  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 Ver fichero

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

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

mouse->AddCursor("Cursor");



+ 3
- 3
src/input/input.h Ver fichero

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

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 -1;


+ 4
- 0
src/platform/sdl/sdlinput.cpp Ver fichero

@@ -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;
}


Cargando…
Cancelar
Guardar