Function in ldk_os.h

ldk_os_initialize

Initialize the OS.

LDK_API bool ldk_os_initialize(void);

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_terminate

Shut down the OS.

LDK_API void ldk_os_terminate(void);
Function in ldk_os.h

ldk_os_stack_trace_print

Print the current stack trace for diagnostics.

LDK_API void ldk_os_stack_trace_print(void);
Function in ldk_os.h

ldk_os_memory_alloc

Allocate memory using the OS abstraction.

LDK_API void * ldk_os_memory_alloc(size_t size);

Parameters

size_t size
Size of the data or region, in bytes where applicable.

Returns

Pointer to the requested object or data; NULL when unavailable.

Function in ldk_os.h

ldk_os_memory_free

Release an OS-allocated memory block.

LDK_API void ldk_os_memory_free(void *memory);

Parameters

void *memory
Memory used by this operation.
Function in ldk_os.h

ldk_os_memory_resize

Resize an OS-allocated block of memory.

LDK_API void * ldk_os_memory_resize(
 void *memory,
 size_t size
);

Parameters

void *memory
Memory used by this operation.
size_t size
Size of the data or region, in bytes where applicable.

Returns

Pointer to the requested object or data; NULL when unavailable.

Function in ldk_os.h

ldk_os_time_ticks_get

Read the high-resolution time counter.

LDK_API u64 ldk_os_time_ticks_get(void);

Returns

The resulting numeric value.

Function in ldk_os.h

ldk_os_time_ticks_interval_get_seconds

Calculate elapsed time between two counter ticks in seconds.

LDK_API double ldk_os_time_ticks_interval_get_seconds(
 u64 start,
 u64 end
);

Parameters

u64 start
Starting timestamp or location for this operation.
u64 end
Ending timestamp or location for this operation.

Returns

Elapsed time in seconds.

Function in ldk_os.h

ldk_os_time_ticks_interval_get_milliseconds

Calculate elapsed time between two counter ticks in milliseconds.

LDK_API double ldk_os_time_ticks_interval_get_milliseconds(
 u64 start,
 u64 end
);

Parameters

u64 start
Starting timestamp or location for this operation.
u64 end
Ending timestamp or location for this operation.

Returns

Elapsed time in milliseconds.

Function in ldk_os.h

ldk_os_time_ticks_interval_get_nanoseconds

Calculate elapsed time between two counter ticks in nanoseconds.

LDK_API double ldk_os_time_ticks_interval_get_nanoseconds(
 u64 start,
 u64 end
);

Parameters

u64 start
Starting timestamp or location for this operation.
u64 end
Ending timestamp or location for this operation.

Returns

Elapsed time in nanoseconds.

Enum in ldk_os.h

LDKWindowFlags

typedef enum{
  LDK_WINDOW_FLAG_NORMAL=1<<1,
  LDK_WINDOW_FLAG_MAXIMIZED=1<<2,
  LDK_WINDOW_FLAG_MINIMIZED=1<<3,
  LDK_WINDOW_FLAG_NORESIZE=1<<4,
  LDK_WINDOW_FLAG_HIDDEN=1<<5,
  LDK_WINDOW_FLAG_CENTERED=1<<6,
  LDK_WINDOW_FLAG_NOTITLEBAR=1<<7,
}LDKWindowFlags;
Function in ldk_os.h

ldk_os_events_pump

Process pending operating-system events.

LDK_API void ldk_os_events_pump(void);
Function in ldk_os.h

ldk_os_event_next

Dequeue the next pending operating-system event.

LDK_API bool ldk_os_event_next(LDKEvent *event);

Parameters

LDKEvent *event
Event to inspect or receive.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_events_poll

Poll for the next platform event.

LDK_API bool ldk_os_events_poll(LDKEvent *event);

Parameters

LDKEvent *event
Event to inspect or receive.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_window_create_with_flags

Create a platform window with explicit window flags.

LDK_API LDKWindow ldk_os_window_create_with_flags(
 const char *title,
 i32 width,
 i32 height,
 LDKWindowFlags flags
);

Parameters

const char *title
Title shown by the window or dialog.
i32 width
Width in pixels or the units expected by the API.
i32 height
Height in pixels or the units expected by the API.
LDKWindowFlags flags
Bitmask of options controlling this operation.

Returns

Handle to the requested object or resource.

Function in ldk_os.h

ldk_os_window_create

Create the OS window.

LDK_API LDKWindow ldk_os_window_create(
 const char *title,
 i32 width,
 i32 height
);

Parameters

const char *title
Title shown by the window or dialog.
i32 width
Width in pixels or the units expected by the API.
i32 height
Height in pixels or the units expected by the API.

Returns

Handle to the requested object or resource.

Function in ldk_os.h

ldk_os_window_should_close

Check whether a native window has requested to close.

LDK_API bool ldk_os_window_should_close(LDKWindow window);

Parameters

LDKWindow window
Native window handle.

Returns

True when the queried condition holds; false otherwise.

Function in ldk_os.h

ldk_os_window_buffers_swap

Present a window by swapping its graphics buffers.

LDK_API void ldk_os_window_buffers_swap(LDKWindow window);

Parameters

LDKWindow window
Native window handle.
Function in ldk_os.h

ldk_os_window_destroy

Destroy the OS window.

LDK_API void ldk_os_window_destroy(LDKWindow window);

Parameters

LDKWindow window
Native window handle.
Function in ldk_os.h

ldk_os_window_fullscreen_get

Get the OS window fullscreen.

LDK_API bool ldk_os_window_fullscreen_get(LDKWindow window);

Parameters

LDKWindow window
Native window handle.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_window_fullscreen_set

Set the OS window fullscreen.

LDK_API bool ldk_os_window_fullscreen_set(
 LDKWindow window,
 bool fs
);

Parameters

LDKWindow window
Native window handle.
bool fs
Whether fullscreen mode should be enabled.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_window_client_area_size_get

Get the OS window client area size.

LDK_API LDKSize ldk_os_window_client_area_size_get(LDKWindow window);

Parameters

LDKWindow window
Native window handle.

Returns

The resulting size.

Function in ldk_os.h

ldk_os_window_client_area_size_set

Set the OS window client area size.

LDK_API void ldk_os_window_client_area_size_set(
 LDKWindow window,
 int width,
 int height
);

Parameters

LDKWindow window
Native window handle.
int width
Width in pixels or the units expected by the API.
int height
Height in pixels or the units expected by the API.
Function in ldk_os.h

ldk_os_window_position_get

Get the OS window position.

LDK_API LDKPoint ldk_os_window_position_get(LDKWindow window);

Parameters

LDKWindow window
Native window handle.

Returns

The resulting point.

Function in ldk_os.h

ldk_os_window_position_set

Set the OS window position.

LDK_API void ldk_os_window_position_set(
 LDKWindow window,
 i32 x,
 i32 y
);

Parameters

LDKWindow window
Native window handle.
i32 x
X coordinate or component.
i32 y
Y coordinate or component.
Function in ldk_os.h

ldk_os_window_size_set

Set the OS window size.

LDK_API void ldk_os_window_size_set(
 LDKWindow window,
 i32 width,
 i32 height
);

Parameters

LDKWindow window
Native window handle.
i32 width
Width in pixels or the units expected by the API.
i32 height
Height in pixels or the units expected by the API.
Function in ldk_os.h

ldk_os_window_size_get

Get the OS window size.

LDK_API LDKSize ldk_os_window_size_get(LDKWindow window);

Parameters

LDKWindow window
Native window handle.

Returns

The resulting size.

Function in ldk_os.h

ldk_os_window_title_set

Change the title shown by a native window.

LDK_API void ldk_os_window_title_set(
 LDKWindow window,
 const char *title
);

Parameters

LDKWindow window
Native window handle.
const char *title
Title shown by the window or dialog.
Function in ldk_os.h

ldk_os_window_title_get

Copy the current native window title into a string.

LDK_API size_t ldk_os_window_title_get(
 LDKWindow window,
 XSmallstr *outTitle
);

Parameters

LDKWindow window
Native window handle.
XSmallstr *outTitle
Receives the current window title.

Returns

The resulting numeric value.

Function in ldk_os.h

ldk_os_window_draggable_area_set

If a window was created with LDK_WINDOW_FLAG_NOTITLEBAR, this function sets the area where the mouse cursor can drag to mode the window. The default value is the whole window. If the window does not have the LDK_WINDOW_FLAG_NOTITLEBAR flag, this function does nothing.

LDK_API void ldk_os_window_draggable_area_set(
 LDKWindow window,
 LDKRect rect
);

Parameters

LDKWindow window
Native window handle.
LDKRect rect
UI or geometry rectangle.
Function in ldk_os.h

ldk_os_window_icon_set

Set the OS window icon.

LDK_API bool ldk_os_window_icon_set(
 LDKWindow window,
 const char *iconPath
);

Parameters

LDKWindow window
Native window handle.
const char *iconPath
Path of the image used as a window icon.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_window_show

Show or hide a window.

LDK_API bool ldk_os_window_show(
 LDKWindow window,
 bool show
);

Parameters

LDKWindow window
The LDK window to show or hide.
bool show
true to show, false to hide the window.
Function in ldk_os.h

ldk_os_window_maximize

Maximizes a window

LDK_API void ldk_os_window_maximize(LDKWindow window);

Parameters

LDKWindow window
The LDK window to maximize. The window is shown if previously hidden.

Returns

void

Function in ldk_os.h

ldk_os_window_minimize

Minimizes a window

LDK_API void ldk_os_window_minimize(LDKWindow window);

Parameters

LDKWindow window
The LDK window to minimize. The window is shown if previously hidden.

Returns

void

Function in ldk_os.h

ldk_os_window_restore

Restores a minimized or maximized window

LDK_API void ldk_os_window_restore(LDKWindow window);

Parameters

LDKWindow window
The LDK window to restore. The window is shown if previously hidden.

Returns

void

Function in ldk_os.h

ldk_os_clipboard_text_set

Store UTF-8 text in the system clipboard.

LDK_API bool ldk_os_clipboard_text_set(
 LDKWindow window,
 const char *text
);

Parameters

LDKWindow window
Native window handle.
const char *text
Text used by this operation.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_clipboard_text_get

Read UTF-8 text from the system clipboard. Passing NULL and zero queries the required byte length. If out_size is too small, out_text is left empty and the required byte length is returned. The returned length excludes the null terminator.

LDK_API size_t ldk_os_clipboard_text_get(
 LDKWindow window,
 char *out_text,
 size_t out_size
);

Parameters

LDKWindow window
Native window handle.
char *out_text
Destination buffer for the resulting text.
size_t out_size
Receives or specifies the byte size of the output buffer, as defined by the operation.

Returns

The resulting numeric value.

Typedef in ldk_os.h

LDKGCtx

typedef void *LDKGCtx;
Function in ldk_os.h

ldk_os_graphics_context_opengl_create

Create the OS graphics context opengl.

LDK_API LDKGCtx ldk_os_graphics_context_opengl_create(
 i32 version_major,
 i32 version_minor,
 i32 color_bits,
 i32 depth_bits
);

Parameters

i32 version_major
Requested major graphics API version.
i32 version_minor
Requested minor graphics API version.
i32 color_bits
Requested number of color bits.
i32 depth_bits
Requested number of depth bits.

Returns

The requested value.

Function in ldk_os.h

ldk_os_graphics_context_opengles_create

Create the OS graphics context opengles.

LDK_API LDKGCtx ldk_os_graphics_context_opengles_create(
 i32 version_major,
 i32 version_minor,
 i32 color_bits,
 i32 depth_bits
);

Parameters

i32 version_major
Requested major graphics API version.
i32 version_minor
Requested minor graphics API version.
i32 color_bits
Requested number of color bits.
i32 depth_bits
Requested number of depth bits.

Returns

The requested value.

Function in ldk_os.h

ldk_os_graphics_context_make_current

Make a graphics context current for a window.

LDK_API void ldk_os_graphics_context_make_current(
 LDKWindow window,
 LDKGCtx context
);

Parameters

LDKWindow window
Native window handle.
LDKGCtx context
Context used by this operation.
Function in ldk_os.h

ldk_os_graphics_context_destroy

Destroy the OS graphics context.

LDK_API void ldk_os_graphics_context_destroy(LDKGCtx context);

Parameters

LDKGCtx context
Context used by this operation.
Function in ldk_os.h

ldk_os_graphics_vsync_set

Set the OS graphics vsync.

LDK_API bool ldk_os_graphics_vsync_set(bool vsync);

Parameters

bool vsync
Vsync used by this operation.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_graphics_vsync_get

Query the currently configured vertical synchronization setting.

LDK_API i32 ldk_os_graphics_vsync_get(void);

Returns

The resulting integer value.

Typedef in ldk_os.h

LDKLibrary

typedef void LDKLibrary;
Function in ldk_os.h

ldk_os_library_load

Load the OS library.

LDK_API LDKLibrary * ldk_os_library_load(const char *path);

Parameters

const char *path
Path identifying the file or resource.

Returns

Pointer to the requested object or data; NULL when unavailable.

Function in ldk_os.h

ldk_os_library_unload

Unload the OS library.

LDK_API bool ldk_os_library_unload(LDKLibrary *library);

Parameters

LDKLibrary *library
Library used by this operation.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_library_fuction_ptr_get

Find an exported function pointer in a dynamic library.

LDK_API void * ldk_os_library_fuction_ptr_get(
 LDKLibrary *library,
 const char *name
);

Parameters

LDKLibrary *library
Library used by this operation.
const char *name
Name identifying the object or setting.

Returns

Pointer to the requested object or data; NULL when unavailable.

Struct in ldk_os.h

LDKOSProcessDesc

typedef struct LDKOSProcessDesc{
  const char *executable;
  const char *arguments;
  const char *working_directory;
  bool new_console;
}LDKOSProcessDesc;
Struct in ldk_os.h

LDKOSProcessResult

typedef struct LDKOSProcessResult{
  bool started;
  bool completed;
  u32 exit_code;
  u32 os_error;
}LDKOSProcessResult;
Struct in ldk_os.h

LDKOSProcess

typedef struct LDKOSProcess LDKOSProcess;
Function in ldk_os.h

ldk_os_process_launch

Launches a process without waiting for it to exit and without retaining a process handle. This is intended for opening external editor applications rather than managed editor jobs. On success started is true and completed is false.

LDK_API LDKOSProcessResult ldk_os_process_launch(const LDKOSProcessDesc *desc);

Parameters

const LDKOSProcessDesc *desc
Description or configuration for this operation.

Returns

Result of the operation.

Function in ldk_os.h

ldk_os_open_default

Opens a file or directory with the operating system default handler.

LDK_API bool ldk_os_open_default(const char *path);

Parameters

const char *path
Path identifying the file or resource.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_process_start

Starts a process and captures stdout and stderr into one output stream. The returned process must be destroyed with ldk_os_process_destroy(). When out_result is not NULL it receives the initial process result. On success started is true and completed is false. On failure NULL is returned and os_error contains the platform error when available.

LDK_API LDKOSProcess * ldk_os_process_start(
 const LDKOSProcessDesc *desc,
 LDKOSProcessResult *out_result
);

Parameters

const LDKOSProcessDesc *desc
Description or configuration for this operation.
LDKOSProcessResult *out_result
Receives additional status or diagnostic information.

Returns

Pointer to the requested object or data; NULL when unavailable.

Function in ldk_os.h

ldk_os_process_output_read

Reads currently available captured output without blocking. stdout and stderr are merged and returned in process order as observed by the shared pipe. The returned byte count may be zero while the process is still running.

LDK_API size_t ldk_os_process_output_read(
 LDKOSProcess *process,
 char *out_buffer,
 size_t buffer_size
);

Parameters

LDKOSProcess *process
Process used by this operation.
char *out_buffer
Destination buffer that receives the result.
size_t buffer_size
Capacity of the buffer in bytes.

Returns

The resulting numeric value.

Function in ldk_os.h

ldk_os_process_poll

Polls the current process state without blocking. Returns false only when polling fails. out_result is always updated when it is not NULL. completed becomes true after the child process exits.

LDK_API bool ldk_os_process_poll(
 LDKOSProcess *process,
 LDKOSProcessResult *out_result
);

Parameters

LDKOSProcess *process
Process used by this operation.
LDKOSProcessResult *out_result
Receives additional status or diagnostic information.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_process_cancel

Cancels the process and its child process tree.

LDK_API bool ldk_os_process_cancel(LDKOSProcess *process);

Parameters

LDKOSProcess *process
Process used by this operation.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_process_was_cancelled

Returns true when cancellation was successfully requested for the process.

LDK_API bool ldk_os_process_was_cancelled(const LDKOSProcess *process);

Parameters

const LDKOSProcess *process
Process used by this operation.

Returns

True when the queried condition holds; false otherwise.

Function in ldk_os.h

ldk_os_process_destroy

Releases the process resources. A still-running process tree is terminated.

LDK_API void ldk_os_process_destroy(LDKOSProcess *process);

Parameters

LDKOSProcess *process
Process used by this operation.
Enum in ldk_os.h

LDKMouseButton

typedef enum{
  LDK_MOUSE_BUTTON_LEFT=0,
  LDK_MOUSE_BUTTON_RIGHT=1,
  LDK_MOUSE_BUTTON_MIDDLE=2,
  LDK_MOUSE_BUTTON_EXTRA_0=3,
  LDK_MOUSE_BUTTON_EXTRA_1=4,
  LDK_MOUSE_CHANGED_THIS_FRAME_BIT=1<<1,
  LDK_MOUSE_PRESSED_BIT=1,
  LDK_MOUSE_MAX_BUTTONS=5
}LDKMouseButton;
Enum in ldk_os.h

LDKCursorType

typedef enum{
  LDK_CURSOR_ARROW=0,
  LDK_CURSOR_TEXT_SELECT=1,
  LDK_CURSOR_SIZE_NWSE=2,
  LDK_CURSOR_SIZE_NESW=3,
  LDK_CURSOR_SIZE_WE=4,
  LDK_CURSOR_SIZE_NS=5,
}LDKCursorType;
Function in ldk_os.h

ldk_os_cursor_type_get

Get the OS cursor type.

LDK_API LDKCursorType ldk_os_cursor_type_get();

Returns

The requested value.

Function in ldk_os.h

ldk_os_cursor_is_in_client_area

Check whether the pointer is inside the active window client area.

LDK_API bool ldk_os_cursor_is_in_client_area();

Returns

True when the queried condition holds; false otherwise.

Struct in ldk_os.h

LDKMouseState

typedef struct{
  i32 wheel_delta;
  LDKPoint cursor;
  LDKPoint cursor_relative;
  unsigned char button[LDK_MOUSE_MAX_BUTTONS];
}LDKMouseState;
Function in ldk_os.h

ldk_os_mouse_state_get

Get the OS mouse state.

LDK_API void ldk_os_mouse_state_get(LDKMouseState *outState);

Parameters

LDKMouseState *outState
Receives the requested input state snapshot.
Function in ldk_os.h

ldk_os_mouse_button_is_pressed

Test whether the button is currently held.

LDK_API bool ldk_os_mouse_button_is_pressed(
 LDKMouseState *state,
 LDKMouseButton button
);

Parameters

LDKMouseState *state
Input snapshot or state object to query.
LDKMouseButton button
Mouse or input button to query.

Returns

True when the queried condition holds; false otherwise.

Function in ldk_os.h

ldk_os_mouse_button_down

Test whether the button was pressed during the current input update.

LDK_API bool ldk_os_mouse_button_down(
 LDKMouseState *state,
 LDKMouseButton button
);

Parameters

LDKMouseState *state
Input snapshot or state object to query.
LDKMouseButton button
Mouse or input button to query.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_mouse_button_up

Test whether the button was released during the current input update.

LDK_API bool ldk_os_mouse_button_up(
 LDKMouseState *state,
 LDKMouseButton button
);

Parameters

LDKMouseState *state
Input snapshot or state object to query.
LDKMouseButton button
Mouse or input button to query.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_mouse_wheel_delta

Get the accumulated mouse wheel movement in the input snapshot.

LDK_API i32 ldk_os_mouse_wheel_delta(LDKMouseState *state);

Parameters

LDKMouseState *state
Input snapshot or state object to query.

Returns

The resulting integer value.

Function in ldk_os.h

ldk_os_mouse_cursor_relative

Get the mouse cursor position relative to the active client area.

LDK_API LDKPoint ldk_os_mouse_cursor_relative(LDKMouseState *state);

Parameters

LDKMouseState *state
Input snapshot or state object to query.

Returns

The resulting point.

Macro in ldk_os.h

LDK_KEYBOARD_KEYCODES

#define LDK_KEYBOARD_KEYCODES \
X(LDK_KEYCODE_INVALID, "", 0x00)\
X(LDK_KEYCODE_BACKSPACE, "BACK", 0x08)\
X(LDK_KEYCODE_TAB, "TAB", 0x09)\
X(LDK_KEYCODE_CLEAR, "CLEAR", 0x0C)\
X(LDK_KEYCODE_RETURN, "RETURN", 0x0D)\
X(LDK_KEYCODE_ENTER, "RETURN", 0x0D)\
X(LDK_KEYCODE_SHIFT, "SHIFT", 0x10)\
X(LDK_KEYCODE_CONTROL, "CONTROL", 0x11)\
X(LDK_KEYCODE_ALT, "ALT", 0x12)\
X(LDK_KEYCODE_PAUSE, "PAUSE", 0x13)\
X(LDK_KEYCODE_CAPITAL, "CAPITAL", 0x14)\
X(LDK_KEYCODE_ESCAPE, "ESCAPE", 0x1B)\
X(LDK_KEYCODE_CONVERT, "CONVERT", 0x1C)\
X(LDK_KEYCODE_NONCONVERT, "NONCONVERT", 0x1D)\
X(LDK_KEYCODE_ACCEPT, "ACCEPT", 0x1E)\
X(LDK_KEYCODE_MODECHANGE, "MODECHANGE", 0x1F)\
X(LDK_KEYCODE_SPACE, "SPACE", 0x20)\
X(LDK_KEYCODE_PRIOR, "PRIOR", 0x21)\
X(LDK_KEYCODE_NEXT, "NEXT", 0x22)\
X(LDK_KEYCODE_END, "END", 0x23)\
X(LDK_KEYCODE_HOME, "HOME", 0x24)\
X(LDK_KEYCODE_LEFT, "LEFT", 0x25)\
X(LDK_KEYCODE_UP, "UP", 0x26)\
X(LDK_KEYCODE_RIGHT, "RIGHT", 0x27)\
X(LDK_KEYCODE_DOWN, "DOWN", 0x28)\
X(LDK_KEYCODE_SELECT, "SELECT", 0x29)\
X(LDK_KEYCODE_PRINT, "PRINT", 0x2A)\
X(LDK_KEYCODE_EXECUTE, "EXECUTE", 0x2B)\
X(LDK_KEYCODE_SNAPSHOT, "SNAPSHOT", 0x2C)\
X(LDK_KEYCODE_INSERT, "INSERT", 0x2D)\
X(LDK_KEYCODE_DELETE, "DELETE", 0x2E)\
X(LDK_KEYCODE_HELP, "HELP", 0x2F)\
X(LDK_KEYCODE_0, "0", 0x30)\
X(LDK_KEYCODE_1, "1", 0x31)\
X(LDK_KEYCODE_2, "2", 0x32)\
X(LDK_KEYCODE_3, "3", 0x33)\
X(LDK_KEYCODE_4, "4", 0x34)\
X(LDK_KEYCODE_5, "5", 0x35)\
X(LDK_KEYCODE_6, "6", 0x36)\
X(LDK_KEYCODE_7, "7", 0x37)\
X(LDK_KEYCODE_8, "8", 0x38)\
X(LDK_KEYCODE_9, "9", 0x39)\
X(LDK_KEYCODE_A, "A", 0x41)\
X(LDK_KEYCODE_B, "B", 0x42)\
X(LDK_KEYCODE_C, "C", 0x43)\
X(LDK_KEYCODE_D, "D", 0x44)\
X(LDK_KEYCODE_E, "E", 0x45)\
X(LDK_KEYCODE_F, "F", 0x46)\
X(LDK_KEYCODE_G, "G", 0x47)\
X(LDK_KEYCODE_H, "H", 0x48)\
X(LDK_KEYCODE_I, "I", 0x49)\
X(LDK_KEYCODE_J, "J", 0x4A)\
X(LDK_KEYCODE_K, "K", 0x4B)\
X(LDK_KEYCODE_L, "L", 0x4C)\
X(LDK_KEYCODE_M, "M", 0x4D)\
X(LDK_KEYCODE_N, "N", 0x4E)\
X(LDK_KEYCODE_O, "O", 0x4F)\
X(LDK_KEYCODE_P, "P", 0x50)\
X(LDK_KEYCODE_Q, "Q", 0x51)\
X(LDK_KEYCODE_R, "R", 0x52)\
X(LDK_KEYCODE_S, "S", 0x53)\
X(LDK_KEYCODE_T, "T", 0x54)\
X(LDK_KEYCODE_U, "U", 0x55)\
X(LDK_KEYCODE_V, "V", 0x56)\
X(LDK_KEYCODE_W, "W", 0x57)\
X(LDK_KEYCODE_X, "X", 0x58)\
X(LDK_KEYCODE_Y, "Y", 0x59)\
X(LDK_KEYCODE_Z, "Z", 0x5A)\
X(LDK_KEYCODE_NUMPAD0, "NUMPAD0", 0x60)\
X(LDK_KEYCODE_NUMPAD1, "NUMPAD1", 0x61)\
X(LDK_KEYCODE_NUMPAD2, "NUMPAD2", 0x62)\
X(LDK_KEYCODE_NUMPAD3, "NUMPAD3", 0x63)\
X(LDK_KEYCODE_NUMPAD4, "NUMPAD4", 0x64)\
X(LDK_KEYCODE_NUMPAD5, "NUMPAD5", 0x65)\
X(LDK_KEYCODE_NUMPAD6, "NUMPAD6", 0x66)\
X(LDK_KEYCODE_NUMPAD7, "NUMPAD7", 0x67)\
X(LDK_KEYCODE_NUMPAD8, "NUMPAD8", 0x68)\
X(LDK_KEYCODE_NUMPAD9, "NUMPAD9", 0x69)\
X(LDK_KEYCODE_MULTIPLY, "MULTIPLY", 0x6A)\
X(LDK_KEYCODE_ADD, "ADD", 0x6B)\
X(LDK_KEYCODE_SEPARATOR, "SEPARATOR", 0x6C)\
X(LDK_KEYCODE_SUBTRACT, "SUBTRACT", 0x6D)\
X(LDK_KEYCODE_DECIMAL, "DECIMAL", 0x6E)\
X(LDK_KEYCODE_DIVIDE, "DIVIDE", 0x6F)\
X(LDK_KEYCODE_F1, "F1", 0x70)\
X(LDK_KEYCODE_F2, "F2", 0x71)\
X(LDK_KEYCODE_F3, "F3", 0x72)\
X(LDK_KEYCODE_F4, "F4", 0x73)\
X(LDK_KEYCODE_F5, "F5", 0x74)\
X(LDK_KEYCODE_F6, "F6", 0x75)\
X(LDK_KEYCODE_F7, "F7", 0x76)\
X(LDK_KEYCODE_F8, "F8", 0x77)\
X(LDK_KEYCODE_F9, "F9", 0x78)\
X(LDK_KEYCODE_F10, "F10", 0x79)\
X(LDK_KEYCODE_F11, "F11", 0x7A)\
X(LDK_KEYCODE_F12, "F12", 0x7B)\
X(LDK_KEYCODE_F13, "F13", 0x7C)\
X(LDK_KEYCODE_F14, "F14", 0x7D)\
X(LDK_KEYCODE_F15, "F15", 0x7E)\
X(LDK_KEYCODE_F16, "F16", 0x7F)\
X(LDK_KEYCODE_F17, "F17", 0x80)\
X(LDK_KEYCODE_F18, "F18", 0x81)\
X(LDK_KEYCODE_F19, "F19", 0x82)\
X(LDK_KEYCODE_F20, "F20", 0x83)\
X(LDK_KEYCODE_F21, "F21", 0x84)\
X(LDK_KEYCODE_F22, "F22", 0x85)\
X(LDK_KEYCODE_F23, "F23", 0x86)\
X(LDK_KEYCODE_F24, "F24", 0x87)\
X(LDK_KEYCODE_LEFT_CONTROL, "LEFT_CONTROL", 0xA2)\
X(LDK_KEYCODE_RIGHT_CONTROL, "RIGHT_CONTROL", 0xA3)\
X(LDK_KEYCODE_OEM1, "OEM1", 0xBA)\
X(LDK_KEYCODE_OEM2, "OEM2", 0xBF)\
X(LDK_KEYCODE_OEM3, "OEM3", 0xC0)\
X(LDK_KEYCODE_OEM4, "OEM4", 0xDB)\
X(LDK_KEYCODE_OEM5, "OEM5", 0xDC)\
X(LDK_KEYCODE_OEM6, "OEM6", 0xDD)\
X(LDK_KEYCODE_OEM7, "OEM7", 0xDE)\
X(LDK_KEYCODE_OEM8, "OEM8", 0xDF)\
X(LDK_NUM_KEYCODES, "", 0xE0)
Macro in ldk_os.h

X

#define X(keycode, name, value) keycode=value,
Enum in ldk_os.h

LDK_KEYBOARD_PRESSED_BIT

enum{
  LDK_KEYBOARD_PRESSED_BIT=1,
  LDK_KEYBOARD_CHANGED_THIS_FRAME_BIT=1<<1,
  LDK_KEYBOARD_MAX_KEYS=256
};
Struct in ldk_os.h

LDKKeyboardState

typedef struct{
  unsigned char key[LDK_KEYBOARD_MAX_KEYS];
}LDKKeyboardState;
Function in ldk_os.h

ldk_os_keyboard_key_is_pressed

Test whether the key is currently held.

LDK_API bool ldk_os_keyboard_key_is_pressed(
 LDKKeyboardState *state,
 LDKKeycode keycode
);

Parameters

LDKKeyboardState *state
Input snapshot or state object to query.
LDKKeycode keycode
Keyboard key to query.

Returns

True when the queried condition holds; false otherwise.

Function in ldk_os.h

ldk_os_keyboard_key_down

Test whether the key was pressed during the current input update.

LDK_API bool ldk_os_keyboard_key_down(
 LDKKeyboardState *state,
 LDKKeycode keycode
);

Parameters

LDKKeyboardState *state
Input snapshot or state object to query.
LDKKeycode keycode
Keyboard key to query.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_keyboard_key_up

Test whether the key was released during the current input update.

LDK_API bool ldk_os_keyboard_key_up(
 LDKKeyboardState *state,
 LDKKeycode keycode
);

Parameters

LDKKeyboardState *state
Input snapshot or state object to query.
LDKKeycode keycode
Keyboard key to query.

Returns

True if the operation succeeds; false otherwise.

Macro in ldk_os.h

LDK_JOYSTICK_BUTTONS

#define LDK_JOYSTICK_BUTTONS \
X(LDK_JOYSTICK_BUTTON_DPAD_UP, "LDK_JOYSTICK_BUTTON_DPAD_UP", 0x00)\
X(LDK_JOYSTICK_BUTTON_DPAD_DOWN, "LDK_JOYSTICK_BUTTON_DPAD_DOWN", 0x01)\
X(LDK_JOYSTICK_BUTTON_DPAD_LEFT, "LDK_JOYSTICK_BUTTON_DPAD_LEFT", 0x02)\
X(LDK_JOYSTICK_BUTTON_DPAD_RIGHT, "LDK_JOYSTICK_BUTTON_DPAD_RIGHT", 0x03)\
X(LDK_JOYSTICK_BUTTON_START, "LDK_JOYSTICK_BUTTON_START", 0x04)\
X(LDK_JOYSTICK_BUTTON_FN1, "LDK_JOYSTICK_BUTTON_FN1", 0x04)\
X(LDK_JOYSTICK_BUTTON_BACK, "LDK_JOYSTICK_BUTTON_BACK", 0x05)\
X(LDK_JOYSTICK_BUTTON_FN2, "LDK_JOYSTICK_BUTTON_FN2", 0x05)\
X(LDK_JOYSTICK_BUTTON_LEFT_THUMB, "LDK_JOYSTICK_BUTTON_LEFT_THUMB", 0x06)\
X(LDK_JOYSTICK_BUTTON_RIGHT_THUMB, "LDK_JOYSTICK_BUTTON_RIGHT_THUMB", 0x07)\
X(LDK_JOYSTICK_BUTTON_LEFT_SHOULDER, "LDK_JOYSTICK_BUTTON_LEFT_SHOULDER", \
0x08)\
X(LDK_JOYSTICK_BUTTON_RIGHT_SHOULDER, "LDK_JOYSTICK_BUTTON_RIGHT_SHOULDER", \
0x09)\
X(LDK_JOYSTICK_BUTTON_A, "LDK_JOYSTICK_BUTTON_A", 0x0A)\
X(LDK_JOYSTICK_BUTTON_B, "LDK_JOYSTICK_BUTTON_B", 0x0B)\
X(LDK_JOYSTICK_BUTTON_X, "LDK_JOYSTICK_BUTTON_X", 0x0C)\
X(LDK_JOYSTICK_BUTTON_Y, "LDK_JOYSTICK_BUTTON_Y", 0x0D)\
X(LDK_JOYSTICK_BUTTON_BTN1, "LDK_JOYSTICK_BUTTON1", 0x0A)\
X(LDK_JOYSTICK_BUTTON_BTN2, "LDK_JOYSTICK_BUTTON2", 0x0B)\
X(LDK_JOYSTICK_BUTTON_BTN3, "LDK_JOYSTICK_BUTTON3", 0x0C)\
X(LDK_JOYSTICK_BUTTON_BTN4, "LDK_JOYSTICK_BUTTON4", 0x0D)
Macro in ldk_os.h

X

#define X(keycode, name, value) keycode=value,
Enum in ldk_os.h

LDKJoystickButton

typedef enum{
  LDK_JOYSTICK_CHANGED_THIS_FRAME_BIT=1<<1,
  LDK_JOYSTICK_PRESSED_BIT=1,
  LDK_JOYSTICK_NUM_BUTTONS=14,
  LDK_JOYSTICK_BUTTONS
}LDKJoystickButton;
Macro in ldk_os.h

LDK_JOYSTICK_AXIS

#define LDK_JOYSTICK_AXIS \
X(LDK_JOYSTICK_AXIS_LX, "LDK_JOYSTICK_AXIS_LX", 0x00)\
X(LDK_JOYSTICK_AXIS_LY, "LDK_JOYSTICK_AXIS_LY", 0x01)\
X(LDK_JOYSTICK_AXIS_RX, "LDK_JOYSTICK_AXIS_RX", 0x02)\
X(LDK_JOYSTICK_AXIS_RY, "LDK_JOYSTICK_AXIS_RY", 0x03)\
X(LDK_JOYSTICK_AXIS_LTRIGGER, "LDK_JOYSTICK_AXIS_LTRIGGER", 0x04)\
X(LDK_JOYSTICK_AXIS_RTRIGGER, "LDK_JOYSTICK_AXIS_RTRIGGER", 0x05)
Macro in ldk_os.h

LDK_JOYSTICK_MAX

#define LDK_JOYSTICK_MAX 4
Enum in ldk_os.h

LDKJoystickID

typedef enum{
  LDK_JOYSTICK_0,
  LDK_JOYSTICK_1,
  LDK_JOYSTICK_2,
  LDK_JOYSTICK_3,
}LDKJoystickID;
Macro in ldk_os.h

X

#define X(keycode, name, value) keycode=value,
Struct in ldk_os.h

LDKJoystickState

typedef struct{
  u32 button[LDK_JOYSTICK_NUM_BUTTONS];
  float axis[LDK_JOYSTICK_NUM_AXIS];
  bool connected;
  float vibration_left;
  float vibration_right;
}LDKJoystickState;
Function in ldk_os.h

ldk_os_joystick_count

Count the OS joystick.

LDK_API u32 ldk_os_joystick_count(void);

Returns

Number of matching entries.

Function in ldk_os.h

ldk_os_joystick_is_connected

Check whether the indicated joystick is connected.

LDK_API u32 ldk_os_joystick_is_connected(LDKJoystickID id);

Parameters

LDKJoystickID id
Identifier of the target object.

Returns

The resulting numeric value.

Function in ldk_os.h

ldk_os_joystick_vibration_left_set

Set the OS joystick vibration left.

LDK_API void ldk_os_joystick_vibration_left_set(
 LDKJoystickID id,
 float speed
);

Parameters

LDKJoystickID id
Identifier of the target object.
float speed
Speed used by this operation.
Function in ldk_os.h

ldk_os_joystick_vibration_right_set

Set the OS joystick vibration right.

LDK_API void ldk_os_joystick_vibration_right_set(
 LDKJoystickID id,
 float speed
);

Parameters

LDKJoystickID id
Identifier of the target object.
float speed
Speed used by this operation.
Function in ldk_os.h

ldk_os_joystick_vibration_left_get

Get the OS joystick vibration left.

LDK_API float ldk_os_joystick_vibration_left_get(LDKJoystickID id);

Parameters

LDKJoystickID id
Identifier of the target object.

Returns

The resulting value.

Function in ldk_os.h

ldk_os_joystick_vibration_right_get

Get the OS joystick vibration right.

LDK_API float ldk_os_joystick_vibration_right_get(LDKJoystickID id);

Parameters

LDKJoystickID id
Identifier of the target object.

Returns

The resulting value.

Enum in ldk_os.h

LDKOSDialogResult

typedef enum{
  LDK_OS_DIALOG_RESULT_NONE=0,
  LDK_OS_DIALOG_RESULT_OK,
  LDK_OS_DIALOG_RESULT_CANCEL,
  LDK_OS_DIALOG_RESULT_YES,
  LDK_OS_DIALOG_RESULT_NO,
}LDKOSDialogResult;
Function in ldk_os.h

ldk_os_dialog_show_open_file

Open a native file selection dialog.

LDK_API bool ldk_os_dialog_show_open_file(
 LDKWindow owner,
 const char *title,
 const char *filter,
 XFSPath *out_path
);

Parameters

LDKWindow owner
Parent window for the dialog.
const char *title
Title shown by the window or dialog.
const char *filter
File type filter passed to the native dialog.
XFSPath *out_path
Receives the resulting path.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_dialog_color_picker_show

Open the native color selection dialog.

LDK_API bool ldk_os_dialog_color_picker_show(
 LDKWindow owner,
 rgba32 *color
);

Parameters

LDKWindow owner
Parent window for the dialog.
rgba32 *color
Color value used by the operation.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_dialog_show_open_folder

Open a native folder selection dialog.

LDK_API bool ldk_os_dialog_show_open_folder(
 LDKWindow owner,
 const char *title,
 const char *filter,
 char *out_path,
 size_t out_path_size
);

Parameters

LDKWindow owner
Parent window for the dialog.
const char *title
Title shown by the window or dialog.
const char *filter
File type filter passed to the native dialog.
char *out_path
Receives the resulting path.
size_t out_path_size
Receives the resulting path size.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_dialog_show_save_file

Open a native save-file dialog.

LDK_API bool ldk_os_dialog_show_save_file(
 LDKWindow owner,
 const char *title,
 const char *filter,
 XFSPath *out_path
);

Parameters

LDKWindow owner
Parent window for the dialog.
const char *title
Title shown by the window or dialog.
const char *filter
File type filter passed to the native dialog.
XFSPath *out_path
Receives the resulting path.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_dialog_show_yes_no

Show a Yes/No message dialog.

LDK_API bool ldk_os_dialog_show_yes_no(
 LDKWindow owner,
 const char *title,
 const char *message
);

Parameters

LDKWindow owner
Parent window for the dialog.
const char *title
Title shown by the window or dialog.
const char *message
Message displayed to the user.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_dialog_show_ok_cancel

Show an OK/Cancel message dialog.

LDK_API bool ldk_os_dialog_show_ok_cancel(
 LDKWindow owner,
 const char *title,
 const char *message
);

Parameters

LDKWindow owner
Parent window for the dialog.
const char *title
Title shown by the window or dialog.
const char *message
Message displayed to the user.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_dialog_show_ok

Show an OK message dialog.

LDK_API bool ldk_os_dialog_show_ok(
 LDKWindow owner,
 const char *title,
 const char *message
);

Parameters

LDKWindow owner
Parent window for the dialog.
const char *title
Title shown by the window or dialog.
const char *message
Message displayed to the user.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_os.h

ldk_os_dialog_show_error

Show an error message dialog.

LDK_API bool ldk_os_dialog_show_error(
 LDKWindow owner,
 const char *title,
 const char *message
);

Parameters

LDKWindow owner
Parent window for the dialog.
const char *title
Title shown by the window or dialog.
const char *message
Message displayed to the user.

Returns

True if the operation succeeds; false otherwise.