Ignore:
Timestamp:
May 9, 2012, 6:40:38 PM (8 years ago)
Author:
sam
Message:

input: allow to remap gamepad axes in the generic input layer.

File:
1 edited

Legend:

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

    r1342 r1355  
    3333
    3434private:
    35     Array<float> m_axes;
    36     Array<int> m_buttons;
     35    /* First element is the remap target */
     36    Array<int, float> m_axes;
     37    Array<int, int> m_buttons;
    3738}
    3839stickdata;
     
    5657    m_data->m_axes.Empty();
    5758    for (int i = 0; i < n; i++)
    58         m_data->m_axes.Push(0.f);
     59        m_data->m_axes.Push(i, 0.f);
    5960}
    6061
     
    6364    m_data->m_buttons.Empty();
    6465    for (int i = 0; i < n; i++)
    65         m_data->m_buttons.Push(0);
     66        m_data->m_buttons.Push(i, 0);
    6667}
    6768
    6869void Stick::SetAxis(int n, float val)
    6970{
    70     m_data->m_axes[n] = val;
     71    m_data->m_axes[m_data->m_axes[n].m1].m2 = val;
    7172}
    7273
    7374void Stick::SetButton(int n, int val)
    7475{
    75     m_data->m_buttons[n] = val;
     76    m_data->m_buttons[m_data->m_buttons[n].m1].m2 = val;
     77}
     78
     79void Stick::RemapAxis(int src, int dst)
     80{
     81    m_data->m_axes[src].m1 = dst;
     82}
     83
     84void Stick::RemapButton(int src, int dst)
     85{
     86    m_data->m_buttons[src].m1 = dst;
    7687}
    7788
     
    8899float Stick::GetAxis(int n)
    89100{
    90     return m_data->m_axes[n];
     101    return m_data->m_axes[n].m2;
    91102}
    92103
    93104int Stick::GetButton(int n)
    94105{
    95     return m_data->m_buttons[n];
     106    return m_data->m_buttons[n].m2;
    96107}
    97108
Note: See TracChangeset for help on using the changeset viewer.