blob: 4fd0b1df4aa476d0c4e91272a2f267d2dfd6f959 (
plain) (
tree)
|
|
#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_KPSLASH 53
#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 vt;
class keyboard : public node {
private:
keymap* km;
vt *output;
protected:
bool num, caps, scroll;
bool shift, altgr;
bool alt, ctrl;
virtual void updateLeds() = 0;
public:
keyboard(node* parent);
virtual ~keyboard() {}
void outputTo(vt *vt);
void handle(int scancode, bool pressed);
int link(node* to, int mode);
};
#endif
|