Quick hack on our temporary keyboard driver to allow cursor movement and stuff like Control-D.
For example, command line history now works in the bash :) git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9721 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -31,6 +31,16 @@ enum keycodes {
|
|||||||
NUM_LOCK = 69,
|
NUM_LOCK = 69,
|
||||||
SCR_LOCK = 70,
|
SCR_LOCK = 70,
|
||||||
SYS_REQ = 55,
|
SYS_REQ = 55,
|
||||||
|
LCONTROL = 29,
|
||||||
|
RCONTROL = 29, // dunno what it really is
|
||||||
|
|
||||||
|
CURSOR_LEFT = 75,
|
||||||
|
CURSOR_RIGHT = 77,
|
||||||
|
CURSOR_UP = 72,
|
||||||
|
CURSOR_DOWN = 80,
|
||||||
|
|
||||||
|
HOME = 71,
|
||||||
|
END = 79,
|
||||||
|
|
||||||
F1 = 0x3b,
|
F1 = 0x3b,
|
||||||
F2, F3, F4, F5, F6,
|
F2, F3, F4, F5, F6,
|
||||||
@@ -46,7 +56,7 @@ enum keycodes {
|
|||||||
|
|
||||||
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
||||||
|
|
||||||
static bool shift;
|
static bool shift, sControl;
|
||||||
static int leds;
|
static int leds;
|
||||||
static sem_id keyboard_sem;
|
static sem_id keyboard_sem;
|
||||||
static mutex keyboard_read_mutex;
|
static mutex keyboard_read_mutex;
|
||||||
@@ -54,6 +64,9 @@ static char keyboard_buf[1024];
|
|||||||
static unsigned int head, tail;
|
static unsigned int head, tail;
|
||||||
static isa_module_info *gISA;
|
static isa_module_info *gISA;
|
||||||
|
|
||||||
|
// begins with HOME, end with CURSOR_DOWN
|
||||||
|
static const char sControlKeys[] = {'@', 'A', 0, 0, 'D', 0, 'C', 0, '[', 'B'};
|
||||||
|
|
||||||
// stolen from nujeffos
|
// stolen from nujeffos
|
||||||
const char unshifted_keymap[128] = {
|
const char unshifted_keymap[128] = {
|
||||||
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, '\t',
|
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, '\t',
|
||||||
@@ -138,6 +151,8 @@ handle_keyboard_interrupt(void *data)
|
|||||||
// key up
|
// key up
|
||||||
if (key == LSHIFT + 0x80 || key == RSHIFT + 0x80)
|
if (key == LSHIFT + 0x80 || key == RSHIFT + 0x80)
|
||||||
shift = false;
|
shift = false;
|
||||||
|
if (key == LCONTROL + 0x80 || key == RCONTROL + 0x80)
|
||||||
|
sControl = false;
|
||||||
|
|
||||||
return B_HANDLED_INTERRUPT;
|
return B_HANDLED_INTERRUPT;
|
||||||
}
|
}
|
||||||
@@ -147,6 +162,10 @@ handle_keyboard_interrupt(void *data)
|
|||||||
case RSHIFT:
|
case RSHIFT:
|
||||||
shift = true;
|
shift = true;
|
||||||
break;
|
break;
|
||||||
|
case LCONTROL:
|
||||||
|
//case RCONTROL:
|
||||||
|
sControl = true;
|
||||||
|
break;
|
||||||
case CAPS_LOCK:
|
case CAPS_LOCK:
|
||||||
if (leds & LED_CAPS)
|
if (leds & LED_CAPS)
|
||||||
leds &= ~LED_CAPS;
|
leds &= ~LED_CAPS;
|
||||||
@@ -190,10 +209,22 @@ handle_keyboard_interrupt(void *data)
|
|||||||
reboot();
|
reboot();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HOME:
|
||||||
|
case END:
|
||||||
|
case CURSOR_DOWN:
|
||||||
|
case CURSOR_UP:
|
||||||
|
case CURSOR_LEFT:
|
||||||
|
case CURSOR_RIGHT:
|
||||||
|
insert_in_buf(0x1b);
|
||||||
|
insert_in_buf('[');
|
||||||
|
insert_in_buf(sControlKeys[key - HOME]);
|
||||||
|
retval = B_INVOKE_SCHEDULER;
|
||||||
|
break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
char ascii;
|
char ascii;
|
||||||
|
|
||||||
if (shift)
|
if (shift || sControl)
|
||||||
ascii = shifted_keymap[key];
|
ascii = shifted_keymap[key];
|
||||||
else {
|
else {
|
||||||
if (leds & LED_CAPS)
|
if (leds & LED_CAPS)
|
||||||
@@ -202,6 +233,9 @@ handle_keyboard_interrupt(void *data)
|
|||||||
ascii = unshifted_keymap[key];
|
ascii = unshifted_keymap[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sControl && ascii >= 64 && ascii < 96)
|
||||||
|
ascii -= 0100;
|
||||||
|
|
||||||
TRACE(("ascii = 0x%x, '%c'\n", ascii, ascii));
|
TRACE(("ascii = 0x%x, '%c'\n", ascii, ascii));
|
||||||
|
|
||||||
if (ascii != 0) {
|
if (ascii != 0) {
|
||||||
@@ -380,7 +414,8 @@ init_driver()
|
|||||||
if (mutex_init(&keyboard_read_mutex, "keyboard_read_mutex") < 0)
|
if (mutex_init(&keyboard_read_mutex, "keyboard_read_mutex") < 0)
|
||||||
panic("could not create keyboard read mutex!\n");
|
panic("could not create keyboard read mutex!\n");
|
||||||
|
|
||||||
shift = 0;
|
shift = false;
|
||||||
|
sControl = false;
|
||||||
leds = 0;
|
leds = 0;
|
||||||
|
|
||||||
// have the scroll lock reflect the state of serial debugging
|
// have the scroll lock reflect the state of serial debugging
|
||||||
|
|||||||
Reference in New Issue
Block a user