Changeset 2841


Ignore:
Timestamp:
Aug 12, 2013, 5:00:04 PM (6 years ago)
Author:
benlitz
Message:

input: Removed previous input system

Location:
trunk
Files:
7 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/demos/tutorial/07_input.cpp

    r2834 r2841  
    2626    InputTutorial()
    2727    {
    28 #if LOL_INPUT_V2
    2928        m_controller = new Controller(KEY_MAX, AXIS_MAX);
    3029
     
    4746            m_controller->GetAxis(AXIS_YAW).Bind("Joystick1", "Axis1");
    4847        }
    49 #endif
    5048
    5149        m_pitch_angle = 0;
     
    9189        WorldEntity::TickGame(seconds);
    9290
    93 #if LOL_INPUT_V2
    9491        /* Handle keyboard */
    9592        if (m_keyboard)
     
    130127        }
    131128        else
    132 #endif
    133129        {
    134130            m_text->SetText("no mouse detected");
     
    218214    };
    219215
    220 #if LOL_INPUT_V2
    221216    InputDevice *m_keyboard, *m_mouse, *m_joystick;
    222217    Controller *m_controller;
    223 #endif
    224218
    225219    bool m_autorot;
  • trunk/src/core.h

    r2816 r2841  
    125125#include "audio.h"
    126126#include "scene.h"
    127 #include "input/input.h"
    128 #include "input/keyboard.h"
    129 #include "input/stick.h"
    130127#include "profiler.h"
    131128
    132 // Input (v2)
     129// Input
    133130#include "input/input.h"
    134 #include "input/inputdevice.h"
    135131#include "input/controller.h"
    136132
  • trunk/src/debug/fps.cpp

    r2823 r2841  
    8888    data->lines[4]->SetText(buf);
    8989#else
    90     sprintf(buf, "%2.2f/%2.2f/%2.2f/%2.2f %2.2f fps (%i)",
     90    sprintf(buf, "%2.2f/%2.2f/%2.2f/%2.2f %2.2f fps (%i) %2.2f",
    9191            1e3f * Profiler::GetAvg(Profiler::STAT_TICK_GAME),
    9292            1e3f * Profiler::GetAvg(Profiler::STAT_TICK_DRAW),
     
    9494            1e3f * Profiler::GetAvg(Profiler::STAT_TICK_FRAME),
    9595            1.0f / Profiler::GetAvg(Profiler::STAT_TICK_FRAME),
    96             Ticker::GetFrameNum());
     96                        1e3f * Profiler::GetAvg(Profiler::STAT_USER_00),
     97           Ticker::GetFrameNum());
    9798    data->lines[0]->SetText(buf);
    9899#endif
  • trunk/src/eglapp.cpp

    r2818 r2841  
    252252
    253253#   if defined USE_SDL
    254 #       if defined LOL_INPUT_V2
    255254    new SdlInput(res.x, res.y, data->screen_size.x, data->screen_size.y);
    256 #       else
    257     new SdlInput();
    258 #       endif
    259255#   endif
    260256
  • trunk/src/input/controller.cpp

    r2836 r2841  
    1414
    1515#include "core.h"
    16 
    17 #ifdef LOL_INPUT_V2
    1816
    1917namespace lol
     
    138136
    139137} /* namespace lol */
    140 
    141 #endif // LOL_INPUT_V2
  • trunk/src/input/controller.h

    r2836 r2841  
    1313
    1414#include "core.h"
    15 
    16 #if defined LOL_INPUT_V2
    1715
    1816namespace lol
     
    9997} /* namespace lol */
    10098
    101 #endif // LOL_INPUT_V2
    102 
    10399#endif // __LOL_INPUT_CONTROLLER_H__
    104100
  • trunk/src/input/input.cpp

    r2818 r2841  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2013 Benjamin Litzelmann
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    99//
    1010
    11 
    1211#if defined HAVE_CONFIG_H
    1312#   include "config.h"
    1413#endif
    1514
    16 #include <cstdlib>
    17 
    1815#include "core.h"
    1916
    20 #ifndef LOL_INPUT_V2
     17#include "input/input_internal.h"
    2118
    2219namespace lol
    2320{
    2421
    25 /*
    26  * Input implementation class
    27  */
     22Array<InputDevice*> InputDevice::devices;
     23bool InputDevice::m_capturemouse;
    2824
    29 InputTracker* Input::m_input_tracker = nullptr;
    30 
    31 static class InputData
     25void InputDeviceInternal::AddKey(const char* name)
    3226{
    33     friend class Input;
    34 
    35 public:
    36     InputData()
    37       : mouse(-1),
    38         buttons(0),
    39         nentities(0),
    40         lastfocus(0)
    41     {
    42         m_keystate.Resize(Key::Last);
    43         memset(&m_keystate[0], 0, m_keystate.Bytes());
    44     }
    45 
    46 private:
    47     ivec2 mouse;
    48     uint32_t buttons;
    49 
    50     Array<uint8_t> m_keystate;
    51 
    52     static int const MAX_ENTITIES = 100;
    53     WorldEntity *entities[MAX_ENTITIES];
    54     int nentities;
    55     WorldEntity *lastfocus;
    56 
    57     Array<Stick *> m_sticks;
    58 }
    59 inputdata;
    60 
    61 static InputData * const data = &inputdata;
    62 
    63 /*
    64  * ButtonSetting class
    65  */
    66 
    67 int ButtonSetting::GetActionSettingIdx(Action a)
    68 {
    69     for (int i = 0; i < m_associated_action_list.Count(); i++)
    70         if (ACTION_CMP(m_associated_action_list[i].m_action, a))
    71             return i;
    72     return -1;
     27    m_keynames.Push(name);
     28    m_keys.Push(false);
    7329}
    7430
    75 /*
    76  * InputTracker class
    77  */
    78 
    79 InputTracker::InputTracker()
     31void InputDeviceInternal::AddAxis(const char* name, float sensitivity)
    8032{
    81     m_gamegroup = GAMEGROUP_BEFORE;
    82 
    83     for (int i = 0; i < Key::Last * 2; ++i)
    84         m_input_status << 0;
    85 
    86     Ticker::Ref(this);
     33    m_axisnames.Push(name);
     34    m_axis.Push(0.0f, sensitivity);
    8735}
    8836
    89 //Internal
    90 int InputTracker::GetButtonSettingIdx(Key k)
     37void InputDeviceInternal::AddCursor(const char* name)
    9138{
    92     for (int i = 0; i < m_input_assocation_list.Count(); i++)
    93         if (m_input_assocation_list[i].m_raw_button == k)
    94             return i;
    95     return -1;
     39    m_cursornames.Push(name);
     40    m_cursors.Push(vec2(0.0), ivec2(0));
    9641}
    9742
    98 //-----
    99 int InputTracker::GetCurrentButtonStatus(Key k)
     43InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard()
    10044{
    101     if (k < m_input_status.Count())
    102         return m_input_status[k];
    103     return 0;
     45    InputDeviceInternal* keyboard = new InputDeviceInternal("Keyboard");
     46    /* "value" is unused, what matters is the index. */
     47#   define KEY_FUNC(key, value) \
     48        keyboard->AddKey(#key);
     49#   undef KEY_FUNC
     50    return keyboard;
    10451}
    10552
    106 //-----
    107 int InputTracker::GetPreviousButtonStatus(Key k)
     53InputDeviceInternal* InputDeviceInternal::CreateStandardMouse()
    10854{
    109     if (k < m_input_status.Count())
    110         return m_input_status[(int)k + (int)Key::Last];
    111     return 0;
    112 }
     55    InputDeviceInternal* mouse = new InputDeviceInternal("Mouse");
     56    mouse->AddKey("ButtonLeft");
     57    mouse->AddKey("ButtonMiddle");
     58    mouse->AddKey("ButtonRight");
    11359
    114 //Internal : Updates the action status & timers
    115 void InputTracker::UpdateActionStatus(float seconds)
    116 {
    117     Array<uint8_t> &keystate = Input::GetKeyboardState();
     60    mouse->AddAxis("X");
     61    mouse->AddAxis("Y");
    11862
    119     //SOOOoooo ugly.
    120     for (int i = 0; i < Key::Last; ++i)
    121     {
    122         m_input_status[i + Key::Last] = m_input_status[i];
    123         m_input_status[i] = keystate[i];
    124     }
     63    mouse->AddCursor("Cursor");
    12564
    126     for (int i = 0; i < m_input_assocation_list.Count(); i++)
    127     {
    128         ButtonSetting &CurIT = m_input_assocation_list[i];
    129 
    130         for (int j = 0; j < CurIT.m_associated_action_list.Count(); j++)
    131         {
    132             ActionSetting &CurAS = CurIT.m_associated_action_list[j];
    133 
    134             if (CurAS.m_buffered_since <= CurAS.m_buffering_time)
    135                 CurAS.m_buffered_since += seconds;
    136 
    137             if (GetCurrentButtonStatus(CurIT.m_raw_button) &&
    138                 CurAS.m_buffering_time >= .0f)
    139                 CurAS.m_buffered_since = .0f;
    140         }
    141     }
    142 }
    143 
    144 //Helps link a software input Action-Id to an hardware input Button-Id.
    145 void InputTracker::LinkActionToKey(Action a, Key k)
    146 {
    147     int ITIdx = GetButtonSettingIdx(k);
    148     if (ITIdx == -1)
    149     {
    150         ITIdx = m_input_assocation_list.Count();
    151         m_input_assocation_list << ButtonSetting(k);
    152     }
    153 
    154     ButtonSetting &CurIT = m_input_assocation_list[ITIdx];
    155 
    156     int ASIdx = CurIT.GetActionSettingIdx(a);
    157     if (ASIdx == -1)
    158     {
    159         ASIdx = CurIT.m_associated_action_list.Count();
    160         CurIT.m_associated_action_list << ActionSetting(a);
    161     }
    162 }
    163 
    164 //Helps unlink a software input Action-Id to an hardware input k-Id.
    165 void InputTracker::UnlinkAction(Action a)
    166 {
    167     for (int i = 0; i < m_input_assocation_list.Count(); i++)
    168     {
    169         ButtonSetting &CurIT = m_input_assocation_list[i];
    170         int ASIdx = CurIT.GetActionSettingIdx(a);
    171         if (ASIdx != -1)
    172             CurIT.m_associated_action_list.Remove(ASIdx);
    173     }
    174 }
    175 
    176 //Returns the current status of a given action
    177 int InputTracker::GetStatus(Action a)
    178 {
    179     for (int i = 0; i < m_input_assocation_list.Count(); i++)
    180     {
    181         ButtonSetting &CurIT = m_input_assocation_list[i];
    182         int ASIdx = CurIT.GetActionSettingIdx(a);
    183         if (ASIdx != -1)
    184         {
    185             ActionSetting &CurAS = CurIT.m_associated_action_list[ASIdx];
    186 
    187             if (CurAS.m_buffering_time >= .0f && CurAS.m_buffered_since <= CurAS.m_buffering_time)
    188                 return 1;
    189             return 0;
    190         }
    191     }
    192     return 0;
    193 }
    194 
    195 //Returns TRUE if action status went from Active to Inactive this frame
    196 bool InputTracker::WasReleased(Action a)
    197 {
    198     for (int i = 0; i < m_input_assocation_list.Count(); i++)
    199     {
    200         ButtonSetting &CurIT = m_input_assocation_list[i];
    201         int ASIdx = CurIT.GetActionSettingIdx(a);
    202         if (ASIdx != -1)
    203         {
    204 
    205             if (GetPreviousButtonStatus(CurIT.m_raw_button) &&
    206                 !GetCurrentButtonStatus(CurIT.m_raw_button))
    207                 return true;
    208             return false;
    209         }
    210     }
    211     return false;
    212 }
    213 
    214 //Returns TRUE if action status went from Inactive to Active this frame
    215 bool InputTracker::WasPressed(Action a)
    216 {
    217     for (int i = 0; i < m_input_assocation_list.Count(); i++)
    218     {
    219         ButtonSetting &CurIT = m_input_assocation_list[i];
    220         int ASIdx = CurIT.GetActionSettingIdx(a);
    221         if (ASIdx != -1)
    222         {
    223             if (!GetPreviousButtonStatus(CurIT.m_raw_button) &&
    224                 GetCurrentButtonStatus(CurIT.m_raw_button))
    225                 return true;
    226             return false;
    227         }
    228     }
    229     return false;
    230 }
    231 
    232 //Returns the current status of a given action
    233 int InputTracker::GetStatus(Key k)
    234 {
    235     return GetCurrentButtonStatus(k);
    236 }
    237 
    238 //Returns TRUE if action status went from Active to Inactive this frame
    239 bool InputTracker::WasReleased(Key k)
    240 {
    241     if (GetPreviousButtonStatus(k) &&
    242         !GetCurrentButtonStatus(k))
    243         return true;
    244     return false;
    245 }
    246 
    247 //Returns TRUE if action status went from Inactive to Active this frame
    248 bool InputTracker::WasPressed(Key k)
    249 {
    250     if (!GetPreviousButtonStatus(k) &&
    251         GetCurrentButtonStatus(k))
    252         return true;
    253     return false;
    254 }
    255 
    256 /*
    257  * Public Input class
    258  */
    259 
    260 #if 0
    261 vec2 Input::GetAxis(int axis)
    262 {
    263     vec2 ret;
    264 
    265     /* Simulate a joystick using the keyboard. */
    266     int left = GetKeyState(Key::D) - (GetKeyState(Key::A) | GetKeyState(Key::Q));
    267     int up = (GetKeyState(Key::W) | GetKeyState(Key::Z)) - GetKeyState(Key::S);
    268     ret.x += left;
    269     ret.y += up;
    270     if (left && up)
    271         ret = ret * sqrtf(0.5f);
    272 
    273     return ret;
    274 }
    275 #endif
    276 
    277 ivec2 Input::GetMousePos()
    278 {
    279     return data->mouse;
    280 }
    281 
    282 uint32_t Input::GetMouseButtons()
    283 {
    284     return data->buttons;
    285 }
    286 
    287 Array<uint8_t> &Input::GetKeyboardState()
    288 {
    289     return data->m_keystate;
    290 }
    291 
    292 int Input::GetKeyState(int key)
    293 {
    294     return data->m_keystate[key];
    295 }
    296 
    297 //Helps link a software input Action-Id to an hardware input Button-Id.
    298 void Input::LinkActionToKey(Action a, Key k)
    299 {
    300     if (CheckInputTrackerInit())
    301         Input::m_input_tracker->LinkActionToKey(a, k);
    302 }
    303 
    304 //Helps unlink a software input Action-Id to an hardware input Button-Id.
    305 void Input::UnlinkAction(Action a)
    306 {
    307     if (CheckInputTrackerInit())
    308         Input::m_input_tracker->UnlinkAction(a);
    309 }
    310 
    311 //Returns the current status of a given action
    312 int Input::GetStatus(Action a)
    313 {
    314     if (CheckInputTrackerInit())
    315         return Input::m_input_tracker->GetStatus(a);
    316     return 0;
    317 }
    318 
    319 //Returns TRUE if action status when from Active to Inactive this frame
    320 bool Input::WasPressed(Action a)
    321 {
    322     if (CheckInputTrackerInit())
    323         return Input::m_input_tracker->WasPressed(a);
    324     return false;
    325 }
    326 
    327 //Returns TRUE if action status when from Active to Inactive this frame
    328 bool Input::WasReleased(Action a)
    329 {
    330     if (CheckInputTrackerInit())
    331         return Input::m_input_tracker->WasReleased(a);
    332     return false;
    333 }
    334 
    335 //Returns the current status of a given action
    336 int Input::GetStatus(Key k)
    337 {
    338     if (CheckInputTrackerInit())
    339         return Input::m_input_tracker->GetStatus(k);
    340     return 0;
    341 }
    342 
    343 //Returns TRUE if action status when from Active to Inactive this frame
    344 bool Input::WasPressed(Key k)
    345 {
    346     if (CheckInputTrackerInit())
    347         return Input::m_input_tracker->WasPressed(k);
    348     return false;
    349 }
    350 
    351 //Returns TRUE if action status when from Active to Inactive this frame
    352 bool Input::WasReleased(Key k)
    353 {
    354     if (CheckInputTrackerInit())
    355         return Input::m_input_tracker->WasReleased(k);
    356     return false;
    357 }
    358 
    359 //--
    360 void Input::TrackMouse(WorldEntity *e)
    361 {
    362     if (data->nentities >= InputData::MAX_ENTITIES)
    363         return;
    364     data->entities[data->nentities] = e;
    365     data->nentities++;
    366 }
    367 
    368 void Input::UntrackMouse(WorldEntity *e)
    369 {
    370     for (int n = 0; n < data->nentities; n++)
    371     {
    372         if (data->entities[n] != e)
    373             continue;
    374 
    375         data->entities[n] = data->entities[data->nentities - 1];
    376         data->nentities--;
    377         n--;
    378     }
    379 }
    380 
    381 void Input::SetMousePos(ivec2 coord)
    382 {
    383     data->mouse = coord;
    384 
    385     WorldEntity *top = nullptr;
    386 
    387     /* Find the top “widget” amongst all entities that match the
    388      * mouse coordinates */
    389     for (int n = 0; n < data->nentities; n++)
    390     {
    391         if (coord.x < data->entities[n]->m_bbox[0].x
    392              || coord.x >= data->entities[n]->m_bbox[1].x
    393              || coord.y < data->entities[n]->m_bbox[0].y
    394              || coord.y >= data->entities[n]->m_bbox[1].y)
    395             continue;
    396 
    397         if (!top || top->m_bbox[1].z < data->entities[n]->m_bbox[1].z)
    398             top = data->entities[n];
    399     }
    400 
    401     for (int n = 0; n < data->nentities; n++)
    402     {
    403         if (data->entities[n] == top)
    404         {
    405             data->entities[n]->m_mousepos = coord - (ivec2)top->m_bbox[0].xy;
    406             if (top != data->lastfocus)
    407                 data->entities[n]->m_pressed = data->buttons;
    408             else
    409                 data->entities[n]->m_clicked = 0;
    410         }
    411         else
    412         {
    413             data->entities[n]->m_mousepos = ivec2(-1);
    414             /* FIXME */
    415             data->entities[n]->m_released = 0;
    416             data->entities[n]->m_pressed = 0;
    417             data->entities[n]->m_clicked = 0;
    418         }
    419     }
    420 
    421     data->lastfocus = top;
    422 }
    423 
    424 void Input::SetMouseButton(int index)
    425 {
    426     uint32_t flag = 1 << index;
    427     data->buttons |= flag;
    428 
    429     if (data->lastfocus)
    430     {
    431         if (!(data->lastfocus->m_pressed & flag))
    432             data->lastfocus->m_clicked |= flag;
    433         data->lastfocus->m_pressed |= flag;
    434         data->lastfocus->m_released &= ~flag;
    435     }
    436 }
    437 
    438 void Input::UnsetMouseButton(int index)
    439 {
    440     uint32_t flag = 1 << index;
    441     data->buttons &= ~flag;
    442 
    443     if (data->lastfocus)
    444     {
    445         if (!(data->lastfocus->m_pressed & flag))
    446             data->lastfocus->m_released |= flag;
    447         data->lastfocus->m_pressed &= ~flag;
    448         data->lastfocus->m_clicked &= ~flag;
    449     }
    450 }
    451 
    452 Stick *Input::CreateStick()
    453 {
    454     Stick *stick = new Stick();
    455     Ticker::Ref(stick);
    456     data->m_sticks.Push(stick);
    457     return stick;
    458 }
    459 
    460 void Input::DestroyStick(Stick *stick)
    461 {
    462     for (int i = 0; i < data->m_sticks.Count(); i++)
    463         if (data->m_sticks[i] == stick)
    464             data->m_sticks.Remove(i);
    465     Ticker::Unref(stick);
    466 }
    467 
    468 Stick *Input::TrackStick(int desired)
    469 {
    470     /* FIXME: add the possibility to choose amongst sticks */
    471     if (desired >= data->m_sticks.Count())
    472         return nullptr;
    473     Ticker::Ref(data->m_sticks[desired]);
    474     return data->m_sticks[desired];
    475 }
    476 
    477 void Input::UntrackStick(Stick *stick)
    478 {
    479     Ticker::Unref(stick);
     65    // TODO: extended button, and wheel (as axis or as buttons? or both?)
     66    return mouse;
    48067}
    48168
    48269} /* namespace lol */
    483 
    484 #endif // !LOL_INPUT_V2
  • trunk/src/input/input.h

    r2818 r2841  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2013 Benjamin Litzelmann
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    99//
    1010
    11 //
    12 // The Input static class
    13 // ----------------------
    14 //
    15 
    16 #if !defined __LOL_INPUT_INPUT_H__
    17 #define __LOL_INPUT_INPUT_H__
    18 
    19 #include <cstring>
    20 #include <string.h>
     11#if !defined __LOL_INPUT_H__
     12#define __LOL_INPUT_H__
    2113
    2214#include "core.h"
    23 
    24 #ifndef LOL_INPUT_V2
    25 
    26 #include "lol/math/vector.h"
    27 #include "input/keyboard.h"
    28 #include "input/stick.h"
    2915
    3016namespace lol
    3117{
    3218
    33 typedef std::string Action;
    34 static inline int ACTION_CMP(Action a, Action b) { return a.compare(b) == 0; }
     19class InputDevice
     20{
     21public:
     22    /** Get the name of this input device */
     23    const String& GetName();
    3524
    36 class WorldEntity;
     25    /** Get the index of the corresponding key, needed to call GetKey */
     26    int GetKeyIndex(const char* name) const { return GetItemIndex(name, m_keynames); }
     27    /** Get the index of the corresponding axis, needed to call GetAxis */
     28    int GetAxisIndex(const char* name) const { return GetItemIndex(name, m_axisnames); }
     29    /** Get the index of the corresponding cursor, needed to call GetCursor */
     30    int GetCursorIndex(const char* name) const { return GetItemIndex(name, m_cursornames); }
    3731
    38 /*
    39  * The key enumeration values match libSDL's so that we can
    40  * easily pass information between Lol and SDL.
    41  */
    42 struct Key
    43 {
    44     enum Value
     32    /** Get the current state of the given key, true being pressed and false being released */
     33    bool GetKey(int index) const { return m_keys[index]; }
     34    /** Get the current value of the given axis. Devices should cap this value between -1 and 1 as much as possible, through it is not guaranteed */
     35    float GetAxis(int index) const { return m_axis[index].m1 * m_axis[index].m2; }
     36    /** Get the current value of the given cursor, 0,0 being the bottom-left corner and 1,1 being the top-right corner */
     37    vec2 GetCursor(int index) const { return m_cursors[index].m1; }
     38    /** Get the coordinate of the pixel the cursor is currently over, 0,0 being the bottom-left corner. */
     39    ivec2 GetCursorPixel(int index) const { return m_cursors[index].m2; }
     40
     41
     42    /** Set a per-device-axis sensitivity factor. The value returned by the operating system will be multiplied by this value before being returned by GetAxis */
     43    void SetAxisSensitivity(int index, float sensitivity) { m_axis[index].m2 = sensitivity; }
     44    /** Get the per-device-axis sensitivity factor. The value returned by the operating system will be multiplied by this value before being returned by GetAxis */
     45    float GetAxisSensitivity(int index) const { return m_axis[index].m2; }
     46
     47    /** Get a list of the name of all available keys in this device */
     48    const Array<String>& GetAllKeys() const { return m_keynames; }
     49    /** Get a list of the name of all available axis in this device */
     50    const Array<String>& GetAllAxis() const { return m_axisnames; }
     51    /** Get a list of the name of all available cursors in this device */
     52    const Array<String>& GetAllCursors() const { return m_cursornames; }
     53
     54    /** Get an input device by its name */
     55    static InputDevice* Get(const char* name) { return GetDevice(name); }
     56    /** Set whether the mouse cursor should be captured. */
     57    static void CaptureMouse(bool activated) { m_capturemouse = activated; }
     58
     59protected:
     60    // TODO: hide all of this in a InputDeviceData?
     61
     62    String m_name;
     63
     64    Array<String> m_keynames;
     65    Array<String> m_axisnames;
     66    Array<String> m_cursornames;
     67
     68    /** key states (pressed/released) */
     69    Array<bool> m_keys;
     70    /** axis states (value and sensitivity) */
     71    Array<float, float> m_axis;
     72    /** cursor position */
     73    Array<vec2, ivec2> m_cursors;
     74
     75    static bool m_capturemouse;
     76
     77    InputDevice(const char* name) : m_name(name)
    4578    {
    46         /* ASCII mapped keys */
    47         Unknown =     0,
    48         First =       0,
    49         Backspace =   8,
    50         Tab =         (int)'\t',
    51         Clear =       12,
    52         Return =      13,
    53         Pause =       19,
    54         Escape =      27,
    55         Space =       (int)' ',
    56         Exclaim =     (int)'!',
    57         DoubleQuote = (int)'"',
    58         Hash =        (int)'#',
    59         Dollar =      (int)'$',
    60         Ampersand =   (int)'&',
    61         Quote =       (int)'\'',
    62         LeftParen =   (int)'(',
    63         RightParen =  (int)')',
    64         Asterisk =    (int)'*',
    65         Plus =        (int)'+',
    66         Comma =       (int)',',
    67         Minus =       (int)'-',
    68         Period =      (int)'.',
    69         Slash =       (int)'/',
    70         K0 = (int)'0',
    71         K1 = (int)'1',
    72         K2 = (int)'2',
    73         K3 = (int)'3',
    74         K4 = (int)'4',
    75         K5 = (int)'5',
    76         K6 = (int)'6',
    77         K7 = (int)'7',
    78         K8 = (int)'8',
    79         K9 = (int)'9',
    80         Colon =        (int)':',
    81         Semicolon =    (int)';',
    82         Less =         (int)'<',
    83         Equals =       (int)'=',
    84         Greater =      (int)'>',
    85         Question =     (int)'?',
    86         At =           (int)'@',
    87         /* XXX: SDL decides to skip uppercase characters */
    88         LeftBracket =  (int)'[',
    89         BackSlash =    (int)'\\',
    90         RightBracket = (int)']',
    91         Caret =        (int)'^',
    92         Underscore =   (int)'_',
    93         Backquote =    (int)'`',
    94         A = (int)'a',
    95         B = (int)'b',
    96         C = (int)'c',
    97         D = (int)'d',
    98         E = (int)'e',
    99         F = (int)'f',
    100         G = (int)'g',
    101         H = (int)'h',
    102         I = (int)'i',
    103         J = (int)'j',
    104         K = (int)'k',
    105         L = (int)'l',
    106         M = (int)'m',
    107         N = (int)'n',
    108         O = (int)'o',
    109         P = (int)'p',
    110         Q = (int)'q',
    111         R = (int)'r',
    112         S = (int)'s',
    113         T = (int)'t',
    114         U = (int)'u',
    115         V = (int)'v',
    116         W = (int)'w',
    117         X = (int)'x',
    118         Y = (int)'y',
    119         Z = (int)'z',
    120         Delete = 127,
     79        devices.Push(this);
     80    }
    12181
    122         /* International keyboard syms */
    123         World0 = 160, /* 0xA0 */
    124         World1 = 161,
    125         World2 = 162,
    126         World3 = 163,
    127         World4 = 164,
    128         World5 = 165,
    129         World6 = 166,
    130         World7 = 167,
    131         World8 = 168,
    132         World9 = 169,
    133         World10 = 170,
    134         World11 = 171,
    135         World12 = 172,
    136         World13 = 173,
    137         World14 = 174,
    138         World15 = 175,
    139         World16 = 176,
    140         World17 = 177,
    141         World18 = 178,
    142         World19 = 179,
    143         World20 = 180,
    144         World21 = 181,
    145         World22 = 182,
    146         World23 = 183,
    147         World24 = 184,
    148         World25 = 185,
    149         World26 = 186,
    150         World27 = 187,
    151         World28 = 188,
    152         World29 = 189,
    153         World30 = 190,
    154         World31 = 191,
    155         World32 = 192,
    156         World33 = 193,
    157         World34 = 194,
    158         World35 = 195,
    159         World36 = 196,
    160         World37 = 197,
    161         World38 = 198,
    162         World39 = 199,
    163         World40 = 200,
    164         World41 = 201,
    165         World42 = 202,
    166         World43 = 203,
    167         World44 = 204,
    168         World45 = 205,
    169         World46 = 206,
    170         World47 = 207,
    171         World48 = 208,
    172         World49 = 209,
    173         World50 = 210,
    174         World51 = 211,
    175         World52 = 212,
    176         World53 = 213,
    177         World54 = 214,
    178         World55 = 215,
    179         World56 = 216,
    180         World57 = 217,
    181         World58 = 218,
    182         World59 = 219,
    183         World60 = 220,
    184         World61 = 221,
    185         World62 = 222,
    186         World63 = 223,
    187         World64 = 224,
    188         World65 = 225,
    189         World66 = 226,
    190         World67 = 227,
    191         World68 = 228,
    192         World69 = 229,
    193         World70 = 230,
    194         World71 = 231,
    195         World72 = 232,
    196         World73 = 233,
    197         World74 = 234,
    198         World75 = 235,
    199         World76 = 236,
    200         World77 = 237,
    201         World78 = 238,
    202         World79 = 239,
    203         World80 = 240,
    204         World81 = 241,
    205         World82 = 242,
    206         World83 = 243,
    207         World84 = 244,
    208         World85 = 245,
    209         World86 = 246,
    210         World87 = 247,
    211         World88 = 248,
    212         World89 = 249,
    213         World90 = 250,
    214         World91 = 251,
    215         World92 = 252,
    216         World93 = 253,
    217         World94 = 254,
    218         World95 = 255, /* 0xFF */
    219 
    220         /* Numeric keypad */
    221         KP0 = 256,
    222         KP1 = 257,
    223         KP2 = 258,
    224         KP3 = 259,
    225         KP4 = 260,
    226         KP5 = 261,
    227         KP6 = 262,
    228         KP7 = 263,
    229         KP8 = 264,
    230         KP9 = 265,
    231         KPPeriod = 266,
    232         KPDivide = 267,
    233         KPMultiply = 268,
    234         KPMinus = 269,
    235         KPPlus = 270,
    236         KPEnter = 271,
    237         KPEquals = 272,
    238 
    239         /* Arrows + Home/End pad */
    240         Up = 273,
    241         Down = 274,
    242         Right = 275,
    243         Left = 276,
    244         Insert = 277,
    245         Home = 278,
    246         End = 279,
    247         PageUp = 280,
    248         PageDown = 281,
    249 
    250         /* Function keys */
    251         F1 = 282,
    252         F2 = 283,
    253         F3 = 284,
    254         F4 = 285,
    255         F5 = 286,
    256         F6 = 287,
    257         F7 = 288,
    258         F8 = 289,
    259         F9 = 290,
    260         F10 = 291,
    261         F11 = 292,
    262         F12 = 293,
    263         F13 = 294,
    264         F14 = 295,
    265         F15 = 296,
    266 
    267         /* Modifier keys */
    268         NumLock = 300,
    269         CapsLock = 301,
    270         ScrollLock= 302,
    271         RightShift = 303,
    272         LeftShift = 304,
    273         RightCtrl = 305,
    274         LeftCtrl = 306,
    275         RightAlt = 307,
    276         LeftAlt = 308,
    277         RightMeta = 309,
    278         LeftMeta = 310,
    279         LeftSuper = 311,  /* Left "Windows" key */
    280         RightSuper = 312, /* Right "Windows" key */
    281         Mode = 313,       /* "Alt Gr" key */
    282         Compose = 314,    /* Multi-key compose key */
    283 
    284         /* Miscellaneous function keys */
    285         Help = 315,
    286         Print = 316,
    287         SysReq = 317,
    288         Break = 318,
    289         Menu = 319,
    290         Power = 320, /* Power Macintosh power key */
    291         Euro = 321,  /* Some european keyboards */
    292         Undo = 322,  /* Atari keyboard has Undo */
    293 
    294         /* Add any other keys here */
    295         Last
    296 
     82    ~InputDevice()
     83    {
     84        for (int i = 0; i < devices.Count(); ++i)
     85        {
     86            if (devices[i] == this)
     87            {
     88                devices.Remove(i);
     89                return;
     90            }
     91        }
    29792    }
    298     m_value;
    299 
    300     //BH : Removed KMod from main enum, because I don't have any idea about handling them correctly for now.
    301     /*
    302         //Enumeration of valid key mods (possibly OR'd together)
    303         KM_NONE          = 0x0000,
    304         KM_LSHIFT        = 0x0001,
    305         KM_RSHIFT        = 0x0002,
    306         KM_LCTRL         = 0x0040,
    307         KM_RCTRL         = 0x0080,
    308         KM_LALT          = 0x0100,
    309         KM_RALT          = 0x0200,
    310         KM_LMETA         = 0x0400,
    311         KM_RMETA         = 0x0800,
    312         KM_NUM           = 0x1000,
    313         KM_CAPS          = 0x2000,
    314         KM_MODE          = 0x4000,
    315 
    316         KM_RESERVED        = 0x8000,
    317 
    318         //Left/Right independent key mods definition
    319         KM_CTRL            = (KM_LCTRL|KM_RCTRL),
    320         KM_SHIFT        = (KM_LSHIFT|KM_RSHIFT),
    321         KM_ALT            = (KM_LALT|KM_RALT),
    322         KM_META            = (KM_LMETA|KM_RMETA),
    323     */
    324 
    325     inline Key(Value v) { m_value = v; }
    326     inline operator Value() { return m_value; }
    327     inline bool operator==(const Key& val)
    328     {
    329         return m_value == val.m_value;
    330     }
    331 };
    332 
    333 struct ActionSetting
    334 {
    335     Action m_action;
    336     float m_buffering_time;
    337     float m_buffered_since;
    338 
    339     ActionSetting(Action NewAction)
    340       : m_action(NewAction),
    341         m_buffering_time(.0f),
    342         m_buffered_since(.0f)
    343     { }
    344 };
    345 
    346 struct ButtonSetting
    347 {
    348     Key m_raw_button;
    349     Array<ActionSetting> m_associated_action_list;
    350 
    351     ButtonSetting(Key NewRawButton)
    352       : m_raw_button(NewRawButton)
    353     { }
    354 
    355     int GetActionSettingIdx(Action SearchAction);
    356 };
    357 
    358 class InputTracker : public Entity
    359 {
    360     friend class Input;
    361 
    362 public:
    363     InputTracker();
    36493
    36594private:
    366     Array<uint8_t> m_input_status;
    367     Array<ButtonSetting> m_input_assocation_list;
     95    static Array<InputDevice*> devices;
    36896
    369     int GetButtonSettingIdx(struct Key k);
    370     int GetCurrentButtonStatus(struct Key k);
    371     int GetPreviousButtonStatus(struct Key k);
    372     void UpdateActionStatus(float seconds);
    373 
    374 protected:
    375     virtual char const * GetName()
     97    template <typename T>
     98    int GetItemIndex(const char* name, const Array<String, T>& Array) const
    37699    {
    377         return "<InputTracker>";
    378     }
    379     virtual void TickGame(float seconds)
    380     {
    381         Entity::TickGame(seconds);
    382 
    383         UpdateActionStatus(seconds);
     100        for (int i = 0; i < Array.Count(); ++i)
     101        {
     102            if (Array[i] == name)
     103                return i;
     104        }
     105        return -1;
    384106    }
    385107
    386     void LinkActionToKey(Action a, struct Key k);
    387     void UnlinkAction(Action a);
    388     int GetStatus(Action a);
    389     bool WasPressed(Action a);
    390     bool WasReleased(Action a);
    391 
    392     //You should probably use the Action System
    393     int GetStatus(Key k);
    394     bool WasPressed(Key k);
    395     bool WasReleased(Key k);
    396 };
    397 
    398 class Input
    399 {
    400 private:
    401     static InputTracker* m_input_tracker;
    402 
    403     static bool CheckInputTrackerInit()
     108    static InputDevice* GetDevice(const char* name)
    404109    {
    405         if (Input::m_input_tracker)
    406             return true;
    407 
    408         Input::m_input_tracker = new InputTracker();
    409         return true;
     110        for (int i = 0; i < devices.Count(); ++i)
     111        {
     112            if (devices[i]->m_name == name)
     113                return devices[i];
     114        }
     115        return nullptr;
    410116    }
    411 
    412 public:
    413 
    414     /* These methods are general queries */
    415     static ivec2 GetMousePos();
    416     static uint32_t GetMouseButtons();
    417 
    418     /* Action management */
    419     static void LinkActionToKey(Action a, struct Key k);
    420     static void UnlinkAction(Action a);
    421     static int GetStatus(Action a);
    422     static bool WasPressed(Action a);
    423     static bool WasReleased(Action a);
    424 
    425     /* Raw Button management. You should use actions. */
    426     static int GetStatus(Key k);
    427     static bool WasPressed(Key k);
    428     static bool WasReleased(Key k);
    429 
    430     /* Entities can subscribe to events */
    431     static void TrackMouse(WorldEntity *e);
    432     static void UntrackMouse(WorldEntity *e);
    433 
    434     /* These methods are called by the underlying input listeners */
    435     /* FIXME: this should disappear and be replaced by an input
    436      * system that abstracts mice */
    437     static void SetMousePos(ivec2 coord);
    438     static void SetMouseButton(int index);
    439     static void UnsetMouseButton(int index);
    440 
    441     /* Keyboard handling */
    442     static Array<uint8_t> &GetKeyboardState();
    443     static int GetKeyState(int key);
    444 
    445     static Keyboard *CreateKeyboard();
    446     static void DestroyKeyboard(Keyboard *keyboard);
    447 
    448     static Keyboard *TrackKeyboard(int desired);
    449     static void UntrackKeyboard(Keyboard *keyboard);
    450 
    451     /* Joystick handling */
    452     static Stick *CreateStick();
    453     static void DestroyStick(Stick *stick);
    454 
    455     static Stick *TrackStick(int desired);
    456     static void UntrackStick(Stick *stick);
    457117};
    458118
    459119} /* namespace lol */
    460120
    461 #endif // !LOL_INPUT_V2
     121#endif // __LOL_INPUT_H__
    462122
    463 #endif // __LOL_INPUT_INPUT_H__
    464 
  • trunk/src/lolcore.vcxproj

    r2810 r2841  
    147147    <ClCompile Include="input\controller.cpp" />
    148148    <ClCompile Include="input\input.cpp" />
    149     <ClCompile Include="input\inputdevice.cpp" />
    150     <ClCompile Include="input\keyboard.cpp" />
    151     <ClCompile Include="input\stick.cpp" />
    152149    <ClCompile Include="layer.cpp" />
    153150    <ClCompile Include="light.cpp" />
     
    210207    <ClInclude Include="input\controller.h" />
    211208    <ClInclude Include="input\input.h" />
    212     <ClInclude Include="input\inputdevice.h" />
    213     <ClInclude Include="input\inputdevice_internal.h" />
    214     <ClInclude Include="input\keyboard.h" />
     209    <ClInclude Include="input\input_internal.h" />
    215210    <ClInclude Include="input\keys.h" />
    216     <ClInclude Include="input\stick.h" />
    217211    <ClInclude Include="layer.h" />
    218212    <ClInclude Include="light.h" />
  • trunk/src/lolcore.vcxproj.filters

    r2810 r2841  
    4444      <UniqueIdentifier>{1eaa8df5-7a31-4358-a1e9-0e265de6ed49}</UniqueIdentifier>
    4545    </Filter>
    46     <Filter Include="platform">
    47       <UniqueIdentifier>{a11c55f8-8e10-4270-be24-38e8d4fcf589}</UniqueIdentifier>
    48     </Filter>
    49     <Filter Include="platform\sdl">
    50       <UniqueIdentifier>{4089421f-2cc2-4036-a6b2-9df8a2f4efc8}</UniqueIdentifier>
    51     </Filter>
    52     <Filter Include="platform\xbox">
    53       <UniqueIdentifier>{317cb5cc-5dcc-4e14-be90-40a125a2e2ec}</UniqueIdentifier>
    54     </Filter>
    55     <Filter Include="platform\d3d9">
    56       <UniqueIdentifier>{a914e15d-3201-467a-a9c9-d7c5244b13ee}</UniqueIdentifier>
    57     </Filter>
    58     <Filter Include="platform\ps3">
    59       <UniqueIdentifier>{c6c6b597-ed6c-4d82-a166-964beeeeb525}</UniqueIdentifier>
    60     </Filter>
    6146    <Filter Include="lol\base">
    6247      <UniqueIdentifier>{e17b998c-d494-480b-ae29-5d1564f73327}</UniqueIdentifier>
     
    7964    <Filter Include="lol\debug">
    8065      <UniqueIdentifier>{01285b11-c6c7-4a9e-8dee-daa2c63901e4}</UniqueIdentifier>
     66    </Filter>
     67    <Filter Include="mesh\platform">
     68      <UniqueIdentifier>{a11c55f8-8e10-4270-be24-38e8d4fcf589}</UniqueIdentifier>
     69    </Filter>
     70    <Filter Include="mesh\platform\sdl">
     71      <UniqueIdentifier>{4089421f-2cc2-4036-a6b2-9df8a2f4efc8}</UniqueIdentifier>
     72    </Filter>
     73    <Filter Include="mesh\platform\xbox">
     74      <UniqueIdentifier>{317cb5cc-5dcc-4e14-be90-40a125a2e2ec}</UniqueIdentifier>
     75    </Filter>
     76    <Filter Include="mesh\platform\d3d9">
     77      <UniqueIdentifier>{a914e15d-3201-467a-a9c9-d7c5244b13ee}</UniqueIdentifier>
     78    </Filter>
     79    <Filter Include="mesh\platform\ps3">
     80      <UniqueIdentifier>{c6c6b597-ed6c-4d82-a166-964beeeeb525}</UniqueIdentifier>
    8181    </Filter>
    8282  </ItemGroup>
     
    9595    </ClCompile>
    9696    <ClCompile Include="platform\sdl\sdlapp.cpp">
    97       <Filter>platform\sdl</Filter>
     97      <Filter>mesh\platform\sdl</Filter>
    9898    </ClCompile>
    9999    <ClCompile Include="platform\sdl\sdlinput.cpp">
    100       <Filter>platform\sdl</Filter>
     100      <Filter>mesh\platform\sdl</Filter>
    101101    </ClCompile>
    102102    <ClCompile Include="math\half.cpp">
     
    152152    </ClCompile>
    153153    <ClCompile Include="platform\xbox\xboxapp.cpp">
    154       <Filter>platform\xbox</Filter>
     154      <Filter>mesh\platform\xbox</Filter>
    155155    </ClCompile>
    156156    <ClCompile Include="platform\xbox\xboxinput.cpp">
    157       <Filter>platform\xbox</Filter>
     157      <Filter>mesh\platform\xbox</Filter>
    158158    </ClCompile>
    159159    <ClCompile Include="gpu\indexbuffer.cpp">
     
    163163      <Filter>input</Filter>
    164164    </ClCompile>
    165     <ClCompile Include="input\keyboard.cpp">
    166       <Filter>input</Filter>
    167     </ClCompile>
    168     <ClCompile Include="input\stick.cpp">
    169       <Filter>input</Filter>
    170     </ClCompile>
    171165    <ClCompile Include="platform\d3d9\d3d9input.cpp">
    172       <Filter>platform\d3d9</Filter>
     166      <Filter>mesh\platform\d3d9</Filter>
    173167    </ClCompile>
    174168    <ClCompile Include="audio.cpp">
     
    269263    </ClCompile>
    270264    <ClCompile Include="platform\ps3\ps3app.cpp">
    271       <Filter>platform\ps3</Filter>
     265      <Filter>mesh\platform\ps3</Filter>
    272266    </ClCompile>
    273267    <ClCompile Include="platform\ps3\ps3input.cpp">
    274       <Filter>platform\ps3</Filter>
     268      <Filter>mesh\platform\ps3</Filter>
    275269    </ClCompile>
    276270    <ClCompile Include="gpu\lolfx-compiler.cpp">
     
    314308    </ClCompile>
    315309    <ClCompile Include="input\controller.cpp">
    316       <Filter>input</Filter>
    317     </ClCompile>
    318     <ClCompile Include="input\inputdevice.cpp">
    319310      <Filter>input</Filter>
    320311    </ClCompile>
     
    331322    </ClInclude>
    332323    <ClInclude Include="platform\sdl\sdlinput.h">
    333       <Filter>platform\sdl</Filter>
     324      <Filter>mesh\platform\sdl</Filter>
    334325    </ClInclude>
    335326    <ClInclude Include="platform\sdl\sdlapp.h">
    336       <Filter>platform\sdl</Filter>
     327      <Filter>mesh\platform\sdl</Filter>
    337328    </ClInclude>
    338329    <ClInclude Include="lol\image\color.h">
     
    370361    </ClInclude>
    371362    <ClInclude Include="platform\xbox\xboxapp.h">
    372       <Filter>platform\xbox</Filter>
     363      <Filter>mesh\platform\xbox</Filter>
    373364    </ClInclude>
    374365    <ClInclude Include="platform\xbox\xboxinput.h">
    375       <Filter>platform\xbox</Filter>
     366      <Filter>mesh\platform\xbox</Filter>
    376367    </ClInclude>
    377368    <ClInclude Include="input\input.h">
    378369      <Filter>input</Filter>
    379370    </ClInclude>
    380     <ClInclude Include="input\keyboard.h">
    381       <Filter>input</Filter>
    382     </ClInclude>
    383     <ClInclude Include="input\stick.h">
    384       <Filter>input</Filter>
    385     </ClInclude>
    386371    <ClInclude Include="platform\d3d9\d3d9input.h">
    387       <Filter>platform\d3d9</Filter>
     372      <Filter>mesh\platform\d3d9</Filter>
    388373    </ClInclude>
    389374    <ClInclude Include="audio.h">
     
    502487    </ClInclude>
    503488    <ClInclude Include="platform\ps3\ps3app.h">
    504       <Filter>platform\ps3</Filter>
     489      <Filter>mesh\platform\ps3</Filter>
    505490    </ClInclude>
    506491    <ClInclude Include="platform\ps3\ps3input.h">
    507       <Filter>platform\ps3</Filter>
     492      <Filter>mesh\platform\ps3</Filter>
    508493    </ClInclude>
    509494    <ClInclude Include="platform\ps3\threadbase.h">
    510       <Filter>platform\ps3</Filter>
     495      <Filter>mesh\platform\ps3</Filter>
    511496    </ClInclude>
    512497    <ClInclude Include="map.h">
     
    615600      <Filter>lol\image</Filter>
    616601    </ClInclude>
    617     <ClInclude Include="input\inputdevice.h">
    618       <Filter>input</Filter>
    619     </ClInclude>
    620602    <ClInclude Include="input\keys.h">
    621603      <Filter>input</Filter>
    622604    </ClInclude>
    623     <ClInclude Include="input\inputdevice_internal.h">
     605    <ClInclude Include="input\controller.h">
    624606      <Filter>input</Filter>
    625607    </ClInclude>
    626     <ClInclude Include="input\controller.h">
     608    <ClInclude Include="input\input_internal.h">
    627609      <Filter>input</Filter>
    628610    </ClInclude>
  • trunk/src/platform/d3d9/d3d9input.cpp

    r2816 r2841  
    2121#include "d3d9input.h"
    2222
    23 #ifdef LOL_INPUT_V2
    24 #include "input/inputdevice_internal.h"
    25 #endif // LOL_INPUT_V2
     23#include "input/input_internal.h"
    2624
    2725namespace lol
     
    3836private:
    3937#if defined USE_XINPUT
    40 #if defined LOL_INPUT_V2
    4138    Array<int, InputDeviceInternal*> m_joysticks;
    42 #else
    43     Array<int, Stick *> m_joysticks;
    44 #endif // LOL_INPUT_V2
    4539#endif // USE_XINPUT
    4640};
     
    5953        if (XInputGetState(i, &state) != ERROR_SUCCESS)
    6054            continue;
    61 #if defined LOL_INPUT_V2
    6255        // TODO: we can put more friendly name here, such as LeftAxisX, ButtonX...
    6356        InputDeviceInternal* stick = new InputDeviceInternal(String::Printf("Joystick%d", i+1).C());
     
    6861
    6962        m_data->m_joysticks.Push(i, stick);
    70 #else
    71         Stick *stick = Input::CreateStick();
    72         stick->SetAxisCount(4);
    73         stick->SetButtonCount(16);
    74         m_data->m_joysticks.Push(i, stick);
    75 #endif // LOL_INPUT_V2
    7663    }
    7764#endif
     
    8673    while (m_data->m_joysticks.Count())
    8774    {
    88 #if defined LOL_INPUT_V2
    8975        delete m_data->m_joysticks[0].m2;
    90 #else
    91         Input::DestroyStick(m_data->m_joysticks[0].m2);
    92 #endif // LOL_INPUT_V2
    9376        m_data->m_joysticks.Remove(0);
    9477    }
     
    119102
    120103        for (int b = 0; b < 16; b++)
    121 #if defined LOL_INPUT_V2
    122104            m_data->m_joysticks[i].m2->SetKey(b, ((uint16_t)(state.Gamepad.wButtons) >> b) & 1);
    123 #else
    124             m_data->m_joysticks[i].m2->SetButton(b, ((uint16_t)(state.Gamepad.wButtons) >> b) & 1);
    125 #endif // LOL_INPUT_V2
    126105    }
    127106#endif
  • trunk/src/platform/sdl/sdlapp.cpp

    r2816 r2841  
    6767    }
    6868
    69 #   ifdef LOL_INPUT_V2
    7069    const SDL_VideoInfo* vidinfo = SDL_GetVideoInfo();
    7170    int screen_w = vidinfo->current_w;
    7271    int screen_h = vidinfo->current_h;
    73 #   endif
    7472
    7573#   if defined USE_D3D9
     
    8482    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    8583    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    86 #   ifdef LOL_INPUT_V2
    87     // TODO: when implementing fullscreen, be sure to overwrite screen_w and screen_h with the value of vidinfo after the call to SDL_SetVideoMode
    88 #   endif
     84
     85        // TODO: when implementing fullscreen, be sure to overwrite screen_w and screen_h with the value of vidinfo after the call to SDL_SetVideoMode
    8986    SDL_Surface *video = SDL_SetVideoMode(res.x, res.y, 0, SDL_OPENGL);
    9087#   endif
     
    110107#   endif
    111108
    112 #   ifdef LOL_INPUT_V2
    113109    new SdlInput(video->w, video->h, screen_w, screen_h);
    114 #   else
    115     new SdlInput();
    116 #   endif
    117110#endif
    118111}
  • trunk/src/platform/sdl/sdlinput.cpp

    r2837 r2841  
    2424#include "sdlinput.h"
    2525
    26 #ifdef LOL_INPUT_V2
    27 #include "input/inputdevice_internal.h"
    28 #endif // LOL_INPUT_V2
     26#include "input/input_internal.h"
    2927
    3028/* We force joystick polling because no events are received when
     
    5048
    5149#if USE_SDL
    52 # ifdef LOL_INPUT_V2
    5350    SdlInputData(int app_w, int app_h, int screen_w, int screen_h) :
    5451        m_prevmouse(ivec2(0)),
     
    6966    float m_screen_h;
    7067    bool m_mousecapture;
    71 # else
    72     Array<SDL_Joystick *, Stick *> m_joysticks;
    73 # endif // LOL_INPUT_V2
    7468#endif // USE_SDL
    7569};
     
    7973 */
    8074
    81 #ifdef LOL_INPUT_V2
    8275SdlInput::SdlInput(int app_w, int app_h, int screen_w, int screen_h)
    8376  : m_data(new SdlInputData(app_w, app_h, screen_w, screen_h))
    84 #else
    85 SdlInput::SdlInput()
    86   : m_data(new SdlInputData())
    87 #endif
    8877{
    8978#if USE_SDL
     
    10089#       endif
    10190
    102 #ifdef LOL_INPUT_V2
    10391    m_data->m_keyboard = InputDeviceInternal::CreateStandardKeyboard();
    10492    m_data->m_mouse = InputDeviceInternal::CreateStandardMouse();
    105 #endif
    10693
    10794    /* Register all the joysticks we can find, and let the input
     
    126113        }
    127114
    128 #       ifdef LOL_INPUT_V2
    129115        InputDeviceInternal* stick = new InputDeviceInternal(String::Printf("Joystick%d", i+1).C());
    130116        for (int j = 0; j < SDL_JoystickNumAxes(sdlstick); ++j)
     
    134120
    135121        m_data->m_joysticks.Push(sdlstick, stick);
    136 #       else // !LOL_INPUT_V2
    137         Stick *stick = Input::CreateStick();
    138         stick->SetAxisCount(SDL_JoystickNumAxes(sdlstick));
    139         stick->SetButtonCount(SDL_JoystickNumButtons(sdlstick));
    140 
    141         /* It's possible to remap axes */
    142         //stick->RemapAxis(4, 2);
    143         //stick->RemapAxis(2, 4);
    144 
    145         m_data->m_joysticks.Push(sdlstick, stick);
    146 #       endif
    147122    }
    148123#   endif
     
    159134    {
    160135        SDL_JoystickClose(m_data->m_joysticks[0].m1);
    161 #       ifdef LOL_INPUT_V2
    162136        delete m_data->m_joysticks[0].m2;
    163 #       else
    164         Input::DestroyStick(m_data->m_joysticks[0].m2);
    165 #       endif
    166137        m_data->m_joysticks.Remove(0);
    167138    }
     
    196167    for (int j = 0; j < m_joysticks.Count(); j++)
    197168    {
    198 #       ifdef LOL_INPUT_V2
    199169        for (int i = 0; i < SDL_JoystickNumButtons(m_joysticks[j].m1); i++)
    200170            m_joysticks[j].m2->SetKey(i, SDL_JoystickGetButton(m_joysticks[j].m1, i) != 0);
    201171        for (int i = 0; i < SDL_JoystickNumAxes(m_joysticks[j].m1); i++)
    202172            m_joysticks[j].m2->SetAxis(i, (float)SDL_JoystickGetAxis(m_joysticks[j].m1, i) / 32768.f);
    203 #       else // !LOL_INPUT_V2
    204         for (int i = 0; i < SDL_JoystickNumButtons(m_joysticks[j].m1); i++)
    205             m_joysticks[j].m2->SetButton(i, SDL_JoystickGetButton(m_joysticks[j].m1, i));
    206         for (int i = 0; i < SDL_JoystickNumAxes(m_joysticks[j].m1); i++)
    207             m_joysticks[j].m2->SetAxis(i, (float)SDL_JoystickGetAxis(m_joysticks[j].m1, i) / 32768.f);
    208 
    209 #       endif
    210173    }
    211174#   endif
     
    229192        case SDL_MOUSEBUTTONUP:
    230193        {
    231 #ifdef LOL_INPUT_V2
    232194            m_mouse->SetKey(event.button.button - 1, event.type == SDL_MOUSEBUTTONDOWN);
    233 #else // !LOL_INPUT_V2
    234             if (event.type == SDL_MOUSEBUTTONDOWN)
    235                 Input::SetMouseButton(event.button.button - 1);
    236             else
    237                 Input::UnsetMouseButton(event.button.button - 1);
    238 #endif // LOL_INPUT_V2
    239195            break;
    240196        }
    241197
    242198#   if !SDL_FORCE_POLL_JOYSTICK
    243 #     ifdef LOL_INPUT_V2
    244199        case SDL_JOYAXISMOTION:
    245200            m_joysticks[event.jaxis.which].m2->SetAxis(event.jaxis.axis, (float)event.jaxis.value / 32768.f);
     
    250205            m_joysticks[event.jbutton.which].m2->SetKey(event.jbutton.button, event.jbutton.state);
    251206            break;
    252 #     else // !LOL_INPUT_V2
    253         case SDL_JOYAXISMOTION:
    254             m_joysticks[event.jaxis.which].m2->SetAxis(event.jaxis.axis, (float)event.jaxis.value / 32768.f);
    255             break;
    256 
    257         case SDL_JOYBUTTONUP:
    258         case SDL_JOYBUTTONDOWN:
    259             m_joysticks[event.jbutton.which].m2->SetButton(event.jbutton.button, event.jbutton.state);
    260             break;
    261 #     endif // LOL_INPUT_V2
    262207#   endif
    263208        }
     
    266211    /* Handle mouse input */
    267212    ivec2 mouse = SdlInputData::GetMousePos();
    268 #   ifdef LOL_INPUT_V2
    269213    if (InputDeviceInternal::GetMouseCapture() != m_mousecapture)
    270214    {
     
    290234    m_prevmouse = mouse;
    291235
    292 #   else // !LOL_INPUT_V2
    293     Input::SetMousePos(mouse);
    294 #   endif // LOL_INPUT_V2
    295 
    296236#   if SDL_VERSION_ATLEAST(1,3,0)
    297237    Uint8 *sdlstate = SDL_GetKeyboardState(nullptr);
     
    301241
    302242    int keyindex = 0;
    303 #   ifdef LOL_INPUT_V2
    304243#       define KEY_FUNC(name, index) \
    305244            m_keyboard->SetKey(keyindex++, sdlstate[index] != 0);
    306245        /* FIXME: we ignore SDLK_WORLD_0, which means our list of
    307246         * 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
    311 
    312     /* Send the whole keyboard state to the input system */
    313     Array<uint8_t> &lolstate = Input::GetKeyboardState();
    314 
    315     lolstate[Key::Unknown] = sdlstate[SDLK_UNKNOWN];
    316     lolstate[Key::Backspace] = sdlstate[SDLK_BACKSPACE];
    317     lolstate[Key::Tab] = sdlstate[SDLK_TAB];
    318     lolstate[Key::Clear] = sdlstate[SDLK_CLEAR];
    319     lolstate[Key::Return] = sdlstate[SDLK_RETURN];
    320     lolstate[Key::Pause] = sdlstate[SDLK_PAUSE];
    321     lolstate[Key::Escape] = sdlstate[SDLK_ESCAPE];
    322     lolstate[Key::Space] = sdlstate[SDLK_SPACE];
    323     lolstate[Key::Exclaim] = sdlstate[SDLK_EXCLAIM];
    324     lolstate[Key::DoubleQuote] = sdlstate[SDLK_QUOTEDBL];
    325     lolstate[Key::Hash] = sdlstate[SDLK_HASH];
    326     lolstate[Key::Dollar] = sdlstate[SDLK_DOLLAR];
    327     lolstate[Key::Ampersand] = sdlstate[SDLK_AMPERSAND];
    328     lolstate[Key::Quote] = sdlstate[SDLK_QUOTE];
    329     lolstate[Key::LeftParen] = sdlstate[SDLK_LEFTPAREN];
    330     lolstate[Key::RightParen] = sdlstate[SDLK_RIGHTPAREN];
    331     lolstate[Key::Asterisk] = sdlstate[SDLK_ASTERISK];
    332     lolstate[Key::Plus] = sdlstate[SDLK_PLUS];
    333     lolstate[Key::Comma] = sdlstate[SDLK_COMMA];
    334     lolstate[Key::Minus] = sdlstate[SDLK_MINUS];
    335     lolstate[Key::Period] = sdlstate[SDLK_PERIOD];
    336     lolstate[Key::Slash] = sdlstate[SDLK_SLASH];
    337     lolstate[Key::K0] = sdlstate[SDLK_0];
    338     lolstate[Key::K1] = sdlstate[SDLK_1];
    339     lolstate[Key::K2] = sdlstate[SDLK_2];
    340     lolstate[Key::K3] = sdlstate[SDLK_3];
    341     lolstate[Key::K4] = sdlstate[SDLK_4];
    342     lolstate[Key::K5] = sdlstate[SDLK_5];
    343     lolstate[Key::K6] = sdlstate[SDLK_6];
    344     lolstate[Key::K7] = sdlstate[SDLK_7];
    345     lolstate[Key::K8] = sdlstate[SDLK_8];
    346     lolstate[Key::K9] = sdlstate[SDLK_9];
    347     lolstate[Key::Colon] = sdlstate[SDLK_COLON];
    348     lolstate[Key::Semicolon] = sdlstate[SDLK_SEMICOLON];
    349     lolstate[Key::Less] = sdlstate[SDLK_LESS];
    350     lolstate[Key::Equals] = sdlstate[SDLK_EQUALS];
    351     lolstate[Key::Greater] = sdlstate[SDLK_GREATER];
    352     lolstate[Key::Question] = sdlstate[SDLK_QUESTION];
    353     lolstate[Key::At] = sdlstate[SDLK_AT];
    354 
    355     lolstate[Key::LeftBracket] = sdlstate[SDLK_LEFTBRACKET];
    356     lolstate[Key::BackSlash] = sdlstate[SDLK_BACKSLASH];
    357     lolstate[Key::RightBracket] = sdlstate[SDLK_RIGHTBRACKET];
    358     lolstate[Key::Caret] = sdlstate[SDLK_CARET];
    359     lolstate[Key::Underscore] = sdlstate[SDLK_UNDERSCORE];
    360     lolstate[Key::Backquote] = sdlstate[SDLK_BACKQUOTE];
    361     lolstate[Key::A] = sdlstate[SDLK_a];
    362     lolstate[Key::B] = sdlstate[SDLK_b];
    363     lolstate[Key::C] = sdlstate[SDLK_c];
    364     lolstate[Key::D] = sdlstate[SDLK_d];
    365     lolstate[Key::E] = sdlstate[SDLK_e];
    366     lolstate[Key::F] = sdlstate[SDLK_f];
    367     lolstate[Key::G] = sdlstate[SDLK_g];
    368     lolstate[Key::H] = sdlstate[SDLK_h];
    369     lolstate[Key::I] = sdlstate[SDLK_i];
    370     lolstate[Key::J] = sdlstate[SDLK_j];
    371     lolstate[Key::K] = sdlstate[SDLK_k];
    372     lolstate[Key::L] = sdlstate[SDLK_l];
    373     lolstate[Key::M] = sdlstate[SDLK_m];
    374     lolstate[Key::N] = sdlstate[SDLK_n];
    375     lolstate[Key::O] = sdlstate[SDLK_o];
    376     lolstate[Key::P] = sdlstate[SDLK_p];
    377     lolstate[Key::Q] = sdlstate[SDLK_q];
    378     lolstate[Key::R] = sdlstate[SDLK_r];
    379     lolstate[Key::S] = sdlstate[SDLK_s];
    380     lolstate[Key::T] = sdlstate[SDLK_t];
    381     lolstate[Key::U] = sdlstate[SDLK_u];
    382     lolstate[Key::V] = sdlstate[SDLK_v];
    383     lolstate[Key::W] = sdlstate[SDLK_w];
    384     lolstate[Key::X] = sdlstate[SDLK_x];
    385     lolstate[Key::Y] = sdlstate[SDLK_y];
    386     lolstate[Key::Z] = sdlstate[SDLK_z];
    387     lolstate[Key::Delete] = sdlstate[SDLK_DELETE];
    388 
    389 #if SDLK_WORLD_0
    390     lolstate[Key::World0] = sdlstate[SDLK_WORLD_0];
    391     lolstate[Key::World1] = sdlstate[SDLK_WORLD_1];
    392     lolstate[Key::World2] = sdlstate[SDLK_WORLD_2];
    393     lolstate[Key::World3] = sdlstate[SDLK_WORLD_3];
    394     lolstate[Key::World4] = sdlstate[SDLK_WORLD_4];
    395     lolstate[Key::World5] = sdlstate[SDLK_WORLD_5];
    396     lolstate[Key::World6] = sdlstate[SDLK_WORLD_6];
    397     lolstate[Key::World7] = sdlstate[SDLK_WORLD_7];
    398     lolstate[Key::World8] = sdlstate[SDLK_WORLD_8];
    399     lolstate[Key::World9] = sdlstate[SDLK_WORLD_9];
    400     lolstate[Key::World10] = sdlstate[SDLK_WORLD_10];
    401     lolstate[Key::World11] = sdlstate[SDLK_WORLD_11];
    402     lolstate[Key::World12] = sdlstate[SDLK_WORLD_12];
    403     lolstate[Key::World13] = sdlstate[SDLK_WORLD_13];
    404     lolstate[Key::World14] = sdlstate[SDLK_WORLD_14];
    405     lolstate[Key::World15] = sdlstate[SDLK_WORLD_15];
    406     lolstate[Key::World16] = sdlstate[SDLK_WORLD_16];
    407     lolstate[Key::World17] = sdlstate[SDLK_WORLD_17];
    408     lolstate[Key::World18] = sdlstate[SDLK_WORLD_18];
    409     lolstate[Key::World19] = sdlstate[SDLK_WORLD_19];
    410     lolstate[Key::World20] = sdlstate[SDLK_WORLD_20];
    411     lolstate[Key::World21] = sdlstate[SDLK_WORLD_21];
    412     lolstate[Key::World22] = sdlstate[SDLK_WORLD_22];
    413     lolstate[Key::World23] = sdlstate[SDLK_WORLD_23];
    414     lolstate[Key::World24] = sdlstate[SDLK_WORLD_24];
    415     lolstate[Key::World25] = sdlstate[SDLK_WORLD_25];
    416     lolstate[Key::World26] = sdlstate[SDLK_WORLD_26];
    417     lolstate[Key::World27] = sdlstate[SDLK_WORLD_27];
    418     lolstate[Key::World28] = sdlstate[SDLK_WORLD_28];
    419     lolstate[Key::World29] = sdlstate[SDLK_WORLD_29];
    420     lolstate[Key::World30] = sdlstate[SDLK_WORLD_30];
    421     lolstate[Key::World31] = sdlstate[SDLK_WORLD_31];
    422     lolstate[Key::World32] = sdlstate[SDLK_WORLD_32];
    423     lolstate[Key::World33] = sdlstate[SDLK_WORLD_33];
    424     lolstate[Key::World34] = sdlstate[SDLK_WORLD_34];
    425     lolstate[Key::World35] = sdlstate[SDLK_WORLD_35];
    426     lolstate[Key::World36] = sdlstate[SDLK_WORLD_36];
    427     lolstate[Key::World37] = sdlstate[SDLK_WORLD_37];
    428     lolstate[Key::World38] = sdlstate[SDLK_WORLD_38];
    429     lolstate[Key::World39] = sdlstate[SDLK_WORLD_39];
    430     lolstate[Key::World40] = sdlstate[SDLK_WORLD_40];
    431     lolstate[Key::World41] = sdlstate[SDLK_WORLD_41];
    432     lolstate[Key::World42] = sdlstate[SDLK_WORLD_42];
    433     lolstate[Key::World43] = sdlstate[SDLK_WORLD_43];
    434     lolstate[Key::World44] = sdlstate[SDLK_WORLD_44];
    435     lolstate[Key::World45] = sdlstate[SDLK_WORLD_45];
    436     lolstate[Key::World46] = sdlstate[SDLK_WORLD_46];
    437     lolstate[Key::World47] = sdlstate[SDLK_WORLD_47];
    438     lolstate[Key::World48] = sdlstate[SDLK_WORLD_48];
    439     lolstate[Key::World49] = sdlstate[SDLK_WORLD_49];
    440     lolstate[Key::World50] = sdlstate[SDLK_WORLD_50];
    441     lolstate[Key::World51] = sdlstate[SDLK_WORLD_51];
    442     lolstate[Key::World52] = sdlstate[SDLK_WORLD_52];
    443     lolstate[Key::World53] = sdlstate[SDLK_WORLD_53];
    444     lolstate[Key::World54] = sdlstate[SDLK_WORLD_54];
    445     lolstate[Key::World55] = sdlstate[SDLK_WORLD_55];
    446     lolstate[Key::World56] = sdlstate[SDLK_WORLD_56];
    447     lolstate[Key::World57] = sdlstate[SDLK_WORLD_57];
    448     lolstate[Key::World58] = sdlstate[SDLK_WORLD_58];
    449     lolstate[Key::World59] = sdlstate[SDLK_WORLD_59];
    450     lolstate[Key::World60] = sdlstate[SDLK_WORLD_60];
    451     lolstate[Key::World61] = sdlstate[SDLK_WORLD_61];
    452     lolstate[Key::World62] = sdlstate[SDLK_WORLD_62];
    453     lolstate[Key::World63] = sdlstate[SDLK_WORLD_63];
    454     lolstate[Key::World64] = sdlstate[SDLK_WORLD_64];
    455     lolstate[Key::World65] = sdlstate[SDLK_WORLD_65];
    456     lolstate[Key::World66] = sdlstate[SDLK_WORLD_66];
    457     lolstate[Key::World67] = sdlstate[SDLK_WORLD_67];
    458     lolstate[Key::World68] = sdlstate[SDLK_WORLD_68];
    459     lolstate[Key::World69] = sdlstate[SDLK_WORLD_69];
    460     lolstate[Key::World70] = sdlstate[SDLK_WORLD_70];
    461     lolstate[Key::World71] = sdlstate[SDLK_WORLD_71];
    462     lolstate[Key::World72] = sdlstate[SDLK_WORLD_72];
    463     lolstate[Key::World73] = sdlstate[SDLK_WORLD_73];
    464     lolstate[Key::World74] = sdlstate[SDLK_WORLD_74];
    465     lolstate[Key::World75] = sdlstate[SDLK_WORLD_75];
    466     lolstate[Key::World76] = sdlstate[SDLK_WORLD_76];
    467     lolstate[Key::World77] = sdlstate[SDLK_WORLD_77];
    468     lolstate[Key::World78] = sdlstate[SDLK_WORLD_78];
    469     lolstate[Key::World79] = sdlstate[SDLK_WORLD_79];
    470     lolstate[Key::World80] = sdlstate[SDLK_WORLD_80];
    471     lolstate[Key::World81] = sdlstate[SDLK_WORLD_81];
    472     lolstate[Key::World82] = sdlstate[SDLK_WORLD_82];
    473     lolstate[Key::World83] = sdlstate[SDLK_WORLD_83];
    474     lolstate[Key::World84] = sdlstate[SDLK_WORLD_84];
    475     lolstate[Key::World85] = sdlstate[SDLK_WORLD_85];
    476     lolstate[Key::World86] = sdlstate[SDLK_WORLD_86];
    477     lolstate[Key::World87] = sdlstate[SDLK_WORLD_87];
    478     lolstate[Key::World88] = sdlstate[SDLK_WORLD_88];
    479     lolstate[Key::World89] = sdlstate[SDLK_WORLD_89];
    480     lolstate[Key::World90] = sdlstate[SDLK_WORLD_90];
    481     lolstate[Key::World91] = sdlstate[SDLK_WORLD_91];
    482     lolstate[Key::World92] = sdlstate[SDLK_WORLD_92];
    483     lolstate[Key::World93] = sdlstate[SDLK_WORLD_93];
    484     lolstate[Key::World94] = sdlstate[SDLK_WORLD_94];
    485     lolstate[Key::World95] = sdlstate[SDLK_WORLD_95];
    486 #endif // SDLK_WORLD_0
    487 
    488     lolstate[Key::KP0] = sdlstate[SDLK_KP0];
    489     lolstate[Key::KP1] = sdlstate[SDLK_KP1];
    490     lolstate[Key::KP2] = sdlstate[SDLK_KP2];
    491     lolstate[Key::KP3] = sdlstate[SDLK_KP3];
    492     lolstate[Key::KP4] = sdlstate[SDLK_KP4];
    493     lolstate[Key::KP5] = sdlstate[SDLK_KP5];
    494     lolstate[Key::KP6] = sdlstate[SDLK_KP6];
    495     lolstate[Key::KP7] = sdlstate[SDLK_KP7];
    496     lolstate[Key::KP8] = sdlstate[SDLK_KP8];
    497     lolstate[Key::KP9] = sdlstate[SDLK_KP9];
    498     lolstate[Key::KPPeriod] = sdlstate[SDLK_KP_PERIOD];
    499     lolstate[Key::KPDivide] = sdlstate[SDLK_KP_DIVIDE];
    500     lolstate[Key::KPMultiply] = sdlstate[SDLK_KP_MULTIPLY];
    501     lolstate[Key::KPMinus] = sdlstate[SDLK_KP_MINUS];
    502     lolstate[Key::KPPlus] = sdlstate[SDLK_KP_PLUS];
    503     lolstate[Key::KPEnter] = sdlstate[SDLK_KP_ENTER];
    504     lolstate[Key::KPEquals] = sdlstate[SDLK_KP_EQUALS];
    505 
    506     lolstate[Key::Up] = sdlstate[SDLK_UP];
    507     lolstate[Key::Down] = sdlstate[SDLK_DOWN];
    508     lolstate[Key::Right] = sdlstate[SDLK_RIGHT];
    509     lolstate[Key::Left] = sdlstate[SDLK_LEFT];
    510     lolstate[Key::Insert] = sdlstate[SDLK_INSERT];
    511     lolstate[Key::Home] = sdlstate[SDLK_HOME];
    512     lolstate[Key::End] = sdlstate[SDLK_END];
    513     lolstate[Key::PageUp] = sdlstate[SDLK_PAGEUP];
    514     lolstate[Key::PageDown] = sdlstate[SDLK_PAGEDOWN];
    515 
    516     lolstate[Key::F1] = sdlstate[SDLK_F1];
    517     lolstate[Key::F2] = sdlstate[SDLK_F2];
    518     lolstate[Key::F3] = sdlstate[SDLK_F3];
    519     lolstate[Key::F4] = sdlstate[SDLK_F4];
    520     lolstate[Key::F5] = sdlstate[SDLK_F5];
    521     lolstate[Key::F6] = sdlstate[SDLK_F6];
    522     lolstate[Key::F7] = sdlstate[SDLK_F7];
    523     lolstate[Key::F8] = sdlstate[SDLK_F8];
    524     lolstate[Key::F9] = sdlstate[SDLK_F9];
    525     lolstate[Key::F10] = sdlstate[SDLK_F10];
    526     lolstate[Key::F11] = sdlstate[SDLK_F11];
    527     lolstate[Key::F12] = sdlstate[SDLK_F12];
    528     lolstate[Key::F13] = sdlstate[SDLK_F13];
    529     lolstate[Key::F14] = sdlstate[SDLK_F14];
    530     lolstate[Key::F15] = sdlstate[SDLK_F15];
    531 
    532     lolstate[Key::NumLock] = sdlstate[SDLK_NUMLOCK];
    533     lolstate[Key::CapsLock] = sdlstate[SDLK_CAPSLOCK];
    534     lolstate[Key::ScrollLock] = sdlstate[SDLK_SCROLLOCK];
    535     lolstate[Key::RightShift] = sdlstate[SDLK_RSHIFT];
    536     lolstate[Key::LeftShift] = sdlstate[SDLK_LSHIFT];
    537     lolstate[Key::RightCtrl] = sdlstate[SDLK_RCTRL];
    538     lolstate[Key::LeftCtrl] = sdlstate[SDLK_LCTRL];
    539     lolstate[Key::RightAlt] = sdlstate[SDLK_RALT];
    540     lolstate[Key::LeftAlt] = sdlstate[SDLK_LALT];
    541     lolstate[Key::RightMeta] = sdlstate[SDLK_RMETA];
    542     lolstate[Key::LeftMeta] = sdlstate[SDLK_LMETA];
    543     lolstate[Key::LeftSuper] = sdlstate[SDLK_LSUPER];
    544     lolstate[Key::RightSuper] = sdlstate[SDLK_RSUPER];
    545     lolstate[Key::Mode] = sdlstate[SDLK_MODE];
    546     lolstate[Key::Compose] = sdlstate[SDLK_COMPOSE];
    547 
    548     lolstate[Key::Help] = sdlstate[SDLK_HELP];
    549     lolstate[Key::Print] = sdlstate[SDLK_PRINT];
    550     lolstate[Key::SysReq] = sdlstate[SDLK_SYSREQ];
    551     lolstate[Key::Break] = sdlstate[SDLK_BREAK];
    552     lolstate[Key::Menu] = sdlstate[SDLK_MENU];
    553     lolstate[Key::Power] = sdlstate[SDLK_POWER];
    554     lolstate[Key::Euro] = sdlstate[SDLK_EURO];
    555     lolstate[Key::Undo] = sdlstate[SDLK_UNDO];
    556 
    557     UNUSED(seconds);
    558 #    endif // LOL_INPUT_V2
     247#    include "input/keys.h"
     248#    undef KEY_FUNC
    559249
    560250#endif // USE_SDL
  • trunk/src/platform/sdl/sdlinput.h

    r2816 r2841  
    2727{
    2828public:
    29 #ifdef LOL_INPUT_V2
    3029    /** passing the screen resolution (note: not the windowed app resolution!) allows to make the mouse axis resolution-independent */
    3130    SdlInput(int app_w, int app_h, int screen_w, int screen_h);
    32 #else
    33     SdlInput();
    34 #endif
    35     virtual ~SdlInput();
     31
     32        virtual ~SdlInput();
    3633    void SetScreenResolution();
    3734
Note: See TracChangeset for help on using the changeset viewer.