GBDK 2020 Docs 4.4.0 API Documentation for GBDK 2020

laptop_keycodes.h
Go to the documentation of this file.
1 #include <gbdk/platform.h>
2 #include <stdint.h>
3 #include <stdbool.h>
4
5 #ifndef _MEGADUCK_LAPTOP_KEYCODES_H
6 #define _MEGADUCK_LAPTOP_KEYCODES_H
7
8
9 // - Left /right shift are shared
10 //
11 // Keyboard serial reply scan codes have different ordering than System ROM character codes
12 // - They go diagonal down from upper left for the first *4* rows
13 // - The bottom 4 rows (including piano keys) are more varied
14
15 // Modifier Keys / Flags
16 //
17 // See input_key_modifier_flags__RAM_D027_
18 #define DUCK_IO_KEY_FLAG_KEY_REPEAT 0x01u
19 #define DUCK_IO_KEY_FLAG_KEY_REPEAT_BIT 0x0u
20 #define DUCK_IO_KEY_FLAG_CAPSLOCK 0x02u
21 #define DUCK_IO_KEY_FLAG_CAPSLOCK_BIT 0x1u
22 #define DUCK_IO_KEY_FLAG_SHIFT 0x04u
23 #define DUCK_IO_KEY_FLAG_SHIFT_BIT 0x2u
24 // Right Print Screen has actual scancode vs Left being in a flag
25 #define DUCK_IO_KEY_FLAG_PRINTSCREEN_LEFT 0x08u
26 #define DUCK_IO_KEY_FLAG_PRINTSCREEN_LEFT_BIT 0x3u
27
28 // Keyboard scancodes
29 // All valid keys seem to have bit 7 set (0x80+)
30 #define DUCK_IO_KEY_BASE_BIT 0x7u
31 #define DUCK_IO_KEY_BASE 0x80u
32
33
34 // First 4 rows (top of keyboard) ~ 0x80 - 0xB7
35 //
36 // - For each row, most chars are +4 vs char to immediate left
37 // due to the diagonal down-right scancode ordering
38 //
39 // Starting values
40 // - Row 1: 0x80
41 // - Row 2: 0x81
42 // - Row 3: 0x82
43 // - Row 4: 0x83
44
45 // Row 1
46 #define DUCK_IO_KEY_F1 0x80u
47 #define DUCK_IO_KEY_F2 0x84u
48 #define DUCK_IO_KEY_F3 0x88u
49 #define DUCK_IO_KEY_F4 0x8Cu
50 #define DUCK_IO_KEY_F5 0x90u
51 #define DUCK_IO_KEY_F6 0x94u
52 #define DUCK_IO_KEY_F7 0x98u
53 #define DUCK_IO_KEY_F8 0x9Cu
54 #define DUCK_IO_KEY_F9 0xA0u
55 #define DUCK_IO_KEY_F10 0xA4u
56 #define DUCK_IO_KEY_F11 0xA8u
57 #define DUCK_IO_KEY_F12 0xACu
58 // GAP at 0xB0 maybe Blank spot where F13 would be
59 // GAP at 0xB4 maybe ON Key?
60
61 // Row 2
62 #define DUCK_IO_KEY_ESCAPE 0x81u // Spanish label: Salida | German label: Esc
63 #define DUCK_IO_KEY_1 0x85u // Shift alt: !
64 #define DUCK_IO_KEY_2 0x89u // Shift alt: "
65 #define DUCK_IO_KEY_3 0x8Du // Shift alt: · (Spanish, mid-dot) | § (German, legal section)
66 #define DUCK_IO_KEY_4 0x91u // Shift alt: $
67 #define DUCK_IO_KEY_5 0x95u // Shift alt: %
68 #define DUCK_IO_KEY_6 0x99u // Shift alt: &
69 #define DUCK_IO_KEY_7 0x9Du // Shift alt: /
70 #define DUCK_IO_KEY_8 0xA1u // Shift alt: (
71 #define DUCK_IO_KEY_9 0xA5u // Shift alt: )
72 #define DUCK_IO_KEY_0 0xA9u // Shift alt: "\"
73 #define DUCK_IO_KEY_SINGLE_QUOTE 0xADu // Shift alt: ? | German version: ß (eszett)
74 #define DUCK_IO_KEY_EXCLAMATION_FLIPPED 0xB1u // Shift alt: ¿ (Spanish) | ` (German) // German version: ' (single quote?)
75 #define DUCK_IO_KEY_BACKSPACE 0xB5u // German label: Lösch
76 // See Continued Row 2 below
77
78 // Row 3
79 #define DUCK_IO_KEY_HELP 0x82u // Spanish label: Ayuda | German label: Hilfe
80 #define DUCK_IO_KEY_Q 0x86u
81 #define DUCK_IO_KEY_W 0x8Au
82 #define DUCK_IO_KEY_E 0x8Eu
83 #define DUCK_IO_KEY_R 0x92u
84 #define DUCK_IO_KEY_T 0x96u
85 #define DUCK_IO_KEY_Y 0x9Au // German version: z
86 #define DUCK_IO_KEY_U 0x9Eu
87 #define DUCK_IO_KEY_I 0xA2u
88 #define DUCK_IO_KEY_O 0xA6u
89 #define DUCK_IO_KEY_P 0xAAu
90 #define DUCK_IO_KEY_BACKTICK 0xAEu // Shift alt: [ (Spanish, only shift mode works) | German version: Ü
91 #define DUCK_IO_KEY_RIGHT_SQ_BRACKET 0xB2u // Shift alt: * | German version: · (mid-dot)
92 #define DUCK_IO_KEY_ENTER 0xB6u // Spanish label: Entra | German label: Ein-gabe
93 // See Continued Row 3 below
94
95 // Row 4
96 // GAP at 0x83 maybe CAPS LOCK (Spanish label: Mayuscula, German label: Groß)
97 #define DUCK_IO_KEY_A 0x87u
98 #define DUCK_IO_KEY_S 0x8Bu
99 #define DUCK_IO_KEY_D 0x8Fu
100 #define DUCK_IO_KEY_F 0x93u
101 #define DUCK_IO_KEY_G 0x97u
102 #define DUCK_IO_KEY_H 0x9Bu
103 #define DUCK_IO_KEY_J 0x9Fu
104 #define DUCK_IO_KEY_K 0xA3u
105 #define DUCK_IO_KEY_L 0xA7u
106 #define DUCK_IO_KEY_N_TILDE 0xABu // German version: ö
107 #define DUCK_IO_KEY_U_UMLAUT 0xAFu // German version: ä
108 #define DUCK_IO_KEY_O_OVER_LINE 0xB3u // Shift alt: [A over line] (Spanish) | ^ (German) | German version: #
109 // ? GAP at 0x87 ?
110
111
112 // Second 4 rows (bottom of keyboard) ~ 0x80 - 0xB7
113 //
114 // - For each row, most chars are +4 vs char to immediate left
115 //
116 // Starting values
117 // - Row 5: 0xB8
118 // - Row 6: 0xB9
119 // - Row 7: 0xBA
120 // - Row 8: 0xBB
121
122 // Row 5
123 #define DUCK_IO_KEY_Z 0xB8u // German version: y
124 #define DUCK_IO_KEY_X 0xBCu
125 #define DUCK_IO_KEY_C 0xC0u
126 #define DUCK_IO_KEY_V 0xC4u
127 #define DUCK_IO_KEY_B 0xC8u
128 #define DUCK_IO_KEY_N 0xCCu
129 #define DUCK_IO_KEY_M 0xD0u
130 #define DUCK_IO_KEY_COMMA 0xD4u
131 #define DUCK_IO_KEY_PERIOD 0xD8u
132 #define DUCK_IO_KEY_DASH 0xDCu // Shift alt: _ | German version: @
133 // See Continued Row 5 below
134 // Row 6 Continued (from below)
135 #define DUCK_IO_KEY_DELETE 0xE0u // * Spanish label: Borrar | German label: Entf.
136
137
138
139 // Encoding is less orderly below
140
141 // Row 6
142 #define DUCK_IO_KEY_SPACE 0xB9u // Spanish label: Espacio | German label (blank)
143 // Continued Row 5
144 #define DUCK_IO_KEY_LESS_THAN 0xBDu // Shift alt: >
145 // Continued Row 6
146 #define DUCK_IO_KEY_PAGE_UP 0xC1u // Spanish label: Pg Arriba | German label: Zu-rück
147 #define DUCK_IO_KEY_PAGE_DOWN 0xC5u // Spanish label: Pg Abajo | German label: Wei-ter
148 #define DUCK_IO_KEY_MEMORY_MINUS 0xC9u
149 // Continued Row 5
150 #define DUCK_IO_KEY_MEMORY_PLUS 0xCDu
151 #define DUCK_IO_KEY_MEMORY_RECALL 0xD1u
152 #define DUCK_IO_KEY_SQUAREROOT 0xD5u
153 // ** 3x3 Arrow and Math Key area **
154 // Continued Row 6
155 #define DUCK_IO_KEY_MULTIPLY 0xD9u
156 #define DUCK_IO_KEY_ARROW_DOWN 0xDDu
157 #define DUCK_IO_KEY_MINUS 0xE1u
158 // Continued Row 3
159 #define DUCK_IO_KEY_ARROW_LEFT 0xE5u
160 #define DUCK_IO_KEY_EQUALS 0xE9u
161 #define DUCK_IO_KEY_ARROW_RIGHT 0xEDu
162 // Continued Row 2
163 #define DUCK_IO_KEY_DIVIDE 0xE4u // German version: :
164 #define DUCK_IO_KEY_ARROW_UP 0xE8u
165 #define DUCK_IO_KEY_PLUS 0xECu
166
167 // Row 7
168 // Piano Sharp Keys
169 #define DUCK_IO_KEY_PIANO_DO_SHARP 0xBAu
170 #define DUCK_IO_KEY_PIANO_RE_SHARP 0xBEu
171 // GAP at 0xC2 where there is no key
172 #define DUCK_IO_KEY_PIANO_FA_SHARP 0xC6u
173 #define DUCK_IO_KEY_PIANO_SOL_SHARP 0xCAu
174 #define DUCK_IO_KEY_PIANO_LA_SHARP 0xCEu
175 // GAP at 0xD2 where there is no key
176 //
177 // Octave 2 maybe
178 #define DUCK_IO_KEY_PIANO_DO_2_SHARP 0xD6u
179 #define DUCK_IO_KEY_PIANO_RE_2_SHARP 0xDAu
180 // Row 6 Continued
181 #define DUCK_IO_KEY_PRINTSCREEN_RIGHT 0xDEu // German label: Druck (* Mixed in with piano keys)
182 // Row 7 Continued
183 #define DUCK_IO_KEY_PIANO_FA_2_SHARP 0xE2u
184 #define DUCK_IO_KEY_PIANO_SOL_2_SHARP 0xE6u
185 #define DUCK_IO_KEY_PIANO_LA_2_SHARP 0xEAu
186
187 // Row 8
188 // Piano Primary Keys
189 #define DUCK_IO_KEY_PIANO_DO 0xBBu
190 #define DUCK_IO_KEY_PIANO_RE 0xBFu
191 #define DUCK_IO_KEY_PIANO_MI 0xC3u
192 #define DUCK_IO_KEY_PIANO_FA 0xC7u
193 #define DUCK_IO_KEY_PIANO_SOL 0xCBu
194 #define DUCK_IO_KEY_PIANO_LA 0xCFu
195 #define DUCK_IO_KEY_PIANO_SI 0xD3u
196 #define DUCK_IO_KEY_PIANO_DO_2 0xD7u
197 #define DUCK_IO_KEY_PIANO_RE_2 0xDBu
198 #define DUCK_IO_KEY_PIANO_MI_2 0xDFu
199 #define DUCK_IO_KEY_PIANO_FA_2 0xE3u
200 #define DUCK_IO_KEY_PIANO_SOL_2 0xE7u
201 #define DUCK_IO_KEY_PIANO_LA_2 0xEBu
202 #define DUCK_IO_KEY_PIANO_SI_2 0xEFu
203
204 #define DUCK_IO_KEY_LAST_KEY (DUCK_IO_KEY_PIANO_SI_2u)
205
206 // Special System Codes? 0xF0+
207 #define DUCK_IO_KEY_MAYBE_SYST_CODES_START 0xF0u
208 #define DUCK_IO_KEY_MAYBE_RX_NOT_A_KEY 0xF6u
209
210 #endif // _MEGADUCK_LAPTOP_KEYCODES_H
platform.h
stdbool.h
stdint.h