Changeset 2825


Ignore:
Timestamp:
Jul 31, 2013, 3:54:15 PM (6 years ago)
Author:
benlitz
Message:

fixed a crash when updating a binding that has been bound to an unexisting key/axis of an existing device

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/input/controller.h

    r2818 r2825  
    3131    void Bind(const char* device_name, const char* key_name);
    3232
     33    bool IsBound() { return m_device && m_keyindex != -1; }
     34
    3335protected:
    34     void Update() { m_previous = m_current; m_current = m_device ? m_device->GetKey(m_keyindex) : false; }
     36    void Update() { m_previous = m_current; m_current = IsBound() ? m_device->GetKey(m_keyindex) : false; }
    3537
    3638    const InputDevice* m_device;
     
    5254    void Bind(const char* device_name, const char* axis_name);
    5355
     56    bool IsBound() { return m_device && m_axisindex != -1; }
     57
    5458protected:
    55     void Update() { m_previous = m_current; m_current = m_device ? m_device->GetAxis(m_axisindex) : 0.0f; }
     59    void Update() { m_previous = m_current; m_current = IsBound() ? m_device->GetAxis(m_axisindex) : 0.0f; }
    5660
    5761    const InputDevice* m_device;
Note: See TracChangeset for help on using the changeset viewer.