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 "toscalls.h" 10 11#include <boot/platform.h> 12 13 14static uint32 15check_for_key(void) 16{ 17 union key k; 18 if (Bconstat(DEV_CON) == 0) 19 return 0; 20 21 k.d0 = Bconin(DEV_CON); 22 return k.d0; 23} 24 25 26extern "C" void 27clear_key_buffer(void) 28{ 29 while (check_for_key() != 0) 30 ; 31} 32 33 34extern "C" union key 35wait_for_key(void) 36{ 37 union key key; 38 key.d0 = Bconin(DEV_CON); 39 40 return key; 41} 42 43 44extern "C" uint32 45check_for_boot_keys(void) 46{ 47 union key key; 48 uint32 options = 0; 49 50 while ((key.d0 = check_for_key()) != 0) { 51 switch (key.code.ascii) { 52 case ' ': 53 options |= BOOT_OPTION_MENU; 54 break; 55 case 0x1b: // escape 56 options |= BOOT_OPTION_DEBUG_OUTPUT; 57 break; 58 case 0: 59 // evaluate BIOS scan codes 60 // ... 61 break; 62 } 63 } 64 65 dprintf("options = %ld\n", options); 66 return options; 67} 68 69