Ignore:
Timestamp:
Jul 23, 2013, 5:42:32 PM (7 years ago)
Author:
benlitz
Message:

Completely reworked input system. Unified device interface, button, axis and cursor support, controller and binding system, mouse capture. Tutorial 07_input provided. Require to compile lolcore with LOL_INPUT_V2 to be activated (also needed app-side before including core.h)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/platform/d3d9/d3d9input.cpp

    r2216 r2810  
    2121#include "d3d9input.h"
    2222
     23#ifdef LOL_INPUT_V2
     24#include "input/inputdevice_internal.h"
     25#endif // LOL_INPUT_V2
     26
    2327namespace lol
    2428{
     
    3438private:
    3539#if defined USE_XINPUT
     40#if defined LOL_INPUT_V2
     41    Array<int, InputDeviceInternal*> m_joysticks;
     42#else
    3643    Array<int, Stick *> m_joysticks;
    37 #endif
     44#endif // LOL_INPUT_V2
     45#endif // USE_XINPUT
    3846};
    3947
     
    5159        if (XInputGetState(i, &state) != ERROR_SUCCESS)
    5260            continue;
     61#if defined LOL_INPUT_V2
     62                // TODO: we can put more friendly name here, such as LeftAxisX, ButtonX...
     63                InputDeviceInternal* stick = new InputDeviceInternal(String::Printf("Joystick%d", i+1).C());
     64                for (int j = 0; j < 4; ++j)
     65                        stick->AddAxis(String::Printf("Axis%d", j+1).C());
     66                for (int j = 0; j < 16; ++j)
     67                        stick->AddKey(String::Printf("Button%d", j+1).C());
    5368
     69                m_data->m_joysticks.Push(i, stick);
     70#else
    5471        Stick *stick = Input::CreateStick();
    5572        stick->SetAxisCount(4);
    5673        stick->SetButtonCount(16);
    5774        m_data->m_joysticks.Push(i, stick);
     75#endif // LOL_INPUT_V2
    5876    }
    5977#endif
     
    6886    while (m_data->m_joysticks.Count())
    6987    {
    70         Input::DestroyStick(m_data->m_joysticks[0].m2);
    71         m_data->m_joysticks.Remove(0);
     88#if defined LOL_INPUT_V2
     89                delete m_data->m_joysticks[0].m2;
     90#else
     91                Input::DestroyStick(m_data->m_joysticks[0].m2);
     92#endif // LOL_INPUT_V2
     93                m_data->m_joysticks.Remove(0);
    7294    }
    7395#endif
     
    97119
    98120        for (int b = 0; b < 16; b++)
    99             m_data->m_joysticks[i].m2->SetButton(b, ((uint16_t)(state.Gamepad.wButtons) >> b) & 1);
    100     }
     121#if defined LOL_INPUT_V2
     122                        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
     126        }
    101127#endif
    102128}
Note: See TracChangeset for help on using the changeset viewer.