* Error out on the num events ioctl in case the device was removed, otherwise

the original BeOS input_server will fail to detect the error and never close
  the device.
* Remove the empty kernel_cpp header and use the one from kernel util instead.
* Add some missing headers for completeness.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33242 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2009-09-23 05:30:04 +00:00
parent ecd60dec1a
commit e65227c272
9 changed files with 20 additions and 4 deletions
@@ -4,7 +4,7 @@
Distributed under the terms of the MIT license.
*/
#include "DeviceList.h"
#include <kernel_cpp.h>
#include <util/kernel_cpp.h>
#include <stdlib.h>
#include <string.h>
#include <new>
@@ -10,9 +10,9 @@
#include <KernelExport.h>
#include <OS.h>
#include <USB3.h>
#include <util/kernel_cpp.h>
#include "DeviceList.h"
#include "kernel_cpp.h"
#define DRIVER_NAME "usb_hid"
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <new>
@@ -11,6 +11,7 @@
#include <new>
#include <stdlib.h>
#include <string.h>
HIDReport::HIDReport(HIDParser *parser, uint8 type, uint8 id)
@@ -217,6 +218,7 @@ HIDReport::WaitForReport(bigtime_t timeout)
fConditionVariable.Add(&conditionVariableEntry);
status_t result = fParser->Device()->MaybeScheduleTransfer();
if (result != B_OK) {
TRACE_ALWAYS("scheduling transfer failed\n");
conditionVariableEntry.Wait(B_RELATIVE_TIMEOUT, 0);
return result;
}
@@ -3,6 +3,8 @@
* Distributed under the terms of the MIT license.
*/
#include <new>
#include <stdlib.h>
#include <string.h>
#include <usb/USB_hid.h>
@@ -11,6 +11,7 @@
#include "HIDReport.h"
#include "HIDReportItem.h"
#include <new>
#include <string.h>
#include <usb/USB_hid.h>
@@ -91,7 +92,12 @@ MouseDevice::Control(uint32 op, void *buffer, size_t length)
return RingBufferRead(buffer, sizeof(mouse_movement));
case MS_NUM_EVENTS:
return RingBufferReadable() / sizeof(mouse_movement);
{
int32 count = RingBufferReadable() / sizeof(mouse_movement);
if (count == 0 && fReport->Device()->IsRemoved())
return B_DEV_NOT_READY;
return count;
}
case MS_SET_CLICKSPEED:
#ifdef __HAIKU__
@@ -113,7 +119,7 @@ MouseDevice::_ReadReport()
if (result != B_OK) {
if (fReport->Device()->IsRemoved()) {
TRACE("device has been removed\n");
return B_ERROR;
return B_DEV_NOT_READY;
}
if (result != B_INTERRUPTED) {
@@ -7,6 +7,10 @@
#include <InterfaceDefs.h>
#ifndef B_MAX_MOUSE_BUTTONS
#define B_MAX_MOUSE_BUTTONS 8
#endif
#include "ProtocolHandler.h"
class HIDReportItem;
@@ -3,6 +3,7 @@
* Distributed under the terms of the MIT License.
*/
#include <stdlib.h>
#include <ring_buffer.h>
#include "Driver.h"