From 30ce68004fa21036b37f85a592005f40dbb25322 Mon Sep 17 00:00:00 2001 From: James Davis Date: Fri, 10 Jan 2025 13:18:45 -0500 Subject: [PATCH] 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 --- lib/generate_functions.py | 1 + lib/raylib-ext.zig | 2 +- lib/raylib.zig | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/generate_functions.py b/lib/generate_functions.py index c4d0c4f..65683f9 100755 --- a/lib/generate_functions.py +++ b/lib/generate_functions.py @@ -173,6 +173,7 @@ _fix_enums_data = [ ("flag", "ConfigFlags", r"IsWindowState"), ("flags", "Gesture", r"SetGesturesEnabled"), ("button", "GamepadButton", r".*GamepadButton.*"), + ("axis", "GamepadAxis", r".*GamepadAxis.*"), ("button", "MouseButton", r".*MouseButton.*"), ("control", "GuiControl", r"Gui.etStyle"), # ("property", "GuiControlProperty", r"Gui.etStyle"), diff --git a/lib/raylib-ext.zig b/lib/raylib-ext.zig index 26e4f8f..a3944a0 100644 --- a/lib/raylib-ext.zig +++ b/lib/raylib-ext.zig @@ -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 GetGamepadButtonPressed() rl.GamepadButton; 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 SetGamepadVibration(gamepad: c_int, leftMotor: f32, rightMotor: f32, duration: f32) void; pub extern "c" fn IsMouseButtonPressed(button: rl.MouseButton) bool; diff --git a/lib/raylib.zig b/lib/raylib.zig index a539d48..8a9383b 100644 --- a/lib/raylib.zig +++ b/lib/raylib.zig @@ -3169,8 +3169,8 @@ pub fn getGamepadAxisCount(gamepad: i32) i32 { } /// Get axis movement value for a gamepad axis -pub fn getGamepadAxisMovement(gamepad: i32, axis: i32) f32 { - return cdef.GetGamepadAxisMovement(@as(c_int, gamepad), @as(c_int, axis)); +pub fn getGamepadAxisMovement(gamepad: i32, axis: GamepadAxis) f32 { + return cdef.GetGamepadAxisMovement(@as(c_int, gamepad), axis); } /// Set internal gamepad mappings (SDL_GameControllerDB)