Files
Wellington Dias 1d51343ac1 Build and run the runtime natively on Linux.
Shared runtime code now goes through runtime/platform/platform.h, implemented by platform/win32.c and a new
platform/linux.c: futex locks, a userfaultfd and PAGEMAP_SCAN write watch, signal-based async preemption, our own
fiber switch, and a SIGSEGV handler for the thaw and crash hooks. The window, input, menu and software keyboard get
SDL3 back ends beside the Win32 ones, with the swapchain (gfx_present.c) and input merging (input.c) shared. SHA-256
replaces BCrypt, ELF builds get their own override sections, and the build tools gain Linux branches.

On Linux the selftest and the gfx-abi, astc, nvn and window probes pass. probe-vkmem still fails: imported guest
memory cannot be write-watched on Linux, which the shadow buffers in vk_memory.c will address.
2026-10-29 16:56:56 -03:00

29 lines
1.5 KiB
C

// nn::swkbd::ShowKeyboard (swkbd.c) and its front end, the window that takes the text (swkbd_win.c with Win32,
// swkbd_sdl.c with SDL).
#pragma once
#include <stddef.h>
#include <stdint.h>
#define KB_LIMIT 500 // the applet's longest text
// The request, front-end independent.
typedef struct {
uint16_t prompt[0x101]; // header, else guide, else sub text (UTF-16, NUL-terminated; may be empty)
uint16_t initial[KB_LIMIT + 1]; // starting text (the game's, else the catalog's default name)
int game_initial; // the starting text is the game's
int max_len, min_len, password, numeric;
uint32_t disabled;
} SwkbdRequest;
// Shows the text entry and waits for the answer, on the guest thread that called (its virtual core given up, the
// game's input blocked). Returns 1 with the text in out (n units), 0 when cancelled.
int text_entry_run(const SwkbdRequest *req, uint16_t *out, size_t cap, size_t *n);
// UTF-16 (n units) -> NUL-terminated UTF-8 in cap bytes, cut at a character boundary; the bytes written.
size_t swkbd_utf16_to_utf8(const uint16_t *s, size_t n, char *out, size_t cap);
// UTF-8 -> UTF-16, at most cap units (a character that does not fit whole is dropped); bad bytes become U+FFFD.
size_t swkbd_utf8_to_utf16(const char *s, uint16_t *out, size_t cap);
// Whether the applet would let this character through (single UTF-16 units). Disabled-key bits as the applet's: 1 space,
// 2 '@', 3 '%', 4 '/', 5 '\', 6 digits.
int swkbd_allowed(uint16_t c, uint32_t disabled, int digits_only);