From 9607eb0de784fab1a99833f567c0eaca72b67e4a Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 10 Dec 2021 09:42:10 +0100 Subject: all: rig up Hare-native error handling --- sdl2/gamecontroller.ha | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'sdl2/gamecontroller.ha') diff --git a/sdl2/gamecontroller.ha b/sdl2/gamecontroller.ha index 3b752e1..cf78674 100644 --- a/sdl2/gamecontroller.ha +++ b/sdl2/gamecontroller.ha @@ -27,16 +27,20 @@ export type controller_axis = enum u8 { // 'joystick_index' is the same as the 'device_index' passed to // [[joystick_open]]. // -// Returns SDL_TRUE if the given joystick is supported by the game controller -// interface, SDL_FALSE if it isn't or it's an invalid index. +// Returns true if the given joystick is supported by the game controller +// interface, false if it isn't or it's an invalid index. export @symbol("SDL_IsGameController") fn is_game_controller( joystick_index: int) bool; +@symbol("SDL_GameControllerOpen") fn _game_controller_open( + joystick_index: int) nullable *gamecontroller; + // Get the SDL_GameController associated with an instance id. -// -// Returns a [[controller]] on success or NULL on failure. -export @symbol("SDL_GameControllerOpen") fn game_controller_open( - joystick_index: int) *gamecontroller; +export fn game_controller_open( + joystick_index: int, +) (*gamecontroller | error) = { + return wrapptr(_game_controller_open(joystick_index))?: *gamecontroller; +}; // Close a game controller previously opened with [[game_controller_open]]. export @symbol("SDL_GameControllerClose") fn game_controller_close( -- cgit v1.2.3