Implemented the BIOS functions to access the keyboard buffer.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8035 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
|
** Distributed under the terms of the OpenBeOS License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "keyboard.h"
|
||||||
|
#include "bios.h"
|
||||||
|
|
||||||
|
#include <boot/platform.h>
|
||||||
|
|
||||||
|
|
||||||
|
/** Note, checking for keys doesn't seem to work in graphics
|
||||||
|
* mode, at least in Bochs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static uint16
|
||||||
|
check_for_key(void)
|
||||||
|
{
|
||||||
|
bios_regs regs;
|
||||||
|
regs.eax = 0x0100;
|
||||||
|
call_bios(0x16, ®s);
|
||||||
|
|
||||||
|
// the zero flag is set when there is no key stroke waiting for us
|
||||||
|
if (regs.flags & ZERO_FLAG)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// remove the key from the buffer
|
||||||
|
regs.eax = 0;
|
||||||
|
call_bios(0x16, ®s);
|
||||||
|
|
||||||
|
return regs.eax & 0xffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" union key
|
||||||
|
wait_for_key(void)
|
||||||
|
{
|
||||||
|
bios_regs regs;
|
||||||
|
regs.eax = 0;
|
||||||
|
call_bios(0x16, ®s);
|
||||||
|
|
||||||
|
union key key;
|
||||||
|
key.ax = regs.eax & 0xffff;
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" uint32
|
||||||
|
check_for_boot_keys(void)
|
||||||
|
{
|
||||||
|
union key key;
|
||||||
|
uint32 options = 0;
|
||||||
|
|
||||||
|
while ((key.ax = check_for_key()) != 0) {
|
||||||
|
dprintf("pressed %lx\n", key.ax);
|
||||||
|
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);
|
||||||
|
panic("\n");
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#ifndef KEYBOARD_H
|
||||||
|
#define KEYBOARD_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
union key {
|
||||||
|
uint16 ax;
|
||||||
|
struct {
|
||||||
|
uint8 ascii;
|
||||||
|
uint8 bios;
|
||||||
|
} code;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define BIOS_KEY_UP 0x48
|
||||||
|
#define BIOS_KEY_DOWN 0x50
|
||||||
|
#define BIOS_KEY_LEFT 0x4b
|
||||||
|
#define BIOS_KEY_RIGHT 0x4d
|
||||||
|
#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 union key wait_for_key(void);
|
||||||
|
extern uint32 check_for_boot_keys(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* KEYBOARD_H */
|
||||||
Reference in New Issue
Block a user