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:
parent
a3c6cfb7b7
commit
fc17fe17eb
76
src/kernel/boot/platform/bios_ia32/keyboard.cpp
Normal file
76
src/kernel/boot/platform/bios_ia32/keyboard.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. 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;
|
||||
}
|
||||
|
36
src/kernel/boot/platform/bios_ia32/keyboard.h
Normal file
36
src/kernel/boot/platform/bios_ia32/keyboard.h
Normal file
@ -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 */
|
Loading…
Reference in New Issue
Block a user