sdl3.c3l/sdl3_mouse.c3i

73 lines
3.3 KiB
Plaintext

module sdl3::sdl;
typedef MouseID = uint;
typedef Cursor = void;
enum SystemCursor : inline CInt {
SYSTEM_CURSOR_DEFAULT,
SYSTEM_CURSOR_TEXT,
SYSTEM_CURSOR_WAIT,
SYSTEM_CURSOR_CROSSHAIR,
SYSTEM_CURSOR_PROGRESS,
SYSTEM_CURSOR_NWSE_RESIZE,
SYSTEM_CURSOR_NESW_RESIZE,
SYSTEM_CURSOR_EW_RESIZE,
SYSTEM_CURSOR_NS_RESIZE,
SYSTEM_CURSOR_MOVE,
SYSTEM_CURSOR_NOT_ALLOWED,
SYSTEM_CURSOR_POINTER,
SYSTEM_CURSOR_NW_RESIZE,
SYSTEM_CURSOR_N_RESIZE,
SYSTEM_CURSOR_NE_RESIZE,
SYSTEM_CURSOR_E_RESIZE,
SYSTEM_CURSOR_SE_RESIZE,
SYSTEM_CURSOR_S_RESIZE,
SYSTEM_CURSOR_SW_RESIZE,
SYSTEM_CURSOR_W_RESIZE,
SYSTEM_CURSOR_COUNT
}
enum MouseWheelDirection : inline CInt {
SDL_MOUSEWHEEL_NORMAL,
SDL_MOUSEWHEEL_FLIPPED
}
typedef MouseButtonFlags = uint;
const MouseButtonFlags BUTTON_LEFT @builtin = 1;
const MouseButtonFlags BUTTON_MIDDLE @builtin = 2;
const MouseButtonFlags BUTTON_RIGHT @builtin = 3;
const MouseButtonFlags BUTTON_X1 @builtin = 4;
const MouseButtonFlags BUTTON_X2 @builtin = 5;
macro MouseButtonFlags @button_mask(MouseButtonFlags $x) => (1 << (($x)-1));
const MouseButtonFlags BUTTON_LMASK @builtin = @button_mask(BUTTON_LEFT);
const MouseButtonFlags BUTTON_MMASK @builtin = @button_mask(BUTTON_MIDDLE);
const MouseButtonFlags BUTTON_RMASK @builtin = @button_mask(BUTTON_RIGHT);
const MouseButtonFlags BUTTON_X1MASK @builtin = @button_mask(BUTTON_X1);
const MouseButtonFlags BUTTON_X2MASK @builtin = @button_mask(BUTTON_X2);
extern fn bool has_mouse() @extern("SDL_HasMouse");
extern fn MouseID* get_mice(int *count) @extern("SDL_GetMice");
extern fn ZString get_mouse_name_for_id(MouseID instance_id) @extern("SDL_GetMouseNameForID");
extern fn Window* get_mouse_focus() @extern("SDL_GetMouseFocus");
extern fn MouseButtonFlags get_mouse_state(float *x, float *y) @extern("SDL_GetMouseState");
extern fn MouseButtonFlags get_global_mouse_state(float *x, float *y) @extern("SDL_GetGlobalMouseState");
extern fn MouseButtonFlags get_relative_mouse_state(float *x, float *y) @extern("SDL_GetRelativeMouseState");
extern fn void warp_mouse_in_window(Window* window, float x, float y) @extern("SDL_WarpMouseInWindow");
extern fn bool warp_mouse_global(float x, float y) @extern("SDL_WarpMouseGlobal");
extern fn bool set_window_relative_mouse_mode(Window* window, bool enabled) @extern("SDL_SetWindowRelativeMouseMode");
extern fn bool get_window_relative_mouse_mode(Window* window) @extern("SDL_GetWindowRelativeMouseMode");
extern fn bool capture_mouse(bool enabled) @extern("SDL_CaptureMouse");
extern fn Cursor* create_cursor(char *data, char *mask, int w, int h, int hot_x, int hot_y) @extern("SDL_CreateCursor");
extern fn Cursor* create_color_cursor(Surface *surface, int hot_x, int hot_y) @extern("SDL_CreateColorCursor");
extern fn Cursor* create_system_cursor(SystemCursor id) @extern("SDL_CreateSystemCursor");
extern fn bool set_cursor(Cursor* cursor) @extern("SDL_SetCursor");
extern fn Cursor* get_cursor() @extern("SDL_GetCursor");
extern fn Cursor* get_default_cursor() @extern("SDL_GetDefaultCursor");
extern fn void destroy_cursor(Cursor* cursor) @extern("SDL_DestroyCursor");
extern fn bool show_cursor() @extern("SDL_ShowCursor");
extern fn bool hide_cursor() @extern("SDL_HideCursor");
extern fn bool cursor_visible() @extern("SDL_CursorVisible");