Sfoglia il codice sorgente

input: fix a problem with the SDLK_WORLD_0 macro; arrow keys weren't

handled properly.
undefined
Sam Hocevar 11 anni fa
parent
commit
0529e067f2
2 ha cambiato i file con 17 aggiunte e 14 eliminazioni
  1. +3
    -1
      src/input/inputdevice.cpp
  2. +14
    -13
      src/platform/sdl/sdlinput.cpp

+ 3
- 1
src/input/inputdevice.cpp Vedi File

@@ -45,7 +45,9 @@ void InputDeviceInternal::AddCursor(const char* name)
InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard()
{
InputDeviceInternal* keyboard = new InputDeviceInternal("Keyboard");
# define KEY_FUNC(key, value) keyboard->AddKey(#key);
/* "value" is unused, what matters is the index. */
# define KEY_FUNC(key, value) \
keyboard->AddKey(#key);
# include "input/keys.h"
# undef KEY_FUNC
return keyboard;


+ 14
- 13
src/platform/sdl/sdlinput.cpp Vedi File

@@ -61,6 +61,7 @@ private:
Array<SDL_Joystick*, InputDeviceInternal*> m_joysticks;
InputDeviceInternal* m_mouse;
InputDeviceInternal* m_keyboard;

ivec2 m_prevmouse;
float m_app_w;
float m_app_h;
@@ -126,10 +127,10 @@ SdlInput::SdlInput()

# ifdef LOL_INPUT_V2
InputDeviceInternal* stick = new InputDeviceInternal(String::Printf("Joystick%d", i+1).C());
for (int i = 0; i < SDL_JoystickNumAxes(sdlstick); ++i)
stick->AddAxis(String::Printf("Axis%d", i+1).C());
for (int i = 0; i < SDL_JoystickNumButtons(sdlstick); ++i)
stick->AddKey(String::Printf("Button%d", i+1).C());
for (int j = 0; j < SDL_JoystickNumAxes(sdlstick); ++j)
stick->AddAxis(String::Printf("Axis%d", j + 1).C());
for (int j = 0; j < SDL_JoystickNumButtons(sdlstick); ++j)
stick->AddKey(String::Printf("Button%d", j + 1).C());

m_data->m_joysticks.Push(sdlstick, stick);
# else // !LOL_INPUT_V2
@@ -290,7 +291,7 @@ void SdlInputData::Tick(float seconds)

# else // !LOL_INPUT_V2
Input::SetMousePos(mouse);
# endif // LOL_INPUT_V2
# endif // LOL_INPUT_V2

# if SDL_VERSION_ATLEAST(1,3,0)
Uint8 *sdlstate = SDL_GetKeyboardState(nullptr);
@@ -299,14 +300,14 @@ void SdlInputData::Tick(float seconds)
# endif

int keyindex = 0;
# ifdef LOL_INPUT_V2
# define KEY_FUNC(name, index) m_keyboard->SetKey(keyindex++, sdlstate[index] != 0);
# if !defined SDLK_WORLD_0
# define KEY_DISABLE_WORLD
# endif // !SDLK_WORLD_0
# include "input/keys.h"
# undef KEY_FUNC
# else // !LOL_INPUT_V2
# ifdef LOL_INPUT_V2
# define KEY_FUNC(name, index) \
m_keyboard->SetKey(keyindex++, sdlstate[index] != 0);
/* FIXME: we ignore SDLK_WORLD_0, which means our list of
* keys and SDL's list of keys could be out of sync. */
# include "input/keys.h"
# undef KEY_FUNC
# else // !LOL_INPUT_V2

/* Send the whole keyboard state to the input system */
Array<uint8_t> &lolstate = Input::GetKeyboardState();


Caricamento…
Annulla
Salva