#pragma once #include #include #include "base/base_core.h" #include "base/base_math.h" //////////////////////////////// // Input — accumulated per frame, consumed by the app each tick. #define PLATFORM_MAX_CHARS_PER_FRAME 64 #define PLATFORM_MAX_KEYS_PER_FRAME 32 // Virtual key codes (subset matching Win32 VK_ codes) enum { PKEY_BACKSPACE = 0x08, PKEY_TAB = 0x09, PKEY_RETURN = 0x0D, PKEY_ESCAPE = 0x1B, PKEY_DELETE = 0x2E, PKEY_LEFT = 0x25, PKEY_UP = 0x26, PKEY_RIGHT = 0x27, PKEY_DOWN = 0x28, PKEY_HOME = 0x24, PKEY_END = 0x23, PKEY_A = 0x41, PKEY_C = 0x43, PKEY_V = 0x56, PKEY_X = 0x58, }; struct PlatformInput { // Typed characters (UTF-16 code units, printable only) uint16_t chars[PLATFORM_MAX_CHARS_PER_FRAME]; int32_t char_count; // Key-down events (virtual key codes) uint8_t keys[PLATFORM_MAX_KEYS_PER_FRAME]; int32_t key_count; // Modifier state at time of last key event bool ctrl_held; bool shift_held; // Mouse state (polled per frame) Vec2F32 mouse_pos; Vec2F32 scroll_delta; B32 mouse_down; B32 was_mouse_down; }; struct PlatformWindow; struct PlatformWindowDesc { const char *title = "autosample"; int32_t width = 1280; int32_t height = 720; }; struct PlatformMenuItem { const char *label; // nullptr = separator int32_t id; // command ID (ignored for separators) }; struct PlatformMenu { const char *label; PlatformMenuItem *items; int32_t item_count; }; // Called by the platform layer when the window needs a frame rendered // (e.g., during a live resize). user_data is the pointer passed to // platform_set_frame_callback. typedef void (*PlatformFrameCallback)(void *user_data); PlatformWindow *platform_create_window(PlatformWindowDesc *desc); void platform_destroy_window(PlatformWindow *window); bool platform_poll_events(PlatformWindow *window); void platform_get_size(PlatformWindow *window, int32_t *w, int32_t *h); void *platform_get_native_handle(PlatformWindow *window); void platform_set_frame_callback(PlatformWindow *window, PlatformFrameCallback cb, void *user_data); void platform_set_menu(PlatformWindow *window, PlatformMenu *menus, int32_t menu_count); int32_t platform_poll_menu_command(PlatformWindow *window); // Returns accumulated input since last call (keyboard events + polled mouse state), then clears the buffer. PlatformInput platform_get_input(PlatformWindow *window); // Clipboard operations (null-terminated UTF-8 strings). // platform_clipboard_set copies text to the system clipboard. // platform_clipboard_get returns a pointer to a static buffer (valid until next call), or nullptr. void platform_clipboard_set(const char *text); const char *platform_clipboard_get();