|
@@ -188,28 +188,26 @@ static void bios_putchar ( int character ) {
|
188
|
188
|
*/
|
189
|
189
|
static const char *ansi_input = "";
|
190
|
190
|
|
191
|
|
-/**
|
192
|
|
- * Lowest BIOS scancode of interest
|
193
|
|
- *
|
194
|
|
- * Most of the BIOS key scancodes that we are interested in are in a
|
195
|
|
- * dense range, so subtracting a constant and treating them as offsets
|
196
|
|
- * into an array works efficiently.
|
197
|
|
- */
|
198
|
|
-#define BIOS_KEY_MIN 0x42
|
199
|
|
-
|
200
|
|
-/** Offset into list of interesting BIOS scancodes */
|
201
|
|
-#define BIOS_KEY(scancode) ( (scancode) - BIOS_KEY_MIN )
|
|
191
|
+/** A mapping from a BIOS scan code to an ANSI escape sequence */
|
|
192
|
+#define BIOS_KEY( key, ansi ) key ansi "\0"
|
202
|
193
|
|
203
|
194
|
/** Mapping from BIOS scan codes to ANSI escape sequences */
|
204
|
|
-static const char *ansi_sequences[] = {
|
205
|
|
- [ BIOS_KEY ( 0x42 ) ] = "[19~", /* F8 (required for PXE) */
|
206
|
|
- [ BIOS_KEY ( 0x47 ) ] = "[H", /* Home */
|
207
|
|
- [ BIOS_KEY ( 0x48 ) ] = "[A", /* Up arrow */
|
208
|
|
- [ BIOS_KEY ( 0x4b ) ] = "[D", /* Left arrow */
|
209
|
|
- [ BIOS_KEY ( 0x4d ) ] = "[C", /* Right arrow */
|
210
|
|
- [ BIOS_KEY ( 0x4f ) ] = "[F", /* End */
|
211
|
|
- [ BIOS_KEY ( 0x50 ) ] = "[B", /* Down arrow */
|
212
|
|
- [ BIOS_KEY ( 0x53 ) ] = "[3~", /* Delete */
|
|
195
|
+static const char ansi_sequences[] = {
|
|
196
|
+ BIOS_KEY ( "\x53", "[3~" ) /* Delete */
|
|
197
|
+ BIOS_KEY ( "\x48", "[A" ) /* Up arrow */
|
|
198
|
+ BIOS_KEY ( "\x50", "[B" ) /* Down arrow */
|
|
199
|
+ BIOS_KEY ( "\x4b", "[D" ) /* Left arrow */
|
|
200
|
+ BIOS_KEY ( "\x4d", "[C" ) /* Right arrow */
|
|
201
|
+ BIOS_KEY ( "\x47", "[H" ) /* Home */
|
|
202
|
+ BIOS_KEY ( "\x4f", "[F" ) /* End */
|
|
203
|
+ BIOS_KEY ( "\x3f", "[15~" ) /* F5 */
|
|
204
|
+ BIOS_KEY ( "\x40", "[17~" ) /* F6 */
|
|
205
|
+ BIOS_KEY ( "\x41", "[18~" ) /* F7 */
|
|
206
|
+ BIOS_KEY ( "\x42", "[19~" ) /* F8 (required for PXE) */
|
|
207
|
+ BIOS_KEY ( "\x43", "[20~" ) /* F9 */
|
|
208
|
+ BIOS_KEY ( "\x44", "[21~" ) /* F10 */
|
|
209
|
+ BIOS_KEY ( "\x85", "[23~" ) /* F11 */
|
|
210
|
+ BIOS_KEY ( "\x86", "[24~" ) /* F12 */
|
213
|
211
|
};
|
214
|
212
|
|
215
|
213
|
/**
|
|
@@ -219,11 +217,12 @@ static const char *ansi_sequences[] = {
|
219
|
217
|
* @ret ansi_seq ANSI escape sequence, if any, otherwise NULL
|
220
|
218
|
*/
|
221
|
219
|
static const char * scancode_to_ansi_seq ( unsigned int scancode ) {
|
222
|
|
- unsigned int bios_key = BIOS_KEY ( scancode );
|
223
|
|
-
|
224
|
|
- if ( bios_key < ( sizeof ( ansi_sequences ) /
|
225
|
|
- sizeof ( ansi_sequences[0] ) ) ) {
|
226
|
|
- return ansi_sequences[bios_key];
|
|
220
|
+ const char *seq = ansi_sequences;
|
|
221
|
+
|
|
222
|
+ while ( *seq ) {
|
|
223
|
+ if ( *(seq++) == ( ( char ) scancode ) )
|
|
224
|
+ return seq;
|
|
225
|
+ seq += ( strlen ( seq ) + 1 );
|
227
|
226
|
}
|
228
|
227
|
DBG ( "Unrecognised BIOS scancode %02x\n", scancode );
|
229
|
228
|
return NULL;
|