glfw: add glfw.updateGamepadMappings
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
b5f2f64bd9
commit
71036baa25
1 changed files with 32 additions and 29 deletions
|
@ -386,35 +386,33 @@ const GamepadState = extern struct {
|
||||||
// /// @ingroup input
|
// /// @ingroup input
|
||||||
// GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
|
// GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
|
||||||
|
|
||||||
// TODO(joystick)
|
/// Adds the specified SDL_GameControllerDB gamepad mappings.
|
||||||
// /// Adds the specified SDL_GameControllerDB gamepad mappings.
|
///
|
||||||
// ///
|
/// This function parses the specified ASCII encoded string and updates the internal list with any
|
||||||
// /// This function parses the specified ASCII encoded string and updates the
|
/// gamepad mappings it finds. This string may contain either a single gamepad mapping or many
|
||||||
// /// internal list with any gamepad mappings it finds. This string may
|
/// mappings separated by newlines. The parser supports the full format of the `gamecontrollerdb.txt`
|
||||||
// /// contain either a single gamepad mapping or many mappings separated by
|
/// source file including empty lines and comments.
|
||||||
// /// newlines. The parser supports the full format of the `gamecontrollerdb.txt`
|
///
|
||||||
// /// source file including empty lines and comments.
|
/// See gamepad_mapping for a description of the format.
|
||||||
// ///
|
///
|
||||||
// /// See @ref gamepad_mapping for a description of the format.
|
/// If there is already a gamepad mapping for a given GUID in the internal list, it will be
|
||||||
// ///
|
/// replaced by the one passed to this function. If the library is terminated and re-initialized
|
||||||
// /// If there is already a gamepad mapping for a given GUID in the internal list,
|
/// the internal list will revert to the built-in default.
|
||||||
// /// it will be replaced by the one passed to this function. If the library is
|
///
|
||||||
// /// terminated and re-initialized the internal list will revert to the built-in
|
/// @param[in] string The string containing the gamepad mappings.
|
||||||
// /// default.
|
///
|
||||||
// ///
|
/// Possible errors include glfw.Error.NotInitialized and glfw.Error.InvalidValue.
|
||||||
// /// @param[in] string The string containing the gamepad mappings.
|
///
|
||||||
// /// @return `true` if successful, or `false` if an
|
/// @thread_safety This function must only be called from the main thread.
|
||||||
// /// error occurred.
|
///
|
||||||
// ///
|
/// see also: gamepad, glfw.Joystick.isGamepad, glfwGetGamepadName
|
||||||
// /// Possible errors include glfw.Error.NotInitialized and glfw.Error.InvalidValue.
|
///
|
||||||
// ///
|
///
|
||||||
// /// @thread_safety This function must only be called from the main thread.
|
/// @ingroup input
|
||||||
// ///
|
pub inline fn updateGamepadMappings(gamepad_mappings: [*c]const u8) Error!void {
|
||||||
// /// see also: gamepad, glfw.Joystick.isGamepad, glfwGetGamepadName
|
_ = c.glfwUpdateGamepadMappings(gamepad_mappings);
|
||||||
// ///
|
try getError();
|
||||||
// ///
|
}
|
||||||
// /// @ingroup input
|
|
||||||
// GLFWAPI int glfwUpdateGamepadMappings(const char* string);
|
|
||||||
|
|
||||||
/// Returns the human-readable gamepad name for the specified joystick.
|
/// Returns the human-readable gamepad name for the specified joystick.
|
||||||
///
|
///
|
||||||
|
@ -472,6 +470,11 @@ pub inline fn getGamepadState(self: Joystick) Error!?GamepadState {
|
||||||
return if (success == c.GLFW_TRUE) state else null;
|
return if (success == c.GLFW_TRUE) state else null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "updateGamepadMappings_syntax" {
|
||||||
|
// We don't have a gamepad mapping to test with, just confirm the syntax is good.
|
||||||
|
_ = updateGamepadMappings;
|
||||||
|
}
|
||||||
|
|
||||||
test "getGamepadName" {
|
test "getGamepadName" {
|
||||||
const glfw = @import("main.zig");
|
const glfw = @import("main.zig");
|
||||||
try glfw.init();
|
try glfw.init();
|
||||||
|
|
Loading…
Add table
Reference in a new issue