92 lines
3.7 KiB
C
92 lines
3.7 KiB
C
// user32.c - Win32 user interface stubs (no window manager yet)
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Syscall stubs (from syscall.dll)
|
|
// ---------------------------------------------------------------------------
|
|
extern void SysScreenBlit(int x, int y, int w, int h, const uint32_t* pixels);
|
|
extern void SysYield(void);
|
|
extern void SysDebugPrint(const char* str);
|
|
extern uint32_t SysKbPoll(void);
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Types
|
|
// ---------------------------------------------------------------------------
|
|
typedef void* HWND;
|
|
|
|
#define IDOK 1
|
|
#define IDCANCEL 2
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Keyboard
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// GetAsyncKeyState: returns non-zero if a key is available in the input
|
|
// buffer. We have no per-key state, so the vKey argument is ignored and
|
|
// the high bit (key-down) is set whenever SysKbPoll reports data waiting.
|
|
__declspec(dllexport) short GetAsyncKeyState(int vKey) {
|
|
(void)vKey;
|
|
// High bit (0x8000 / INT16_MIN) = key is down.
|
|
// Low bit = key pressed since last call; we have no per-key history to
|
|
// track, so it is left clear.
|
|
return SysKbPoll() ? (short)(-32768) : 0;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Screen output
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// BitBlt is the only graphical primitive available at this stage.
|
|
__declspec(dllexport) void BitBlt(int x, int y, int w, int h, const uint32_t* pixels) {
|
|
SysScreenBlit(x, y, w, h, pixels);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Message loop (stubs - always return 0 / no messages)
|
|
// ---------------------------------------------------------------------------
|
|
__declspec(dllexport) int GetMessage(void* msg, HWND hwnd,
|
|
unsigned int min, unsigned int max) {
|
|
(void)msg; (void)hwnd; (void)min; (void)max;
|
|
SysYield();
|
|
return 0;
|
|
}
|
|
|
|
__declspec(dllexport) int DispatchMessage(const void* msg) { (void)msg; return 0; }
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Window queries (stubs - no WM exists yet, all return NULL / 0)
|
|
// ---------------------------------------------------------------------------
|
|
__declspec(dllexport) HWND GetDesktopWindow(void) { return (HWND)0; }
|
|
__declspec(dllexport) HWND GetActiveWindow(void) { return (HWND)0; }
|
|
__declspec(dllexport) HWND GetTopWindow(HWND hwnd){ (void)hwnd; return (HWND)0; }
|
|
|
|
__declspec(dllexport) HWND GetWindow(HWND hwnd, unsigned int cmd) {
|
|
(void)hwnd; (void)cmd; return (HWND)0;
|
|
}
|
|
|
|
__declspec(dllexport) long GetWindowLongA(HWND hwnd, int index) {
|
|
(void)hwnd; (void)index; return 0;
|
|
}
|
|
|
|
__declspec(dllexport) intptr_t GetWindowLongPtrA(HWND hwnd, int index) {
|
|
(void)hwnd; (void)index; return 0;
|
|
}
|
|
|
|
__declspec(dllexport) unsigned long GetWindowThreadProcessId(HWND hwnd, unsigned long* pid) {
|
|
(void)hwnd;
|
|
if (pid) *pid = 1;
|
|
return 1; // Thread ID
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Dialogs
|
|
// ---------------------------------------------------------------------------
|
|
__declspec(dllexport) int MessageBoxA(HWND hwnd, const char* text,
|
|
const char* caption, unsigned int type) {
|
|
(void)hwnd; (void)text; (void)caption; (void)type;
|
|
// No UI available, console
|
|
SysDebugPrint(text);
|
|
return IDOK;
|
|
}
|