diff --git a/src/add-ons/kernel/drivers/input/usb_hid/DeviceList.cpp b/src/add-ons/kernel/drivers/input/usb_hid/DeviceList.cpp index 3916920844..626ba40b4c 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/DeviceList.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/DeviceList.cpp @@ -7,6 +7,7 @@ #include #include #include +#include struct device_list_entry { char * name; @@ -40,7 +41,7 @@ DeviceList::~DeviceList() status_t DeviceList::AddDevice(const char *name, void *device) { - device_list_entry *entry = new device_list_entry; + device_list_entry *entry = new(std::nothrow) device_list_entry; if (entry == NULL) return B_NO_MEMORY; diff --git a/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp b/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp index ca42fd0d9c..e1707550c6 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp @@ -16,6 +16,8 @@ #include "BeOSCompatibility.h" // for pseudo mutex #endif +#include + int32 api_version = B_CUR_DRIVER_API_VERSION; usb_module_info *gUSBModule = NULL; @@ -68,9 +70,9 @@ usb_hid_device_added(usb_device device, void **cookie) const usb_interface_info *interface = config->interface[i].active; uint8 interfaceClass = interface->descr->interface_class; uint8 interfaceSubclass = interface->descr->interface_subclass; - uint8 interfaceProtocol = interface->descr->interface_protocol; TRACE("interface %lu: class: %u; subclass: %u; protocol: %u\n", - i, interfaceClass, interfaceSubclass, interfaceProtocol); + i, interfaceClass, interfaceSubclass, + interface->descr->interface_protocol); if (interfaceClass == USB_INTERFACE_CLASS_HID && interfaceSubclass == USB_INTERFACE_SUBCLASS_HID_BOOT) { @@ -221,7 +223,7 @@ init_driver() if (get_module(B_USB_MODULE_NAME, (module_info **)&gUSBModule) != B_OK) return B_ERROR; - gDeviceList = new DeviceList(); + gDeviceList = new(std::nothrow) DeviceList(); if (gDeviceList == NULL) { put_module(B_USB_MODULE_NAME); return B_NO_MEMORY; diff --git a/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp b/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp index fb96a3b1eb..4cee5514a7 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp @@ -8,6 +8,7 @@ #include #include #include +#include // includes for the different device types #include "KeyboardDevice.h" @@ -181,11 +182,14 @@ HIDDevice::MakeHIDDevice(usb_device device, // determine device type and create the device object if (deviceType == USB_HID_DEVICE_TYPE_KEYBOARD) { - return new KeyboardDevice(device, interruptPipe, interfaceIndex, - finalInstructions, instructionCount, totalReportSize); - } else if (deviceType == USB_HID_DEVICE_TYPE_MOUSE) { - return new MouseDevice(device, interruptPipe, interfaceIndex, - finalInstructions, instructionCount, totalReportSize); + return new(std::nothrow) KeyboardDevice(device, interruptPipe, + interfaceIndex, finalInstructions, instructionCount, + totalReportSize); + } else if (deviceType == USB_HID_DEVICE_TYPE_MOUSE + || deviceType == 0x01250015) { + return new(std::nothrow) MouseDevice(device, interruptPipe, + interfaceIndex, finalInstructions, instructionCount, + totalReportSize); } TRACE_ALWAYS("unsupported device type 0x%08lx\n", deviceType);