Set the debug keyboard info for the kernel debugger when initializing keyboard

handlers. A full sized keyboard is assumed when LEDs are found and those are
preferred then. This makes USB keyboards work (at least those that worked
by voluntarily entering KDL before, i.e. those that are hooked up to UHCI root
ports) also when entering KDL by means of a panic. The first (few) keys are
swallowed though, but that's certainly better than it not working at all.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41898 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2011-06-03 23:24:58 +00:00
parent 93344365ca
commit e36050e83d
@@ -32,6 +32,7 @@
#define KEYBOARD_FLAG_DEBUGGER 0x02
static bool sDebugKeyboardFound = false;
static usb_id sDebugKeyboardPipe = 0;
static size_t sDebugKeyboardReportSize = 0;
static int32 sDebuggerCommandAdded = 0;
@@ -70,6 +71,7 @@ KeyboardProtocolHandler::KeyboardProtocolHandler(HIDReport &inputReport,
mutex_init(&fLock, "usb keyboard");
// find modifiers and keys
bool debugUsable = false;
for (uint32 i = 0; i < inputReport.CountItems(); i++) {
HIDReportItem *item = inputReport.ItemAt(i);
if (!item->HasData())
@@ -84,6 +86,9 @@ KeyboardProtocolHandler::KeyboardProtocolHandler(HIDReport &inputReport,
// normal or "consumer"/button keys handled as array items
if (fKeyCount < MAX_KEYS)
fKeys[fKeyCount++] = item;
if (item->UsagePage() == B_HID_USAGE_PAGE_KEYBOARD)
debugUsable = true;
} else {
if (item->UsagePage() == B_HID_USAGE_PAGE_KEYBOARD
&& item->UsageID() >= B_HID_UID_KB_LEFT_CONTROL
@@ -91,11 +96,24 @@ KeyboardProtocolHandler::KeyboardProtocolHandler(HIDReport &inputReport,
// modifiers are generally implemented as bitmaps
if (fModifierCount < MAX_MODIFIERS)
fModifiers[fModifierCount++] = item;
debugUsable = true;
}
}
}
}
if (!sDebugKeyboardFound && debugUsable) {
// It's a keyboard, not just some additional buttons, set up the kernel
// debugger info here so that it is ready on panics or crashes that
// don't go through the emergency keys. If we also found LEDs we assume
// it is a full sized keyboard and discourage further setting the info.
sDebugKeyboardPipe = fInputReport.Device()->InterruptPipe();
sDebugKeyboardReportSize = fInputReport.Parser()->MaxReportSize();
if (outputReport != NULL)
sDebugKeyboardFound = true;
}
TRACE("keyboard device with %lu keys and %lu modifiers\n", fKeyCount,
fModifierCount);
TRACE("input report: %u; output report: %u\n", inputReport.ID(),