diff --git a/src/system/boot/platform/amiga_m68k/keyboard.cpp b/src/system/boot/platform/amiga_m68k/keyboard.cpp new file mode 100644 index 0000000000..03b69c25b5 --- /dev/null +++ b/src/system/boot/platform/amiga_m68k/keyboard.cpp @@ -0,0 +1,67 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + + +#include "keyboard.h" +#include "toscalls.h" + +#include + + +static uint32 +check_for_key(void) +{ + union key k; + if (Bconstat(DEV_CON) == 0) + return 0; + + k.d0 = Bconin(DEV_CON); + return k.d0; +} + + +extern "C" void +clear_key_buffer(void) +{ + while (check_for_key() != 0) + ; +} + + +extern "C" union key +wait_for_key(void) +{ + union key key; + key.d0 = Bconin(DEV_CON); + + return key; +} + + +extern "C" uint32 +check_for_boot_keys(void) +{ + union key key; + uint32 options = 0; + + while ((key.d0 = check_for_key()) != 0) { + switch (key.code.ascii) { + case ' ': + options |= BOOT_OPTION_MENU; + break; + case 0x1b: // escape + options |= BOOT_OPTION_DEBUG_OUTPUT; + break; + case 0: + // evaluate BIOS scan codes + // ... + break; + } + } + + dprintf("options = %ld\n", options); + return options; +} + diff --git a/src/system/boot/platform/amiga_m68k/keyboard.h b/src/system/boot/platform/amiga_m68k/keyboard.h new file mode 100644 index 0000000000..306a80c04c --- /dev/null +++ b/src/system/boot/platform/amiga_m68k/keyboard.h @@ -0,0 +1,40 @@ +#ifndef KEYBOARD_H +#define KEYBOARD_H + + +#include + + +union key { + uint32 d0; + struct { + uint8 modifiers; // not always present! + uint8 bios; // scan code + uint8 dummy; + uint8 ascii; + } code; +}; + +#define BIOS_KEY_UP 0x48 +#define BIOS_KEY_DOWN 0x50 +#define BIOS_KEY_LEFT 0x4b +#define BIOS_KEY_RIGHT 0x4d +// XXX: FIXME +#define BIOS_KEY_HOME 0x47 +#define BIOS_KEY_END 0x4f +#define BIOS_KEY_PAGE_UP 0x49 +#define BIOS_KEY_PAGE_DOWN 0x51 + +#ifdef __cplusplus +extern "C" { +#endif + +extern void clear_key_buffer(void); +extern union key wait_for_key(void); +extern uint32 check_for_boot_keys(void); + +#ifdef __cplusplus +} +#endif + +#endif /* KEYBOARD_H */