// Native logical-input service protocol and client helpers. #pragma once #include #include #include #include #include #define NTL_INPUT_PROTOCOL_VERSION 1u #define NTL_INPUT_SERVICE_PATH "/Services/Input" #define NTL_INPUT_FLAG_NONE 0x00000000u #define NTL_INPUT_OP_READ_KEY 1u #define NTL_INPUT_OP_PEEK_KEY 2u #define NTL_INPUT_OP_READ_MOUSE 3u #define NTL_INPUT_OP_PEEK_MOUSE 4u #define NTL_INPUT_OP_QUERY_STATE 5u #define NTL_INPUT_STATE_FLAG_NONE 0x00000000u #define NTL_INPUT_KEY_BYTES 32u // RSSRV-owned logical input state. This is distinct from the legacy kernel-global input snapshot. typedef struct NTL_INPUT_STATE { uint32_t Size; uint32_t Flags; uint64_t Generation; uint32_t Modifiers; uint8_t KeyDown[NTL_INPUT_KEY_BYTES]; int32_t MouseX; int32_t MouseY; int32_t MouseWheel; uint32_t MouseButtons; } NTL_INPUT_STATE; // Request header for all logical-input service operations. typedef struct NTL_INPUT_REQUEST { uint32_t Size; uint32_t Version; uint32_t Operation; uint32_t Flags; uint64_t TimeoutMilliseconds; } NTL_INPUT_REQUEST; // Fixed reply. Only the field associated with Operation is meaningful on success. typedef struct NTL_INPUT_REPLY { uint32_t Size; uint32_t Version; uint32_t Operation; uint32_t Flags; KSTATUS Status; uint32_t Reserved; INPUT_KEY_RECORD Key; INPUT_MOUSE_EVENT Mouse; NTL_INPUT_STATE State; } NTL_INPUT_REPLY; #if defined(NTL_SYSCALL_STATIC) #define NTL_INPUT_API #elif defined(NTL_SYSCALL_BUILD) #define NTL_INPUT_API __declspec(dllexport) #else #define NTL_INPUT_API #endif // Opens one session to RSSRV's logical-input service. NTL_INPUT_API KSTATUS NtlInputConnect(SYS_HANDLE* sessionOut); NTL_INPUT_API KSTATUS NtlInputClose(SYS_HANDLE session); // Reads or peeks one logical keyboard record. SYS_HANDLE_INVALID selects the process-default session; a zero timeout is nonblocking. NTL_INPUT_API KSTATUS NtlInputReadEvent(SYS_HANDLE session, uint64_t timeoutMilliseconds, INPUT_KEY_RECORD* recordOut); NTL_INPUT_API KSTATUS NtlInputPeekEvent(SYS_HANDLE session, uint64_t timeoutMilliseconds, INPUT_KEY_RECORD* recordOut); // Reads or peeks one logical mouse event. SYS_HANDLE_INVALID selects the process-default session; a zero timeout is nonblocking. NTL_INPUT_API KSTATUS NtlInputReadMouse(SYS_HANDLE session, uint64_t timeoutMilliseconds, INPUT_MOUSE_EVENT* eventOut); NTL_INPUT_API KSTATUS NtlInputPeekMouse(SYS_HANDLE session, uint64_t timeoutMilliseconds, INPUT_MOUSE_EVENT* eventOut); // Snapshots RSSRV's logical key/modifier/pointer state. NTL_INPUT_API KSTATUS NtlInputQueryState(SYS_HANDLE session, NTL_INPUT_STATE* stateOut); // Process-local convenience wrappers backed by a lazily connected RSSRV session. NTL_INPUT_API KSTATUS NtlInputPollKeyboard(INPUT_KEY* keyOut); NTL_INPUT_API KSTATUS NtlInputIsKeyDown(INPUT_KEY key, bool* downOut); NTL_INPUT_API KSTATUS NtlInputReadKeyboardChar(char* charOut); NTL_INPUT_API KSTATUS NtlInputReadKey(INPUT_KEY* keyOut); NTL_INPUT_API uint32_t NtlInputGetKeyModifiers(void); NTL_INPUT_API KSTATUS NtlInputQueryDefaultState(NTL_INPUT_STATE* stateOut); NTL_INPUT_API KSTATUS NtlInputGetMousePos(int32_t* xOut, int32_t* yOut); #undef NTL_INPUT_API