Changeset 2837


Ignore:
Timestamp:
Aug 2, 2013, 5:50:36 PM (7 years ago)
Author:
sam
Message:

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

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/input/inputdevice.cpp

    r2818 r2837  
    4646{
    4747    InputDeviceInternal* keyboard = new InputDeviceInternal("Keyboard");
    48 #   define KEY_FUNC(key, value) keyboard->AddKey(#key);
     48    /* "value" is unused, what matters is the index. */
     49#   define KEY_FUNC(key, value) \
     50        keyboard->AddKey(#key);
    4951#   include "input/keys.h"
    5052#   undef KEY_FUNC
  • trunk/src/platform/sdl/sdlinput.cpp

    r2816 r2837  
    6262    InputDeviceInternal* m_mouse;
    6363    InputDeviceInternal* m_keyboard;
     64
    6465    ivec2 m_prevmouse;
    6566    float m_app_w;
     
    127128#       ifdef LOL_INPUT_V2
    128129        InputDeviceInternal* stick = new InputDeviceInternal(String::Printf("Joystick%d", i+1).C());
    129         for (int i = 0; i < SDL_JoystickNumAxes(sdlstick); ++i)
    130             stick->AddAxis(String::Printf("Axis%d", i+1).C());
    131         for (int i = 0; i < SDL_JoystickNumButtons(sdlstick); ++i)
    132             stick->AddKey(String::Printf("Button%d", i+1).C());
     130        for (int j = 0; j < SDL_JoystickNumAxes(sdlstick); ++j)
     131            stick->AddAxis(String::Printf("Axis%d", j + 1).C());
     132        for (int j = 0; j < SDL_JoystickNumButtons(sdlstick); ++j)
     133            stick->AddKey(String::Printf("Button%d", j + 1).C());
    133134
    134135        m_data->m_joysticks.Push(sdlstick, stick);
     
    291292#   else // !LOL_INPUT_V2
    292293    Input::SetMousePos(mouse);
    293 #    endif // LOL_INPUT_V2
     294#   endif // LOL_INPUT_V2
    294295
    295296#   if SDL_VERSION_ATLEAST(1,3,0)
     
    300301
    301302    int keyindex = 0;
    302 #    ifdef LOL_INPUT_V2
    303 #    define KEY_FUNC(name, index) m_keyboard->SetKey(keyindex++, sdlstate[index] != 0);
    304 #    if !defined SDLK_WORLD_0
    305 #     define KEY_DISABLE_WORLD
    306 #   endif // !SDLK_WORLD_0
    307 #    include "input/keys.h"
    308 #    undef KEY_FUNC
    309 #    else // !LOL_INPUT_V2
     303#   ifdef LOL_INPUT_V2
     304#       define KEY_FUNC(name, index) \
     305            m_keyboard->SetKey(keyindex++, sdlstate[index] != 0);
     306        /* FIXME: we ignore SDLK_WORLD_0, which means our list of
     307         * keys and SDL's list of keys could be out of sync. */
     308#       include "input/keys.h"
     309#       undef KEY_FUNC
     310#   else // !LOL_INPUT_V2
    310311
    311312    /* Send the whole keyboard state to the input system */
Note: See TracChangeset for help on using the changeset viewer.