summaryrefslogtreecommitdiff
path: root/src/kernel/dev/keyboard.h
blob: 61fdbe7fc3b334554cfc7aa903d7456fc224857f (plain) (blame)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef DEF_DEV_KEYBOARD_H
#define DEF_DEV_KEYBOARD_H

#include <vfs/node.h>


// Control keys - arbitrary constants
#define KB_ESCAPE		1
#define KB_BACKSPACE	2
#define KB_TAB			3
#define KB_ENTER		4
#define KB_LCTRL		5
#define KB_RCTRL		6
#define KB_LSHIFT		7
#define KB_RSHIFT		8
#define KB_ALT			9
#define KB_CAPSLOCK		10
#define KB_F1			11
#define KB_F2			12
#define KB_F3			13
#define KB_F4			14
#define KB_F5			15
#define KB_F6			16
#define KB_F7			17
#define KB_F8			18
#define KB_F9			19
#define KB_F10			20
#define KB_F11			21
#define KB_F12			22
#define KB_NUMLOCK		23
#define KB_SCRLLOCK		24

#define KB_KPDEL		25		// also keypad .
#define KB_KPINS		26		// also keypad 0
#define KB_KPEND		27		// also 1
#define KB_KPDOWN		28		// also 2
#define KB_KPPGDOWN		29		// also 3
#define KB_KPLEFT		30		//...
#define KB_KP5			31
#define KB_KPRIGHT		32
#define KB_KPHOME		33
#define KB_KPUP			34
#define KB_KPPGUP		35		// also 9

#define KB_SYSREQ		36
#define KB_PRTSCN		38
#define KB_ALTGR		39
#define KB_HOME			40
#define KB_END			41
#define KB_PGUP			42
#define KB_PGDOWN		43
#define KB_INS			44
#define KB_DEL			45
#define KB_DOWN			46
#define KB_UP			47
#define KB_LEFT			48
#define KB_RIGHT		49
#define KB_LSUPER		50
#define KB_RSUPER		51
#define KB_MENU			52

#define KB_CMD_ALT		64		// any command with alt will have this flag
#define KB_CMD_CTRL		128		// any command with controll will have this flag

struct keypress {
	bool pressed;		// false = key was released
	int scancode;
	int command;
	int character;
};

struct keymap {
	int normal[128];
	int shift[128];
	int caps[128];
	int altgr[128];
	int shiftaltgr[128];
};

class keyboard : public node {
	private:
	keymap* km;

	protected:
	bool num, caps, scroll;
	bool shift, altgr;
	bool alt, ctrl;

	virtual void updateLeds() = 0;

	public:
	keyboard(node* parent);
	virtual ~keyboard() {}
	
	void handle(int scancode, bool pressed);
};

#endif