diff --git a/ffi/glfw-input.c b/ffi/glfw-input.c index 9e6a7fa..60852d7 100644 --- a/ffi/glfw-input.c +++ b/ffi/glfw-input.c @@ -66,3 +66,27 @@ float getLeftJoystickYAxisState() { return 99.0; } } + +int isCrossButtonPressed() { + return state.buttons[GLFW_GAMEPAD_BUTTON_CROSS]; +} + +int isCircleButtonPressed() { + return state.buttons[GLFW_GAMEPAD_BUTTON_CIRCLE]; +} + +int isSquareButtonPressed() { + return state.buttons[GLFW_GAMEPAD_BUTTON_SQUARE]; +} + +int isTriangleButtonPressed() { + return state.buttons[GLFW_GAMEPAD_BUTTON_TRIANGLE]; +} + +int isR1ButtonPressed() { + return state.buttons[GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER]; +} + +int isL1ButtonPressed() { + return state.buttons[GLFW_GAMEPAD_BUTTON_LEFT_BUMPER]; +} diff --git a/ffi/glfw-input.sml b/ffi/glfw-input.sml index b34144e..27320c0 100644 --- a/ffi/glfw-input.sml +++ b/ffi/glfw-input.sml @@ -53,6 +53,7 @@ struct _symbol "KEY_ARROW_DOWN" public : ( unit -> int ) * ( int -> unit ); val KEY_ARROW_DOWN = KEY_ARROW_DOWN () + (* gamepad bindings below *) val getGamepadState = _import "getGamepadState" public : int -> unit; @@ -60,4 +61,17 @@ struct _import "getLeftJoystickXAxisState" public : unit -> Real32.real; val getLeftJoystickYAxisState = _import "getLeftJoystickYAxisState" public : unit -> Real32.real; + + val isCrossButtonPressed = + _import "isCrossButtonPressed" public : unit -> int; + val isCircleButtonPressed = + _import "isCircleButtonPressed" public : unit -> int; + val isSquareButtonPressed = + _import "isSquareButtonPressed" public : unit -> int; + val isTriangleButtonPressed = + _import "isTriangleButtonPressed" public : unit -> int; + val isR1ButtonPressed = + _import "isR1ButtonPressed" public : unit -> int; + val isL1ButtonPressed = + _import "isL1ButtonPressed" public : unit -> int; end