From bce944d1498eaa3b6940ee234c863b3548a66b37 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 24 Jan 2021 12:00:11 -0500 Subject: graphics! --- src/shared/include/keypack.h | 137 +++++++++++++++++++++++++++++++++++++++++++ src/shared/include/winact.h | 19 ++++++ 2 files changed, 156 insertions(+) create mode 100644 src/shared/include/keypack.h create mode 100644 src/shared/include/winact.h (limited to 'src/shared') diff --git a/src/shared/include/keypack.h b/src/shared/include/keypack.h new file mode 100644 index 0000000..1b356a3 --- /dev/null +++ b/src/shared/include/keypack.h @@ -0,0 +1,137 @@ +#ifndef SHARED_KEYPACK_H +#define SHARED_KEYPACK_H + +struct key_packet { + enum key_id_t { + KEY_BSPACE = 0x08, + KEY_TAB, + KEY_ENTER, + KEY_SPACE = ' ', + KEY_APOSTRAPHE = '\'', + KEY_COMMA = ',', + KEY_HYPHEN, + KEY_PERIOD, + KEY_SLASH, + KEY_ZERO, + KEY_ONE, + KEY_TWO, + KEY_THREE, + KEY_FOUR, + KEY_FIVE, + KEY_SIX, + KEY_SEVEN, + KEY_EIGHT, + KEY_NINE, + KEY_SEMICOLON = ';', + KEY_EQUALS = '=', + KEY_OPEN_BRACKET = '[', + KEY_BACKSLASH, + KEY_CLOSE_BRACKET, + KEY_GRAVE = '`', + KEY_A, + KEY_B, + KEY_C, + KEY_D, + KEY_E, + KEY_F, + KEY_G, + KEY_H, + KEY_I, + KEY_J, + KEY_K, + KEY_L, + KEY_M, + KEY_N, + KEY_O, + KEY_P, + KEY_Q, + KEY_R, + KEY_S, + KEY_T, + KEY_U, + KEY_V, + KEY_W, + KEY_X, + KEY_Y, + KEY_Z, + + KEY_LEFT_SHIFT = 0x80, + KEY_RIGHT_SHIFT, + KEY_LEFT_CONTROL, + KEY_RIGHT_CONTROL, + KEY_LEFT_ALT, + KEY_RIGHT_ALT, + KEY_LEFT_WIN, + KEY_RIGHT_WIN, + KEY_CAPS_LOCK, + KEY_NUM_LOCK, + KEY_SCROLL_LOCK, + KEY_INSERT, + + KEY_F1 = 0xa0, + KEY_F2, + KEY_F3, + KEY_F4, + KEY_F5, + KEY_F6, + KEY_F7, + KEY_F8, + KEY_F9, + KEY_F10, + KEY_F11, + KEY_F12, + KEY_NUM_ZERO = 0xb0, + KEY_NUM_ONE, + KEY_NUM_TWO, + KEY_NUM_THREE, + KEY_NUM_FOUR, + KEY_NUM_FIVE, + KEY_NUM_SIX, + KEY_NUM_SEVEN, + KEY_NUM_EIGHT, + KEY_NUM_NINE, + KEY_NUM_TIMES, + KEY_NUM_PLUS, + KEY_NUM_ENTER, + KEY_NUM_MINUS, + KEY_NUM_DOT, + KEY_NUM_DIVIDE, + KEY_DELETE = 0xc1, + KEY_HOME, + KEY_END, + KEY_PAGE_UP, + KEY_PAGE_DOWN, + KEY_UP_ARROW, + KEY_DOWN_ARROW, + KEY_LEFT_ARROW, + KEY_RIGHT_ARROW, + KEY_ESCAPE, + KEY_MENU, + KEY_PAUSE, + KEY_PRINT_SCREEN + } key_id; + enum key_modifiers_t { + LSHIFT = 0x001, + RSHIFT = 0x002, + LCTRL = 0x004, + RCTRL = 0x008, + LALT = 0x010, + RALT = 0x020, + LWIN = 0x040, + RWIN = 0x080, + + CAPS = 0x100, + NUM = 0x200, + SCROLL = 0x400, + INSERT = 0x800, + + SHIFTS = 0x003, + CTRLS = 0x00c, + ALTS = 0x030, + WINS = 0x0c0, + + NO_MODS = 0x000 + } modifiers; +} __attribute__ ((__packed__)); + +#endif \ No newline at end of file diff --git a/src/shared/include/winact.h b/src/shared/include/winact.h new file mode 100644 index 0000000..bc18cb4 --- /dev/null +++ b/src/shared/include/winact.h @@ -0,0 +1,19 @@ +#ifndef SHARED_WINACT_H +#define SHARED_WINACT_H + +#include + +struct window_action { + enum { + NOT_READY, + KEY_DOWN, + KEY_UP, + FOCUS_ENTER, + FOCUS_LEAVE + } action_type; + union { + struct key_packet as_key; + }; +} __attribute__ ((__packed__)); + +#endif \ No newline at end of file -- cgit v1.2.3