Files
2026-05-27 19:34:54 +02:00

40 lines
1.2 KiB
C

// SPDX-License-Identifier: MPL-2.0
#ifndef SH_LIB_EVENT_H
#define SH_LIB_EVENT_H
#include "std/type.h"
// Events types
typedef sh_uint8 sh_event_TYPE;
#define SH_EVENT_TYPE_PS2_NORMAL 0U
#define SH_EVENT_TYPE_PS2_E0 1U
#define SH_EVENT_TYPE_KBD_CONTEXT 2U
#define SH_EVENT_TYPE_KBD_PAUSE 3U
// Keyboard events context flags
#define SH_KBD_EVENT_SHIFT_ACTIVE (1u<<0)
#define SH_KBD_EVENT_WIN_ACTIVE (1u<<1)
#define SH_KBD_EVENT_LEFT_ACTIVE (1u<<1)
#define SH_KBD_EVENT_RIGHT_ACTIVE (1u<<0)
#define SH_KBD_EVENT_NUMLOCK_ACTIVE (1u<<0)
#define SH_KBD_EVENT_CAPSLOCK_ACTIVE (1u<<1)
// Keyboard contexts key scancodes
#define SH_KBD_CONTEXT_LSHIFT 0U
#define SH_KBD_CONTEXT_RSHIFT 1U
#define SH_KBD_CONTEXT_LCTRL 2U
#define SH_KBD_CONTEXT_RCTRL 3U
#define SH_KBD_CONTEXT_LALT 4U
#define SH_KBD_CONTEXT_RALT 5U
#define SH_KBD_CONTEXT_WIN 6U
#define SH_KBD_CONTEXT_NUMLOCK 7U
#define SH_KBD_CONTEXT_CAPSLOCK 8U
// Keyboard event structure
typedef struct {
sh_uint16 scancode;
sh_bool pressed;
sh_uint8 context_shift_win;
sh_uint8 context_alt;
sh_uint8 context_ctrl;
sh_uint8 context_lock_status;
sh_uint8 event_type;
sh_uint64 timestamp; // tsc
} sh_kbd_EVENT;
#endif