summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/keymap.h
blob: 8bfbe07a5c4dcdc8d03fddb78ba9bfec3850741f (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
#ifndef _IPXE_KEYMAP_H
#define _IPXE_KEYMAP_H

/**
 * @file
 *
 * Keyboard mappings
 *
 */

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );

#include <stdint.h>
#include <ipxe/tables.h>

/** A remapped key
 *
 * Represents a mapping from an ASCII character (as interpreted from a
 * keyboard scancode by the US-only keyboard driver provided by the
 * BIOS) to the appropriate ASCII value for the keyboard layout.
 */
struct keymap_key {
	/** Character read from keyboard */
	uint8_t from;
	/** Character to be used instead */
	uint8_t to;
} __attribute__ (( packed ));

/** A keyboard mapping */
struct keymap {
	/** Name */
	const char *name;
	/** Basic remapping table (zero-terminated) */
	struct keymap_key *basic;
	/** AltGr remapping table (zero-terminated) */
	struct keymap_key *altgr;
};

/** Keyboard mapping table */
#define KEYMAP __table ( struct keymap, "keymap" )

/** Define a default keyboard mapping */
#define __keymap_default __table_entry ( KEYMAP, 01 )

/** Define a keyboard mapping */
#define __keymap __table_entry ( KEYMAP, 02 )

/** Mappable character mask */
#define KEYMAP_MASK 0xff

/** Pseudo key flag */
#define KEYMAP_PSEUDO 0x80

/** Ctrl key flag */
#define KEYMAP_CTRL 0x0100

/** CapsLock key flag */
#define KEYMAP_CAPSLOCK 0x0200

/** Undo CapsLock key flag
 *
 * Used when the keyboard driver has already interpreted the CapsLock
 * key, in which case the effect needs to be undone before remapping
 * in order to correctly handle keyboard mappings that swap alphabetic
 * and non-alphabetic keys.
 */
#define KEYMAP_CAPSLOCK_UNDO 0x0400

/** Undo and redo CapsLock key flags */
#define KEYMAP_CAPSLOCK_REDO ( KEYMAP_CAPSLOCK | KEYMAP_CAPSLOCK_UNDO )

/** AltGr key flag */
#define KEYMAP_ALTGR 0x0800

extern unsigned int key_remap ( unsigned int character );
extern struct keymap * keymap_find ( const char *name );
extern void keymap_set ( struct keymap *keymap );

#endif /* _IPXE_KEYMAP_H */