155 lines
7.4 KiB
Zig
155 lines
7.4 KiB
Zig
// C
|
|
pub extern fn aligned_malloc(len: usize, alignment: usize) ?*anyopaque;
|
|
pub extern fn aligned_free(ptr: *anyopaque) void;
|
|
pub extern fn malloc(size: usize) ?*anyopaque;
|
|
pub extern fn memset(dest: *anyopaque, c: i32, count: usize) *anyopaque;
|
|
pub extern fn free(memblock: *anyopaque) void;
|
|
pub extern fn snprintf(buffer: [*:0]u8, count: usize, format: [*:0]const u8, ...) i32;
|
|
|
|
// Canvas
|
|
pub extern fn canvas_clear(canvas: *anyopaque) void;
|
|
pub extern fn canvas_draw_str(canvas: *anyopaque, x: u8, y: u8, str: [*:0]const u8) void;
|
|
pub extern fn canvas_set_font(canvas: *anyopaque, font: Font) void;
|
|
|
|
// Furi
|
|
pub const FuriMutexType = enum(u8) {
|
|
FuriMutexTypeNormal,
|
|
FuriMutexTypeRecursive,
|
|
};
|
|
pub const FuriWait = enum(u32) {
|
|
FuriWaitForever = 0xFFFFFFFF,
|
|
};
|
|
pub const FuriStatus = enum(i32) { FuriStatusOk = 0, FuriStatusError = -1, FuriStatusErrorTimeout = -2, FuriStatusErrorResource = -3, FuriStatusErrorParameter = -4, FuriStatusErrorNoMemory = -5, FuriStatusErrorISR = -6, FuriStatusReserved = 0x7FFFFFFF };
|
|
|
|
pub extern fn furi_delay_us(microseconds: u32) void;
|
|
pub extern fn furi_message_queue_alloc(msg_count: u32, msg_size: u32) *anyopaque;
|
|
pub extern fn furi_message_queue_free(instance: *anyopaque) void;
|
|
pub extern fn furi_message_queue_get(instance: *anyopaque, msg_ptr: *anyopaque, timeout: u32) FuriStatus;
|
|
pub extern fn furi_message_queue_put(instance: *anyopaque, msg_ptr: *const anyopaque, timeout: u32) FuriStatus;
|
|
pub extern fn furi_mutex_alloc(type: FuriMutexType) *anyopaque;
|
|
pub extern fn furi_mutex_free(instance: *anyopaque) void;
|
|
pub extern fn furi_record_close(name: [*:0]const u8) void;
|
|
pub extern fn furi_record_open(name: [*:0]const u8) *anyopaque;
|
|
|
|
// GUI
|
|
pub const RECORD_GUI = "gui";
|
|
pub const Font = enum(u8) {
|
|
FontPrimary,
|
|
FontSecondary,
|
|
FontKeyboard,
|
|
FontBigNumbers,
|
|
FontTotalNumber,
|
|
};
|
|
pub const GuiLayer = enum(u8) {
|
|
GuiLayerDesktop,
|
|
GuiLayerWindow,
|
|
GuiLayerStatusBarTop, // Custom on RogueMaster
|
|
GuiLayerStatusBarLeft,
|
|
GuiLayerStatusBarLeftSlim, // Custom on RogueMaster
|
|
GuiLayerStatusBarRight,
|
|
GuiLayerStatusBarRightSlim, // Custom on RogueMaster
|
|
GuiLayerFullscreen,
|
|
GuiLayerMAX,
|
|
};
|
|
|
|
pub extern fn gui_add_view_port(gui: *anyopaque, view_port: *anyopaque, layer: GuiLayer) void;
|
|
pub extern fn gui_remove_view_port(gui: *anyopaque, view_port: *anyopaque) void;
|
|
|
|
// Input
|
|
pub const InputEvent = extern struct {
|
|
sequence: u32 align(4),
|
|
key: InputKey align(1),
|
|
type: InputType align(1),
|
|
};
|
|
pub const InputKey = enum(u8) {
|
|
InputKeyUp,
|
|
InputKeyDown,
|
|
InputKeyRight,
|
|
InputKeyLeft,
|
|
InputKeyOk,
|
|
InputKeyBack,
|
|
InputKeyMAX,
|
|
};
|
|
pub const InputType = enum(u8) {
|
|
InputTypePress,
|
|
InputTypeRelease,
|
|
InputTypeShort,
|
|
InputTypeLong,
|
|
InputTypeRepeat,
|
|
InputTypeMAX,
|
|
};
|
|
|
|
pub extern fn input_get_key_name(key: InputKey) [*:0]const u8;
|
|
pub extern fn input_get_type_name(type: InputType) [*:0]const u8;
|
|
|
|
// SceneManager
|
|
pub extern fn scene_manager_alloc() *anyopaque;
|
|
pub extern fn scene_manager_free(scene_manager: *anyopaque) void;
|
|
pub extern fn scene_manager_get_scene_state(scene_manager: *anyopaque, scene_id: u32) u32;
|
|
pub extern fn scene_manager_handle_back_event(scene_manager: *anyopaque) bool;
|
|
pub extern fn scene_manager_handle_custom_event(scene_manager: *anyopaque, custom_event: u32) bool;
|
|
pub extern fn scene_manager_handle_tick_event(scene_manager: *anyopaque) void;
|
|
pub extern fn scene_manager_has_previous_scene(scene_manager: *const anyopaque, scene_id: u32) bool;
|
|
pub extern fn scene_manager_next_scene(scene_manager: *anyopaque, next_scene_id: u32) bool;
|
|
pub extern fn scene_manager_previous_scene(scene_manager: *anyopaque) bool;
|
|
pub extern fn scene_manager_search_and_switch_to_another_scene(scene_manager: *anyopaque, scene_id: u32) bool;
|
|
pub extern fn scene_manager_search_and_switch_to_previous_scene(scene_manager: *anyopaque, scene_id: u32) bool;
|
|
pub extern fn scene_manager_search_and_switch_to_previous_scene_one_of(scene_manager: *anyopaque, scene_ids: *const u32, scene_ids_size: usize) bool;
|
|
pub extern fn scene_manager_set_scene_state(scene_manager: *anyopaque, scene_id: u32, state: u32) void;
|
|
pub extern fn scene_manager_stop(scene_manager: *anyopaque) void;
|
|
|
|
// Storage
|
|
pub const RECORD_STORAGE = "storage";
|
|
|
|
// View
|
|
pub const ViewModelType = enum(u8) {
|
|
ViewModelTypeNone,
|
|
ViewModelTypeLockFree,
|
|
ViewModelTypeLocking,
|
|
};
|
|
|
|
pub extern fn view_alloc() *anyopaque;
|
|
pub extern fn view_allocate_model(view: *anyopaque, type: ViewModelType, size: usize) void;
|
|
pub extern fn view_commit_model(view: *anyopaque, update: bool) void;
|
|
pub extern fn view_free(view: *anyopaque) void;
|
|
pub extern fn view_free_model(view: *anyopaque) void;
|
|
pub extern fn view_get_model(view: *anyopaque) *anyopaque;
|
|
|
|
// Viewdispatcher
|
|
pub const ViewDispatcherType = enum(u8) {
|
|
ViewDispatcherTypeDesktop,
|
|
ViewDispatcherTypeWindow,
|
|
ViewDispatcherTypeFullscreen,
|
|
};
|
|
|
|
pub extern fn view_dispatcher_add_view(view_dispatcher: *anyopaque, view_id: u32, view: *anyopaque) void;
|
|
pub extern fn view_dispatcher_alloc() *anyopaque;
|
|
pub extern fn view_dispatcher_attach_to_gui(view_dispatcher: *anyopaque, gui: *anyopaque, type: ViewDispatcherType) void;
|
|
pub extern fn view_dispatcher_enable_queue(view_dispatcher: *anyopaque) void;
|
|
pub extern fn view_dispatcher_free(view_dispatcher: *anyopaque) void;
|
|
pub extern fn view_dispatcher_get_event_loop(view_dispatcher: *anyopaque) *anyopaque;
|
|
pub extern fn view_dispatcher_remove_view(view_dispatcher: *anyopaque, view_id: u32) void;
|
|
pub extern fn view_dispatcher_run(view_dispatcher: *anyopaque) void;
|
|
pub extern fn view_dispatcher_send_custom_event(view_dispatcher: *anyopaque, event: u32) void;
|
|
pub extern fn view_dispatcher_send_to_back(view_dispatcher: *anyopaque) void;
|
|
pub extern fn view_dispatcher_send_to_front(view_dispatcher: *anyopaque) void;
|
|
pub const ViewDispatcherCustomEventCallback = *const fn (?*anyopaque, event: u32) callconv(.C) void;
|
|
pub extern fn view_dispatcher_set_custom_event_callback(view_dispatcher: *anyopaque, callback: ViewDispatcherCustomEventCallback) void;
|
|
pub extern fn view_dispatcher_set_event_callback_context(view_dispatcher: *anyopaque, context: ?*anyopaque) void;
|
|
pub const ViewDispatcherNavigationEventCallback = *const fn (?*anyopaque) callconv(.C) void;
|
|
pub extern fn view_dispatcher_set_navigation_event_callback(view_dispatcher: *anyopaque, callback: ViewDispatcherNavigationEventCallback) void;
|
|
pub const ViewDispatcherTickEventCallback = *const fn (*anyopaque) callconv(.C) void;
|
|
pub extern fn view_dispatcher_set_tick_event_callback(view_dispatcher: *anyopaque, callback: ViewDispatcherTickEventCallback, tick_period: u32) void;
|
|
pub extern fn view_dispatcher_stop(view_dispatcher: *anyopaque) void;
|
|
pub extern fn view_dispatcher_switch_to_view(view_dispatcher: *anyopaque, view_id: u32) void;
|
|
|
|
// Viewport
|
|
pub extern fn view_port_alloc() *anyopaque;
|
|
pub const ViewPortDrawCallback = *const fn (*anyopaque, ?*anyopaque) callconv(.C) void;
|
|
pub extern fn view_port_draw_callback_set(view_port: *anyopaque, draw_callback: ViewPortDrawCallback, context: ?*anyopaque) void;
|
|
pub extern fn view_port_enabled_set(view_port: *anyopaque, enabled: bool) void;
|
|
pub extern fn view_port_free(view_port: *anyopaque) void;
|
|
pub const ViewPortInputCallback = *const fn (*InputEvent, ?*anyopaque) callconv(.C) void;
|
|
pub extern fn view_port_input_callback_set(view_port: *anyopaque, input_callback: ViewPortInputCallback, context: ?*anyopaque) void;
|
|
pub extern fn view_port_update(view_port: *anyopaque) void;
|