cleanup: namespace Montauk (capital M) => montauk::abi
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
namespace Montauk {
|
||||
namespace montauk::abi {
|
||||
|
||||
// Syscall numbers
|
||||
static constexpr uint64_t SYS_EXIT = 0;
|
||||
|
||||
@@ -56,7 +56,7 @@ struct Engine {
|
||||
}
|
||||
|
||||
// Create window
|
||||
Montauk::WinCreateResult wres;
|
||||
montauk::abi::WinCreateResult wres;
|
||||
if (montauk::win_create(title, w, h, &wres) < 0 || wres.id < 0)
|
||||
return false;
|
||||
|
||||
@@ -77,7 +77,7 @@ struct Engine {
|
||||
}
|
||||
|
||||
// Poll one window event. Returns true if an event was received.
|
||||
bool poll(Montauk::WinEvent* ev) {
|
||||
bool poll(montauk::abi::WinEvent* ev) {
|
||||
int r = montauk::win_poll(win_id, ev);
|
||||
if (r < 0) { running = false; return false; }
|
||||
if (r == 0) return false;
|
||||
|
||||
@@ -55,7 +55,7 @@ struct InputState {
|
||||
}
|
||||
|
||||
// Process a window event
|
||||
void handle_event(const Montauk::WinEvent& ev) {
|
||||
void handle_event(const montauk::abi::WinEvent& ev) {
|
||||
if (ev.type == 0) { // keyboard
|
||||
// PS/2 scan code set 1: release codes have bit 7 set.
|
||||
// Mask to base scancode so press and release map to the same index.
|
||||
|
||||
@@ -22,13 +22,13 @@ namespace gui {
|
||||
return clipboard_set_text(text, text ? montauk::slen(text) : 0);
|
||||
}
|
||||
|
||||
inline bool clipboard_get_info(Montauk::ClipboardInfo* out) {
|
||||
inline bool clipboard_get_info(montauk::abi::ClipboardInfo* out) {
|
||||
if (out == nullptr) return false;
|
||||
return montauk::clipboard_get_info(out) == 0;
|
||||
}
|
||||
|
||||
inline bool clipboard_has_text() {
|
||||
Montauk::ClipboardInfo info = {};
|
||||
montauk::abi::ClipboardInfo info = {};
|
||||
return clipboard_get_info(&info) && info.textBytes > 0;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace gui {
|
||||
if (out_len) *out_len = 0;
|
||||
if (out_serial) *out_serial = 0;
|
||||
|
||||
Montauk::ClipboardInfo info = {};
|
||||
montauk::abi::ClipboardInfo info = {};
|
||||
if (!clipboard_get_info(&info) || info.textBytes == 0)
|
||||
return nullptr;
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ struct DesktopState {
|
||||
char user_config_dir[128]; // "0:/users/<username>/config"
|
||||
bool is_admin;
|
||||
|
||||
Montauk::MouseState mouse;
|
||||
montauk::abi::MouseState mouse;
|
||||
uint8_t prev_buttons;
|
||||
|
||||
bool app_menu_open;
|
||||
@@ -160,7 +160,7 @@ struct DesktopState {
|
||||
int ctx_menu_x, ctx_menu_y;
|
||||
|
||||
bool net_popup_open;
|
||||
Montauk::NetCfg cached_net_cfg;
|
||||
montauk::abi::NetCfg cached_net_cfg;
|
||||
uint64_t net_cfg_last_poll;
|
||||
Rect net_icon_rect;
|
||||
|
||||
@@ -175,7 +175,7 @@ struct DesktopState {
|
||||
|
||||
// Temperature monitoring
|
||||
static constexpr int MAX_THERMAL_ZONES = 8;
|
||||
Montauk::ThermalInfo thermal_zones[MAX_THERMAL_ZONES];
|
||||
montauk::abi::ThermalInfo thermal_zones[MAX_THERMAL_ZONES];
|
||||
int thermal_zone_count;
|
||||
uint64_t thermal_last_poll;
|
||||
Rect temp_icon_rect;
|
||||
@@ -214,6 +214,6 @@ void desktop_raise_window(DesktopState* ds, int idx);
|
||||
void desktop_draw_panel(DesktopState* ds);
|
||||
void desktop_draw_window(DesktopState* ds, int idx);
|
||||
void desktop_handle_mouse(DesktopState* ds);
|
||||
void desktop_handle_keyboard(DesktopState* ds, const Montauk::KeyEvent& key);
|
||||
void desktop_handle_keyboard(DesktopState* ds, const montauk::abi::KeyEvent& key);
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -61,7 +61,7 @@ class Framebuffer {
|
||||
|
||||
public:
|
||||
Framebuffer() : hw_fb(nullptr), back_buf(nullptr), fb_width(0), fb_height(0), fb_pitch(0) {
|
||||
Montauk::FbInfo info;
|
||||
montauk::abi::FbInfo info;
|
||||
montauk::fb_info(&info);
|
||||
|
||||
fb_width = (int)info.width;
|
||||
|
||||
@@ -552,7 +552,7 @@ inline int text_input_handle_mouse(TextInputState& state,
|
||||
inline int text_input_key(TextInputState& state,
|
||||
char* text,
|
||||
int cap,
|
||||
const Montauk::KeyEvent& key,
|
||||
const montauk::abi::KeyEvent& key,
|
||||
TextInputCharFilter filter = nullptr,
|
||||
void* userdata = nullptr,
|
||||
bool masked = false) {
|
||||
|
||||
@@ -24,7 +24,7 @@ struct WsWindow {
|
||||
: id(-1), pixels(nullptr), width(0), height(0), scale_factor(1), closed(false) {}
|
||||
|
||||
bool create(const char* title, int w, int h) {
|
||||
Montauk::WinCreateResult wres;
|
||||
montauk::abi::WinCreateResult wres;
|
||||
if (montauk::win_create(title, w, h, &wres) < 0 || wres.id < 0)
|
||||
return false;
|
||||
|
||||
@@ -37,7 +37,7 @@ struct WsWindow {
|
||||
return true;
|
||||
}
|
||||
|
||||
int poll(Montauk::WinEvent* ev) {
|
||||
int poll(montauk::abi::WinEvent* ev) {
|
||||
if (id < 0 || closed) return -1;
|
||||
|
||||
int r = montauk::win_poll(id, ev);
|
||||
|
||||
@@ -831,7 +831,7 @@ static inline void terminal_resize(TerminalState* t, int new_cols, int new_rows)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void terminal_handle_key(TerminalState* t, const Montauk::KeyEvent& key) {
|
||||
static inline void terminal_handle_key(TerminalState* t, const montauk::abi::KeyEvent& key) {
|
||||
// Snap to live on any keyboard input
|
||||
if (t->view_offset > 0) {
|
||||
t->view_offset = 0;
|
||||
|
||||
@@ -227,7 +227,7 @@ struct TextBox {
|
||||
}
|
||||
}
|
||||
|
||||
void handle_key(const Montauk::KeyEvent& key) {
|
||||
void handle_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!focused || !key.pressed) return;
|
||||
|
||||
if (key.ascii == '\b' || key.scancode == 0x0E) {
|
||||
|
||||
@@ -32,7 +32,7 @@ static constexpr int MIN_WINDOW_H = 80;
|
||||
struct Window;
|
||||
using WindowDrawCallback = void (*)(Window* win, Framebuffer& fb);
|
||||
using WindowMouseCallback = void (*)(Window* win, MouseEvent& ev);
|
||||
using WindowKeyCallback = void (*)(Window* win, const Montauk::KeyEvent& key);
|
||||
using WindowKeyCallback = void (*)(Window* win, const montauk::abi::KeyEvent& key);
|
||||
using WindowCloseCallback = void (*)(Window* win);
|
||||
using WindowPollCallback = void (*)(Window* win);
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ inline Response get_plain(const char* host, const char* path,
|
||||
int reqLen = build_request(req, sizeof(req), "GET", host, path,
|
||||
nullptr, nullptr, 0, extra_headers);
|
||||
|
||||
int sock = montauk::socket(Montauk::SOCK_TCP);
|
||||
int sock = montauk::socket(montauk::abi::SOCK_TCP);
|
||||
if (sock < 0) return resp;
|
||||
if (montauk::connect(sock, ip, 80) < 0) { montauk::closesocket(sock); return resp; }
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace heap_detail {
|
||||
|
||||
static inline void heap_lock_acquire() {
|
||||
while (__atomic_exchange_n(&g_heap_lock, 1, __ATOMIC_ACQUIRE) != 0) {
|
||||
syscall0(Montauk::SYS_YIELD);
|
||||
syscall0(montauk::abi::SYS_YIELD);
|
||||
}
|
||||
}
|
||||
static inline void heap_lock_release() {
|
||||
|
||||
+170
-170
@@ -110,519 +110,519 @@ namespace montauk {
|
||||
|
||||
// Process
|
||||
[[noreturn]] inline void exit(int code = 0) {
|
||||
syscall1(Montauk::SYS_EXIT, (uint64_t)code);
|
||||
syscall1(montauk::abi::SYS_EXIT, (uint64_t)code);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
inline void yield() { syscall0(Montauk::SYS_YIELD); }
|
||||
inline void sleep_ms(uint64_t ms) { syscall1(Montauk::SYS_SLEEP_MS, ms); }
|
||||
inline int getpid() { return (int)syscall0(Montauk::SYS_GETPID); }
|
||||
inline void yield() { syscall0(montauk::abi::SYS_YIELD); }
|
||||
inline void sleep_ms(uint64_t ms) { syscall1(montauk::abi::SYS_SLEEP_MS, ms); }
|
||||
inline int getpid() { return (int)syscall0(montauk::abi::SYS_GETPID); }
|
||||
inline int spawn(const char* path, const char* args = nullptr) {
|
||||
return (int)syscall2(Montauk::SYS_SPAWN, (uint64_t)path, (uint64_t)args);
|
||||
return (int)syscall2(montauk::abi::SYS_SPAWN, (uint64_t)path, (uint64_t)args);
|
||||
}
|
||||
inline int chdir(const char* path) {
|
||||
return (int)syscall1(Montauk::SYS_CHDIR, (uint64_t)path);
|
||||
return (int)syscall1(montauk::abi::SYS_CHDIR, (uint64_t)path);
|
||||
}
|
||||
inline int getcwd(char* buf, uint64_t maxLen) {
|
||||
return (int)syscall2(Montauk::SYS_GETCWD, (uint64_t)buf, maxLen);
|
||||
return (int)syscall2(montauk::abi::SYS_GETCWD, (uint64_t)buf, maxLen);
|
||||
}
|
||||
|
||||
// Console
|
||||
inline void print(const char* text) { syscall1(Montauk::SYS_PRINT, (uint64_t)text); }
|
||||
inline void putchar(char c) { syscall1(Montauk::SYS_PUTCHAR, (uint64_t)c); }
|
||||
inline void print(const char* text) { syscall1(montauk::abi::SYS_PRINT, (uint64_t)text); }
|
||||
inline void putchar(char c) { syscall1(montauk::abi::SYS_PUTCHAR, (uint64_t)c); }
|
||||
|
||||
// File I/O
|
||||
inline int open(const char* path) { return (int)syscall1(Montauk::SYS_OPEN, (uint64_t)path); }
|
||||
inline int open(const char* path) { return (int)syscall1(montauk::abi::SYS_OPEN, (uint64_t)path); }
|
||||
inline int read(int handle, uint8_t* buf, uint64_t off, uint64_t size) {
|
||||
return (int)syscall4(Montauk::SYS_READ, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||
return (int)syscall4(montauk::abi::SYS_READ, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||
}
|
||||
inline uint64_t getsize(int handle) { return (uint64_t)syscall1(Montauk::SYS_GETSIZE, (uint64_t)handle); }
|
||||
inline void close(int handle) { syscall1(Montauk::SYS_CLOSE, (uint64_t)handle); }
|
||||
inline uint64_t getsize(int handle) { return (uint64_t)syscall1(montauk::abi::SYS_GETSIZE, (uint64_t)handle); }
|
||||
inline void close(int handle) { syscall1(montauk::abi::SYS_CLOSE, (uint64_t)handle); }
|
||||
inline int readdir(const char* path, const char** names, int max) {
|
||||
return (int)syscall3(Montauk::SYS_READDIR, (uint64_t)path, (uint64_t)names, (uint64_t)max);
|
||||
return (int)syscall3(montauk::abi::SYS_READDIR, (uint64_t)path, (uint64_t)names, (uint64_t)max);
|
||||
}
|
||||
// Paginated directory read: returns entries [startIndex, startIndex+max).
|
||||
// Call repeatedly with increasing startIndex (advancing by the returned
|
||||
// count) until it returns 0 to enumerate directories of any size.
|
||||
inline int readdir_at(const char* path, const char** names, int max, int startIndex) {
|
||||
return (int)syscall4(Montauk::SYS_READDIR_AT, (uint64_t)path, (uint64_t)names,
|
||||
return (int)syscall4(montauk::abi::SYS_READDIR_AT, (uint64_t)path, (uint64_t)names,
|
||||
(uint64_t)max, (uint64_t)startIndex);
|
||||
}
|
||||
|
||||
// File write/create
|
||||
inline int fwrite(int handle, const uint8_t* buf, uint64_t off, uint64_t size) {
|
||||
return (int)syscall4(Montauk::SYS_FWRITE, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||
return (int)syscall4(montauk::abi::SYS_FWRITE, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||
}
|
||||
inline int fcreate(const char* path) {
|
||||
return (int)syscall1(Montauk::SYS_FCREATE, (uint64_t)path);
|
||||
return (int)syscall1(montauk::abi::SYS_FCREATE, (uint64_t)path);
|
||||
}
|
||||
inline int fdelete(const char* path) {
|
||||
return (int)syscall1(Montauk::SYS_FDELETE, (uint64_t)path);
|
||||
return (int)syscall1(montauk::abi::SYS_FDELETE, (uint64_t)path);
|
||||
}
|
||||
inline int fmkdir(const char* path) {
|
||||
return (int)syscall1(Montauk::SYS_FMKDIR, (uint64_t)path);
|
||||
return (int)syscall1(montauk::abi::SYS_FMKDIR, (uint64_t)path);
|
||||
}
|
||||
inline int frename(const char* oldPath, const char* newPath) {
|
||||
return (int)syscall2(Montauk::SYS_FRENAME, (uint64_t)oldPath, (uint64_t)newPath);
|
||||
return (int)syscall2(montauk::abi::SYS_FRENAME, (uint64_t)oldPath, (uint64_t)newPath);
|
||||
}
|
||||
inline int drivelist(int* outDrives, int max) {
|
||||
return (int)syscall2(Montauk::SYS_DRIVELIST, (uint64_t)outDrives, (uint64_t)max);
|
||||
return (int)syscall2(montauk::abi::SYS_DRIVELIST, (uint64_t)outDrives, (uint64_t)max);
|
||||
}
|
||||
inline int drivelabel(int drive, char* outLabel, int maxLen) {
|
||||
return (int)syscall3(Montauk::SYS_DRIVELABEL, (uint64_t)drive, (uint64_t)outLabel, (uint64_t)maxLen);
|
||||
return (int)syscall3(montauk::abi::SYS_DRIVELABEL, (uint64_t)drive, (uint64_t)outLabel, (uint64_t)maxLen);
|
||||
}
|
||||
// Returns the kernel BlockDeviceKind backing the drive: 0=unknown/ramdisk,
|
||||
// 1=SATA, 2=SATAPI, 3=NVMe, 4=USB MSC.
|
||||
inline int drivekind(int drive) {
|
||||
return (int)syscall1(Montauk::SYS_DRIVEKIND, (uint64_t)drive);
|
||||
return (int)syscall1(montauk::abi::SYS_DRIVEKIND, (uint64_t)drive);
|
||||
}
|
||||
|
||||
// Memory
|
||||
inline void* alloc(uint64_t size) { return (void*)syscall1(Montauk::SYS_ALLOC, size); }
|
||||
inline void free(void* ptr) { syscall1(Montauk::SYS_FREE, (uint64_t)ptr); }
|
||||
inline void* alloc(uint64_t size) { return (void*)syscall1(montauk::abi::SYS_ALLOC, size); }
|
||||
inline void free(void* ptr) { syscall1(montauk::abi::SYS_FREE, (uint64_t)ptr); }
|
||||
|
||||
// Timekeeping
|
||||
inline uint64_t get_ticks() { return (uint64_t)syscall0(Montauk::SYS_GETTICKS); }
|
||||
inline uint64_t get_milliseconds() { return (uint64_t)syscall0(Montauk::SYS_GETMILLISECONDS); }
|
||||
inline uint64_t get_ticks() { return (uint64_t)syscall0(montauk::abi::SYS_GETTICKS); }
|
||||
inline uint64_t get_milliseconds() { return (uint64_t)syscall0(montauk::abi::SYS_GETMILLISECONDS); }
|
||||
|
||||
// System
|
||||
inline void get_info(Montauk::SysInfo* info) { syscall1(Montauk::SYS_GETINFO, (uint64_t)info); }
|
||||
inline void get_info(montauk::abi::SysInfo* info) { syscall1(montauk::abi::SYS_GETINFO, (uint64_t)info); }
|
||||
|
||||
// Keyboard
|
||||
inline bool is_key_available() { return (bool)syscall0(Montauk::SYS_ISKEYAVAILABLE); }
|
||||
inline void getkey(Montauk::KeyEvent* out) { syscall1(Montauk::SYS_GETKEY, (uint64_t)out); }
|
||||
inline char getchar() { return (char)syscall0(Montauk::SYS_GETCHAR); }
|
||||
inline bool is_key_available() { return (bool)syscall0(montauk::abi::SYS_ISKEYAVAILABLE); }
|
||||
inline void getkey(montauk::abi::KeyEvent* out) { syscall1(montauk::abi::SYS_GETKEY, (uint64_t)out); }
|
||||
inline char getchar() { return (char)syscall0(montauk::abi::SYS_GETCHAR); }
|
||||
inline uint64_t input_wait(uint64_t observedSerial, uint64_t timeoutMs) {
|
||||
return (uint64_t)syscall2(Montauk::SYS_INPUT_WAIT, observedSerial, timeoutMs);
|
||||
return (uint64_t)syscall2(montauk::abi::SYS_INPUT_WAIT, observedSerial, timeoutMs);
|
||||
}
|
||||
|
||||
// Networking
|
||||
inline int32_t ping(uint32_t ip, uint32_t timeoutMs = 3000) {
|
||||
return (int32_t)syscall2(Montauk::SYS_PING, (uint64_t)ip, (uint64_t)timeoutMs);
|
||||
return (int32_t)syscall2(montauk::abi::SYS_PING, (uint64_t)ip, (uint64_t)timeoutMs);
|
||||
}
|
||||
|
||||
// DNS resolve: returns IP in network byte order, or 0 on failure
|
||||
inline uint32_t resolve(const char* hostname) {
|
||||
return (uint32_t)syscall1(Montauk::SYS_RESOLVE, (uint64_t)hostname);
|
||||
return (uint32_t)syscall1(montauk::abi::SYS_RESOLVE, (uint64_t)hostname);
|
||||
}
|
||||
|
||||
// Network configuration
|
||||
inline void get_netcfg(Montauk::NetCfg* out) { syscall1(Montauk::SYS_GETNETCFG, (uint64_t)out); }
|
||||
inline int set_netcfg(const Montauk::NetCfg* cfg) { return (int)syscall1(Montauk::SYS_SETNETCFG, (uint64_t)cfg); }
|
||||
inline int net_status(Montauk::NetStatus* out) { return (int)syscall1(Montauk::SYS_NETSTATUS, (uint64_t)out); }
|
||||
inline void get_netcfg(montauk::abi::NetCfg* out) { syscall1(montauk::abi::SYS_GETNETCFG, (uint64_t)out); }
|
||||
inline int set_netcfg(const montauk::abi::NetCfg* cfg) { return (int)syscall1(montauk::abi::SYS_SETNETCFG, (uint64_t)cfg); }
|
||||
inline int net_status(montauk::abi::NetStatus* out) { return (int)syscall1(montauk::abi::SYS_NETSTATUS, (uint64_t)out); }
|
||||
|
||||
// Sockets
|
||||
inline int socket(int type) {
|
||||
return (int)syscall1(Montauk::SYS_SOCKET, (uint64_t)type);
|
||||
return (int)syscall1(montauk::abi::SYS_SOCKET, (uint64_t)type);
|
||||
}
|
||||
inline int connect(int fd, uint32_t ip, uint16_t port) {
|
||||
return (int)syscall3(Montauk::SYS_CONNECT, (uint64_t)fd, (uint64_t)ip, (uint64_t)port);
|
||||
return (int)syscall3(montauk::abi::SYS_CONNECT, (uint64_t)fd, (uint64_t)ip, (uint64_t)port);
|
||||
}
|
||||
inline int bind(int fd, uint16_t port) {
|
||||
return (int)syscall2(Montauk::SYS_BIND, (uint64_t)fd, (uint64_t)port);
|
||||
return (int)syscall2(montauk::abi::SYS_BIND, (uint64_t)fd, (uint64_t)port);
|
||||
}
|
||||
inline int listen(int fd) {
|
||||
return (int)syscall1(Montauk::SYS_LISTEN, (uint64_t)fd);
|
||||
return (int)syscall1(montauk::abi::SYS_LISTEN, (uint64_t)fd);
|
||||
}
|
||||
inline int accept(int fd) {
|
||||
return (int)syscall1(Montauk::SYS_ACCEPT, (uint64_t)fd);
|
||||
return (int)syscall1(montauk::abi::SYS_ACCEPT, (uint64_t)fd);
|
||||
}
|
||||
inline int send(int fd, const void* data, uint32_t len) {
|
||||
return (int)syscall3(Montauk::SYS_SEND, (uint64_t)fd, (uint64_t)data, (uint64_t)len);
|
||||
return (int)syscall3(montauk::abi::SYS_SEND, (uint64_t)fd, (uint64_t)data, (uint64_t)len);
|
||||
}
|
||||
inline int recv(int fd, void* buf, uint32_t maxLen) {
|
||||
return (int)syscall3(Montauk::SYS_RECV, (uint64_t)fd, (uint64_t)buf, (uint64_t)maxLen);
|
||||
return (int)syscall3(montauk::abi::SYS_RECV, (uint64_t)fd, (uint64_t)buf, (uint64_t)maxLen);
|
||||
}
|
||||
inline int closesocket(int fd) {
|
||||
return (int)syscall1(Montauk::SYS_CLOSESOCK, (uint64_t)fd);
|
||||
return (int)syscall1(montauk::abi::SYS_CLOSESOCK, (uint64_t)fd);
|
||||
}
|
||||
inline int sendto(int fd, const void* data, uint32_t len, uint32_t destIp, uint16_t destPort) {
|
||||
return (int)syscall5(Montauk::SYS_SENDTO, (uint64_t)fd, (uint64_t)data,
|
||||
return (int)syscall5(montauk::abi::SYS_SENDTO, (uint64_t)fd, (uint64_t)data,
|
||||
(uint64_t)len, (uint64_t)destIp, (uint64_t)destPort);
|
||||
}
|
||||
inline int recvfrom(int fd, void* buf, uint32_t maxLen, uint32_t* srcIp, uint16_t* srcPort) {
|
||||
return (int)syscall5(Montauk::SYS_RECVFROM, (uint64_t)fd, (uint64_t)buf,
|
||||
return (int)syscall5(montauk::abi::SYS_RECVFROM, (uint64_t)fd, (uint64_t)buf,
|
||||
(uint64_t)maxLen, (uint64_t)srcIp, (uint64_t)srcPort);
|
||||
}
|
||||
|
||||
// Generic IPC
|
||||
inline int dup_handle(int handle) {
|
||||
return (int)syscall1(Montauk::SYS_DUPHANDLE, (uint64_t)handle);
|
||||
return (int)syscall1(montauk::abi::SYS_DUPHANDLE, (uint64_t)handle);
|
||||
}
|
||||
inline uint32_t wait_handle(int handle, uint32_t wantedSignals, uint64_t timeoutMs = ~0ULL) {
|
||||
return (uint32_t)syscall3(Montauk::SYS_WAIT_HANDLE, (uint64_t)handle,
|
||||
return (uint32_t)syscall3(montauk::abi::SYS_WAIT_HANDLE, (uint64_t)handle,
|
||||
(uint64_t)wantedSignals, timeoutMs);
|
||||
}
|
||||
inline int stream_create(int* outReadHandle, int* outWriteHandle, uint32_t capacity = 0) {
|
||||
return (int)syscall3(Montauk::SYS_STREAM_CREATE, (uint64_t)outReadHandle,
|
||||
return (int)syscall3(montauk::abi::SYS_STREAM_CREATE, (uint64_t)outReadHandle,
|
||||
(uint64_t)outWriteHandle, (uint64_t)capacity);
|
||||
}
|
||||
inline int stream_read(int handle, void* buf, int maxLen) {
|
||||
return (int)syscall3(Montauk::SYS_STREAM_READ, (uint64_t)handle, (uint64_t)buf, (uint64_t)maxLen);
|
||||
return (int)syscall3(montauk::abi::SYS_STREAM_READ, (uint64_t)handle, (uint64_t)buf, (uint64_t)maxLen);
|
||||
}
|
||||
inline int stream_write(int handle, const void* data, int len) {
|
||||
return (int)syscall3(Montauk::SYS_STREAM_WRITE, (uint64_t)handle, (uint64_t)data, (uint64_t)len);
|
||||
return (int)syscall3(montauk::abi::SYS_STREAM_WRITE, (uint64_t)handle, (uint64_t)data, (uint64_t)len);
|
||||
}
|
||||
inline int mailbox_create(int* outSendHandle, int* outRecvHandle) {
|
||||
return (int)syscall2(Montauk::SYS_MAILBOX_CREATE, (uint64_t)outSendHandle, (uint64_t)outRecvHandle);
|
||||
return (int)syscall2(montauk::abi::SYS_MAILBOX_CREATE, (uint64_t)outSendHandle, (uint64_t)outRecvHandle);
|
||||
}
|
||||
inline int mailbox_send(int handle, uint32_t msgType, const void* data, uint16_t len, int attachHandle = -1) {
|
||||
return (int)syscall5(Montauk::SYS_MAILBOX_SEND, (uint64_t)handle, (uint64_t)msgType,
|
||||
return (int)syscall5(montauk::abi::SYS_MAILBOX_SEND, (uint64_t)handle, (uint64_t)msgType,
|
||||
(uint64_t)data, (uint64_t)len, (uint64_t)(int64_t)attachHandle);
|
||||
}
|
||||
inline int mailbox_recv(int handle, uint32_t* outMsgType, void* data,
|
||||
uint16_t* inOutLen, int* outAttachHandle = nullptr) {
|
||||
return (int)syscall5(Montauk::SYS_MAILBOX_RECV, (uint64_t)handle, (uint64_t)outMsgType,
|
||||
return (int)syscall5(montauk::abi::SYS_MAILBOX_RECV, (uint64_t)handle, (uint64_t)outMsgType,
|
||||
(uint64_t)data, (uint64_t)inOutLen, (uint64_t)outAttachHandle);
|
||||
}
|
||||
inline int waitset_create() {
|
||||
return (int)syscall0(Montauk::SYS_WAITSET_CREATE);
|
||||
return (int)syscall0(montauk::abi::SYS_WAITSET_CREATE);
|
||||
}
|
||||
inline int waitset_add(int waitsetHandle, int targetHandle, uint32_t signals) {
|
||||
return (int)syscall3(Montauk::SYS_WAITSET_ADD, (uint64_t)waitsetHandle,
|
||||
return (int)syscall3(montauk::abi::SYS_WAITSET_ADD, (uint64_t)waitsetHandle,
|
||||
(uint64_t)targetHandle, (uint64_t)signals);
|
||||
}
|
||||
inline int waitset_remove(int waitsetHandle, int index) {
|
||||
return (int)syscall2(Montauk::SYS_WAITSET_REMOVE, (uint64_t)waitsetHandle, (uint64_t)index);
|
||||
return (int)syscall2(montauk::abi::SYS_WAITSET_REMOVE, (uint64_t)waitsetHandle, (uint64_t)index);
|
||||
}
|
||||
inline int waitset_wait(int waitsetHandle, Montauk::IpcWaitResult* outReady, uint64_t timeoutMs = ~0ULL) {
|
||||
return (int)syscall3(Montauk::SYS_WAITSET_WAIT, (uint64_t)waitsetHandle, (uint64_t)outReady, timeoutMs);
|
||||
inline int waitset_wait(int waitsetHandle, montauk::abi::IpcWaitResult* outReady, uint64_t timeoutMs = ~0ULL) {
|
||||
return (int)syscall3(montauk::abi::SYS_WAITSET_WAIT, (uint64_t)waitsetHandle, (uint64_t)outReady, timeoutMs);
|
||||
}
|
||||
inline int proc_open(int pid) {
|
||||
return (int)syscall1(Montauk::SYS_PROC_OPEN, (uint64_t)pid);
|
||||
return (int)syscall1(montauk::abi::SYS_PROC_OPEN, (uint64_t)pid);
|
||||
}
|
||||
inline int surface_create(uint64_t byteSize) {
|
||||
return (int)syscall1(Montauk::SYS_SURFACE_CREATE, byteSize);
|
||||
return (int)syscall1(montauk::abi::SYS_SURFACE_CREATE, byteSize);
|
||||
}
|
||||
inline void* surface_map(int handle) {
|
||||
return (void*)syscall1(Montauk::SYS_SURFACE_MAP, (uint64_t)handle);
|
||||
return (void*)syscall1(montauk::abi::SYS_SURFACE_MAP, (uint64_t)handle);
|
||||
}
|
||||
inline int surface_resize(int handle, uint64_t newSize) {
|
||||
return (int)syscall2(Montauk::SYS_SURFACE_RESIZE, (uint64_t)handle, newSize);
|
||||
return (int)syscall2(montauk::abi::SYS_SURFACE_RESIZE, (uint64_t)handle, newSize);
|
||||
}
|
||||
|
||||
// Shared library support
|
||||
inline int load_lib(const char* path) {
|
||||
return (int)syscall1(Montauk::SYS_LOAD_LIB, (uint64_t)path);
|
||||
return (int)syscall1(montauk::abi::SYS_LOAD_LIB, (uint64_t)path);
|
||||
}
|
||||
inline int unload_lib(int handle) {
|
||||
return (int)syscall1(Montauk::SYS_UNLOAD_LIB, (uint64_t)handle);
|
||||
return (int)syscall1(montauk::abi::SYS_UNLOAD_LIB, (uint64_t)handle);
|
||||
}
|
||||
inline void* dlsym(int handle, uint64_t symbolOffset) {
|
||||
return (void*)syscall2(Montauk::SYS_DLSYM, (uint64_t)handle, symbolOffset);
|
||||
return (void*)syscall2(montauk::abi::SYS_DLSYM, (uint64_t)handle, symbolOffset);
|
||||
}
|
||||
inline uint64_t get_libbase(int handle) {
|
||||
return (uint64_t)syscall1(Montauk::SYS_GETLIBBASE, (uint64_t)handle);
|
||||
return (uint64_t)syscall1(montauk::abi::SYS_GETLIBBASE, (uint64_t)handle);
|
||||
}
|
||||
|
||||
// Crash report retrieval
|
||||
inline int crash_report(Montauk::CrashReportInfo* out) {
|
||||
return (int)syscall1(Montauk::SYS_CRASH_REPORT, (uint64_t)out);
|
||||
inline int crash_report(montauk::abi::CrashReportInfo* out) {
|
||||
return (int)syscall1(montauk::abi::SYS_CRASH_REPORT, (uint64_t)out);
|
||||
}
|
||||
|
||||
// Process management
|
||||
inline void waitpid(int pid) { syscall1(Montauk::SYS_WAITPID, (uint64_t)pid); }
|
||||
inline void waitpid(int pid) { syscall1(montauk::abi::SYS_WAITPID, (uint64_t)pid); }
|
||||
|
||||
// Framebuffer
|
||||
inline void fb_info(Montauk::FbInfo* info) { syscall1(Montauk::SYS_FBINFO, (uint64_t)info); }
|
||||
inline void* fb_map() { return (void*)syscall0(Montauk::SYS_FBMAP); }
|
||||
inline void fb_info(montauk::abi::FbInfo* info) { syscall1(montauk::abi::SYS_FBINFO, (uint64_t)info); }
|
||||
inline void* fb_map() { return (void*)syscall0(montauk::abi::SYS_FBMAP); }
|
||||
|
||||
// Arguments
|
||||
inline int getargs(char* buf, uint64_t maxLen) {
|
||||
return (int)syscall2(Montauk::SYS_GETARGS, (uint64_t)buf, maxLen);
|
||||
return (int)syscall2(montauk::abi::SYS_GETARGS, (uint64_t)buf, maxLen);
|
||||
}
|
||||
|
||||
// Terminal
|
||||
inline void termsize(int* cols, int* rows) {
|
||||
uint64_t r = (uint64_t)syscall0(Montauk::SYS_TERMSIZE);
|
||||
uint64_t r = (uint64_t)syscall0(montauk::abi::SYS_TERMSIZE);
|
||||
if (cols) *cols = (int)(r & 0xFFFFFFFF);
|
||||
if (rows) *rows = (int)(r >> 32);
|
||||
}
|
||||
|
||||
inline void termscale(int scale_x, int scale_y) {
|
||||
syscall2(Montauk::SYS_TERMSCALE, (uint64_t)scale_x, (uint64_t)scale_y);
|
||||
syscall2(montauk::abi::SYS_TERMSCALE, (uint64_t)scale_x, (uint64_t)scale_y);
|
||||
}
|
||||
|
||||
inline void get_termscale(int* scale_x, int* scale_y) {
|
||||
uint64_t r = (uint64_t)syscall2(Montauk::SYS_TERMSCALE, 0, 0);
|
||||
uint64_t r = (uint64_t)syscall2(montauk::abi::SYS_TERMSCALE, 0, 0);
|
||||
if (scale_x) *scale_x = (int)(r & 0xFFFFFFFF);
|
||||
if (scale_y) *scale_y = (int)(r >> 32);
|
||||
}
|
||||
|
||||
// Timekeeping (wall-clock)
|
||||
inline void gettime(Montauk::DateTime* out) { syscall1(Montauk::SYS_GETTIME, (uint64_t)out); }
|
||||
inline void gettime(montauk::abi::DateTime* out) { syscall1(montauk::abi::SYS_GETTIME, (uint64_t)out); }
|
||||
|
||||
// Timezone offset (total minutes from UTC)
|
||||
inline void settz(int offset_minutes) { syscall1(Montauk::SYS_SETTZ, (uint64_t)(int64_t)offset_minutes); }
|
||||
inline int gettz() { return (int)syscall0(Montauk::SYS_GETTZ); }
|
||||
inline void settz(int offset_minutes) { syscall1(montauk::abi::SYS_SETTZ, (uint64_t)(int64_t)offset_minutes); }
|
||||
inline int gettz() { return (int)syscall0(montauk::abi::SYS_GETTZ); }
|
||||
|
||||
// Random number generation
|
||||
inline int64_t getrandom(void* buf, uint32_t len) {
|
||||
return syscall2(Montauk::SYS_GETRANDOM, (uint64_t)buf, (uint64_t)len);
|
||||
return syscall2(montauk::abi::SYS_GETRANDOM, (uint64_t)buf, (uint64_t)len);
|
||||
}
|
||||
|
||||
// Power management
|
||||
[[noreturn]] inline void reset() {
|
||||
syscall0(Montauk::SYS_RESET);
|
||||
syscall0(montauk::abi::SYS_RESET);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
[[noreturn]] inline void shutdown() {
|
||||
syscall0(Montauk::SYS_SHUTDOWN);
|
||||
syscall0(montauk::abi::SYS_SHUTDOWN);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
inline int suspend() {
|
||||
return (int)syscall0(Montauk::SYS_SUSPEND);
|
||||
return (int)syscall0(montauk::abi::SYS_SUSPEND);
|
||||
}
|
||||
|
||||
// Graceful power-off request channel. The desktop posts a pending action
|
||||
// (Montauk::POWER_REQ_SHUTDOWN / POWER_REQ_REBOOT) then exits; login.elf
|
||||
// (montauk::abi::POWER_REQ_SHUTDOWN / POWER_REQ_REBOOT) then exits; login.elf
|
||||
// reads it with POWER_REQ_QUERY (read-and-clear), runs the shutdown stages,
|
||||
// and finally calls shutdown()/reset(). Returns the pending action for a
|
||||
// query, or 0 when posting one.
|
||||
inline int power_request(int action) {
|
||||
return (int)syscall1(Montauk::SYS_POWER_REQUEST, (uint64_t)(int64_t)action);
|
||||
return (int)syscall1(montauk::abi::SYS_POWER_REQUEST, (uint64_t)(int64_t)action);
|
||||
}
|
||||
|
||||
// Mouse
|
||||
inline void mouse_state(Montauk::MouseState* out) { syscall1(Montauk::SYS_MOUSESTATE, (uint64_t)out); }
|
||||
inline void mouse_state(montauk::abi::MouseState* out) { syscall1(montauk::abi::SYS_MOUSESTATE, (uint64_t)out); }
|
||||
inline void set_mouse_bounds(int32_t maxX, int32_t maxY) {
|
||||
syscall2(Montauk::SYS_SETMOUSEBOUNDS, (uint64_t)maxX, (uint64_t)maxY);
|
||||
syscall2(montauk::abi::SYS_SETMOUSEBOUNDS, (uint64_t)maxX, (uint64_t)maxY);
|
||||
}
|
||||
|
||||
// Kernel log
|
||||
inline int64_t read_klog(char* buf, uint64_t size) {
|
||||
return syscall2(Montauk::SYS_KLOG, (uint64_t)buf, size);
|
||||
return syscall2(montauk::abi::SYS_KLOG, (uint64_t)buf, size);
|
||||
}
|
||||
|
||||
// I/O redirection
|
||||
inline int spawn_redir(const char* path, const char* args = nullptr) {
|
||||
return (int)syscall2(Montauk::SYS_SPAWN_REDIR, (uint64_t)path, (uint64_t)args);
|
||||
return (int)syscall2(montauk::abi::SYS_SPAWN_REDIR, (uint64_t)path, (uint64_t)args);
|
||||
}
|
||||
inline int childio_read(int childPid, char* buf, int maxLen) {
|
||||
return (int)syscall3(Montauk::SYS_CHILDIO_READ, (uint64_t)childPid, (uint64_t)buf, (uint64_t)maxLen);
|
||||
return (int)syscall3(montauk::abi::SYS_CHILDIO_READ, (uint64_t)childPid, (uint64_t)buf, (uint64_t)maxLen);
|
||||
}
|
||||
inline int childio_write(int childPid, const char* data, int len) {
|
||||
return (int)syscall3(Montauk::SYS_CHILDIO_WRITE, (uint64_t)childPid, (uint64_t)data, (uint64_t)len);
|
||||
return (int)syscall3(montauk::abi::SYS_CHILDIO_WRITE, (uint64_t)childPid, (uint64_t)data, (uint64_t)len);
|
||||
}
|
||||
inline int childio_writekey(int childPid, const Montauk::KeyEvent* key) {
|
||||
return (int)syscall2(Montauk::SYS_CHILDIO_WRITEKEY, (uint64_t)childPid, (uint64_t)key);
|
||||
inline int childio_writekey(int childPid, const montauk::abi::KeyEvent* key) {
|
||||
return (int)syscall2(montauk::abi::SYS_CHILDIO_WRITEKEY, (uint64_t)childPid, (uint64_t)key);
|
||||
}
|
||||
inline int childio_settermsz(int childPid, int cols, int rows) {
|
||||
return (int)syscall3(Montauk::SYS_CHILDIO_SETTERMSZ, (uint64_t)childPid, (uint64_t)cols, (uint64_t)rows);
|
||||
return (int)syscall3(montauk::abi::SYS_CHILDIO_SETTERMSZ, (uint64_t)childPid, (uint64_t)cols, (uint64_t)rows);
|
||||
}
|
||||
|
||||
// Process listing / kill
|
||||
inline int proclist(Montauk::ProcInfo* buf, int max) {
|
||||
return (int)syscall2(Montauk::SYS_PROCLIST, (uint64_t)buf, (uint64_t)max);
|
||||
inline int proclist(montauk::abi::ProcInfo* buf, int max) {
|
||||
return (int)syscall2(montauk::abi::SYS_PROCLIST, (uint64_t)buf, (uint64_t)max);
|
||||
}
|
||||
inline int kill(int pid) {
|
||||
return (int)syscall1(Montauk::SYS_KILL, (uint64_t)pid);
|
||||
return (int)syscall1(montauk::abi::SYS_KILL, (uint64_t)pid);
|
||||
}
|
||||
inline int devlist(Montauk::DevInfo* buf, int max) {
|
||||
return (int)syscall2(Montauk::SYS_DEVLIST, (uint64_t)buf, (uint64_t)max);
|
||||
inline int devlist(montauk::abi::DevInfo* buf, int max) {
|
||||
return (int)syscall2(montauk::abi::SYS_DEVLIST, (uint64_t)buf, (uint64_t)max);
|
||||
}
|
||||
inline int diskinfo(Montauk::DiskInfo* buf, int port) {
|
||||
return (int)syscall2(Montauk::SYS_DISKINFO, (uint64_t)buf, (uint64_t)port);
|
||||
inline int diskinfo(montauk::abi::DiskInfo* buf, int port) {
|
||||
return (int)syscall2(montauk::abi::SYS_DISKINFO, (uint64_t)buf, (uint64_t)port);
|
||||
}
|
||||
|
||||
// Partition table
|
||||
inline int partlist(Montauk::PartInfo* buf, int max) {
|
||||
return (int)syscall2(Montauk::SYS_PARTLIST, (uint64_t)buf, (uint64_t)max);
|
||||
inline int partlist(montauk::abi::PartInfo* buf, int max) {
|
||||
return (int)syscall2(montauk::abi::SYS_PARTLIST, (uint64_t)buf, (uint64_t)max);
|
||||
}
|
||||
|
||||
// Raw block device I/O (driver-agnostic)
|
||||
inline int64_t disk_read(int blockDev, uint64_t lba, uint32_t sectorCount, void* buf) {
|
||||
return syscall4(Montauk::SYS_DISKREAD, (uint64_t)blockDev, lba,
|
||||
return syscall4(montauk::abi::SYS_DISKREAD, (uint64_t)blockDev, lba,
|
||||
(uint64_t)sectorCount, (uint64_t)buf);
|
||||
}
|
||||
inline int64_t disk_write(int blockDev, uint64_t lba, uint32_t sectorCount, const void* buf) {
|
||||
return syscall4(Montauk::SYS_DISKWRITE, (uint64_t)blockDev, lba,
|
||||
return syscall4(montauk::abi::SYS_DISKWRITE, (uint64_t)blockDev, lba,
|
||||
(uint64_t)sectorCount, (uint64_t)buf);
|
||||
}
|
||||
|
||||
// GPT management
|
||||
inline int gpt_init(int blockDev) {
|
||||
return (int)syscall1(Montauk::SYS_GPTINIT, (uint64_t)blockDev);
|
||||
return (int)syscall1(montauk::abi::SYS_GPTINIT, (uint64_t)blockDev);
|
||||
}
|
||||
inline int gpt_add(const Montauk::GptAddParams* params) {
|
||||
return (int)syscall1(Montauk::SYS_GPTADD, (uint64_t)params);
|
||||
inline int gpt_add(const montauk::abi::GptAddParams* params) {
|
||||
return (int)syscall1(montauk::abi::SYS_GPTADD, (uint64_t)params);
|
||||
}
|
||||
inline int fs_mount(int partIndex, int driveNum) {
|
||||
return (int)syscall2(Montauk::SYS_FSMOUNT, (uint64_t)partIndex, (uint64_t)driveNum);
|
||||
return (int)syscall2(montauk::abi::SYS_FSMOUNT, (uint64_t)partIndex, (uint64_t)driveNum);
|
||||
}
|
||||
// Flush all block-device write caches and cleanly unmount disk-backed
|
||||
// volumes ahead of power-off. Returns the number of volumes unmounted.
|
||||
inline int fs_sync() {
|
||||
return (int)syscall0(Montauk::SYS_FS_SYNC);
|
||||
return (int)syscall0(montauk::abi::SYS_FS_SYNC);
|
||||
}
|
||||
inline int fs_format(const Montauk::FsFormatParams* params) {
|
||||
return (int)syscall1(Montauk::SYS_FSFORMAT, (uint64_t)params);
|
||||
inline int fs_format(const montauk::abi::FsFormatParams* params) {
|
||||
return (int)syscall1(montauk::abi::SYS_FSFORMAT, (uint64_t)params);
|
||||
}
|
||||
|
||||
// Audio
|
||||
inline int audio_open(uint32_t sampleRate, uint8_t channels, uint8_t bitsPerSample) {
|
||||
return (int)syscall3(Montauk::SYS_AUDIOOPEN, (uint64_t)sampleRate,
|
||||
return (int)syscall3(montauk::abi::SYS_AUDIOOPEN, (uint64_t)sampleRate,
|
||||
(uint64_t)channels, (uint64_t)bitsPerSample);
|
||||
}
|
||||
inline void audio_close(int handle) {
|
||||
syscall1(Montauk::SYS_AUDIOCLOSE, (uint64_t)handle);
|
||||
syscall1(montauk::abi::SYS_AUDIOCLOSE, (uint64_t)handle);
|
||||
}
|
||||
inline int audio_write(int handle, const void* data, uint32_t size) {
|
||||
return (int)syscall3(Montauk::SYS_AUDIOWRITE, (uint64_t)handle,
|
||||
return (int)syscall3(montauk::abi::SYS_AUDIOWRITE, (uint64_t)handle,
|
||||
(uint64_t)data, (uint64_t)size);
|
||||
}
|
||||
inline int audio_ctl(int handle, int cmd, int value) {
|
||||
return (int)syscall3(Montauk::SYS_AUDIOCTL, (uint64_t)handle,
|
||||
return (int)syscall3(montauk::abi::SYS_AUDIOCTL, (uint64_t)handle,
|
||||
(uint64_t)cmd, (uint64_t)value);
|
||||
}
|
||||
inline int audio_set_volume(int handle, int percent) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_SET_VOLUME, percent);
|
||||
return audio_ctl(handle, montauk::abi::AUDIO_CTL_SET_VOLUME, percent);
|
||||
}
|
||||
inline int audio_get_volume(int handle) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_GET_VOLUME, 0);
|
||||
return audio_ctl(handle, montauk::abi::AUDIO_CTL_GET_VOLUME, 0);
|
||||
}
|
||||
inline int audio_get_pos(int handle) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_GET_POS, 0);
|
||||
return audio_ctl(handle, montauk::abi::AUDIO_CTL_GET_POS, 0);
|
||||
}
|
||||
inline int audio_pause(int handle) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_PAUSE, 1);
|
||||
return audio_ctl(handle, montauk::abi::AUDIO_CTL_PAUSE, 1);
|
||||
}
|
||||
inline int audio_resume(int handle) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_PAUSE, 0);
|
||||
return audio_ctl(handle, montauk::abi::AUDIO_CTL_PAUSE, 0);
|
||||
}
|
||||
inline int audio_get_output(int handle) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_GET_OUTPUT, 0);
|
||||
return audio_ctl(handle, montauk::abi::AUDIO_CTL_GET_OUTPUT, 0);
|
||||
}
|
||||
inline int audio_bt_status(int handle) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_BT_STATUS, 0);
|
||||
return audio_ctl(handle, montauk::abi::AUDIO_CTL_BT_STATUS, 0);
|
||||
}
|
||||
inline int audio_set_master_volume(int percent) {
|
||||
return audio_ctl(-1, Montauk::AUDIO_CTL_SET_MASTER_VOLUME, percent);
|
||||
return audio_ctl(-1, montauk::abi::AUDIO_CTL_SET_MASTER_VOLUME, percent);
|
||||
}
|
||||
inline int audio_get_master_volume() {
|
||||
return audio_ctl(-1, Montauk::AUDIO_CTL_GET_MASTER_VOLUME, 0);
|
||||
return audio_ctl(-1, montauk::abi::AUDIO_CTL_GET_MASTER_VOLUME, 0);
|
||||
}
|
||||
inline int audio_set_master_mute(bool muted) {
|
||||
return audio_ctl(-1, Montauk::AUDIO_CTL_SET_MASTER_MUTE, muted ? 1 : 0);
|
||||
return audio_ctl(-1, montauk::abi::AUDIO_CTL_SET_MASTER_MUTE, muted ? 1 : 0);
|
||||
}
|
||||
inline int audio_get_master_mute() {
|
||||
return audio_ctl(-1, Montauk::AUDIO_CTL_GET_MASTER_MUTE, 0);
|
||||
return audio_ctl(-1, montauk::abi::AUDIO_CTL_GET_MASTER_MUTE, 0);
|
||||
}
|
||||
inline int audio_set_mute(int handle, bool muted) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_SET_MUTE, muted ? 1 : 0);
|
||||
return audio_ctl(handle, montauk::abi::AUDIO_CTL_SET_MUTE, muted ? 1 : 0);
|
||||
}
|
||||
inline int audio_get_mute(int handle) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_GET_MUTE, 0);
|
||||
return audio_ctl(handle, montauk::abi::AUDIO_CTL_GET_MUTE, 0);
|
||||
}
|
||||
inline int audio_list(Montauk::AudioStreamInfo* buf, int maxCount) {
|
||||
return (int)syscall2(Montauk::SYS_AUDIOLIST, (uint64_t)buf, (uint64_t)maxCount);
|
||||
inline int audio_list(montauk::abi::AudioStreamInfo* buf, int maxCount) {
|
||||
return (int)syscall2(montauk::abi::SYS_AUDIOLIST, (uint64_t)buf, (uint64_t)maxCount);
|
||||
}
|
||||
// Returns the current mixer state serial. With timeoutMs > 0 the call
|
||||
// blocks until the serial differs from `prevSerial` or the timeout
|
||||
// elapses. With timeoutMs == 0 it returns immediately (cheap snapshot).
|
||||
inline uint64_t audio_wait(uint64_t prevSerial, uint64_t timeoutMs) {
|
||||
return syscall2(Montauk::SYS_AUDIOWAIT, prevSerial, timeoutMs);
|
||||
return syscall2(montauk::abi::SYS_AUDIOWAIT, prevSerial, timeoutMs);
|
||||
}
|
||||
|
||||
// Bluetooth
|
||||
inline int bt_scan(Montauk::BtScanResult* buf, int maxCount, uint32_t timeoutMs) {
|
||||
return (int)syscall3(Montauk::SYS_BTSCAN, (uint64_t)buf, (uint64_t)maxCount, (uint64_t)timeoutMs);
|
||||
inline int bt_scan(montauk::abi::BtScanResult* buf, int maxCount, uint32_t timeoutMs) {
|
||||
return (int)syscall3(montauk::abi::SYS_BTSCAN, (uint64_t)buf, (uint64_t)maxCount, (uint64_t)timeoutMs);
|
||||
}
|
||||
inline int bt_connect(const uint8_t* bdAddr) {
|
||||
return (int)syscall1(Montauk::SYS_BTCONNECT, (uint64_t)bdAddr);
|
||||
return (int)syscall1(montauk::abi::SYS_BTCONNECT, (uint64_t)bdAddr);
|
||||
}
|
||||
inline int bt_disconnect(const uint8_t* bdAddr) {
|
||||
return (int)syscall1(Montauk::SYS_BTDISCONNECT, (uint64_t)bdAddr);
|
||||
return (int)syscall1(montauk::abi::SYS_BTDISCONNECT, (uint64_t)bdAddr);
|
||||
}
|
||||
// Change the adapter's BD_ADDR. bdAddr is a 6-byte buffer with bdAddr[0] as
|
||||
// the least-significant octet (same order as BtAdapterInfo::bdAddr). Returns
|
||||
// 0 on success, negative on failure. Persist separately to bluetooth.toml.
|
||||
inline int bt_set_addr(const uint8_t* bdAddr) {
|
||||
return (int)syscall1(Montauk::SYS_BTSETADDR, (uint64_t)bdAddr);
|
||||
return (int)syscall1(montauk::abi::SYS_BTSETADDR, (uint64_t)bdAddr);
|
||||
}
|
||||
// List bonded (paired) devices. Returns count written to buf (may be 0).
|
||||
inline int bt_bonds(Montauk::BtBondInfo* buf, int maxCount) {
|
||||
return (int)syscall2(Montauk::SYS_BTBONDS, (uint64_t)buf, (uint64_t)maxCount);
|
||||
inline int bt_bonds(montauk::abi::BtBondInfo* buf, int maxCount) {
|
||||
return (int)syscall2(montauk::abi::SYS_BTBONDS, (uint64_t)buf, (uint64_t)maxCount);
|
||||
}
|
||||
// Forget a paired device (removes the bond; it must re-pair next time).
|
||||
inline int bt_forget(const uint8_t* bdAddr) {
|
||||
return (int)syscall1(Montauk::SYS_BTFORGET, (uint64_t)bdAddr);
|
||||
return (int)syscall1(montauk::abi::SYS_BTFORGET, (uint64_t)bdAddr);
|
||||
}
|
||||
inline int bt_list(Montauk::BtDevInfo* buf, int maxCount) {
|
||||
return (int)syscall2(Montauk::SYS_BTLIST, (uint64_t)buf, (uint64_t)maxCount);
|
||||
inline int bt_list(montauk::abi::BtDevInfo* buf, int maxCount) {
|
||||
return (int)syscall2(montauk::abi::SYS_BTLIST, (uint64_t)buf, (uint64_t)maxCount);
|
||||
}
|
||||
inline int bt_info(Montauk::BtAdapterInfo* buf) {
|
||||
return (int)syscall1(Montauk::SYS_BTINFO, (uint64_t)buf);
|
||||
inline int bt_info(montauk::abi::BtAdapterInfo* buf) {
|
||||
return (int)syscall1(montauk::abi::SYS_BTINFO, (uint64_t)buf);
|
||||
}
|
||||
|
||||
// Kernel introspection
|
||||
inline void memstats(Montauk::MemStats* out) { syscall1(Montauk::SYS_MEMSTATS, (uint64_t)out); }
|
||||
inline void memstats(montauk::abi::MemStats* out) { syscall1(montauk::abi::SYS_MEMSTATS, (uint64_t)out); }
|
||||
|
||||
// User management
|
||||
inline int setuser(int pid, const char* name) {
|
||||
return (int)syscall2(Montauk::SYS_SETUSER, (uint64_t)pid, (uint64_t)name);
|
||||
return (int)syscall2(montauk::abi::SYS_SETUSER, (uint64_t)pid, (uint64_t)name);
|
||||
}
|
||||
inline int getuser(char* buf, uint64_t maxLen) {
|
||||
return (int)syscall2(Montauk::SYS_GETUSER, (uint64_t)buf, maxLen);
|
||||
return (int)syscall2(montauk::abi::SYS_GETUSER, (uint64_t)buf, maxLen);
|
||||
}
|
||||
|
||||
// Clipboard
|
||||
inline int clipboard_set_text(const char* data, uint32_t len) {
|
||||
return (int)syscall2(Montauk::SYS_CLIPBOARD_SET_TEXT, (uint64_t)data, (uint64_t)len);
|
||||
return (int)syscall2(montauk::abi::SYS_CLIPBOARD_SET_TEXT, (uint64_t)data, (uint64_t)len);
|
||||
}
|
||||
inline int clipboard_get_info(Montauk::ClipboardInfo* out) {
|
||||
return (int)syscall1(Montauk::SYS_CLIPBOARD_GET_INFO, (uint64_t)out);
|
||||
inline int clipboard_get_info(montauk::abi::ClipboardInfo* out) {
|
||||
return (int)syscall1(montauk::abi::SYS_CLIPBOARD_GET_INFO, (uint64_t)out);
|
||||
}
|
||||
inline int clipboard_get_text(char* buf, uint32_t bufLen, uint32_t* outLen,
|
||||
uint64_t* outSerial = nullptr) {
|
||||
return (int)syscall4(Montauk::SYS_CLIPBOARD_GET_TEXT, (uint64_t)buf, (uint64_t)bufLen,
|
||||
return (int)syscall4(montauk::abi::SYS_CLIPBOARD_GET_TEXT, (uint64_t)buf, (uint64_t)bufLen,
|
||||
(uint64_t)outLen, (uint64_t)outSerial);
|
||||
}
|
||||
inline int clipboard_clear() {
|
||||
return (int)syscall0(Montauk::SYS_CLIPBOARD_CLEAR);
|
||||
return (int)syscall0(montauk::abi::SYS_CLIPBOARD_CLEAR);
|
||||
}
|
||||
|
||||
// Window server
|
||||
inline int win_create(const char* title, int w, int h, Montauk::WinCreateResult* result) {
|
||||
return (int)syscall4(Montauk::SYS_WINCREATE, (uint64_t)title, (uint64_t)w, (uint64_t)h, (uint64_t)result);
|
||||
inline int win_create(const char* title, int w, int h, montauk::abi::WinCreateResult* result) {
|
||||
return (int)syscall4(montauk::abi::SYS_WINCREATE, (uint64_t)title, (uint64_t)w, (uint64_t)h, (uint64_t)result);
|
||||
}
|
||||
inline int win_destroy(int id) {
|
||||
return (int)syscall1(Montauk::SYS_WINDESTROY, (uint64_t)id);
|
||||
return (int)syscall1(montauk::abi::SYS_WINDESTROY, (uint64_t)id);
|
||||
}
|
||||
inline uint64_t win_present(int id) {
|
||||
return (uint64_t)syscall1(Montauk::SYS_WINPRESENT, (uint64_t)id);
|
||||
return (uint64_t)syscall1(montauk::abi::SYS_WINPRESENT, (uint64_t)id);
|
||||
}
|
||||
inline int win_poll(int id, Montauk::WinEvent* event) {
|
||||
return (int)syscall2(Montauk::SYS_WINPOLL, (uint64_t)id, (uint64_t)event);
|
||||
inline int win_poll(int id, montauk::abi::WinEvent* event) {
|
||||
return (int)syscall2(montauk::abi::SYS_WINPOLL, (uint64_t)id, (uint64_t)event);
|
||||
}
|
||||
inline int win_enumerate(Montauk::WinInfo* info, int max) {
|
||||
return (int)syscall2(Montauk::SYS_WINENUM, (uint64_t)info, (uint64_t)max);
|
||||
inline int win_enumerate(montauk::abi::WinInfo* info, int max) {
|
||||
return (int)syscall2(montauk::abi::SYS_WINENUM, (uint64_t)info, (uint64_t)max);
|
||||
}
|
||||
inline uint64_t win_map(int id) {
|
||||
return (uint64_t)syscall1(Montauk::SYS_WINMAP, (uint64_t)id);
|
||||
return (uint64_t)syscall1(montauk::abi::SYS_WINMAP, (uint64_t)id);
|
||||
}
|
||||
inline int win_unmap(int id) {
|
||||
return (int)syscall1(Montauk::SYS_WINUNMAP, (uint64_t)id);
|
||||
return (int)syscall1(montauk::abi::SYS_WINUNMAP, (uint64_t)id);
|
||||
}
|
||||
inline int win_sendevent(int id, const Montauk::WinEvent* event) {
|
||||
return (int)syscall2(Montauk::SYS_WINSENDEVENT, (uint64_t)id, (uint64_t)event);
|
||||
inline int win_sendevent(int id, const montauk::abi::WinEvent* event) {
|
||||
return (int)syscall2(montauk::abi::SYS_WINSENDEVENT, (uint64_t)id, (uint64_t)event);
|
||||
}
|
||||
inline uint64_t win_resize(int id, int w, int h) {
|
||||
return (uint64_t)syscall3(Montauk::SYS_WINRESIZE, (uint64_t)id, (uint64_t)w, (uint64_t)h);
|
||||
return (uint64_t)syscall3(montauk::abi::SYS_WINRESIZE, (uint64_t)id, (uint64_t)w, (uint64_t)h);
|
||||
}
|
||||
inline int win_setscale(int scale) {
|
||||
return (int)syscall1(Montauk::SYS_WINSETSCALE, (uint64_t)scale);
|
||||
return (int)syscall1(montauk::abi::SYS_WINSETSCALE, (uint64_t)scale);
|
||||
}
|
||||
inline int win_getscale() {
|
||||
return (int)syscall0(Montauk::SYS_WINGETSCALE);
|
||||
return (int)syscall0(montauk::abi::SYS_WINGETSCALE);
|
||||
}
|
||||
inline int win_setcursor(int id, int cursor) {
|
||||
return (int)syscall2(Montauk::SYS_WINSETCURSOR, (uint64_t)id, (uint64_t)cursor);
|
||||
return (int)syscall2(montauk::abi::SYS_WINSETCURSOR, (uint64_t)id, (uint64_t)cursor);
|
||||
}
|
||||
inline int win_setflags(int id, uint32_t flags) {
|
||||
return (int)syscall2(Montauk::SYS_WINSETFLAGS, (uint64_t)id, (uint64_t)flags);
|
||||
return (int)syscall2(montauk::abi::SYS_WINSETFLAGS, (uint64_t)id, (uint64_t)flags);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace montauk {
|
||||
// Terminate the calling thread. Never returns. If called by the main
|
||||
// thread this is equivalent to exit() (the whole process exits).
|
||||
[[noreturn]] inline void thread_exit(int code = 0) {
|
||||
syscall1(Montauk::SYS_THREAD_EXIT, (uint64_t)code);
|
||||
syscall1(montauk::abi::SYS_THREAD_EXIT, (uint64_t)code);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace montauk {
|
||||
ctx->stack_base = stack;
|
||||
|
||||
uint64_t stack_top = ((uint64_t)stack + stack_bytes) & ~0xFULL;
|
||||
int tid = (int)syscall3(Montauk::SYS_THREAD_SPAWN,
|
||||
int tid = (int)syscall3(montauk::abi::SYS_THREAD_SPAWN,
|
||||
(uint64_t)&detail::thread_trampoline,
|
||||
(uint64_t)ctx, stack_top);
|
||||
if (tid < 0) {
|
||||
@@ -101,13 +101,13 @@ namespace montauk {
|
||||
// success (with the thread's exit code in *out_code if non-null) or
|
||||
// -1 if `tid` is not a joinable sibling.
|
||||
inline int thread_join(int tid, int* out_code = nullptr) {
|
||||
return (int)syscall2(Montauk::SYS_THREAD_JOIN,
|
||||
return (int)syscall2(montauk::abi::SYS_THREAD_JOIN,
|
||||
(uint64_t)tid, (uint64_t)out_code);
|
||||
}
|
||||
|
||||
// Return the calling thread's TID (== getpid() for the main thread).
|
||||
inline int thread_self() {
|
||||
return (int)syscall0(Montauk::SYS_THREAD_SELF);
|
||||
return (int)syscall0(montauk::abi::SYS_THREAD_SELF);
|
||||
}
|
||||
|
||||
// Lightweight mutex backed by a single atomic word + the kernel
|
||||
|
||||
@@ -218,7 +218,7 @@ inline void parse_key_value_lines(char* text, Fn fn) {
|
||||
|
||||
inline void now_string(char* out, int out_len) {
|
||||
if (out == nullptr || out_len <= 0) return;
|
||||
Montauk::DateTime dt = {};
|
||||
montauk::abi::DateTime dt = {};
|
||||
montauk::gettime(&dt);
|
||||
snprintf(out, (size_t)out_len, "%04d-%02d-%02d %02d:%02d:%02d",
|
||||
(int)dt.Year, (int)dt.Month, (int)dt.Day,
|
||||
@@ -1010,11 +1010,11 @@ inline bool daemon_is_running(int* out_pid) {
|
||||
|
||||
int handle = montauk::proc_open(pid);
|
||||
if (handle < 0) return false;
|
||||
uint32_t sig = montauk::wait_handle(handle, Montauk::IPC_SIGNAL_EXITED, 0);
|
||||
uint32_t sig = montauk::wait_handle(handle, montauk::abi::IPC_SIGNAL_EXITED, 0);
|
||||
montauk::close(handle);
|
||||
if (sig & Montauk::IPC_SIGNAL_EXITED) return false;
|
||||
if (sig & montauk::abi::IPC_SIGNAL_EXITED) return false;
|
||||
|
||||
Montauk::ProcInfo procs[128];
|
||||
montauk::abi::ProcInfo procs[128];
|
||||
int proc_count = montauk::proclist(procs, (int)(sizeof(procs) / sizeof(procs[0])));
|
||||
bool matched = false;
|
||||
for (int i = 0; i < proc_count; i++) {
|
||||
@@ -1289,9 +1289,9 @@ inline int send_all_plain(int fd, const uint8_t* data, int len) {
|
||||
if (n < 0) return -1;
|
||||
|
||||
uint32_t sig = montauk::wait_handle(fd,
|
||||
Montauk::IPC_SIGNAL_WRITABLE | Montauk::IPC_SIGNAL_PEER_CLOSED,
|
||||
montauk::abi::IPC_SIGNAL_WRITABLE | montauk::abi::IPC_SIGNAL_PEER_CLOSED,
|
||||
1000);
|
||||
if (sig & Montauk::IPC_SIGNAL_PEER_CLOSED) return -1;
|
||||
if (sig & montauk::abi::IPC_SIGNAL_PEER_CLOSED) return -1;
|
||||
if (montauk::get_milliseconds() >= deadline) return -1;
|
||||
montauk::sleep_ms(1);
|
||||
}
|
||||
@@ -1379,13 +1379,13 @@ inline int recv_http_plain(int fd, char* buf, int cap) {
|
||||
if (montauk::get_milliseconds() >= deadline) break;
|
||||
|
||||
uint32_t sig = montauk::wait_handle(fd,
|
||||
Montauk::IPC_SIGNAL_READABLE | Montauk::IPC_SIGNAL_PEER_CLOSED,
|
||||
montauk::abi::IPC_SIGNAL_READABLE | montauk::abi::IPC_SIGNAL_PEER_CLOSED,
|
||||
1000);
|
||||
if (sig == 0) continue;
|
||||
|
||||
if (sig & Montauk::IPC_SIGNAL_PEER_CLOSED)
|
||||
if (sig & montauk::abi::IPC_SIGNAL_PEER_CLOSED)
|
||||
peer_closed = true;
|
||||
if (!(sig & Montauk::IPC_SIGNAL_READABLE)) {
|
||||
if (!(sig & montauk::abi::IPC_SIGNAL_READABLE)) {
|
||||
if (peer_closed) break;
|
||||
continue;
|
||||
}
|
||||
@@ -1525,7 +1525,7 @@ inline bool ipp_http_post(const IppUri* uri,
|
||||
tas, raw, HTTP_RESPONSE_MAX - 1);
|
||||
if (tas.anchors) free(tas.anchors);
|
||||
} else {
|
||||
int fd = montauk::socket(Montauk::SOCK_TCP);
|
||||
int fd = montauk::socket(montauk::abi::SOCK_TCP);
|
||||
if (fd < 0) {
|
||||
free(raw);
|
||||
free(req);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -147,7 +147,7 @@ TrustAnchors load_trust_anchors() {
|
||||
}
|
||||
|
||||
void get_bearssl_time(uint32_t* days, uint32_t* seconds) {
|
||||
Montauk::DateTime dt;
|
||||
montauk::abi::DateTime dt;
|
||||
montauk::gettime(&dt);
|
||||
int y = dt.Year, m = dt.Month, d = dt.Day;
|
||||
uint32_t total = 365u * (uint32_t)y
|
||||
@@ -244,7 +244,7 @@ int https_fetch(const char* host, uint32_t ip, uint16_t port,
|
||||
const TrustAnchors& tas,
|
||||
char* respBuf, int respMax,
|
||||
AbortCheckFn abort_check) {
|
||||
int fd = montauk::socket(Montauk::SOCK_TCP);
|
||||
int fd = montauk::socket(montauk::abi::SOCK_TCP);
|
||||
if (fd < 0) return -1;
|
||||
if (montauk::connect(fd, ip, port) < 0) { montauk::closesocket(fd); return -1; }
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ extern "C" int hello_run() {
|
||||
static constexpr int kInitialWidth = 320;
|
||||
static constexpr int kInitialHeight = 200;
|
||||
static constexpr uint32_t kBackgroundColor = 0xFFFFFFFF;
|
||||
Montauk::WinCreateResult wres;
|
||||
montauk::abi::WinCreateResult wres;
|
||||
if (montauk::win_create("libhello Demo", kInitialWidth, kInitialHeight, &wres) < 0 || wres.id < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ extern "C" int hello_run() {
|
||||
|
||||
// Event loop
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = montauk::win_poll(winId, &ev);
|
||||
|
||||
if (r < 0) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
fb_info, fb_map - direct framebuffer access
|
||||
|
||||
.SH SYNOPSIS
|
||||
.BI void montauk::fb_info(Montauk::FbInfo* info);
|
||||
.BI void montauk::fb_info(montauk::abi::FbInfo* info);
|
||||
.BI void* montauk::fb_map();
|
||||
|
||||
.SH DESCRIPTION
|
||||
@@ -13,7 +13,7 @@
|
||||
.SS fb_info
|
||||
Fills in an FbInfo structure with the framebuffer geometry:
|
||||
|
||||
Montauk::FbInfo fb;
|
||||
montauk::abi::FbInfo fb;
|
||||
montauk::fb_info(&fb);
|
||||
// fb.width, fb.height, fb.pitch, fb.bpp
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
.SH EXAMPLE
|
||||
Fill the screen with blue:
|
||||
|
||||
Montauk::FbInfo fb;
|
||||
montauk::abi::FbInfo fb;
|
||||
montauk::fb_info(&fb);
|
||||
uint32_t* pixels = (uint32_t*)montauk::fb_map();
|
||||
|
||||
|
||||
@@ -93,14 +93,14 @@
|
||||
|
||||
.B SYS_GETTIME (28)
|
||||
Get the current wall-clock date and time (UTC).
|
||||
Fills a Montauk::DateTime struct with Year, Month, Day,
|
||||
Fills a montauk::abi::DateTime struct with Year, Month, Day,
|
||||
Hour, Minute, and Second fields.
|
||||
void montauk::gettime(Montauk::DateTime* out);
|
||||
void montauk::gettime(montauk::abi::DateTime* out);
|
||||
|
||||
.SH SYSTEM
|
||||
.B SYS_GETINFO (15)
|
||||
Get OS name, version, and configuration.
|
||||
void montauk::get_info(Montauk::SysInfo* info);
|
||||
void montauk::get_info(montauk::abi::SysInfo* info);
|
||||
|
||||
.SH KEYBOARD
|
||||
.B SYS_ISKEYAVAILABLE (16)
|
||||
@@ -109,7 +109,7 @@
|
||||
|
||||
.B SYS_GETKEY (17)
|
||||
Get the next key event (press or release).
|
||||
void montauk::getkey(Montauk::KeyEvent* out);
|
||||
void montauk::getkey(montauk::abi::KeyEvent* out);
|
||||
|
||||
.B SYS_GETCHAR (18)
|
||||
Block until a printable character is typed.
|
||||
@@ -123,16 +123,16 @@
|
||||
.B SYS_GETNETCFG (37)
|
||||
Get the current network configuration (IP, mask, gateway, MAC,
|
||||
DNS server).
|
||||
void montauk::get_netcfg(Montauk::NetCfg* out);
|
||||
void montauk::get_netcfg(montauk::abi::NetCfg* out);
|
||||
|
||||
.B SYS_SETNETCFG (38)
|
||||
Set the network configuration (IP, mask, gateway, DNS server).
|
||||
int montauk::set_netcfg(const Montauk::NetCfg* cfg);
|
||||
int montauk::set_netcfg(const montauk::abi::NetCfg* cfg);
|
||||
|
||||
.B SYS_NETSTATUS (125)
|
||||
Get adapter status including driver name, link state, polling mode,
|
||||
and RX/TX packet counters.
|
||||
int montauk::net_status(Montauk::NetStatus* out);
|
||||
int montauk::net_status(montauk::abi::NetStatus* out);
|
||||
|
||||
.B SYS_RESOLVE (44)
|
||||
Resolve a hostname to an IPv4 address via DNS. Sends a UDP
|
||||
@@ -202,7 +202,7 @@
|
||||
.SH FRAMEBUFFER
|
||||
.B SYS_FBINFO (21)
|
||||
Get framebuffer dimensions and format.
|
||||
void montauk::fb_info(Montauk::FbInfo* info);
|
||||
void montauk::fb_info(montauk::abi::FbInfo* info);
|
||||
|
||||
.B SYS_FBMAP (22)
|
||||
Map the framebuffer into process memory at 0x50000000.
|
||||
|
||||
@@ -452,7 +452,7 @@ static bool apply_move(MoveDir dir) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
||||
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return false;
|
||||
|
||||
if (key.scancode == 0x01)
|
||||
@@ -478,7 +478,7 @@ static bool handle_key(const Montauk::KeyEvent& key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool handle_mouse(const Montauk::WinEvent& ev) {
|
||||
static bool handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||
int old_x = g_mouse_x;
|
||||
int old_y = g_mouse_y;
|
||||
g_mouse_x = ev.mouse.x;
|
||||
@@ -511,7 +511,7 @@ extern "C" void _start() {
|
||||
render();
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = g_win.poll(&ev);
|
||||
|
||||
if (r < 0) break;
|
||||
|
||||
@@ -53,7 +53,7 @@ static WsWindow g_win;
|
||||
static int g_master_vol = 80;
|
||||
static bool g_master_muted = false;
|
||||
|
||||
static Montauk::AudioStreamInfo g_streams[8];
|
||||
static montauk::abi::AudioStreamInfo g_streams[8];
|
||||
static int g_stream_count = 0;
|
||||
|
||||
// Drag target: -2 = none, -1 = master, 0..N-1 = stream slot in g_streams.
|
||||
@@ -385,7 +385,7 @@ static bool handle_mouse(int mx, int my, uint8_t buttons, uint8_t prev) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
||||
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return false;
|
||||
if (key.scancode == 0x01) {
|
||||
g_win.closed = true;
|
||||
@@ -428,7 +428,7 @@ extern "C" void _start() {
|
||||
render();
|
||||
|
||||
while (g_win.id >= 0 && !g_win.closed) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = g_win.poll(&ev);
|
||||
|
||||
bool redraw = false;
|
||||
|
||||
@@ -76,16 +76,16 @@ static int g_mouse_y = -1;
|
||||
static int g_hover_row = -1;
|
||||
|
||||
// Adapter info
|
||||
static Montauk::BtAdapterInfo g_adapter;
|
||||
static montauk::abi::BtAdapterInfo g_adapter;
|
||||
static bool g_adapter_ok = false;
|
||||
|
||||
// Connected/paired devices
|
||||
static Montauk::BtDevInfo g_devices[MAX_CONNECTED];
|
||||
static montauk::abi::BtDevInfo g_devices[MAX_CONNECTED];
|
||||
static char g_device_names[MAX_CONNECTED][64];
|
||||
static int g_device_count = 0;
|
||||
|
||||
// Scan results
|
||||
static Montauk::BtScanResult g_scan[MAX_SCAN];
|
||||
static montauk::abi::BtScanResult g_scan[MAX_SCAN];
|
||||
static int g_scan_count = 0;
|
||||
static bool g_scanning = false;
|
||||
|
||||
@@ -268,7 +268,7 @@ static void refresh_devices() {
|
||||
|
||||
// Append bonded (paired) devices that aren't currently connected, so the
|
||||
// Devices tab remembers them across sessions/reboots.
|
||||
Montauk::BtBondInfo bonds[8];
|
||||
montauk::abi::BtBondInfo bonds[8];
|
||||
int nb = montauk::bt_bonds(bonds, 8);
|
||||
for (int i = 0; i < nb && g_device_count < MAX_CONNECTED; i++) {
|
||||
bool already = false;
|
||||
@@ -277,7 +277,7 @@ static void refresh_devices() {
|
||||
}
|
||||
if (already) continue;
|
||||
|
||||
Montauk::BtDevInfo d = {};
|
||||
montauk::abi::BtDevInfo d = {};
|
||||
montauk::memcpy(d.bdAddr, bonds[i].bdAddr, 6);
|
||||
d.connected = 0; // paired but not connected
|
||||
d.encrypted = 0;
|
||||
@@ -642,7 +642,7 @@ static bool handle_adapter_mouse(int mx, int my, uint8_t buttons,
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool handle_adapter_key(const Montauk::KeyEvent& key) {
|
||||
static bool handle_adapter_key(const montauk::abi::KeyEvent& key) {
|
||||
if (key.ascii == '\n' || key.ascii == '\r') { apply_mac(); return true; }
|
||||
if (key.ascii == '\t') { g_mac_focus = !g_mac_focus; return true; }
|
||||
|
||||
@@ -883,7 +883,7 @@ extern "C" void _start() {
|
||||
uint64_t last_refresh = montauk::get_milliseconds();
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = win.poll(&ev);
|
||||
|
||||
if (r < 0) break;
|
||||
|
||||
@@ -530,7 +530,7 @@ static void render(Canvas& c) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool handle_mouse(const Montauk::WinEvent& ev, int win_w, int win_h) {
|
||||
static bool handle_mouse(const montauk::abi::WinEvent& ev, int win_w, int win_h) {
|
||||
CalcLayout layout;
|
||||
calc_build_layout(win_w, win_h, &layout);
|
||||
|
||||
@@ -558,7 +558,7 @@ static bool handle_mouse(const Montauk::WinEvent& ev, int win_w, int win_h) {
|
||||
return redraw;
|
||||
}
|
||||
|
||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
||||
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return false;
|
||||
|
||||
if (key.ascii >= '0' && key.ascii <= '9') {
|
||||
@@ -602,7 +602,7 @@ extern "C" void _start() {
|
||||
win.present();
|
||||
|
||||
while (win.id >= 0 && !win.closed) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = win.poll(&ev);
|
||||
|
||||
if (r < 0) break;
|
||||
|
||||
@@ -21,7 +21,7 @@ static constexpr int COL1_W = 200;
|
||||
static constexpr int SECTION_GAP = 10;
|
||||
|
||||
WsWindow g_win;
|
||||
Montauk::CrashReportInfo g_report = {};
|
||||
montauk::abi::CrashReportInfo g_report = {};
|
||||
int g_scroll = 0;
|
||||
|
||||
// Colors - light theme matching DiskDetail
|
||||
@@ -213,7 +213,7 @@ extern "C" void _start() {
|
||||
render();
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = g_win.poll(&ev);
|
||||
if (r < 0) break;
|
||||
if (r == 0) {
|
||||
|
||||
@@ -37,7 +37,7 @@ static const char* month_name(int m) {
|
||||
}
|
||||
|
||||
extern "C" void _start() {
|
||||
Montauk::DateTime dt;
|
||||
montauk::abi::DateTime dt;
|
||||
montauk::gettime(&dt);
|
||||
|
||||
print_int(dt.Day);
|
||||
|
||||
@@ -233,7 +233,7 @@ void open_sleep_dialog(DesktopState* ds);
|
||||
// Hand a graceful power-off request to login.elf and exit the desktop so the
|
||||
// user returns to the login screen, where the shutdown stages run (Bluetooth
|
||||
// teardown, filesystem flush) before the final ACPI power-off / reset. Pass
|
||||
// Montauk::POWER_REQ_SHUTDOWN or Montauk::POWER_REQ_REBOOT.
|
||||
// montauk::abi::POWER_REQ_SHUTDOWN or montauk::abi::POWER_REQ_REBOOT.
|
||||
[[noreturn]] inline void desktop_request_power(int action) {
|
||||
montauk::power_request(action);
|
||||
montauk::exit(0);
|
||||
|
||||
@@ -319,7 +319,7 @@ void filemanager_on_mouse(Window* win, MouseEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
void filemanager_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
void filemanager_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
FileManagerState* fm = (FileManagerState*)win->app_data;
|
||||
if (!fm || !key.pressed) return;
|
||||
|
||||
|
||||
@@ -297,7 +297,7 @@ int filemanager_collect_selection(const FileManagerState* fm, int* out, int max
|
||||
void filemanager_draw_header(Canvas& c, FileManagerState* fm, Color toolbar_color, Color btn_bg);
|
||||
void filemanager_on_draw(Window* win, Framebuffer& fb);
|
||||
void filemanager_on_mouse(Window* win, MouseEvent& ev);
|
||||
void filemanager_on_key(Window* win, const Montauk::KeyEvent& key);
|
||||
void filemanager_on_key(Window* win, const montauk::abi::KeyEvent& key);
|
||||
void filemanager_on_close(Window* win);
|
||||
|
||||
} // namespace filemanager
|
||||
|
||||
@@ -238,7 +238,7 @@ static void fileop_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void fileop_dialog_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void fileop_dialog_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
FileOpJob* job = (FileOpJob*)win->app_data;
|
||||
if (!job || !key.pressed) return;
|
||||
if (key.scancode == 0x01) job->cancel = 1; // Escape requests cancel
|
||||
|
||||
@@ -392,7 +392,7 @@ static void props_on_mouse(Window* win, MouseEvent& ev) {
|
||||
props_close_self(st->desktop, st);
|
||||
}
|
||||
|
||||
static void props_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void props_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
FilePropertiesDialogState* st = (FilePropertiesDialogState*)win->app_data;
|
||||
if (!st || !key.pressed) return;
|
||||
if (key.scancode == 0x01 || key.ascii == '\n' || key.ascii == '\r')
|
||||
@@ -576,7 +576,7 @@ static void delete_confirm_on_mouse(Window* win, MouseEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void delete_confirm_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void delete_confirm_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
FileDeleteConfirmDialogState* st = (FileDeleteConfirmDialogState*)win->app_data;
|
||||
if (!st || !key.pressed) return;
|
||||
|
||||
@@ -820,7 +820,7 @@ static void multi_props_on_mouse(Window* win, MouseEvent& ev) {
|
||||
props_close_self(st->desktop, st);
|
||||
}
|
||||
|
||||
static void multi_props_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void multi_props_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
MultiPropertiesDialogState* st = (MultiPropertiesDialogState*)win->app_data;
|
||||
if (!st || !key.pressed) return;
|
||||
if (key.scancode == 0x01 || key.ascii == '\n' || key.ascii == '\r')
|
||||
|
||||
@@ -60,7 +60,7 @@ static void settings_on_mouse(Window* win, MouseEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void settings_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void settings_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
// Settings main window no longer needs keyboard handling.
|
||||
(void)win;
|
||||
(void)key;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace settings_app {
|
||||
struct SettingsState {
|
||||
DesktopState* desktop;
|
||||
int active_tab; // 0=Appearance, 1=Display, 2=About
|
||||
Montauk::SysInfo sys_info;
|
||||
montauk::abi::SysInfo sys_info;
|
||||
uint64_t uptime_ms;
|
||||
WallpaperFileList wp_files;
|
||||
bool wp_scanned;
|
||||
|
||||
@@ -32,7 +32,7 @@ static void usermanager_on_mouse(Window* win, MouseEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void usermanager_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void usermanager_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
(void)win;
|
||||
(void)key;
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ static void adduser_on_mouse(Window* win, MouseEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void adduser_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void adduser_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
AddUserDialogState* st = (AddUserDialogState*)win->app_data;
|
||||
if (!st || !key.pressed) return;
|
||||
|
||||
@@ -495,7 +495,7 @@ static void chpwd_on_mouse(Window* win, MouseEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void chpwd_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void chpwd_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
ChPwdDialogState* st = (ChPwdDialogState*)win->app_data;
|
||||
if (!st || !key.pressed) return;
|
||||
|
||||
@@ -647,7 +647,7 @@ static void deluser_on_mouse(Window* win, MouseEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void deluser_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void deluser_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
DeleteUserDialogState* st = (DeleteUserDialogState*)win->app_data;
|
||||
if (!st || !key.pressed) return;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ void desktop_draw_lock_screen(DesktopState* ds) {
|
||||
fb.fill_rect_alpha(0, 0, sw, sh, Color::from_rgba(0, 0, 0, 0x80));
|
||||
|
||||
// Clock display above card
|
||||
Montauk::DateTime dt;
|
||||
montauk::abi::DateTime dt;
|
||||
montauk::gettime(&dt);
|
||||
char time_str[12];
|
||||
snprintf(time_str, sizeof(time_str), "%02d:%02d", (int)dt.Hour, (int)dt.Minute);
|
||||
|
||||
@@ -124,7 +124,7 @@ inline int menu_add_external(const char* label, const char* binary, SvgIcon* ico
|
||||
// ============================================================================
|
||||
|
||||
inline bool desktop_window_fullscreen(const gui::Window* win) {
|
||||
return win && win->external && (win->ext_flags & Montauk::WIN_FLAG_FULLSCREEN);
|
||||
return win && win->external && (win->ext_flags & montauk::abi::WIN_FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
inline gui::Rect desktop_content_rect(const gui::Window* win) {
|
||||
@@ -160,7 +160,7 @@ inline const char* month_names[] = {
|
||||
|
||||
// launcher.cpp
|
||||
void desktop_init_launcher(gui::DesktopState* ds);
|
||||
bool desktop_handle_launcher_keyboard(gui::DesktopState* ds, const Montauk::KeyEvent& key);
|
||||
bool desktop_handle_launcher_keyboard(gui::DesktopState* ds, const montauk::abi::KeyEvent& key);
|
||||
void desktop_handle_launcher_mouse(gui::DesktopState* ds);
|
||||
void desktop_draw_launcher(gui::DesktopState* ds);
|
||||
uint64_t desktop_launcher_blink_token(const gui::DesktopState* ds, uint64_t now);
|
||||
|
||||
@@ -69,7 +69,7 @@ static void reboot_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
||||
rs->hover_cancel = cb.contains(lx, ly);
|
||||
|
||||
if (ev.left_pressed()) {
|
||||
if (rs->hover_reboot) desktop_request_power(Montauk::POWER_REQ_REBOOT);
|
||||
if (rs->hover_reboot) desktop_request_power(montauk::abi::POWER_REQ_REBOOT);
|
||||
if (rs->hover_cancel) {
|
||||
for (int i = 0; i < rs->ds->window_count; i++) {
|
||||
if (rs->ds->windows[i].app_data == rs) {
|
||||
@@ -81,12 +81,12 @@ static void reboot_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void reboot_dialog_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void reboot_dialog_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
RebootDialogState* rs = (RebootDialogState*)win->app_data;
|
||||
if (!rs || !key.pressed) return;
|
||||
|
||||
if (key.ascii == '\n' || key.ascii == '\r') {
|
||||
desktop_request_power(Montauk::POWER_REQ_REBOOT);
|
||||
desktop_request_power(montauk::abi::POWER_REQ_REBOOT);
|
||||
}
|
||||
if (key.scancode == 0x01) { // Escape
|
||||
for (int i = 0; i < rs->ds->window_count; i++) {
|
||||
@@ -181,7 +181,7 @@ static void shutdown_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
||||
ss->hover_cancel = cb.contains(lx, ly);
|
||||
|
||||
if (ev.left_pressed()) {
|
||||
if (ss->hover_shutdown) desktop_request_power(Montauk::POWER_REQ_SHUTDOWN);
|
||||
if (ss->hover_shutdown) desktop_request_power(montauk::abi::POWER_REQ_SHUTDOWN);
|
||||
if (ss->hover_cancel) {
|
||||
for (int i = 0; i < ss->ds->window_count; i++) {
|
||||
if (ss->ds->windows[i].app_data == ss) {
|
||||
@@ -193,12 +193,12 @@ static void shutdown_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void shutdown_dialog_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void shutdown_dialog_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
ShutdownDialogState* ss = (ShutdownDialogState*)win->app_data;
|
||||
if (!ss || !key.pressed) return;
|
||||
|
||||
if (key.ascii == '\n' || key.ascii == '\r') {
|
||||
desktop_request_power(Montauk::POWER_REQ_SHUTDOWN);
|
||||
desktop_request_power(montauk::abi::POWER_REQ_SHUTDOWN);
|
||||
}
|
||||
if (key.scancode == 0x01) { // Escape
|
||||
for (int i = 0; i < ss->ds->window_count; i++) {
|
||||
@@ -314,7 +314,7 @@ static void sleep_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void sleep_dialog_on_key(Window* win, const Montauk::KeyEvent& key) {
|
||||
static void sleep_dialog_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||
SleepDialogState* ss = (SleepDialogState*)win->app_data;
|
||||
if (!ss || !key.pressed) return;
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ static void handle_lock_mouse(DesktopState* ds) {
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_lock_keyboard(DesktopState* ds, const Montauk::KeyEvent& key) {
|
||||
static void handle_lock_keyboard(DesktopState* ds, const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return;
|
||||
|
||||
// Enter submits
|
||||
@@ -101,7 +101,7 @@ static void forward_external_mouse(gui::Window* win,
|
||||
uint8_t buttons,
|
||||
uint8_t prev) {
|
||||
gui::Rect cr = desktop_content_rect(win);
|
||||
Montauk::WinEvent wev;
|
||||
montauk::abi::WinEvent wev;
|
||||
montauk::memset(&wev, 0, sizeof(wev));
|
||||
wev.type = 1; // mouse
|
||||
wev.mouse.x = mx - cr.x;
|
||||
@@ -242,7 +242,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
||||
}
|
||||
} else {
|
||||
Rect cr = desktop_content_rect(win);
|
||||
Montauk::WinEvent rev;
|
||||
montauk::abi::WinEvent rev;
|
||||
montauk::memset(&rev, 0, sizeof(rev));
|
||||
rev.type = 2;
|
||||
rev.resize.w = cr.w;
|
||||
@@ -264,7 +264,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
||||
}
|
||||
} else {
|
||||
Rect cr = desktop_content_rect(win);
|
||||
Montauk::WinEvent rev;
|
||||
montauk::abi::WinEvent rev;
|
||||
montauk::memset(&rev, 0, sizeof(rev));
|
||||
rev.type = 2;
|
||||
rev.resize.w = cr.w;
|
||||
@@ -331,7 +331,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
||||
win->dirty = true;
|
||||
} else {
|
||||
Rect cr = desktop_content_rect(win);
|
||||
Montauk::WinEvent rev;
|
||||
montauk::abi::WinEvent rev;
|
||||
montauk::memset(&rev, 0, sizeof(rev));
|
||||
rev.type = 2;
|
||||
rev.resize.w = cr.w;
|
||||
@@ -615,7 +615,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
||||
}
|
||||
} else {
|
||||
Rect cr = desktop_content_rect(win);
|
||||
Montauk::WinEvent rev;
|
||||
montauk::abi::WinEvent rev;
|
||||
montauk::memset(&rev, 0, sizeof(rev));
|
||||
rev.type = 2;
|
||||
rev.resize.w = cr.w;
|
||||
@@ -661,7 +661,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
||||
Window* raised = &ds->windows[new_idx];
|
||||
if (raised->external) {
|
||||
// Forward mouse event to external window
|
||||
Montauk::WinEvent wev;
|
||||
montauk::abi::WinEvent wev;
|
||||
montauk::memset(&wev, 0, sizeof(wev));
|
||||
wev.type = 1; // mouse
|
||||
wev.mouse.x = mx - cr.x;
|
||||
@@ -700,7 +700,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
||||
// Forward if mouse is over content (hover/move) or button is held/released (drag continuity)
|
||||
if (cr.contains(mx, my) || left_held || left_released) {
|
||||
if (win->external) {
|
||||
Montauk::WinEvent wev;
|
||||
montauk::abi::WinEvent wev;
|
||||
montauk::memset(&wev, 0, sizeof(wev));
|
||||
wev.type = 1; // mouse
|
||||
wev.mouse.x = mx - cr.x;
|
||||
@@ -726,7 +726,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
||||
Rect cr = desktop_content_rect(win);
|
||||
if (cr.contains(mx, my)) {
|
||||
if (win->external) {
|
||||
Montauk::WinEvent wev;
|
||||
montauk::abi::WinEvent wev;
|
||||
montauk::memset(&wev, 0, sizeof(wev));
|
||||
wev.type = 1; // mouse
|
||||
wev.mouse.x = mx - cr.x;
|
||||
@@ -763,7 +763,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
||||
}
|
||||
}
|
||||
|
||||
void gui::desktop_handle_keyboard(DesktopState* ds, const Montauk::KeyEvent& key) {
|
||||
void gui::desktop_handle_keyboard(DesktopState* ds, const montauk::abi::KeyEvent& key) {
|
||||
if (ds->screen_locked) {
|
||||
handle_lock_keyboard(ds, key);
|
||||
return;
|
||||
@@ -776,7 +776,7 @@ void gui::desktop_handle_keyboard(DesktopState* ds, const Montauk::KeyEvent& key
|
||||
if (!desktop_window_fullscreen(win))
|
||||
break;
|
||||
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
montauk::memset(&ev, 0, sizeof(ev));
|
||||
ev.type = 0; // key
|
||||
ev.key = key;
|
||||
@@ -828,7 +828,7 @@ void gui::desktop_handle_keyboard(DesktopState* ds, const Montauk::KeyEvent& key
|
||||
Window* win = &ds->windows[ds->focused_window];
|
||||
if (win->external) {
|
||||
// Forward key event to external window via syscall
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
montauk::memset(&ev, 0, sizeof(ev));
|
||||
ev.type = 0; // key
|
||||
ev.key = key;
|
||||
|
||||
@@ -339,11 +339,11 @@ static void launcher_activate_selected(DesktopState* ds) {
|
||||
break;
|
||||
case LAUNCHER_ITEM_COMMAND_REBOOT:
|
||||
desktop_close_launcher(ds);
|
||||
desktop_request_power(Montauk::POWER_REQ_REBOOT);
|
||||
desktop_request_power(montauk::abi::POWER_REQ_REBOOT);
|
||||
return;
|
||||
case LAUNCHER_ITEM_COMMAND_SHUTDOWN:
|
||||
desktop_close_launcher(ds);
|
||||
desktop_request_power(Montauk::POWER_REQ_SHUTDOWN);
|
||||
desktop_request_power(montauk::abi::POWER_REQ_SHUTDOWN);
|
||||
return;
|
||||
case LAUNCHER_ITEM_SPECIAL_FOLDER:
|
||||
if (item->path[0] != '\0') {
|
||||
@@ -355,7 +355,7 @@ static void launcher_activate_selected(DesktopState* ds) {
|
||||
desktop_close_launcher(ds);
|
||||
}
|
||||
|
||||
static void launcher_update_super_state(DesktopState* ds, const Montauk::KeyEvent& key) {
|
||||
static void launcher_update_super_state(DesktopState* ds, const montauk::abi::KeyEvent& key) {
|
||||
uint8_t sc = key.scancode & 0x7F;
|
||||
if (sc == 0x5B) {
|
||||
ds->super_left_down = key.pressed;
|
||||
@@ -411,7 +411,7 @@ void desktop_close_launcher(DesktopState* ds) {
|
||||
ds->launcher_scroll = 0;
|
||||
}
|
||||
|
||||
bool desktop_handle_launcher_keyboard(DesktopState* ds, const Montauk::KeyEvent& key) {
|
||||
bool desktop_handle_launcher_keyboard(DesktopState* ds, const montauk::abi::KeyEvent& key) {
|
||||
launcher_update_super_state(ds, key);
|
||||
uint8_t sc = key.scancode & 0x7F;
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ void gui::desktop_init(DesktopState* ds) {
|
||||
ds->app_menu_open = false;
|
||||
desktop_init_launcher(ds);
|
||||
|
||||
montauk::memset(&ds->mouse, 0, sizeof(Montauk::MouseState));
|
||||
montauk::memset(&ds->mouse, 0, sizeof(montauk::abi::MouseState));
|
||||
montauk::set_mouse_bounds(ds->screen_w - 1, ds->screen_h - 1);
|
||||
gui::clipboard_clear();
|
||||
|
||||
@@ -333,7 +333,7 @@ void gui::desktop_init(DesktopState* ds) {
|
||||
// ============================================================================
|
||||
|
||||
static uint64_t desktop_clock_token() {
|
||||
Montauk::DateTime dt;
|
||||
montauk::abi::DateTime dt;
|
||||
montauk::gettime(&dt);
|
||||
return ((uint64_t)dt.Year << 32)
|
||||
| ((uint64_t)dt.Month << 24)
|
||||
@@ -369,7 +369,7 @@ static void desktop_clear_window_dirty(DesktopState* ds) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool desktop_netcfg_equal(const Montauk::NetCfg& a, const Montauk::NetCfg& b) {
|
||||
static bool desktop_netcfg_equal(const montauk::abi::NetCfg& a, const montauk::abi::NetCfg& b) {
|
||||
if (a.ipAddress != b.ipAddress || a.subnetMask != b.subnetMask ||
|
||||
a.gateway != b.gateway || a.dnsServer != b.dnsServer) {
|
||||
return false;
|
||||
@@ -385,7 +385,7 @@ static bool desktop_refresh_panel_state(DesktopState* ds, uint64_t now) {
|
||||
|
||||
bool changed = false;
|
||||
if (now - ds->net_cfg_last_poll > 5000) {
|
||||
Montauk::NetCfg next;
|
||||
montauk::abi::NetCfg next;
|
||||
montauk::get_netcfg(&next);
|
||||
if (!desktop_netcfg_equal(next, ds->cached_net_cfg)) {
|
||||
ds->cached_net_cfg = next;
|
||||
@@ -425,7 +425,7 @@ static bool desktop_refresh_panel_state(DesktopState* ds, uint64_t now) {
|
||||
|
||||
bool desktop_poll_external_windows(DesktopState* ds) {
|
||||
bool changed = false;
|
||||
Montauk::WinInfo extWins[8];
|
||||
montauk::abi::WinInfo extWins[8];
|
||||
int extCount = montauk::win_enumerate(extWins, 8);
|
||||
|
||||
// Check for new external windows and map them
|
||||
@@ -649,7 +649,7 @@ void gui::desktop_run(DesktopState* ds) {
|
||||
|
||||
// Poll keyboard events
|
||||
while (montauk::is_key_available()) {
|
||||
Montauk::KeyEvent key;
|
||||
montauk::abi::KeyEvent key;
|
||||
montauk::getkey(&key);
|
||||
desktop_handle_keyboard(ds, key);
|
||||
keyboardChanged = true;
|
||||
@@ -730,7 +730,7 @@ static DesktopState* g_desktop;
|
||||
static constexpr const char kDesktopBinaryName[] = "desktop.elf";
|
||||
static constexpr int DESKTOP_PROC_SCAN_MAX = 256;
|
||||
|
||||
static bool desktop_proc_alive(const Montauk::ProcInfo& proc) {
|
||||
static bool desktop_proc_alive(const montauk::abi::ProcInfo& proc) {
|
||||
return proc.state == 1 || proc.state == 2 || proc.state == 3;
|
||||
}
|
||||
|
||||
@@ -745,7 +745,7 @@ static bool proc_name_is_desktop(const char* name) {
|
||||
}
|
||||
|
||||
static bool existing_desktop_running() {
|
||||
static Montauk::ProcInfo procs[DESKTOP_PROC_SCAN_MAX];
|
||||
static montauk::abi::ProcInfo procs[DESKTOP_PROC_SCAN_MAX];
|
||||
int count = montauk::proclist(procs, DESKTOP_PROC_SCAN_MAX);
|
||||
if (count <= 0) return false;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ void gui::desktop_draw_panel(DesktopState* ds) {
|
||||
}
|
||||
|
||||
// Date + Clock (right side)
|
||||
Montauk::DateTime dt;
|
||||
montauk::abi::DateTime dt;
|
||||
montauk::gettime(&dt);
|
||||
|
||||
char clock_str[12];
|
||||
@@ -256,7 +256,7 @@ void desktop_draw_app_menu(DesktopState* ds) {
|
||||
|
||||
void desktop_draw_net_popup(DesktopState* ds) {
|
||||
Framebuffer& fb = ds->fb;
|
||||
Montauk::NetCfg& nc = ds->cached_net_cfg;
|
||||
montauk::abi::NetCfg& nc = ds->cached_net_cfg;
|
||||
bool connected = nc.ipAddress != 0;
|
||||
|
||||
int popup_w = 220;
|
||||
|
||||
@@ -64,7 +64,7 @@ void gui::desktop_close_window(DesktopState* ds, int idx) {
|
||||
if (ds->closing_ext_count < DesktopState::MAX_CLOSING) {
|
||||
ds->closing_ext_ids[ds->closing_ext_count++] = win->ext_win_id;
|
||||
}
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
montauk::memset(&ev, 0, sizeof(ev));
|
||||
ev.type = 3; // close
|
||||
montauk::win_sendevent(win->ext_win_id, &ev);
|
||||
|
||||
@@ -139,7 +139,7 @@ static constexpr int DD_INIT_H = 420;
|
||||
static constexpr int DD_TAB_BAR_H = 32;
|
||||
|
||||
struct DiskDetailState {
|
||||
Montauk::DiskInfo info;
|
||||
montauk::abi::DiskInfo info;
|
||||
int active_tab;
|
||||
int win_id;
|
||||
int win_w, win_h;
|
||||
@@ -152,7 +152,7 @@ struct DiskDetailState {
|
||||
// ============================================================================
|
||||
|
||||
struct DevExplorerState {
|
||||
Montauk::DevInfo devs[MAX_TOTAL_DEVS];
|
||||
montauk::abi::DevInfo devs[MAX_TOTAL_DEVS];
|
||||
int dev_count;
|
||||
bool collapsed[NUM_CATEGORIES];
|
||||
int selected_row;
|
||||
@@ -193,7 +193,7 @@ void render(uint32_t* pixels);
|
||||
// ============================================================================
|
||||
|
||||
int build_display_rows(DevExplorerState* de, DisplayRow* rows);
|
||||
int append_printer_devices(Montauk::DevInfo* out, int max_count);
|
||||
int append_printer_devices(montauk::abi::DevInfo* out, int max_count);
|
||||
ScrollMetrics compute_scroll_metrics(DevExplorerState* de,
|
||||
const DisplayRow* rows, int row_count);
|
||||
void set_scroll_from_px(DevExplorerState* de, const DisplayRow* rows,
|
||||
|
||||
@@ -274,7 +274,7 @@ void open_disk_detail(int port, const char* model) {
|
||||
montauk::memset(&dd.info, 0, sizeof(dd.info));
|
||||
montauk::diskinfo(&dd.info, port);
|
||||
|
||||
Montauk::WinCreateResult wres;
|
||||
montauk::abi::WinCreateResult wres;
|
||||
if (montauk::win_create(title, dd.win_w, dd.win_h, &wres) < 0 || wres.id < 0)
|
||||
return;
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ static bool handle_list_click(int mx, int my) {
|
||||
// Mouse handling (wheel, draggable scrollbar, clicks)
|
||||
// ============================================================================
|
||||
|
||||
static bool handle_main_mouse(const Montauk::WinEvent& ev) {
|
||||
static bool handle_main_mouse(const montauk::abi::WinEvent& ev) {
|
||||
auto& de = g_state;
|
||||
int mx = ev.mouse.x;
|
||||
int my = ev.mouse.y;
|
||||
@@ -272,7 +272,7 @@ static bool handle_main_mouse(const Montauk::WinEvent& ev) {
|
||||
// Key handling
|
||||
// ============================================================================
|
||||
|
||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
||||
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return false;
|
||||
|
||||
auto& de = g_state;
|
||||
@@ -371,7 +371,7 @@ extern "C" void _start() {
|
||||
win.present();
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
bool redraw_main = false;
|
||||
bool redraw_detail = false;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ static void format_printer_detail(const ProbeState& probe,
|
||||
snprintf(out, (size_t)out_len, "Awaiting spooler probe");
|
||||
}
|
||||
|
||||
int append_printer_devices(Montauk::DevInfo* out, int max_count) {
|
||||
int append_printer_devices(montauk::abi::DevInfo* out, int max_count) {
|
||||
if (out == nullptr || max_count <= 0) return 0;
|
||||
|
||||
char current_uri[MAX_PATH_LEN] = {};
|
||||
@@ -65,7 +65,7 @@ int append_printer_devices(Montauk::DevInfo* out, int max_count) {
|
||||
char uri_err[128] = {};
|
||||
bool normalized_ok = normalize_ipp_uri(effective_uri, &normalized, uri_err, sizeof(uri_err));
|
||||
|
||||
Montauk::DevInfo dev = {};
|
||||
montauk::abi::DevInfo dev = {};
|
||||
dev.category = CAT_PRINTER;
|
||||
|
||||
if (has_probe && probe.caps.printer_name[0]) {
|
||||
|
||||
@@ -335,7 +335,7 @@ extern "C" void _start() {
|
||||
montauk::print("MontaukOS DHCP Client\n");
|
||||
|
||||
// 1. Get MAC address
|
||||
Montauk::NetCfg origCfg;
|
||||
montauk::abi::NetCfg origCfg;
|
||||
montauk::get_netcfg(&origCfg);
|
||||
|
||||
char macStr[32];
|
||||
@@ -344,14 +344,14 @@ extern "C" void _start() {
|
||||
montauk::print(msg);
|
||||
|
||||
// 2. Set IP to 0.0.0.0 to allow broadcast send/receive
|
||||
Montauk::NetCfg zeroCfg;
|
||||
montauk::abi::NetCfg zeroCfg;
|
||||
zeroCfg.ipAddress = 0;
|
||||
zeroCfg.subnetMask = 0;
|
||||
zeroCfg.gateway = 0;
|
||||
montauk::set_netcfg(&zeroCfg);
|
||||
|
||||
// 3. Create UDP socket and bind to port 68
|
||||
int fd = montauk::socket(Montauk::SOCK_UDP);
|
||||
int fd = montauk::socket(montauk::abi::SOCK_UDP);
|
||||
if (fd < 0) {
|
||||
montauk::print("Error: failed to create UDP socket\n");
|
||||
montauk::set_netcfg(&origCfg);
|
||||
@@ -399,7 +399,7 @@ extern "C" void _start() {
|
||||
}
|
||||
uint64_t now = montauk::get_milliseconds();
|
||||
if (now >= startMs + 10000) break;
|
||||
montauk::wait_handle(fd, Montauk::IPC_SIGNAL_READABLE, startMs + 10000 - now);
|
||||
montauk::wait_handle(fd, montauk::abi::IPC_SIGNAL_READABLE, startMs + 10000 - now);
|
||||
}
|
||||
|
||||
if (!gotOffer) {
|
||||
@@ -451,7 +451,7 @@ extern "C" void _start() {
|
||||
}
|
||||
uint64_t now = montauk::get_milliseconds();
|
||||
if (now >= startMs + 10000) break;
|
||||
montauk::wait_handle(fd, Montauk::IPC_SIGNAL_READABLE, startMs + 10000 - now);
|
||||
montauk::wait_handle(fd, montauk::abi::IPC_SIGNAL_READABLE, startMs + 10000 - now);
|
||||
}
|
||||
|
||||
montauk::closesocket(fd);
|
||||
@@ -463,7 +463,7 @@ extern "C" void _start() {
|
||||
}
|
||||
|
||||
// 8. Apply configuration
|
||||
Montauk::NetCfg newCfg;
|
||||
montauk::abi::NetCfg newCfg;
|
||||
newCfg.ipAddress = offer.offeredIp;
|
||||
newCfg.subnetMask = offer.subnetMask;
|
||||
newCfg.gateway = offer.router;
|
||||
|
||||
@@ -1047,7 +1047,7 @@ int file_field_mouse(mtk::TextInputState& input, const Rect& rect, char* buf, in
|
||||
focused, false, filter);
|
||||
}
|
||||
|
||||
void handle_file_mouse(const Montauk::WinEvent& ev) {
|
||||
void handle_file_mouse(const montauk::abi::WinEvent& ev) {
|
||||
FileDialogState* st = &g_file;
|
||||
st->mouse_x = ev.mouse.x;
|
||||
st->mouse_y = ev.mouse.y;
|
||||
@@ -1159,7 +1159,7 @@ void handle_file_mouse(const Montauk::WinEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
void handle_file_key(const Montauk::KeyEvent& key) {
|
||||
void handle_file_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return;
|
||||
|
||||
FileDialogState* st = &g_file;
|
||||
@@ -1234,11 +1234,11 @@ void draw() {
|
||||
draw_file_dialog();
|
||||
}
|
||||
|
||||
void handle_mouse(const Montauk::WinEvent& ev) {
|
||||
void handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||
handle_file_mouse(ev);
|
||||
}
|
||||
|
||||
void handle_key(const Montauk::KeyEvent& key) {
|
||||
void handle_key(const montauk::abi::KeyEvent& key) {
|
||||
handle_file_key(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ constexpr int BUTTON_W = 88;
|
||||
|
||||
void init(const gui::dialogs::Request& req);
|
||||
void draw();
|
||||
void handle_mouse(const Montauk::WinEvent& ev);
|
||||
void handle_key(const Montauk::KeyEvent& key);
|
||||
void handle_mouse(const montauk::abi::WinEvent& ev);
|
||||
void handle_key(const montauk::abi::KeyEvent& key);
|
||||
void cleanup();
|
||||
|
||||
} // namespace filedialog
|
||||
|
||||
@@ -35,8 +35,8 @@ static constexpr uint8_t WIN_SCALE = 4;
|
||||
struct DialogCallbacks {
|
||||
void (*draw)();
|
||||
void (*on_close)();
|
||||
void (*handle_mouse)(const Montauk::WinEvent& ev);
|
||||
void (*handle_key)(const Montauk::KeyEvent& key);
|
||||
void (*handle_mouse)(const montauk::abi::WinEvent& ev);
|
||||
void (*handle_key)(const montauk::abi::KeyEvent& key);
|
||||
};
|
||||
|
||||
static void run_dialog_loop(const DialogCallbacks& cb) {
|
||||
@@ -44,7 +44,7 @@ static void run_dialog_loop(const DialogCallbacks& cb) {
|
||||
cb.draw();
|
||||
g_app.win.present();
|
||||
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int rc = g_app.win.poll(&ev);
|
||||
if (rc < 0) { cb.on_close(); break; }
|
||||
if (rc == 0) { montauk::sleep_ms(16); continue; }
|
||||
@@ -143,8 +143,8 @@ DIALOGS_EXPORT bool dialogs_run_request(const dlg::Request* request, dlg::Result
|
||||
}
|
||||
|
||||
void (*draw_fn)() = g_app.is_print ? printdialog::draw : filedialog::draw;
|
||||
void (*mouse_fn)(const Montauk::WinEvent&) = g_app.is_print ? printdialog::handle_mouse : filedialog::handle_mouse;
|
||||
void (*key_fn)(const Montauk::KeyEvent&) = g_app.is_print ? printdialog::handle_key : filedialog::handle_key;
|
||||
void (*mouse_fn)(const montauk::abi::WinEvent&) = g_app.is_print ? printdialog::handle_mouse : filedialog::handle_mouse;
|
||||
void (*key_fn)(const montauk::abi::KeyEvent&) = g_app.is_print ? printdialog::handle_key : filedialog::handle_key;
|
||||
|
||||
draw_fn();
|
||||
g_app.win.present();
|
||||
|
||||
@@ -367,7 +367,7 @@ void draw_message_box() {
|
||||
}
|
||||
}
|
||||
|
||||
void handle_message_mouse(const Montauk::WinEvent& ev) {
|
||||
void handle_message_mouse(const montauk::abi::WinEvent& ev) {
|
||||
MessageBoxState* st = &g_message;
|
||||
st->mouse_x = ev.mouse.x;
|
||||
st->mouse_y = ev.mouse.y;
|
||||
@@ -384,7 +384,7 @@ void handle_message_mouse(const Montauk::WinEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
void handle_message_key(const Montauk::KeyEvent& key) {
|
||||
void handle_message_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return;
|
||||
|
||||
MessageBoxState* st = &g_message;
|
||||
@@ -464,11 +464,11 @@ void draw() {
|
||||
draw_message_box();
|
||||
}
|
||||
|
||||
void handle_mouse(const Montauk::WinEvent& ev) {
|
||||
void handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||
handle_message_mouse(ev);
|
||||
}
|
||||
|
||||
void handle_key(const Montauk::KeyEvent& key) {
|
||||
void handle_key(const montauk::abi::KeyEvent& key) {
|
||||
handle_message_key(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ constexpr int MAX_LINE_LEN = 128;
|
||||
void init(const char* message, uint8_t buttons, uint8_t default_choice = 0);
|
||||
void preferred_size(const char* title, int* out_w, int* out_h);
|
||||
void draw();
|
||||
void handle_mouse(const Montauk::WinEvent& ev);
|
||||
void handle_key(const Montauk::KeyEvent& key);
|
||||
void handle_mouse(const montauk::abi::WinEvent& ev);
|
||||
void handle_key(const montauk::abi::KeyEvent& key);
|
||||
void dismiss();
|
||||
uint8_t selected_choice();
|
||||
void cleanup();
|
||||
|
||||
@@ -420,7 +420,7 @@ void print_submit(PrintDialogState* st) {
|
||||
dialog_finish("ok", "", job_id, msg, printer.uri, printer.name, st->copies);
|
||||
}
|
||||
|
||||
void handle_print_mouse(const Montauk::WinEvent& ev) {
|
||||
void handle_print_mouse(const montauk::abi::WinEvent& ev) {
|
||||
PrintDialogState* st = &g_print;
|
||||
st->mouse_x = ev.mouse.x;
|
||||
st->mouse_y = ev.mouse.y;
|
||||
@@ -456,7 +456,7 @@ void handle_print_mouse(const Montauk::WinEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
void handle_print_key(const Montauk::KeyEvent& key) {
|
||||
void handle_print_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return;
|
||||
if (key.scancode == 0x01) {
|
||||
dialog_cancel();
|
||||
@@ -505,11 +505,11 @@ void draw() {
|
||||
draw_print_dialog();
|
||||
}
|
||||
|
||||
void handle_mouse(const Montauk::WinEvent& ev) {
|
||||
void handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||
handle_print_mouse(ev);
|
||||
}
|
||||
|
||||
void handle_key(const Montauk::KeyEvent& key) {
|
||||
void handle_key(const montauk::abi::KeyEvent& key) {
|
||||
handle_print_key(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ constexpr int BUTTON_W = 88;
|
||||
|
||||
void init(const gui::dialogs::Request& req);
|
||||
void draw();
|
||||
void handle_mouse(const Montauk::WinEvent& ev);
|
||||
void handle_key(const Montauk::KeyEvent& key);
|
||||
void handle_mouse(const montauk::abi::WinEvent& ev);
|
||||
void handle_key(const montauk::abi::KeyEvent& key);
|
||||
void cleanup();
|
||||
|
||||
} // namespace printdialog
|
||||
|
||||
@@ -14,7 +14,7 @@ void disktool_refresh() {
|
||||
auto& dt = g_state;
|
||||
dt.disk_count = 0;
|
||||
for (int port = 0; port < MAX_DISKS; port++) {
|
||||
Montauk::DiskInfo info;
|
||||
montauk::abi::DiskInfo info;
|
||||
montauk::memset(&info, 0, sizeof(info));
|
||||
int r = montauk::diskinfo(&info, port);
|
||||
if (r == 0 && info.type != 0) {
|
||||
@@ -45,7 +45,7 @@ void open_newpart_dialog() {
|
||||
dlg.hover_confirm = false;
|
||||
dlg.hover_cancel = false;
|
||||
|
||||
Montauk::DiskInfo& disk = dt.disks[dt.selected_disk];
|
||||
montauk::abi::DiskInfo& disk = dt.disks[dt.selected_disk];
|
||||
int blockDev = selected_block_dev();
|
||||
char sz[24];
|
||||
format_disk_size(sz, sizeof(sz), disk.sectorCount, disk.sectorSizeLog);
|
||||
@@ -64,7 +64,7 @@ void open_newpart_dialog() {
|
||||
"free region on this disk.");
|
||||
}
|
||||
|
||||
Montauk::WinCreateResult wres;
|
||||
montauk::abi::WinCreateResult wres;
|
||||
const char* title = dlg.will_init_gpt ? "Initialize Disk" : "New Partition";
|
||||
if (montauk::win_create(title, NP_DLG_W, NP_DLG_H, &wres) < 0 || wres.id < 0) {
|
||||
set_status("Failed to open dialog");
|
||||
@@ -100,7 +100,7 @@ void newpart_dialog_confirm() {
|
||||
set_status("Initialized GPT");
|
||||
}
|
||||
|
||||
Montauk::GptAddParams params;
|
||||
montauk::abi::GptAddParams params;
|
||||
montauk::memset(¶ms, 0, sizeof(params));
|
||||
params.blockDev = selected_block_dev();
|
||||
params.startLba = 0;
|
||||
@@ -187,15 +187,15 @@ void open_format_dialog() {
|
||||
dlg.hover_cancel = false;
|
||||
|
||||
// Build partition description
|
||||
Montauk::PartInfo& p = dt.parts[global_idx];
|
||||
Montauk::DiskInfo& disk = dt.disks[dt.selected_disk];
|
||||
montauk::abi::PartInfo& p = dt.parts[global_idx];
|
||||
montauk::abi::DiskInfo& disk = dt.disks[dt.selected_disk];
|
||||
char sz[24];
|
||||
format_disk_size(sz, sizeof(sz), p.sectorCount, disk.sectorSizeLog);
|
||||
const char* pname = p.name[0] ? p.name : "Partition";
|
||||
snprintf(dlg.part_desc, sizeof(dlg.part_desc), "%s (%s)", pname, sz);
|
||||
|
||||
// Create dialog window
|
||||
Montauk::WinCreateResult wres;
|
||||
montauk::abi::WinCreateResult wres;
|
||||
if (montauk::win_create("Format Partition", FMT_DLG_W, FMT_DLG_H, &wres) < 0 || wres.id < 0) {
|
||||
set_status("Failed to open format dialog");
|
||||
return;
|
||||
@@ -219,7 +219,7 @@ void format_dialog_do_format() {
|
||||
auto& dt = g_state;
|
||||
auto& dlg = dt.fmt_dlg;
|
||||
|
||||
Montauk::FsFormatParams params;
|
||||
montauk::abi::FsFormatParams params;
|
||||
montauk::memset(¶ms, 0, sizeof(params));
|
||||
params.partIndex = dlg.global_part_index;
|
||||
params.fsType = g_fsTypes[dlg.selected_fs].id;
|
||||
|
||||
@@ -49,7 +49,7 @@ struct FsTypeEntry {
|
||||
};
|
||||
|
||||
static const FsTypeEntry g_fsTypes[] = {
|
||||
{ "FAT32", Montauk::FS_TYPE_FAT32 },
|
||||
{ "FAT32", montauk::abi::FS_TYPE_FAT32 },
|
||||
};
|
||||
static constexpr int NUM_FS_TYPES = 1;
|
||||
|
||||
@@ -86,9 +86,9 @@ struct NewPartDialog {
|
||||
};
|
||||
|
||||
struct DiskToolState {
|
||||
Montauk::DiskInfo disks[MAX_DISKS];
|
||||
montauk::abi::DiskInfo disks[MAX_DISKS];
|
||||
int disk_count;
|
||||
Montauk::PartInfo parts[MAX_PARTS];
|
||||
montauk::abi::PartInfo parts[MAX_PARTS];
|
||||
int part_count;
|
||||
int selected_disk;
|
||||
int selected_part;
|
||||
|
||||
@@ -146,13 +146,13 @@ static bool handle_content_click(int mx, int my) {
|
||||
int map_x = MAP_PAD;
|
||||
int map_w = g_win_w - MAP_PAD * 2;
|
||||
if (my >= y && my < y + MAP_H) {
|
||||
Montauk::DiskInfo& disk = dt.disks[dt.selected_disk];
|
||||
montauk::abi::DiskInfo& disk = dt.disks[dt.selected_disk];
|
||||
int part_indices[MAX_PARTS];
|
||||
int nparts = get_disk_parts(part_indices, MAX_PARTS);
|
||||
uint64_t total = disk.sectorCount;
|
||||
if (total > 0) {
|
||||
for (int pi = 0; pi < nparts; pi++) {
|
||||
Montauk::PartInfo& p = dt.parts[part_indices[pi]];
|
||||
montauk::abi::PartInfo& p = dt.parts[part_indices[pi]];
|
||||
int px = map_x + (int)((p.startLba * (uint64_t)map_w) / total);
|
||||
int pw = (int)((p.sectorCount * (uint64_t)map_w) / total);
|
||||
if (pw < 2) pw = 2;
|
||||
@@ -278,7 +278,7 @@ static void clamp_scroll() {
|
||||
g_state.scroll_y = gui_clamp(g_state.scroll_y, 0, max_scroll_y());
|
||||
}
|
||||
|
||||
static bool handle_mouse(const Montauk::WinEvent& ev) {
|
||||
static bool handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||
int prev_x = g_state.mouse_x;
|
||||
int prev_y = g_state.mouse_y;
|
||||
int prev_disk_hover = hovered_disk_button(prev_x, prev_y);
|
||||
@@ -320,7 +320,7 @@ static bool handle_mouse(const Montauk::WinEvent& ev) {
|
||||
// Key handling
|
||||
// ============================================================================
|
||||
|
||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
||||
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return false;
|
||||
|
||||
auto& dt = g_state;
|
||||
@@ -403,7 +403,7 @@ extern "C" void _start() {
|
||||
win.present();
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
bool redraw_main = false;
|
||||
bool redraw_dlg = false;
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ static void render_content(Canvas& c, const mtk::Theme& theme) {
|
||||
if (dt.disk_count == 0 || dt.selected_disk < 0 || dt.selected_disk >= dt.disk_count)
|
||||
return;
|
||||
|
||||
Montauk::DiskInfo& disk = dt.disks[dt.selected_disk];
|
||||
montauk::abi::DiskInfo& disk = dt.disks[dt.selected_disk];
|
||||
int y = content_title_y();
|
||||
|
||||
char info_str[64];
|
||||
@@ -138,7 +138,7 @@ static void render_content(Canvas& c, const mtk::Theme& theme) {
|
||||
|
||||
if (total_sectors > 0 && nparts > 0) {
|
||||
for (int pi = 0; pi < nparts; pi++) {
|
||||
Montauk::PartInfo& p = dt.parts[part_indices[pi]];
|
||||
montauk::abi::PartInfo& p = dt.parts[part_indices[pi]];
|
||||
int part_x = map_rect.x + (int)((p.startLba * (uint64_t)map_rect.w) / total_sectors);
|
||||
int part_w = (int)((p.sectorCount * (uint64_t)map_rect.w) / total_sectors);
|
||||
if (part_w < 2) part_w = 2;
|
||||
@@ -214,7 +214,7 @@ static void render_content(Canvas& c, const mtk::Theme& theme) {
|
||||
table_style.row_hover_bg);
|
||||
}
|
||||
|
||||
Montauk::PartInfo& p = dt.parts[part_indices[pi]];
|
||||
montauk::abi::PartInfo& p = dt.parts[part_indices[pi]];
|
||||
|
||||
c.fill_rounded_rect(col_idx, row_y + (ITEM_H - 10) / 2, 10, 10, 5,
|
||||
part_colors[pi % NUM_PART_COLORS]);
|
||||
|
||||
@@ -66,7 +66,7 @@ static inline long _zos_syscall4(long nr, long a1, long a2, long a3, long a4) {
|
||||
#define SYS_WINPRESENT 56
|
||||
#define SYS_WINPOLL 57
|
||||
|
||||
/* Window server structs (must match Montauk::WinCreateResult and Montauk::WinEvent) */
|
||||
/* Window server structs (must match montauk::abi::WinCreateResult and montauk::abi::WinEvent) */
|
||||
struct WinCreateResult {
|
||||
int id; /* -1 on failure */
|
||||
unsigned _pad;
|
||||
|
||||
@@ -396,7 +396,7 @@ static int prompt_input(const char* promptStr, char* out, int outMax) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Montauk::KeyEvent ev;
|
||||
montauk::abi::KeyEvent ev;
|
||||
montauk::getkey(&ev);
|
||||
if (!ev.pressed) continue;
|
||||
|
||||
@@ -732,7 +732,7 @@ static constexpr uint8_t SC_DELETE = 0x53;
|
||||
|
||||
// ---- Input handling ----
|
||||
|
||||
static void handle_key(const Montauk::KeyEvent& ev) {
|
||||
static void handle_key(const montauk::abi::KeyEvent& ev) {
|
||||
if (!ev.pressed) return;
|
||||
|
||||
// Ctrl key combinations
|
||||
@@ -905,7 +905,7 @@ extern "C" void _start() {
|
||||
montauk::yield();
|
||||
}
|
||||
|
||||
Montauk::KeyEvent ev;
|
||||
montauk::abi::KeyEvent ev;
|
||||
montauk::getkey(&ev);
|
||||
handle_key(ev);
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ static void parse_status_text(const char* buf, int len, char* out, int outMax) {
|
||||
|
||||
static bool check_keyboard_abort() {
|
||||
if (montauk::is_key_available()) {
|
||||
Montauk::KeyEvent ev;
|
||||
montauk::abi::KeyEvent ev;
|
||||
montauk::getkey(&ev);
|
||||
if (ev.pressed && ev.ctrl && ev.ascii == 'q') return true;
|
||||
}
|
||||
@@ -189,7 +189,7 @@ static int plain_http_exchange(int fd, const char* request, int reqLen,
|
||||
deadline = montauk::get_milliseconds() + 15000;
|
||||
while (respLen < respMax - 1) {
|
||||
if (montauk::is_key_available()) {
|
||||
Montauk::KeyEvent ev;
|
||||
montauk::abi::KeyEvent ev;
|
||||
montauk::getkey(&ev);
|
||||
if (ev.pressed && ev.ctrl && ev.ascii == 'q') return -2; // aborted
|
||||
}
|
||||
@@ -202,7 +202,7 @@ static int plain_http_exchange(int fd, const char* request, int reqLen,
|
||||
if (now >= deadline) break;
|
||||
uint32_t signals = montauk::wait_handle(
|
||||
fd,
|
||||
Montauk::IPC_SIGNAL_READABLE | Montauk::IPC_SIGNAL_PEER_CLOSED,
|
||||
montauk::abi::IPC_SIGNAL_READABLE | montauk::abi::IPC_SIGNAL_PEER_CLOSED,
|
||||
deadline - now
|
||||
);
|
||||
if (signals == 0 || signals == (uint32_t)-1) break;
|
||||
@@ -404,7 +404,7 @@ extern "C" void _start() {
|
||||
if (verbose) {
|
||||
uint32_t days, secs;
|
||||
tls::get_bearssl_time(&days, &secs);
|
||||
Montauk::DateTime dt;
|
||||
montauk::abi::DateTime dt;
|
||||
montauk::gettime(&dt);
|
||||
char tmsg[128];
|
||||
snprintf(tmsg, sizeof(tmsg), "System time: %u-%02u-%02u %02u:%02u:%02u (days=%u secs=%u)\n",
|
||||
@@ -424,7 +424,7 @@ extern "C" void _start() {
|
||||
}
|
||||
} else {
|
||||
// ---- Plain HTTP ----
|
||||
int fd = montauk::socket(Montauk::SOCK_TCP);
|
||||
int fd = montauk::socket(montauk::abi::SOCK_TCP);
|
||||
if (fd < 0) {
|
||||
montauk::print("Error: failed to create socket\n");
|
||||
montauk::exit(1);
|
||||
|
||||
@@ -369,7 +369,7 @@ extern "C" void _start() {
|
||||
win.present();
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = win.poll(&ev);
|
||||
|
||||
if (r < 0) break;
|
||||
|
||||
@@ -223,7 +223,7 @@ static int parse_request_path(const char* req, int reqLen, char* pathOut, int pa
|
||||
|
||||
static void log_request(const char* method, const char* path, int status, int bodyLen) {
|
||||
// Get timestamp
|
||||
Montauk::DateTime dt;
|
||||
montauk::abi::DateTime dt;
|
||||
montauk::gettime(&dt);
|
||||
|
||||
char msg[256];
|
||||
@@ -236,7 +236,7 @@ static void log_request(const char* method, const char* path, int status, int bo
|
||||
// ---- Page generators ----
|
||||
|
||||
static int generate_index_page(char* buf, int bufSize) {
|
||||
Montauk::SysInfo info;
|
||||
montauk::abi::SysInfo info;
|
||||
montauk::get_info(&info);
|
||||
|
||||
uint64_t ms = montauk::get_milliseconds();
|
||||
@@ -388,13 +388,13 @@ static void handle_client(int clientFd) {
|
||||
} else {
|
||||
uint32_t signals = montauk::wait_handle(
|
||||
clientFd,
|
||||
Montauk::IPC_SIGNAL_READABLE | Montauk::IPC_SIGNAL_PEER_CLOSED,
|
||||
montauk::abi::IPC_SIGNAL_READABLE | montauk::abi::IPC_SIGNAL_PEER_CLOSED,
|
||||
20
|
||||
);
|
||||
if (signals == 0) {
|
||||
idleCount++;
|
||||
if (idleCount > 500) break;
|
||||
} else if (signals & Montauk::IPC_SIGNAL_PEER_CLOSED) {
|
||||
} else if (signals & montauk::abi::IPC_SIGNAL_PEER_CLOSED) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -545,7 +545,7 @@ extern "C" void _start() {
|
||||
}
|
||||
|
||||
// Create server socket
|
||||
int listenFd = montauk::socket(Montauk::SOCK_TCP);
|
||||
int listenFd = montauk::socket(montauk::abi::SOCK_TCP);
|
||||
if (listenFd < 0) {
|
||||
montauk::print("Error: failed to create socket\n");
|
||||
montauk::exit(1);
|
||||
@@ -578,7 +578,7 @@ extern "C" void _start() {
|
||||
while (running) {
|
||||
// Check for Ctrl+Q before blocking on accept
|
||||
while (montauk::is_key_available()) {
|
||||
Montauk::KeyEvent ev;
|
||||
montauk::abi::KeyEvent ev;
|
||||
montauk::getkey(&ev);
|
||||
if (ev.pressed && ev.ctrl && ev.ascii == 'q') {
|
||||
running = false;
|
||||
@@ -599,7 +599,7 @@ extern "C" void _start() {
|
||||
|
||||
// After serving, check for Ctrl+Q
|
||||
while (montauk::is_key_available()) {
|
||||
Montauk::KeyEvent ev;
|
||||
montauk::abi::KeyEvent ev;
|
||||
montauk::getkey(&ev);
|
||||
if (ev.pressed && ev.ctrl && ev.ascii == 'q') {
|
||||
running = false;
|
||||
|
||||
@@ -70,7 +70,7 @@ extern "C" void _start() {
|
||||
|
||||
if (len <= 0 || args[0] == '\0') {
|
||||
// Show current network configuration
|
||||
Montauk::NetCfg cfg;
|
||||
montauk::abi::NetCfg cfg;
|
||||
montauk::get_netcfg(&cfg);
|
||||
montauk::print(" IP Address: ");
|
||||
print_ip(cfg.ipAddress);
|
||||
@@ -135,7 +135,7 @@ extern "C" void _start() {
|
||||
montauk::exit(1);
|
||||
}
|
||||
|
||||
Montauk::NetCfg cfg;
|
||||
montauk::abi::NetCfg cfg;
|
||||
cfg.ipAddress = ip;
|
||||
cfg.subnetMask = mask;
|
||||
cfg.gateway = gw;
|
||||
|
||||
@@ -581,7 +581,7 @@ extern "C" void _start() {
|
||||
|
||||
// Event loop
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = win.poll(&ev);
|
||||
|
||||
if (r < 0) break;
|
||||
|
||||
@@ -23,7 +23,7 @@ static void print_int(uint64_t n) {
|
||||
}
|
||||
|
||||
extern "C" void _start() {
|
||||
Montauk::SysInfo info;
|
||||
montauk::abi::SysInfo info;
|
||||
montauk::get_info(&info);
|
||||
montauk::print(info.osName);
|
||||
montauk::print(" v");
|
||||
|
||||
@@ -90,7 +90,7 @@ static int snprintf(char* buf, int size, const char* fmt, ...) {
|
||||
// ---- Logging ----
|
||||
|
||||
static void log_timestamp(char* buf, int size) {
|
||||
Montauk::DateTime dt;
|
||||
montauk::abi::DateTime dt;
|
||||
montauk::gettime(&dt);
|
||||
snprintf(buf, size, "%02d:%02d:%02d", dt.Hour, dt.Minute, dt.Second);
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
// ============================================================================
|
||||
|
||||
// EFI System Partition: C12A7328-F81F-11D2-BA4B-00A0C93EC93B
|
||||
static Montauk::PartGuid esp_type_guid() {
|
||||
Montauk::PartGuid g;
|
||||
static montauk::abi::PartGuid esp_type_guid() {
|
||||
montauk::abi::PartGuid g;
|
||||
g.Data1 = 0xC12A7328;
|
||||
g.Data2 = 0xF81F;
|
||||
g.Data3 = 0x11D2;
|
||||
@@ -24,8 +24,8 @@ static Montauk::PartGuid esp_type_guid() {
|
||||
}
|
||||
|
||||
// Linux Filesystem: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
|
||||
static Montauk::PartGuid linux_fs_type_guid() {
|
||||
Montauk::PartGuid g;
|
||||
static montauk::abi::PartGuid linux_fs_type_guid() {
|
||||
montauk::abi::PartGuid g;
|
||||
g.Data1 = 0x0FC63DAF;
|
||||
g.Data2 = 0x8483;
|
||||
g.Data3 = 0x4772;
|
||||
@@ -52,7 +52,7 @@ void installer_refresh_disks() {
|
||||
auto& st = g_state;
|
||||
st.disk_count = 0;
|
||||
for (int port = 0; port < MAX_DISKS; port++) {
|
||||
Montauk::DiskInfo info;
|
||||
montauk::abi::DiskInfo info;
|
||||
montauk::memset(&info, 0, sizeof(info));
|
||||
int r = montauk::diskinfo(&info, port);
|
||||
if (r == 0 && info.type != 0) {
|
||||
@@ -272,7 +272,7 @@ static bool copy_recursive(const char* src_dir, const char* dst_dir,
|
||||
// GPT + partition helper
|
||||
// ============================================================================
|
||||
|
||||
static void set_gpt_name(Montauk::GptAddParams& params, const char* name) {
|
||||
static void set_gpt_name(montauk::abi::GptAddParams& params, const char* name) {
|
||||
int i = 0;
|
||||
for (; name[i] && i < 71; i++) params.name[i] = name[i];
|
||||
params.name[i] = '\0';
|
||||
@@ -306,7 +306,7 @@ static void install_efi_ext2(int disk) {
|
||||
add_log("Creating EFI partition (128 MB)...");
|
||||
flush_ui();
|
||||
{
|
||||
Montauk::GptAddParams params;
|
||||
montauk::abi::GptAddParams params;
|
||||
montauk::memset(¶ms, 0, sizeof(params));
|
||||
params.blockDev = disk;
|
||||
params.startLba = FIRST_USABLE_LBA;
|
||||
@@ -327,7 +327,7 @@ static void install_efi_ext2(int disk) {
|
||||
add_log("Creating ext2 partition...");
|
||||
flush_ui();
|
||||
{
|
||||
Montauk::GptAddParams params;
|
||||
montauk::abi::GptAddParams params;
|
||||
montauk::memset(¶ms, 0, sizeof(params));
|
||||
params.blockDev = disk;
|
||||
params.startLba = 0; // auto-fill largest free region
|
||||
@@ -345,7 +345,7 @@ static void install_efi_ext2(int disk) {
|
||||
flush_ui();
|
||||
|
||||
// Step 4: Find partition indices
|
||||
Montauk::PartInfo parts[MAX_PARTS];
|
||||
montauk::abi::PartInfo parts[MAX_PARTS];
|
||||
int part_count = montauk::partlist(parts, MAX_PARTS);
|
||||
int efi_idx = -1, linux_idx = -1;
|
||||
for (int p = 0; p < part_count; p++) {
|
||||
@@ -365,10 +365,10 @@ static void install_efi_ext2(int disk) {
|
||||
add_log("Formatting EFI partition (FAT32)...");
|
||||
flush_ui();
|
||||
{
|
||||
Montauk::FsFormatParams fmt;
|
||||
montauk::abi::FsFormatParams fmt;
|
||||
montauk::memset(&fmt, 0, sizeof(fmt));
|
||||
fmt.partIndex = efi_idx;
|
||||
fmt.fsType = Montauk::FS_TYPE_FAT32;
|
||||
fmt.fsType = montauk::abi::FS_TYPE_FAT32;
|
||||
r = montauk::fs_format(&fmt);
|
||||
if (r < 0) {
|
||||
add_log("ERROR: FAT32 format failed");
|
||||
@@ -382,10 +382,10 @@ static void install_efi_ext2(int disk) {
|
||||
add_log("Formatting root partition (ext2)...");
|
||||
flush_ui();
|
||||
{
|
||||
Montauk::FsFormatParams fmt;
|
||||
montauk::abi::FsFormatParams fmt;
|
||||
montauk::memset(&fmt, 0, sizeof(fmt));
|
||||
fmt.partIndex = linux_idx;
|
||||
fmt.fsType = Montauk::FS_TYPE_EXT2;
|
||||
fmt.fsType = montauk::abi::FS_TYPE_EXT2;
|
||||
r = montauk::fs_format(&fmt);
|
||||
if (r < 0) {
|
||||
add_log("ERROR: ext2 format failed");
|
||||
@@ -515,7 +515,7 @@ static void install_single_fat32(int disk) {
|
||||
// Step 2: Create EFI System Partition (entire disk)
|
||||
add_log("Creating EFI System Partition...");
|
||||
flush_ui();
|
||||
Montauk::GptAddParams params;
|
||||
montauk::abi::GptAddParams params;
|
||||
montauk::memset(¶ms, 0, sizeof(params));
|
||||
params.blockDev = disk;
|
||||
params.startLba = 0;
|
||||
@@ -535,7 +535,7 @@ static void install_single_fat32(int disk) {
|
||||
add_log("Formatting as FAT32...");
|
||||
flush_ui();
|
||||
|
||||
Montauk::PartInfo parts[MAX_PARTS];
|
||||
montauk::abi::PartInfo parts[MAX_PARTS];
|
||||
int part_count = montauk::partlist(parts, MAX_PARTS);
|
||||
int esp_index = -1;
|
||||
for (int p = 0; p < part_count; p++) {
|
||||
@@ -550,10 +550,10 @@ static void install_single_fat32(int disk) {
|
||||
flush_ui(); st.step = STEP_ERROR; return;
|
||||
}
|
||||
|
||||
Montauk::FsFormatParams fmt;
|
||||
montauk::abi::FsFormatParams fmt;
|
||||
montauk::memset(&fmt, 0, sizeof(fmt));
|
||||
fmt.partIndex = esp_index;
|
||||
fmt.fsType = Montauk::FS_TYPE_FAT32;
|
||||
fmt.fsType = montauk::abi::FS_TYPE_FAT32;
|
||||
|
||||
r = montauk::fs_format(&fmt);
|
||||
if (r < 0) {
|
||||
|
||||
@@ -106,13 +106,13 @@ struct InstallerState {
|
||||
int mode; // InstallerMode
|
||||
|
||||
// Install flow
|
||||
Montauk::DiskInfo disks[MAX_DISKS];
|
||||
montauk::abi::DiskInfo disks[MAX_DISKS];
|
||||
int disk_count;
|
||||
int selected_disk;
|
||||
int partition_scheme;
|
||||
|
||||
// Update flow
|
||||
Montauk::PartInfo parts[MAX_PARTS];
|
||||
montauk::abi::PartInfo parts[MAX_PARTS];
|
||||
int part_count;
|
||||
int selected_part;
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ extern "C" void _start() {
|
||||
bool install_triggered = false;
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
bool redraw = false;
|
||||
|
||||
int r = g_window.poll(&ev);
|
||||
|
||||
@@ -917,7 +917,7 @@ extern "C" void _start() {
|
||||
ui_render();
|
||||
|
||||
// Create socket and connect
|
||||
irc.fd = montauk::socket(Montauk::SOCK_TCP);
|
||||
irc.fd = montauk::socket(montauk::abi::SOCK_TCP);
|
||||
if (irc.fd < 0) {
|
||||
msg_add("\033[31m*** Failed to create socket\033[0m");
|
||||
ui_render();
|
||||
@@ -955,7 +955,7 @@ extern "C" void _start() {
|
||||
|
||||
// Poll keyboard
|
||||
if (montauk::is_key_available()) {
|
||||
Montauk::KeyEvent ev;
|
||||
montauk::abi::KeyEvent ev;
|
||||
montauk::getkey(&ev);
|
||||
|
||||
if (!ev.pressed) {
|
||||
@@ -1029,7 +1029,7 @@ extern "C" void _start() {
|
||||
} else {
|
||||
if (!dirty) {
|
||||
montauk::wait_handle(irc.fd,
|
||||
Montauk::IPC_SIGNAL_READABLE | Montauk::IPC_SIGNAL_PEER_CLOSED,
|
||||
montauk::abi::IPC_SIGNAL_READABLE | montauk::abi::IPC_SIGNAL_PEER_CLOSED,
|
||||
10);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ static bool klog_render() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void klog_handle_mouse(const Montauk::WinEvent& ev) {
|
||||
static void klog_handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||
if (ev.mouse.scroll == 0) return;
|
||||
|
||||
g_klog.term.view_offset += (ev.mouse.scroll < 0) ? 3 : -3;
|
||||
@@ -193,7 +193,7 @@ extern "C" void _start() {
|
||||
while (true) {
|
||||
bool redraw = klog_poll();
|
||||
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
bool quit = false;
|
||||
int r = 0;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ struct LoginState {
|
||||
char error_msg[128];
|
||||
bool show_error;
|
||||
|
||||
Montauk::MouseState mouse;
|
||||
montauk::abi::MouseState mouse;
|
||||
uint8_t prev_buttons;
|
||||
gui::mtk::TextInputState username_input;
|
||||
gui::mtk::TextInputState display_name_input;
|
||||
@@ -144,12 +144,12 @@ void draw_login_screen(LoginState* ls);
|
||||
int max_fields(LoginState* ls);
|
||||
bool try_first_boot_submit(LoginState* ls);
|
||||
bool try_login(LoginState* ls);
|
||||
void handle_key(LoginState* ls, const Montauk::KeyEvent& key);
|
||||
void handle_key(LoginState* ls, const montauk::abi::KeyEvent& key);
|
||||
void handle_mouse(LoginState* ls);
|
||||
|
||||
// Graceful shutdown view (login_shutdown.cpp). draw_shutdown_screen paints the
|
||||
// status card; perform_graceful_shutdown runs the staged power-off (Bluetooth
|
||||
// teardown, filesystem flush) and finally issues the ACPI power-off / reset, so
|
||||
// it never returns. `action` is Montauk::POWER_REQ_SHUTDOWN or POWER_REQ_REBOOT.
|
||||
// it never returns. `action` is montauk::abi::POWER_REQ_SHUTDOWN or POWER_REQ_REBOOT.
|
||||
void draw_shutdown_screen(LoginState* ls, const char* heading, const char* status);
|
||||
[[noreturn]] void perform_graceful_shutdown(LoginState* ls, int action);
|
||||
|
||||
@@ -50,8 +50,8 @@ void launch_desktop_session(LoginState* ls) {
|
||||
// exiting (see desktop_request_power). Pick it up now that waitpid has
|
||||
// returned and run the shutdown stages; perform_graceful_shutdown never
|
||||
// returns. A normal logout leaves no request, so we fall through.
|
||||
int req = montauk::power_request(Montauk::POWER_REQ_QUERY);
|
||||
if (req == Montauk::POWER_REQ_SHUTDOWN || req == Montauk::POWER_REQ_REBOOT) {
|
||||
int req = montauk::power_request(montauk::abi::POWER_REQ_QUERY);
|
||||
if (req == montauk::abi::POWER_REQ_SHUTDOWN || req == montauk::abi::POWER_REQ_REBOOT) {
|
||||
perform_graceful_shutdown(ls, req);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ bool try_login(LoginState* ls) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void handle_key(LoginState* ls, const Montauk::KeyEvent& key) {
|
||||
void handle_key(LoginState* ls, const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return;
|
||||
|
||||
// Tab / Shift+Tab cycles fields.
|
||||
@@ -220,10 +220,10 @@ void handle_mouse(LoginState* ls) {
|
||||
}
|
||||
return;
|
||||
} else if (lo.shutdown_button.contains(mx, my)) {
|
||||
perform_graceful_shutdown(ls, Montauk::POWER_REQ_SHUTDOWN);
|
||||
perform_graceful_shutdown(ls, montauk::abi::POWER_REQ_SHUTDOWN);
|
||||
return;
|
||||
} else if (lo.reboot_button.contains(mx, my)) {
|
||||
perform_graceful_shutdown(ls, Montauk::POWER_REQ_REBOOT);
|
||||
perform_graceful_shutdown(ls, montauk::abi::POWER_REQ_REBOOT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,11 +148,11 @@ bool run_stage(void (*fn)(), uint64_t timeout_ms) {
|
||||
// that return immediately when no adapter exists (e.g. under QEMU), so this
|
||||
// gate is effectively free.
|
||||
bool bluetooth_has_active_connection() {
|
||||
Montauk::BtAdapterInfo adapter;
|
||||
montauk::abi::BtAdapterInfo adapter;
|
||||
if (montauk::bt_info(&adapter) != 0 || !adapter.initialized) {
|
||||
return false; // no adapter
|
||||
}
|
||||
Montauk::BtDevInfo devs[8];
|
||||
montauk::abi::BtDevInfo devs[8];
|
||||
int n = montauk::bt_list(devs, 8);
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (devs[i].connected) return true;
|
||||
@@ -162,7 +162,7 @@ bool bluetooth_has_active_connection() {
|
||||
|
||||
// Stage bodies -- no captured state, so they double as bare thread entries.
|
||||
void stage_disconnect_bluetooth() {
|
||||
Montauk::BtDevInfo devs[8];
|
||||
montauk::abi::BtDevInfo devs[8];
|
||||
int n = montauk::bt_list(devs, 8);
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (devs[i].connected) {
|
||||
@@ -178,7 +178,7 @@ void stage_flush_filesystems() {
|
||||
} // namespace
|
||||
|
||||
void perform_graceful_shutdown(LoginState* ls, int action) {
|
||||
const bool rebooting = (action == Montauk::POWER_REQ_REBOOT);
|
||||
const bool rebooting = (action == montauk::abi::POWER_REQ_REBOOT);
|
||||
const char* heading = rebooting ? "Restarting" : "Shutting Down";
|
||||
|
||||
// ==== Stage 1: disconnect connected Bluetooth devices ====
|
||||
|
||||
@@ -94,7 +94,7 @@ extern "C" void _start() {
|
||||
fast_mouse_path = mouse_changed || ls->mouse.buttons != 0;
|
||||
|
||||
while (montauk::is_key_available()) {
|
||||
Montauk::KeyEvent key;
|
||||
montauk::abi::KeyEvent key;
|
||||
montauk::getkey(&key);
|
||||
handle_key(ls, key);
|
||||
key_changed = true;
|
||||
|
||||
@@ -287,7 +287,7 @@ extern "C" void _start() {
|
||||
montauk::yield();
|
||||
}
|
||||
|
||||
Montauk::KeyEvent ev;
|
||||
montauk::abi::KeyEvent ev;
|
||||
montauk::getkey(&ev);
|
||||
if (!ev.pressed) continue;
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ static bool handle_mouse(MandelbrotState* mb, const MouseEvent& ev, int win_w, i
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool handle_key(MandelbrotState* mb, const Montauk::KeyEvent& key, int win_w) {
|
||||
static bool handle_key(MandelbrotState* mb, const montauk::abi::KeyEvent& key, int win_w) {
|
||||
if (!key.pressed) return false;
|
||||
|
||||
if (key.ascii == 'r' || key.ascii == 'R') {
|
||||
@@ -303,7 +303,7 @@ extern "C" void _start() {
|
||||
win.present();
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = win.poll(&ev);
|
||||
|
||||
if (r < 0) break;
|
||||
|
||||
@@ -82,7 +82,7 @@ static const int art_vw[] = {
|
||||
extern "C" void _start() {
|
||||
// ==== Gather system information ====
|
||||
|
||||
Montauk::SysInfo sysinfo;
|
||||
montauk::abi::SysInfo sysinfo;
|
||||
montauk::get_info(&sysinfo);
|
||||
|
||||
const char* username = "user";
|
||||
@@ -97,16 +97,16 @@ extern "C" void _start() {
|
||||
uint64_t mins = (total_secs % 3600) / 60;
|
||||
uint64_t secs = total_secs % 60;
|
||||
|
||||
Montauk::MemStats mem;
|
||||
montauk::abi::MemStats mem;
|
||||
montauk::memstats(&mem);
|
||||
|
||||
Montauk::FbInfo fb;
|
||||
montauk::abi::FbInfo fb;
|
||||
montauk::fb_info(&fb);
|
||||
|
||||
int tcols = 0, trows = 0;
|
||||
montauk::termsize(&tcols, &trows);
|
||||
|
||||
Montauk::DevInfo devs[32];
|
||||
montauk::abi::DevInfo devs[32];
|
||||
int ndev = montauk::devlist(devs, 32);
|
||||
const char* cpu_name = "Unknown";
|
||||
const char* gpu_name = "Unknown";
|
||||
@@ -122,14 +122,14 @@ extern "C" void _start() {
|
||||
}
|
||||
}
|
||||
|
||||
static Montauk::ProcInfo procs[PROC_SCAN_MAX];
|
||||
static montauk::abi::ProcInfo procs[PROC_SCAN_MAX];
|
||||
int nproc = montauk::proclist(procs, PROC_SCAN_MAX);
|
||||
int active = 0;
|
||||
for (int i = 0; i < nproc; i++) {
|
||||
if (process_state_alive(procs[i].state)) active++;
|
||||
}
|
||||
|
||||
Montauk::NetCfg net;
|
||||
montauk::abi::NetCfg net;
|
||||
montauk::get_netcfg(&net);
|
||||
|
||||
// ==== Build info lines ====
|
||||
|
||||
@@ -1402,7 +1402,7 @@ static bool handle_click(int mx, int my) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool handle_key(const Montauk::KeyEvent& key, bool& quit) {
|
||||
static bool handle_key(const montauk::abi::KeyEvent& key, bool& quit) {
|
||||
if (!key.pressed) return false;
|
||||
|
||||
if (key.scancode == 0x01) { // Escape
|
||||
@@ -1620,7 +1620,7 @@ extern "C" void _start() {
|
||||
}
|
||||
|
||||
// Create window
|
||||
Montauk::WinCreateResult wres;
|
||||
montauk::abi::WinCreateResult wres;
|
||||
if (montauk::win_create("Music", g.win_w, g.win_h, &wres) < 0 || wres.id < 0)
|
||||
montauk::exit(1);
|
||||
|
||||
@@ -1638,7 +1638,7 @@ extern "C" void _start() {
|
||||
uint64_t last_render = montauk::get_milliseconds();
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
bool redraw = false;
|
||||
bool quit = false;
|
||||
int r;
|
||||
|
||||
@@ -51,8 +51,8 @@ static Tab g_tab = TAB_STATUS;
|
||||
static int g_mouse_x = -1;
|
||||
static int g_mouse_y = -1;
|
||||
static int g_focus_field = -1;
|
||||
static Montauk::NetCfg g_cfg = {};
|
||||
static Montauk::NetStatus g_net = {};
|
||||
static montauk::abi::NetCfg g_cfg = {};
|
||||
static montauk::abi::NetStatus g_net = {};
|
||||
static Field g_fields[FIELD_COUNT] = {
|
||||
{"IP Address", {}, {}},
|
||||
{"Subnet Mask", {}, {}},
|
||||
@@ -475,7 +475,7 @@ static void launch_dhcp() {
|
||||
}
|
||||
|
||||
static void clear_config() {
|
||||
Montauk::NetCfg cfg = g_cfg;
|
||||
montauk::abi::NetCfg cfg = g_cfg;
|
||||
cfg.ipAddress = 0;
|
||||
cfg.subnetMask = 0;
|
||||
cfg.gateway = 0;
|
||||
@@ -500,7 +500,7 @@ static bool apply_config() {
|
||||
}
|
||||
}
|
||||
|
||||
Montauk::NetCfg cfg = g_cfg;
|
||||
montauk::abi::NetCfg cfg = g_cfg;
|
||||
cfg.ipAddress = values[0];
|
||||
cfg.subnetMask = values[1];
|
||||
cfg.gateway = values[2];
|
||||
@@ -623,7 +623,7 @@ static bool handle_mouse(int mx, int my, uint8_t buttons, uint8_t prev_buttons)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
||||
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return false;
|
||||
|
||||
if (key.scancode == 0x01) {
|
||||
@@ -694,7 +694,7 @@ extern "C" void _start() {
|
||||
render();
|
||||
|
||||
while (g_win.id >= 0 && !g_win.closed) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = g_win.poll(&ev);
|
||||
bool redraw = false;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ extern "C" void _start() {
|
||||
}
|
||||
|
||||
// Show DNS server
|
||||
Montauk::NetCfg cfg;
|
||||
montauk::abi::NetCfg cfg;
|
||||
montauk::get_netcfg(&cfg);
|
||||
|
||||
montauk::print("Server: ");
|
||||
|
||||
@@ -275,7 +275,7 @@ extern "C" void _start() {
|
||||
win.present();
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = win.poll(&ev);
|
||||
|
||||
if (r < 0) break;
|
||||
|
||||
@@ -193,7 +193,7 @@ extern "C" void _start() {
|
||||
win.present();
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = win.poll(&ev);
|
||||
|
||||
if (r < 0) break;
|
||||
|
||||
@@ -524,7 +524,7 @@ static void open_config_popup() {
|
||||
g_app.config_mouse_y = -1;
|
||||
|
||||
if (!g_config.open) {
|
||||
Montauk::WinCreateResult wres;
|
||||
montauk::abi::WinCreateResult wres;
|
||||
if (montauk::win_create("Configure Printer", CONFIG_W, CONFIG_H, &wres) < 0 || wres.id < 0) {
|
||||
set_status("Failed to open printer dialog");
|
||||
return;
|
||||
@@ -671,7 +671,7 @@ static bool handle_config_mouse(int mx, int my, uint8_t buttons, uint8_t prev_bu
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool handle_config_key(const Montauk::KeyEvent& key) {
|
||||
static bool handle_config_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return false;
|
||||
|
||||
if (key.scancode == 0x01) {
|
||||
@@ -1101,7 +1101,7 @@ static bool hover_changed(const Rect& rect, bool enabled,
|
||||
return rect.contains(prev_x, prev_y) != rect.contains(next_x, next_y);
|
||||
}
|
||||
|
||||
static bool handle_mouse(const Montauk::WinEvent& ev) {
|
||||
static bool handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||
if (g_app.config_open)
|
||||
return false;
|
||||
|
||||
@@ -1145,7 +1145,7 @@ static void cycle_tab(int delta) {
|
||||
g_app.active_tab = next;
|
||||
}
|
||||
|
||||
static void handle_key(const Montauk::KeyEvent& key) {
|
||||
static void handle_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed) return;
|
||||
|
||||
if (g_app.config_open) {
|
||||
@@ -1211,7 +1211,7 @@ extern "C" void _start() {
|
||||
render();
|
||||
|
||||
while (g_win.id >= 0 && !g_win.closed) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
bool redraw_config = false;
|
||||
bool redraw_main = false;
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ struct ProcCpuSnapshot {
|
||||
};
|
||||
|
||||
struct ProcMgrState {
|
||||
Montauk::ProcInfo procs[PM_MAX_PROCS];
|
||||
Montauk::WinInfo windows[PM_MAX_WINDOWS];
|
||||
Montauk::MemStats mem;
|
||||
Montauk::SysInfo sys_info;
|
||||
montauk::abi::ProcInfo procs[PM_MAX_PROCS];
|
||||
montauk::abi::WinInfo windows[PM_MAX_WINDOWS];
|
||||
montauk::abi::MemStats mem;
|
||||
montauk::abi::SysInfo sys_info;
|
||||
int proc_count;
|
||||
int win_count;
|
||||
int selected;
|
||||
@@ -130,7 +130,7 @@ static int parse_positive_int_after_comma(const char* text) {
|
||||
}
|
||||
|
||||
static int detect_cpu_count() {
|
||||
Montauk::DevInfo devs[16];
|
||||
montauk::abi::DevInfo devs[16];
|
||||
int count = montauk::devlist(devs, 16);
|
||||
if (count < 0) count = 0;
|
||||
|
||||
@@ -779,7 +779,7 @@ static bool handle_window_click(int mx, int my) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool handle_mouse(const Montauk::WinEvent& ev) {
|
||||
static bool handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||
bool refresh_hover_before = mouse_in_rect(refresh_button_rect());
|
||||
bool kill_hover_before = mouse_in_rect(kill_button_rect());
|
||||
|
||||
@@ -824,7 +824,7 @@ static bool handle_mouse(const Montauk::WinEvent& ev) {
|
||||
return redraw;
|
||||
}
|
||||
|
||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
||||
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed)
|
||||
return false;
|
||||
|
||||
@@ -906,7 +906,7 @@ extern "C" void _start() {
|
||||
while (!g_win.closed) {
|
||||
bool redraw = refresh_state(false);
|
||||
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = g_win.poll(&ev);
|
||||
if (r < 0) break;
|
||||
|
||||
|
||||
@@ -1053,7 +1053,7 @@ extern "C" void _start() {
|
||||
g_input.begin_frame();
|
||||
|
||||
// Process all pending events
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
while (g_engine.poll(&ev)) {
|
||||
g_input.handle_event(ev);
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ static bool run_picker(CaptureMode* out_mode) {
|
||||
|
||||
bool accepted = false;
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = win.poll(&ev);
|
||||
|
||||
if (r < 0) break;
|
||||
@@ -300,7 +300,7 @@ static bool capture_screen(ScreenBuffer* out, char* err, int err_len) {
|
||||
out->height = 0;
|
||||
out->pitch = 0;
|
||||
|
||||
Montauk::FbInfo fb;
|
||||
montauk::abi::FbInfo fb;
|
||||
montauk::fb_info(&fb);
|
||||
|
||||
int width = (int)fb.width;
|
||||
@@ -559,7 +559,7 @@ enum AreaEventResult : uint8_t {
|
||||
static AreaEventResult handle_area_selector_event(WsWindow& win,
|
||||
const ScreenBuffer& screen,
|
||||
AreaSelectorState& st,
|
||||
const Montauk::WinEvent& ev,
|
||||
const montauk::abi::WinEvent& ev,
|
||||
bool* redraw) {
|
||||
if (!redraw) return AREA_EVENT_CONTINUE;
|
||||
|
||||
@@ -660,7 +660,7 @@ static bool run_area_selector(const ScreenBuffer& screen, Rect* out_area) {
|
||||
return false;
|
||||
}
|
||||
if (st.fullscreen)
|
||||
win.set_flags(Montauk::WIN_FLAG_FULLSCREEN);
|
||||
win.set_flags(montauk::abi::WIN_FLAG_FULLSCREEN);
|
||||
|
||||
mtk::StandaloneHost host(&win);
|
||||
Canvas canvas = host.canvas();
|
||||
@@ -669,7 +669,7 @@ static bool run_area_selector(const ScreenBuffer& screen, Rect* out_area) {
|
||||
|
||||
bool accepted = false;
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = win.poll(&ev);
|
||||
|
||||
if (r < 0) break;
|
||||
@@ -803,7 +803,7 @@ static void build_default_save_dir(char* out, int out_len) {
|
||||
}
|
||||
|
||||
static void build_suggested_name(char* out, int out_len) {
|
||||
Montauk::DateTime dt;
|
||||
montauk::abi::DateTime dt;
|
||||
montauk::gettime(&dt);
|
||||
snprintf(out, out_len,
|
||||
"screenshot_%04d%02d%02d_%02d%02d%02d.jpg",
|
||||
|
||||
@@ -352,12 +352,12 @@ static constexpr uint8_t SC_DOWN = 0x50;
|
||||
static constexpr uint8_t SC_LEFT = 0x4B;
|
||||
static constexpr uint8_t SC_RIGHT = 0x4D;
|
||||
|
||||
static bool empty_key_event(const Montauk::KeyEvent& ev) {
|
||||
static bool empty_key_event(const montauk::abi::KeyEvent& ev) {
|
||||
return ev.scancode == 0 && ev.ascii == 0 && !ev.pressed &&
|
||||
!ev.shift && !ev.ctrl && !ev.alt;
|
||||
}
|
||||
|
||||
static void wait_key_event(Montauk::KeyEvent* out) {
|
||||
static void wait_key_event(montauk::abi::KeyEvent* out) {
|
||||
if (!out) return;
|
||||
|
||||
for (;;) {
|
||||
@@ -399,7 +399,7 @@ extern "C" void _start() {
|
||||
prompt();
|
||||
|
||||
while (true) {
|
||||
Montauk::KeyEvent ev;
|
||||
montauk::abi::KeyEvent ev;
|
||||
wait_key_event(&ev);
|
||||
|
||||
if (!ev.pressed) continue;
|
||||
|
||||
@@ -370,7 +370,7 @@ extern "C" void _start() {
|
||||
win.present();
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = win.poll(&ev);
|
||||
|
||||
if (r < 0) break;
|
||||
|
||||
@@ -120,7 +120,7 @@ extern "C" void _start() {
|
||||
}
|
||||
|
||||
// Create socket
|
||||
int fd = montauk::socket(Montauk::SOCK_TCP);
|
||||
int fd = montauk::socket(montauk::abi::SOCK_TCP);
|
||||
if (fd < 0) {
|
||||
montauk::print("Error: failed to create socket\n");
|
||||
montauk::exit(1);
|
||||
@@ -159,7 +159,7 @@ extern "C" void _start() {
|
||||
|
||||
// Poll keyboard
|
||||
if (montauk::is_key_available()) {
|
||||
Montauk::KeyEvent ev;
|
||||
montauk::abi::KeyEvent ev;
|
||||
montauk::getkey(&ev);
|
||||
|
||||
if (!ev.pressed) continue;
|
||||
@@ -187,7 +187,7 @@ extern "C" void _start() {
|
||||
montauk::putchar(ev.ascii);
|
||||
}
|
||||
} else {
|
||||
montauk::wait_handle(fd, Montauk::IPC_SIGNAL_READABLE | Montauk::IPC_SIGNAL_PEER_CLOSED, 10);
|
||||
montauk::wait_handle(fd, montauk::abi::IPC_SIGNAL_READABLE | montauk::abi::IPC_SIGNAL_PEER_CLOSED, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,11 @@ static bool g_should_exit = false;
|
||||
static bool g_force_redraw = true;
|
||||
static int g_last_win_w = 0;
|
||||
static int g_last_win_h = 0;
|
||||
static Montauk::ProcInfo g_kill_procs[256];
|
||||
static montauk::abi::ProcInfo g_kill_procs[256];
|
||||
static int g_kill_pids[256];
|
||||
static int g_kill_pid_count = 0;
|
||||
|
||||
static bool left_pressed(const Montauk::WinEvent& ev) {
|
||||
static bool left_pressed(const montauk::abi::WinEvent& ev) {
|
||||
return (ev.mouse.buttons & 1) && !(ev.mouse.prev_buttons & 1);
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ static bool term_render() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void term_handle_mouse(const Montauk::WinEvent& ev) {
|
||||
static void term_handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||
if (g_tabs.tab_count <= 0) return;
|
||||
|
||||
TerminalState* ts = g_tabs.tabs[g_tabs.active_tab];
|
||||
@@ -319,7 +319,7 @@ static void term_handle_mouse(const Montauk::WinEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void term_handle_key(const Montauk::KeyEvent& key) {
|
||||
static void term_handle_key(const montauk::abi::KeyEvent& key) {
|
||||
if (g_tabs.tab_count <= 0) return;
|
||||
|
||||
if (key.ctrl && key.pressed && key.scancode == 0x14) {
|
||||
@@ -423,7 +423,7 @@ extern "C" void _start() {
|
||||
|
||||
while (!g_should_exit) {
|
||||
bool redraw = false;
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
bool quit = false;
|
||||
int r = 0;
|
||||
|
||||
|
||||
@@ -1033,7 +1033,7 @@ static void open_pathbar_save() {
|
||||
// Keyboard handler
|
||||
// ============================================================================
|
||||
|
||||
static bool handle_key(Montauk::KeyEvent& key, int win_id) {
|
||||
static bool handle_key(montauk::abi::KeyEvent& key, int win_id) {
|
||||
if (!key.pressed) return false;
|
||||
|
||||
if (g_ctx_menu.open) {
|
||||
@@ -1227,7 +1227,7 @@ static bool handle_key(Montauk::KeyEvent& key, int win_id) {
|
||||
// Mouse handler
|
||||
// ============================================================================
|
||||
|
||||
static bool handle_mouse(Montauk::WinEvent& ev, int win_id) {
|
||||
static bool handle_mouse(montauk::abi::WinEvent& ev, int win_id) {
|
||||
int mx = ev.mouse.x;
|
||||
int my = ev.mouse.y;
|
||||
uint8_t btns = ev.mouse.buttons;
|
||||
@@ -1458,7 +1458,7 @@ extern "C" void _start() {
|
||||
}
|
||||
|
||||
// Create window
|
||||
Montauk::WinCreateResult wres;
|
||||
montauk::abi::WinCreateResult wres;
|
||||
if (montauk::win_create(title, INIT_W, INIT_H, &wres) < 0 || wres.id < 0)
|
||||
montauk::exit(1);
|
||||
|
||||
@@ -1469,7 +1469,7 @@ extern "C" void _start() {
|
||||
montauk::win_present(win_id);
|
||||
|
||||
while (true) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = montauk::win_poll(win_id, &ev);
|
||||
|
||||
if (r < 0) break;
|
||||
|
||||
@@ -692,7 +692,7 @@ static void render() {
|
||||
host.present();
|
||||
}
|
||||
|
||||
static bool handle_mouse(const Montauk::WinEvent& ev) {
|
||||
static bool handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||
int prev_x = g_mouse_x;
|
||||
int prev_y = g_mouse_y;
|
||||
g_mouse_x = ev.mouse.x;
|
||||
@@ -803,7 +803,7 @@ static bool handle_mouse(const Montauk::WinEvent& ev) {
|
||||
return redraw;
|
||||
}
|
||||
|
||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
||||
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||
if (!key.pressed || g_country_count <= 0) return false;
|
||||
|
||||
if (key.ascii == '\n' || key.ascii == '\r') {
|
||||
@@ -858,7 +858,7 @@ extern "C" void _start() {
|
||||
render();
|
||||
|
||||
while (g_win.id >= 0 && !g_win.closed) {
|
||||
Montauk::WinEvent ev;
|
||||
montauk::abi::WinEvent ev;
|
||||
int r = g_win.poll(&ev);
|
||||
bool redraw = false;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user