1 /* 2 ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 ** Distributed under the terms of the OpenBeOS License. 4 */ 5 6 7 #include "keyboard.h" 8 #include "bios.h" 9 10 #include <boot/platform.h> 11 12 13 /** Note, checking for keys doesn't seem to work in graphics 14 * mode, at least in Bochs. 15 */ 16 17 static uint16 18 check_for_key(void) 19 { 20 bios_regs regs; 21 regs.eax = 0x0100; 22 call_bios(0x16, ®s); 23 24 // the zero flag is set when there is no key stroke waiting for us 25 if (regs.flags & ZERO_FLAG) 26 return 0; 27 28 // remove the key from the buffer 29 regs.eax = 0; 30 call_bios(0x16, ®s); 31 32 return regs.eax & 0xffff; 33 } 34 35 36 extern "C" void 37 clear_key_buffer(void) 38 { 39 while (check_for_key() != 0) 40 ; 41 } 42 43 44 extern "C" union key 45 wait_for_key(void) 46 { 47 bios_regs regs; 48 regs.eax = 0; 49 call_bios(0x16, ®s); 50 51 union key key; 52 key.ax = regs.eax & 0xffff; 53 54 return key; 55 } 56 57 58 extern "C" uint32 59 check_for_boot_keys(void) 60 { 61 union key key; 62 uint32 options = 0; 63 64 while ((key.ax = check_for_key()) != 0) { 65 switch (key.code.ascii) { 66 case ' ': 67 options |= BOOT_OPTION_MENU; 68 break; 69 case 0x1b: // escape 70 options |= BOOT_OPTION_DEBUG_OUTPUT; 71 break; 72 case 0: 73 // evaluate BIOS scan codes 74 // ... 75 break; 76 } 77 } 78 79 dprintf("options = %ld\n", options); 80 return options; 81 } 82 83