Changeset 2918


Ignore:
Timestamp:
Sep 14, 2013, 6:09:44 PM (6 years ago)
Author:
benlitz
Message:

input: added a GetAvailableDevices function to retrieve device names.

Location:
trunk/src/input
Files:
2 edited

Legend:

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

    r2845 r2918  
    2222Array<InputDevice*> InputDevice::devices;
    2323bool InputDevice::m_capturemouse;
     24
     25Array<String> InputDevice::GetAvailableDevices()
     26{
     27    Array<String> result;
     28    for (int i = 0; i < devices.Count(); ++i)
     29    {
     30        result.Push(devices[i]->m_name);
     31    }
     32    return result;
     33}
    2434
    2535void InputDeviceInternal::AddKey(const char* name)
  • trunk/src/input/input.h

    r2841 r2918  
    2020{
    2121public:
    22     /** Get the name of this input device */
     22    /** Gets the name of this input device */
    2323    const String& GetName();
    2424
    25     /** Get the index of the corresponding key, needed to call GetKey */
     25    /** Gets the index of the corresponding key, needed to call GetKey */
    2626    int GetKeyIndex(const char* name) const { return GetItemIndex(name, m_keynames); }
    27     /** Get the index of the corresponding axis, needed to call GetAxis */
     27    /** Gets the index of the corresponding axis, needed to call GetAxis */
    2828    int GetAxisIndex(const char* name) const { return GetItemIndex(name, m_axisnames); }
    29     /** Get the index of the corresponding cursor, needed to call GetCursor */
     29    /** Gets the index of the corresponding cursor, needed to call GetCursor */
    3030    int GetCursorIndex(const char* name) const { return GetItemIndex(name, m_cursornames); }
    3131
    32     /** Get the current state of the given key, true being pressed and false being released */
     32    /** Gets the current state of the given key, true being pressed and false being released */
    3333    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 */
     34    /** Gets 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 */
    3535    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 */
     36    /** Gets the current value of the given cursor, 0,0 being the bottom-left corner and 1,1 being the top-right corner */
    3737    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. */
     38    /** Gets the coordinate of the pixel the cursor is currently over, 0,0 being the bottom-left corner. */
    3939    ivec2 GetCursorPixel(int index) const { return m_cursors[index].m2; }
    4040
    4141
    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 */
     42    /** Sets a per-device-axis sensitivity factor. The value returned by the operating system will be multiplied by this value before being returned by GetAxis */
    4343    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 */
     44    /** Gets the per-device-axis sensitivity factor. The value returned by the operating system will be multiplied by this value before being returned by GetAxis */
    4545    float GetAxisSensitivity(int index) const { return m_axis[index].m2; }
    4646
    47     /** Get a list of the name of all available keys in this device */
     47    /** Gets a list of the name of all available keys in this device */
    4848    const Array<String>& GetAllKeys() const { return m_keynames; }
    49     /** Get a list of the name of all available axis in this device */
     49    /** Gets a list of the name of all available axis in this device */
    5050    const Array<String>& GetAllAxis() const { return m_axisnames; }
    51     /** Get a list of the name of all available cursors in this device */
     51    /** Gets a list of the name of all available cursors in this device */
    5252    const Array<String>& GetAllCursors() const { return m_cursornames; }
    5353
    54     /** Get an input device by its name */
     54    /** Gets a list of the name of all available input devices */
     55    static Array<String> GetAvailableDevices();
     56    /** Gets an input device by its name */
    5557    static InputDevice* Get(const char* name) { return GetDevice(name); }
    56     /** Set whether the mouse cursor should be captured. */
     58    /** Sets whether the mouse cursor should be captured. */
    5759    static void CaptureMouse(bool activated) { m_capturemouse = activated; }
    5860
Note: See TracChangeset for help on using the changeset viewer.