* Deactivate the device when both the transfers and the clear feature fail

* Some restructuring and cleanup

This keeps the input_server from polling a removed device continuously.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23388 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2008-01-11 11:37:18 +00:00
parent cb6cd9af6f
commit cc2bf27596
1 changed files with 33 additions and 27 deletions

View File

@ -613,32 +613,38 @@ handle_interrupt_transfer(hid_device_info* device)
/* cancelled: device is unplugged */ /* cancelled: device is unplugged */
return status; return status;
} }
#if 1
status = usb->clear_feature(device->ept->handle, USB_FEATURE_ENDPOINT_HALT); status = usb->clear_feature(device->ept->handle, USB_FEATURE_ENDPOINT_HALT);
if (status != B_OK) if (status != B_OK) {
DPRINTF_ERR((MY_ID "clear_feature() error %d\n", (int)status)); DPRINTF_ERR((MY_ID "clear_feature() error %d\n", (int)status));
#endif // probably the device was removed and we just didn't get the
} else { // removed notification yet.
/* got a report */ device->active = false;
#if 0 return status;
uint32 i; }
char linbuf [256];
uint8 *buffer = device->buffer;
for (i = 0; i < device->total_report_size; i++) return device->bus_status;
sprintf (&linbuf[i*3], "%02X ", buffer [i]);
DPRINTF_INFO ((MY_ID "input report: %s\n", linbuf));
#endif
device->timestamp = system_time();
if (device->is_keyboard) {
interpret_kb_buffer(device);
memcpy(device->last_buffer, device->buffer, device->total_report_size);
} else
interpret_mouse_buffer(device);
} }
return status; /* got a report */
#if 0
uint32 i;
char linbuf [256];
uint8 *buffer = device->buffer;
for (i = 0; i < device->total_report_size; i++)
sprintf (&linbuf[i*3], "%02X ", buffer [i]);
DPRINTF_INFO ((MY_ID "input report: %s\n", linbuf));
#endif
device->timestamp = system_time();
if (device->is_keyboard) {
interpret_kb_buffer(device);
memcpy(device->last_buffer, device->buffer, device->total_report_size);
} else
interpret_mouse_buffer(device);
return B_OK;
} }
@ -910,8 +916,7 @@ hid_device_write(driver_cookie *cookie, off_t position,
static status_t static status_t
hid_device_control(driver_cookie *cookie, uint32 op, hid_device_control(driver_cookie *cookie, uint32 op, void *arg, size_t length)
void *arg, size_t len)
{ {
status_t err = B_ERROR; status_t err = B_ERROR;
hid_device_info *device; hid_device_info *device;
@ -967,7 +972,7 @@ hid_device_control(driver_cookie *cookie, uint32 op,
case KB_SET_LEDS: case KB_SET_LEDS:
set_leds(device, (uint8 *)arg); set_leds(device, (uint8 *)arg);
break; return B_OK;
} }
} else { } else {
switch (op) { switch (op) {
@ -1006,11 +1011,12 @@ hid_device_control(driver_cookie *cookie, uint32 op,
default: default:
/* not implemented */ /* not implemented */
break; return B_ERROR;
} }
} }
return err; /* shouldn't get here */
return B_ERROR;
} }
@ -1112,6 +1118,7 @@ uninit_driver(void)
free_device_names(); free_device_names();
} }
/*! /*!
device names are generated dynamically device names are generated dynamically
*/ */
@ -1153,4 +1160,3 @@ find_device(const char *name)
return &hooks; return &hooks;
} }