pub const c = @import("c.zig").c;
pub const events = @import("events.zig");

pub const InitOptions = packed struct(c_int) {
    pad0: u4 = 0, // 0 - 3
    audio: bool = false, // 4
    video: bool = false, // 5
    pad1: u2 = 0, // 6-7
    pad2: u1 = 0, // 8
    joystick: bool = false, // 9
    pad3: u2 = 0, // 10-11
    haptic: bool = false, // 12
    gamepad: bool = false,
    events: bool = false,
    sensor: bool = false,
    camera: bool = false,
    pad4: u3 = 0,
    pad5: u12 = 0,
};

pub const AppResult = enum {
    app_continue,
    app_success,
    app_failure,
};

pub const Window = c.SDL_Window;
pub const Event = c.SDL_Event;
pub const Rect = c.SDL_Rect;

pub fn init(options: InitOptions) !void {
    if (!c.SDL_Init(@bitCast(options))) {
        return error.InitFailed;
    }
}

pub const EventType = events;

var gLastEvent: Event = undefined;
pub fn pollEvent() ?*Event {
    if (c.SDL_PollEvent(&gLastEvent)) {
        return &gLastEvent;
    }
    return null;
}

pub const gpu = @import("gpu.zig");
pub const Scancode = @import("scancode.zig").Scancode;
