1 /* 2 * Copyright 2008-2010, François Revol, revol@free.fr. All rights reserved. 3 * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 7 8 #include "keyboard.h" 9 #include "nextrom.h" 10 11 #include <boot/platform.h> 12 13 14 static uint32 15 check_for_key(void) 16 { 17 union key k; 18 k.d0 = mg->mg_try_getc(); 19 20 return k.d0; 21 } 22 23 24 extern "C" void 25 clear_key_buffer(void) 26 { 27 while (check_for_key() != 0) 28 ; 29 } 30 31 32 extern "C" union key 33 wait_for_key(void) 34 { 35 union key key; 36 key.d0 = mg->mg_getc(); 37 38 return key; 39 } 40 41 42 extern "C" uint32 43 check_for_boot_keys(void) 44 { 45 union key key; 46 uint32 options = 0; 47 48 while ((key.d0 = check_for_key()) != 0) { 49 switch (key.code.ascii) { 50 case ' ': 51 options |= BOOT_OPTION_MENU; 52 break; 53 case 0x1b: // escape 54 options |= BOOT_OPTION_DEBUG_OUTPUT; 55 break; 56 case 0: 57 // evaluate BIOS scan codes 58 // ... 59 break; 60 } 61 } 62 63 dprintf("options = %ld\n", options); 64 return options; 65 } 66 67