45 lines
1.3 KiB
C

#pragma once
#include <stdbool.h>
#include <stdint.h>
#define KEYBOARD_INTERRUPT_BUF_CAP 100
typedef struct {
volatile uint32_t len;
uint8_t *buf;
uint32_t copy_len;
uint8_t *copy_buf;
uint8_t copy_pressed[16];
} keyboard_interrupt_shared_t;
#define KEYCODE_SHIFT 42
#define KEYCODE_ENTER 28
#define KEYCODE_BACKSPACE 14
/* decoding */
static const char keysym_mapped_ascii_lower[] = {
0 , 0 , '1', '2', '3', '4', '5', '6',
'7', '8', '9', '0', '-', '=', 0 , 0 , 'q', 'w', 'e', 'r', 't', 'y',
'u', 'i', 'o', 'p', '[', ']', '\n', 0 , 'a', 's', 'd', 'f', 'g',
'h', 'j', 'k', 'l', ';', '\'', '`', 0 , '\\', 'z', 'x', 'c', 'v',
'b', 'n', 'm', ',', '.', '/', 0 , 0 , 0 , ' ',
};
static const char keysym_mapped_ascii_upper[] = {
0 , 0 , '!', '@', '#', '$', '%', '^',
'&', '*', '(', ')', '_', '+', 0 , 0 , 'Q', 'W', 'E', 'R', 'T', 'Y',
'U', 'I', 'O', 'P', '{', '}', '\n', 0 , 'A', 'S', 'D', 'F', 'G',
'H', 'J', 'K', 'L', ':', '"', '~', 0 , '\\', 'Z', 'X', 'C', 'V',
'B', 'N', 'M', '<', '>', '?' /* an actual question mark */, 0 , 0 , 0 , ' ',
};
extern keyboard_interrupt_shared_t kbd_state_shrd;
void init_keyboard();
uint8_t kbd_take_from_copy_buffer();
bool kbd_can_take_from_copy_buffer();
bool kbd_is_pressed(uint8_t code);