-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkeyboard.h
executable file
·77 lines (60 loc) · 1.83 KB
/
keyboard.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* keyboard.h - Function Header File to be used with "keyboard.c"
*/
#ifndef _KEYBOARD_H
#define _KEYBOARD_H
#include "types.h"
/* PIC Interrupt Line and IDT Vector Number */
#define KEYBOARD_IRQ_LINE 1
#define KEYBOARD_DATA_PORT 0x60
#define KEY_BUFFER_SIZE 127
/* Magic Numbers */
#define KEY_COUNT 60
#define KEY_MODES 4
#define BACKSPACE 0x0E
#define TAB 0x0F
#define CAPS_LOCK 0x3A
#define ENTER 0x1C
#define LSHIFT_DOWN 0x2A
#define LSHIFT_UP 0xAA
#define RSHIFT_DOWN 0x36
#define RSHIFT_UP 0xB6
#define CTRL_DOWN 0x1D
#define ALT_DOWN 0x38
#define CTRL_UP 0x9D
#define ALT_UP 0xB8
#define F1_KEY 0x3B
#define F2_KEY 0x3C
#define F3_KEY 0x3D
#define TERMINAL_ONE 0
#define TERMINAL_TWO 1
#define TERMINAL_THREE 2
#define UNPRESSED 0
#define PRESSED 1
#define ENABLE_CAPS() (key_mode |= 1 << 1)
#define DISABLE_CAPS() (key_mode &= ~(1 << 1))
#define TOGGLE_CAPS() (key_mode ^= 1 << 1)
#define ENABLE_SHIFT() (key_mode |= 1)
#define DISABLE_SHIFT() (key_mode &= ~(1))
#define APPEND_TO_KEY_BUFF(k) key_buffer[key_buffer_idx++] = (k)
#define NULL_KEY '\0'
extern volatile uint8_t key_buffer_idx;
extern volatile uint8_t enter_flag;
extern volatile uint8_t *key_buffer;
/* Initialize Keyboard Function */
extern void init_keyboard(void);
/* Keyboard Interrupt Handler Function */
extern void keyboard_interrupt_handler(void);
/* Clears the key board buffer */
extern void clear_key_buffer(void);
/* Adds key to key buffer */
void append_to_key_buff(uint8_t key);
/* Called when a character key is pressed*/
void handle_key_press(uint8_t scancode);
/* Clears the key buffer */
void clear_key_buffer();
/* Called when enter key is pressed */
void handle_enter();
/* Called when backspace key is pressed */
void handle_backspace();
#endif /* _KEYBOARD_H */