コード例 #1
0
/**
 * Describe USB human interface device
 *
 * @v hid		USB human interface device
 * @v config		Configuration descriptor
 * @ret rc		Return status code
 */
int usbhid_describe ( struct usb_hid *hid,
		      struct usb_configuration_descriptor *config ) {
	struct usb_interface_descriptor *desc;
	int rc;

	/* Locate interface descriptor */
	desc = usb_interface_descriptor ( config, hid->func->interface[0], 0 );
	if ( ! desc ) {
		DBGC ( hid, "HID %s has no interface descriptor\n",
		       hid->func->name );
		return -EINVAL;
	}

	/* Describe interrupt IN endpoint */
	if ( ( rc = usb_endpoint_described ( &hid->in, config, desc,
					     USB_INTERRUPT_IN, 0 ) ) != 0 ) {
		DBGC ( hid, "HID %s could not describe interrupt IN: %s\n",
		       hid->func->name, strerror ( rc ) );
		return rc;
	}

	/* Describe interrupt OUT endpoint, if applicable */
	if ( hid->out.usb &&
	     ( ( rc = usb_endpoint_described ( &hid->out, config, desc,
					       USB_INTERRUPT_OUT, 0 ) ) != 0 )){
		DBGC ( hid, "HID %s could not describe interrupt OUT: %s\n",
		       hid->func->name, strerror ( rc ) );
		return rc;
	}

	return 0;
}
コード例 #2
0
bool AdbInterfaceObject::GetUsbInterfaceDescriptor(
    USB_INTERFACE_DESCRIPTOR* desc) {
  if (!IsOpened()) {
    SetLastError(ERROR_INVALID_HANDLE);
    return false;
  }

  CopyMemory(desc, usb_interface_descriptor(), sizeof(USB_INTERFACE_DESCRIPTOR));

  return true;
}