Use GamepadAxis enum for getGamepadAxisMovement instead of c_int (#187)

* Updated getGamepadAxisMovement to take enum and cast return to f32

* Updated raylib-ext.zig GetGamepadAxisMovement to take enum

* modified generate_functions.py to make changes instead
This commit is contained in:
James Davis 2025-01-10 13:18:45 -05:00 committed by GitHub
parent 561481f4ae
commit 30ce68004f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 3 deletions

View File

@ -173,6 +173,7 @@ _fix_enums_data = [
("flag", "ConfigFlags", r"IsWindowState"), ("flag", "ConfigFlags", r"IsWindowState"),
("flags", "Gesture", r"SetGesturesEnabled"), ("flags", "Gesture", r"SetGesturesEnabled"),
("button", "GamepadButton", r".*GamepadButton.*"), ("button", "GamepadButton", r".*GamepadButton.*"),
("axis", "GamepadAxis", r".*GamepadAxis.*"),
("button", "MouseButton", r".*MouseButton.*"), ("button", "MouseButton", r".*MouseButton.*"),
("control", "GuiControl", r"Gui.etStyle"), ("control", "GuiControl", r"Gui.etStyle"),
# ("property", "GuiControlProperty", r"Gui.etStyle"), # ("property", "GuiControlProperty", r"Gui.etStyle"),

View File

@ -177,7 +177,7 @@ pub extern "c" fn IsGamepadButtonReleased(gamepad: c_int, button: rl.GamepadButt
pub extern "c" fn IsGamepadButtonUp(gamepad: c_int, button: rl.GamepadButton) bool; pub extern "c" fn IsGamepadButtonUp(gamepad: c_int, button: rl.GamepadButton) bool;
pub extern "c" fn GetGamepadButtonPressed() rl.GamepadButton; pub extern "c" fn GetGamepadButtonPressed() rl.GamepadButton;
pub extern "c" fn GetGamepadAxisCount(gamepad: c_int) c_int; pub extern "c" fn GetGamepadAxisCount(gamepad: c_int) c_int;
pub extern "c" fn GetGamepadAxisMovement(gamepad: c_int, axis: c_int) f32; pub extern "c" fn GetGamepadAxisMovement(gamepad: c_int, axis: rl.GamepadAxis) f32;
pub extern "c" fn SetGamepadMappings(mappings: [*c]const u8) c_int; pub extern "c" fn SetGamepadMappings(mappings: [*c]const u8) c_int;
pub extern "c" fn SetGamepadVibration(gamepad: c_int, leftMotor: f32, rightMotor: f32, duration: f32) void; pub extern "c" fn SetGamepadVibration(gamepad: c_int, leftMotor: f32, rightMotor: f32, duration: f32) void;
pub extern "c" fn IsMouseButtonPressed(button: rl.MouseButton) bool; pub extern "c" fn IsMouseButtonPressed(button: rl.MouseButton) bool;

View File

@ -3169,8 +3169,8 @@ pub fn getGamepadAxisCount(gamepad: i32) i32 {
} }
/// Get axis movement value for a gamepad axis /// Get axis movement value for a gamepad axis
pub fn getGamepadAxisMovement(gamepad: i32, axis: i32) f32 { pub fn getGamepadAxisMovement(gamepad: i32, axis: GamepadAxis) f32 {
return cdef.GetGamepadAxisMovement(@as(c_int, gamepad), @as(c_int, axis)); return cdef.GetGamepadAxisMovement(@as(c_int, gamepad), axis);
} }
/// Set internal gamepad mappings (SDL_GameControllerDB) /// Set internal gamepad mappings (SDL_GameControllerDB)