1 /**
2  * @namespace   biewlib
3  * @file        biewlib/sysdep/ia16/dos/kbd_code.h
4  * @brief       This file contains definitions of BIOS keyboard codes.
5  * @version     -
6  * @remark      this source file is part of Binary vIEW project (BIEW).
7  *              The Binary vIEW (BIEW) is copyright (C) 1995 Nickols_K.
8  *              All rights reserved. This software is redistributable under the
9  *              licence given in the file "Licence.en" ("Licence.ru" in russian
10  *              translation) distributed in the BIEW archive.
11  * @note        Requires POSIX compatible development system
12  *
13  * @author      Nickols_K
14  * @since       1995
15  * @note        Development, fixes and improvements
16 **/
17 #ifndef __KBD_CODES_H
18 #define __KBD_CODES_H
19 
20 /* This codes describes shift keys state */
21 
22 #define KS_SHIFT           3
23 #define KS_CTRL            4
24 #define KS_ALT             8
25 #define KS_CTRL_MASK      15
26 #define KS_SCRLOCK        16
27 #define KS_NUMLOCK        32
28 #define KS_CAPSLOCK       64
29 #define KS_INSERT        128
30 
31 /*
32     not real keys, for internal use only
33 */
34 
35 #define KE_SUPERKEY	0xFFFF
36 #define KE_JUSTFIND	0xFFFE
37 
38 /*
39    This code describes mouse event
40 */
41 
42 #define KE_MOUSE        0xFFFB
43 
44 /*
45    This code describes shift keys event
46 */
47 
48 #define KE_SHIFTKEYS    0xFFFA
49 
50 /*
51    This section describes real key code
52 */
53 
54 #define KE_ESCAPE            0x011B
55 #define KE_ENTER             0x1C0D
56 #define KE_CTL_ENTER         0x1C0A
57 #define KE_SPACE             0x3920
58 #define KE_BKSPACE           0x0E08
59 #define KE_CTL_BKSPACE       0x0E7F
60 #define KE_TAB               0x0F09
61 #define KE_SHIFT_TAB         0x0F00
62 
63 #define KE_DOWNARROW         0x5000
64 #define KE_UPARROW           0x4800
65 #define KE_LEFTARROW         0x4b00
66 #define KE_RIGHTARROW        0x4d00
67 
68 #define KE_CTL_LEFTARROW     0x7300
69 #define KE_CTL_RIGHTARROW    0x7400
70 
71 #define KE_HOME              0x4700
72 #define KE_END               0x4f00
73 #define KE_PGUP              0x4900
74 #define KE_PGDN              0x5100
75 #define KE_INS               0x5200
76 #define KE_DEL               0x5300
77 
78 #define KE_CTL_PGDN          0x7600
79 #define KE_CTL_PGUP          0x8400
80 #define KE_CTL_HOME          0x7700
81 #define KE_CTL_END           0x7500
82 #define KE_CTL_INS           0x9200
83 #define KE_CTL_DEL           0x9300
84 
85 #define KE_F(x)		((0x3A+(x))<<8)
86 #define KE_SHIFT_F(x)	((0x53+(x))<<8)
87 #define KE_CTL_F(x)	((0x5D+(x))<<8)
88 #define KE_ALT_F(x)	((0x67+(x))<<8)
89 
90 #define SCAN_A  0x1e
91 #define SCAN_B  0x30
92 #define SCAN_C  0x2e
93 #define SCAN_D  0x20
94 #define SCAN_E  0x12
95 #define SCAN_F  0x21
96 #define SCAN_G  0x22
97 #define SCAN_H  0x23
98 #define SCAN_I  0x17
99 #define SCAN_J  0x24
100 #define SCAN_K  0x25
101 #define SCAN_L  0x26
102 #define SCAN_M  0x31
103 #define SCAN_N  0x32
104 #define SCAN_O  0x18
105 #define SCAN_P  0x19
106 #define SCAN_Q  0x10
107 #define SCAN_R  0x13
108 #define SCAN_S  0x1f
109 #define SCAN_T  0x14
110 #define SCAN_U  0x16
111 #define SCAN_V  0x2f
112 #define SCAN_W  0x11
113 #define SCAN_X  0x2d
114 #define SCAN_Y  0x15
115 #define SCAN_Z  0x2c
116 
117 #define ENUM_A  0x01
118 #define ENUM_B  0x02
119 #define ENUM_C  0x03
120 #define ENUM_D  0x04
121 #define ENUM_E  0x05
122 #define ENUM_F  0x06
123 #define ENUM_G  0x07
124 #define ENUM_H  0x08
125 #define ENUM_I  0x09
126 #define ENUM_J  0x0a
127 #define ENUM_K  0x0b
128 #define ENUM_L  0x0c
129 #define ENUM_M  0x0d
130 #define ENUM_N  0x0e
131 #define ENUM_O  0x0f
132 #define ENUM_P  0x10
133 #define ENUM_Q  0x11
134 #define ENUM_R  0x12
135 #define ENUM_S  0x13
136 #define ENUM_T  0x14
137 #define ENUM_U  0x15
138 #define ENUM_V  0x16
139 #define ENUM_W  0x17
140 #define ENUM_X  0x18
141 #define ENUM_Y  0x19
142 #define ENUM_Z  0x1a
143 
144 #define __SCAN_(x) (SCAN_##x)
145 #define __ENUM_(x) (ENUM_##x)
146 
147 #define KE_CTL_(x) (((__SCAN_(x) << 8) & 0xFF00) | ((__ENUM_(x)-__ENUM_(A)+1) & 0x00FF))
148 #define KE_ALT_(x) (((__SCAN_(x) << 8) & 0xFF00)
149 
150 #endif
151