82 lines
2.8 KiB
C
82 lines
2.8 KiB
C
// Kernel input declarations shared by implementation files and kernel clients.
|
|
|
|
#pragma once
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <ntlite/input.h>
|
|
#include <kernel/hal/hal_api.h>
|
|
#include <ntlite/status.h>
|
|
#include <kernel/ob_object.h>
|
|
#include <kernel/ke_event.h>
|
|
#include <kernel/ke_dpc.h>
|
|
|
|
typedef struct SYS_GLOBAL_INPUT_STATE SYS_GLOBAL_INPUT_STATE;
|
|
|
|
typedef struct INPUT_KEY_QUEUE_ENTRY {
|
|
INPUT_KEY Key;
|
|
char Character;
|
|
uint32_t Modifiers;
|
|
} INPUT_KEY_QUEUE_ENTRY;
|
|
|
|
typedef struct KE_INPUT_CONTEXT {
|
|
const HAL_API* Hal;
|
|
volatile uint8_t KeyDown[256];
|
|
volatile uint32_t Modifiers;
|
|
volatile long long Generation;
|
|
|
|
INPUT_KEY_QUEUE_ENTRY KeyQueue[256];
|
|
volatile int KeyHead;
|
|
volatile int KeyTail;
|
|
volatile INPUT_KEY RepeatKey;
|
|
volatile uint64_t RepeatNextTick;
|
|
KDPC RepeatDpc;
|
|
|
|
INPUT_MOUSE_EVENT MouseQueue[128];
|
|
volatile int MouseHead;
|
|
volatile int MouseTail;
|
|
volatile int MouseX;
|
|
volatile int MouseY;
|
|
volatile int MouseBoundsWidth;
|
|
volatile int MouseBoundsHeight;
|
|
volatile int MouseWheel;
|
|
volatile uint8_t MouseButtons;
|
|
|
|
EVENT* WaitEvent;
|
|
} KE_INPUT_CONTEXT;
|
|
|
|
typedef struct INPUT_QUEUE {
|
|
OBJECT Header;
|
|
KE_INPUT_CONTEXT* Context;
|
|
EVENT* WaitEvent;
|
|
} INPUT_QUEUE;
|
|
|
|
void KeInputInitialize(const HAL_API* hal);
|
|
|
|
__declspec(dllexport) KSTATUS KeInputRegisterDevice(const char* name, uint32_t flags, uint32_t* outDeviceId);
|
|
__declspec(dllexport) void KeInputSubmitKey(const INPUT_KEY_EVENT* event);
|
|
__declspec(dllexport) void KeInputSubmitMouse(const INPUT_MOUSE_EVENT* event);
|
|
__declspec(dllexport) void KeInputSubmitMouseAbsolute(const INPUT_MOUSE_ABSOLUTE_EVENT* event);
|
|
__declspec(dllexport) void KeInputSubmitMouseAbsoluteScaled(uint32_t rawX, uint32_t rawY, uint32_t maxX, uint32_t maxY, int wheel, uint8_t buttons);
|
|
|
|
INPUT_KEY KeInputKbPoll(void);
|
|
KSTATUS KeInputWaitKey(uint8_t alertable, uint64_t timeoutMs);
|
|
void KeInputTimerTick(void);
|
|
bool KeInputIsKeyDown(INPUT_KEY key);
|
|
bool KeInputPeekEvent(INPUT_KEY_RECORD* record);
|
|
bool KeInputReadEvent(INPUT_KEY_RECORD* record);
|
|
KSTATUS KeInputOpenQueue(INPUT_QUEUE** out);
|
|
bool KeInputQueuePeekEvent(INPUT_QUEUE* queue, INPUT_KEY_RECORD* record);
|
|
bool KeInputQueueReadEvent(INPUT_QUEUE* queue, INPUT_KEY_RECORD* record);
|
|
KSTATUS KeInputQueueWaitKey(INPUT_QUEUE* queue, uint8_t alertable, uint64_t timeoutMs);
|
|
EVENT* KeInputQueueWaitEvent(INPUT_QUEUE* queue);
|
|
INPUT_KEY KeInputReadKey(void);
|
|
char KeInputReadChar(void);
|
|
uint32_t KeInputGetModifiers(void);
|
|
KSTATUS KeInputQueryGlobalState(SYS_GLOBAL_INPUT_STATE* out);
|
|
|
|
bool KeInputMousePeek(INPUT_MOUSE_EVENT* event);
|
|
bool KeInputMouseRead(INPUT_MOUSE_EVENT* event);
|
|
void KeInputMouseGetPosition(int* x, int* y);
|
|
void KeInputMouseSetPosition(int x, int y);
|
|
void KeInputMouseSetBounds(int w, int h);
|