Function glfwGetJoystickHats

  • This function returns the state of all hats of the specified joystick. Each element in the array is one of the following values:

    Name Value
    GLFW_HAT_CENTERED 0
    GLFW_HAT_UP 1
    GLFW_HAT_RIGHT 2
    GLFW_HAT_DOWN 4
    GLFW_HAT_LEFT 8
    GLFW_HAT_RIGHT_UP GLFW_HAT_RIGHT | GLFW_HAT_UP
    GLFW_HAT_RIGHT_DOWN GLFW_HAT_RIGHT | GLFW_HAT_DOWN
    GLFW_HAT_LEFT_UP GLFW_HAT_LEFT | GLFW_HAT_UP
    GLFW_HAT_LEFT_DOWN GLFW_HAT_LEFT | GLFW_HAT_DOWN

    The diagonal directions are bitwise combinations of the primary (up, right, down and left) directions and you can test for these individually by ANDing it with the corresponding direction.

    if (hats[2] && GLFW_HAT_RIGHT)
    {
    // State of hat 2 could be right-up, right or right-down
    }

    If the specified joystick is not present this function will return NULL but will not generate an error. This can be used instead of first calling glfwJoystickPresent.

    Parameters

    • jid: number

      The joystick to query.

    • count: number

      Where to store the number of hat states in the returned array. This is set to zero if the joystick is not present or an error occurred.

    Returns string

    An array of hat states, or NULL if the joystick is not present or an error occurred.

Generated using TypeDoc