* Added untested supported for the new emergency keys. Will test next.

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31668 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-07-21 09:25:36 +00:00
parent f74fedd9ba
commit cf2a64ba52
@@ -1,16 +1,22 @@
/* /*
Driver for USB Human Interface Devices. * Copyright (C) 2008 Michael Lotz <[email protected]>
Copyright (C) 2008 Michael Lotz <[email protected]> * Distributed under the terms of the MIT license.
Distributed under the terms of the MIT license. */
/*! Driver for USB Human Interface Devices.
Interpretation code based on the previous usb_hid driver which was written Interpretation code based on the previous usb_hid driver which was written
by Jérôme Duval. by Jérôme Duval.
*/ */
#include <string.h>
#include <usb/USB_hid.h>
#include <debug.h>
#include "Driver.h" #include "Driver.h"
#include "KeyboardDevice.h" #include "KeyboardDevice.h"
#include <string.h>
#include <usb/USB_hid.h>
#include <debug.h>
// input server private for raw_key_info, KB_READ, etc... // input server private for raw_key_info, KB_READ, etc...
#include "kb_mouse_driver.h" #include "kb_mouse_driver.h"
@@ -30,10 +36,14 @@ debug_get_keyboard_config(int argc, char **argv)
} }
// #pragma mark -
KeyboardDevice::KeyboardDevice(usb_device device, usb_pipe interruptPipe, KeyboardDevice::KeyboardDevice(usb_device device, usb_pipe interruptPipe,
size_t interfaceIndex, report_insn *instructions, size_t instructionCount, size_t interfaceIndex, report_insn *instructions, size_t instructionCount,
size_t totalReportSize) size_t totalReportSize)
: HIDDevice(device, interruptPipe, interfaceIndex, instructions, :
HIDDevice(device, interruptPipe, interfaceIndex, instructions,
instructionCount, totalReportSize, 512), instructionCount, totalReportSize, 512),
fRepeatDelay(300000), fRepeatDelay(300000),
fRepeatRate(35000), fRepeatRate(35000),
@@ -165,12 +175,14 @@ KeyboardDevice::Control(uint32 op, void *buffer, size_t length)
} }
case KB_SET_KEY_REPEAT_DELAY: case KB_SET_KEY_REPEAT_DELAY:
if (user_memcpy(&fRepeatDelay, buffer, sizeof(fRepeatDelay)) != B_OK) if (user_memcpy(&fRepeatDelay, buffer, sizeof(fRepeatDelay))
!= B_OK)
return B_BAD_ADDRESS; return B_BAD_ADDRESS;
return B_OK; return B_OK;
case KB_GET_KEY_REPEAT_DELAY: case KB_GET_KEY_REPEAT_DELAY:
if (user_memcpy(buffer, &fRepeatDelay, sizeof(fRepeatDelay)) != B_OK) if (user_memcpy(buffer, &fRepeatDelay, sizeof(fRepeatDelay))
!= B_OK)
return B_BAD_ADDRESS; return B_BAD_ADDRESS;
return B_OK; return B_OK;
} }
@@ -230,7 +242,7 @@ KeyboardDevice::_InterpretBuffer()
return B_OK; return B_OK;
} }
static uint32 sModifierTable[] = { const static uint32 sModifierTable[] = {
KEY_ControlL, KEY_ControlL,
KEY_ShiftL, KEY_ShiftL,
KEY_AltL, KEY_AltL,
@@ -241,7 +253,7 @@ KeyboardDevice::_InterpretBuffer()
KEY_WinR KEY_WinR
}; };
static uint32 sKeyTable[] = { const static uint32 sKeyTable[] = {
0x00, // ERROR 0x00, // ERROR
0x00, // ERROR 0x00, // ERROR
0x00, // ERROR 0x00, // ERROR
@@ -408,6 +420,8 @@ KeyboardDevice::_InterpretBuffer()
return B_OK; return B_OK;
} }
static bool sysReqPressed = false;
bool keyDown = false; bool keyDown = false;
uint8 *current = fLastTransferBuffer; uint8 *current = fLastTransferBuffer;
uint8 *compare = fTransferBuffer; uint8 *compare = fTransferBuffer;
@@ -434,17 +448,20 @@ KeyboardDevice::_InterpretBuffer()
if (key == KEY_Pause && (current[0] & 1)) if (key == KEY_Pause && (current[0] & 1))
key = KEY_Break; key = KEY_Break;
else if (key == 0xe && (current[0] & 1)) else if (key == 0xe && (current[0] & 1)) {
key = KEY_SysRq; key = KEY_SysRq;
#if 1 sysReqPressed = keyDown;
else if (keyDown && key == 0x0d) { } else if (sysReqPressed && keyDown && current[i] >= 4
// ToDo: remove again && current[i] <= 30 && (fLastTransferBuffer[0] & 0x44) != 0) {
// Alt-SysReq+letter was pressed
sDebugKeyboardPipe = fInterruptPipe; sDebugKeyboardPipe = fInterruptPipe;
sDebugKeyboardReportSize = fTotalReportSize; sDebugKeyboardReportSize = fTotalReportSize;
panic("keyboard requested halt.\n");
} char letter = current[i] - 4 + 'a';
#endif
else if (key == 0) { if (debug_emergency_key_pressed(letter))
continue;
} else if (key == 0) {
// unmapped key // unmapped key
key = 0x200000 + current[i]; key = 0x200000 + current[i];
} }