UsbMouse.cpp revision 3fe24a3690526efc4cceece3819d628caadf3140
/** @file
* UsbMouse - USB Human Interface Device Emulation (Mouse).
*/
/*
* Copyright (C) 2007-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_USB_MOUSE
#include <iprt/critsect.h>
#include <iprt/semaphore.h>
#include "VBoxDD.h"
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** @name USB HID string IDs
* @{ */
#define USBHID_STR_ID_MANUFACTURER 1
#define USBHID_STR_ID_PRODUCT_M 2
#define USBHID_STR_ID_PRODUCT_T 3
/** @} */
/** @name USB HID specific descriptor types
* @{ */
#define DT_IF_HID_DESCRIPTOR 0x21
#define DT_IF_HID_REPORT 0x22
/** @} */
/** @name USB HID vendor and product IDs
* @{ */
#define VBOX_USB_VENDOR 0x80EE
#define USBHID_PID_MOUSE 0x0020
#define USBHID_PID_TABLET 0x0021
/** @} */
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* The USB HID request state.
*/
typedef enum USBHIDREQSTATE
{
/** Invalid status. */
/** Ready to receive a new read request. */
/** Have (more) data for the host. */
/** Waiting to supply status information to the host. */
/** The end of the valid states. */
/**
* Endpoint status data.
*/
typedef struct USBHIDEP
{
bool fHalted;
} USBHIDEP;
/** Pointer to the endpoint status. */
/**
* A URB queue.
*/
typedef struct USBHIDURBQUEUE
{
/** The head pointer. */
/** Where to insert the next entry. */
/** Pointer to a URB queue. */
typedef USBHIDURBQUEUE *PUSBHIDURBQUEUE;
/** Pointer to a const URB queue. */
typedef USBHIDURBQUEUE const *PCUSBHIDURBQUEUE;
/**
* Mouse movement accumulator.
*/
typedef struct USBHIDM_ACCUM
{
/**
* The USB HID instance data.
*/
typedef struct USBHID
{
/** USB device instance number. */
/** Critical section protecting the device state. */
/** The current configuration.
* (0 - default, 1 - the one supported configuration, i.e configured.) */
/** Endpoint 0 is the default control pipe, 1 is the dev->host interrupt one. */
/** The state of the HID (state machine).*/
/** Pointer movement accumulator. */
/** Pending to-host queue.
* The URBs waiting here are waiting for data to become available.
*/
/** Done queue
* The URBs stashed here are waiting to be reaped. */
/** Signalled when adding an URB to the done queue and fHaveDoneQueueWaiter
* is set. */
/** Someone is waiting on the done queue. */
bool fHaveDoneQueueWaiter;
/** If device has pending changes. */
bool fHasPendingChanges;
/** Is this an absolute pointing device (tablet)? Relative (mouse) otherwise. */
bool isAbsolute;
/** Tablet coordinate shift factor for old and broken operating systems. */
/**
* Mouse port - LUN#0.
*
* @implements PDMIBASE
* @implements PDMIMOUSEPORT
*/
struct
{
/** The base interface for the mouse port. */
/** The mouse port base interface. */
/** The base interface of the attached mouse driver. */
/** The mouse interface of the attached mouse driver. */
} Lun0;
} USBHID;
/** Pointer to the USB HID instance data. */
/**
* The USB HID report structure for relative device.
*/
typedef struct USBHIDM_REPORT
{
/**
* The USB HID report structure for absolute device.
*/
typedef struct USBHIDT_REPORT
{
/**
* The combined USB HID report union for relative and absolute device.
*/
typedef union USBHIDTM_REPORT
{
/*******************************************************************************
* Global Variables *
*******************************************************************************/
static const PDMUSBDESCCACHESTRING g_aUsbHidStrings_en_US[] =
{
{ USBHID_STR_ID_MANUFACTURER, "VirtualBox" },
{ USBHID_STR_ID_PRODUCT_M, "USB Mouse" },
{ USBHID_STR_ID_PRODUCT_T, "USB Tablet" },
};
static const PDMUSBDESCCACHELANG g_aUsbHidLanguages[] =
{
};
static const VUSBDESCENDPOINTEX g_aUsbHidMEndpointDescs[] =
{
{
{
/* .bLength = */ sizeof(VUSBDESCENDPOINT),
/* .bDescriptorType = */ VUSB_DT_ENDPOINT,
/* .bEndpointAddress = */ 0x81 /* ep=1, in */,
/* .bmAttributes = */ 3 /* interrupt */,
/* .wMaxPacketSize = */ 4,
/* .bInterval = */ 10,
},
/* .pvMore = */ NULL,
/* .pvClass = */ NULL,
/* .cbClass = */ 0
},
};
static const VUSBDESCENDPOINTEX g_aUsbHidTEndpointDescs[] =
{
{
{
/* .bLength = */ sizeof(VUSBDESCENDPOINT),
/* .bDescriptorType = */ VUSB_DT_ENDPOINT,
/* .bEndpointAddress = */ 0x81 /* ep=1, in */,
/* .bmAttributes = */ 3 /* interrupt */,
/* .wMaxPacketSize = */ 6,
/* .bInterval = */ 10,
},
/* .pvMore = */ NULL,
/* .pvClass = */ NULL,
/* .cbClass = */ 0
},
};
/* HID report descriptor (mouse). */
static const uint8_t g_UsbHidMReportDesc[] =
{
/* Usage Page */ 0x05, 0x01, /* Generic Desktop */
/* Usage */ 0x09, 0x02, /* Mouse */
/* Collection */ 0xA1, 0x01, /* Application */
/* Usage */ 0x09, 0x01, /* Pointer */
/* Collection */ 0xA1, 0x00, /* Physical */
/* Usage Page */ 0x05, 0x09, /* Button */
/* Usage Minimum */ 0x19, 0x01, /* Button 1 */
/* Usage Maximum */ 0x29, 0x05, /* Button 5 */
/* Logical Minimum */ 0x15, 0x00, /* 0 */
/* Logical Maximum */ 0x25, 0x01, /* 1 */
/* Report Count */ 0x95, 0x05, /* 5 */
/* Report Size */ 0x75, 0x01, /* 1 */
/* Input */ 0x81, 0x02, /* Data, Value, Absolute, Bit field */
/* Report Count */ 0x95, 0x01, /* 1 */
/* Report Size */ 0x75, 0x03, /* 3 (padding bits) */
/* Input */ 0x81, 0x03, /* Constant, Value, Absolute, Bit field */
/* Usage Page */ 0x05, 0x01, /* Generic Desktop */
/* Usage */ 0x09, 0x30, /* X */
/* Usage */ 0x09, 0x31, /* Y */
/* Usage */ 0x09, 0x38, /* Z (wheel) */
/* Logical Minimum */ 0x15, 0x81, /* -127 */
/* Logical Maximum */ 0x25, 0x7F, /* +127 */
/* Report Size */ 0x75, 0x08, /* 8 */
/* Report Count */ 0x95, 0x03, /* 3 */
/* Input */ 0x81, 0x06, /* Data, Value, Relative, Bit field */
/* End Collection */ 0xC0,
/* End Collection */ 0xC0,
};
/* HID report descriptor (tablet). */
/* NB: The layout is far from random. Having the buttons and Z axis grouped
* together avoids alignment issues. Also, if X/Y is reported first, followed
* by buttons/Z, Windows gets phantom Z movement. That is likely a bug in Windows
* as OS X shows no such problem. When X/Y is reported last, Windows behaves
* properly.
*/
#define REPORTID_MOUSE 1
static const uint8_t g_UsbHidTReportDesc[] =
{
/* Usage Page */ 0x05, 0x01, /* Generic Desktop */
/* Usage */ 0x09, 0x02, /* Mouse */
/* Collection */ 0xA1, 0x01, /* Application */
/* Usage */ 0x09, 0x01, /* Pointer */
/* Collection */ 0xA1, 0x00, /* Physical */
/* Usage Page */ 0x05, 0x09, /* Button */
/* Usage Minimum */ 0x19, 0x01, /* Button 1 */
/* Usage Maximum */ 0x29, 0x05, /* Button 5 */
/* Logical Minimum */ 0x15, 0x00, /* 0 */
/* Logical Maximum */ 0x25, 0x01, /* 1 */
/* Report Count */ 0x95, 0x05, /* 5 */
/* Report Size */ 0x75, 0x01, /* 1 */
/* Input */ 0x81, 0x02, /* Data, Value, Absolute, Bit field */
/* Report Count */ 0x95, 0x01, /* 1 */
/* Report Size */ 0x75, 0x03, /* 3 (padding bits) */
/* Input */ 0x81, 0x03, /* Constant, Value, Absolute, Bit field */
/* Usage Page */ 0x05, 0x01, /* Generic Desktop */
/* Usage */ 0x09, 0x38, /* Z (wheel) */
/* Logical Minimum */ 0x15, 0x81, /* -127 */
/* Logical Maximum */ 0x25, 0x7F, /* +127 */
/* Report Size */ 0x75, 0x08, /* 8 */
/* Report Count */ 0x95, 0x01, /* 1 */
/* Input */ 0x81, 0x06, /* Data, Value, Relative, Bit field */
/* Report Count */ 0x95, 0x01, /* 1 (padding byte) */
/* Input */ 0x81, 0x03, /* Constant, Value, Absolute, Bit field */
/* Usage Page */ 0x05, 0x01, /* Generic Desktop */
/* Usage */ 0x09, 0x30, /* X */
/* Usage */ 0x09, 0x31, /* Y */
/* Logical Minimum */ 0x15, 0x00, /* 0 */
/* Logical Maximum */ 0x26, 0xFF,0x7F,/* 0x7fff */
/* Physical Minimum */ 0x35, 0x00, /* 0 */
/* Physical Maximum */ 0x46, 0xFF,0x7F,/* 0x7fff */
/* Report Size */ 0x75, 0x10, /* 16 */
/* Report Count */ 0x95, 0x02, /* 2 */
/* Input */ 0x81, 0x02, /* Data, Value, Absolute, Bit field */
/* End Collection */ 0xC0,
/* End Collection */ 0xC0,
};
/* Additional HID class interface descriptor. */
static const uint8_t g_UsbHidMIfHidDesc[] =
{
/* .bLength = */ 0x09,
/* .bDescriptorType = */ 0x21, /* HID */
/* .bcdHID = */ 0x10, 0x01, /* 1.1 */
/* .bCountryCode = */ 0,
/* .bNumDescriptors = */ 1,
/* .bDescriptorType = */ 0x22, /* Report */
};
/* Additional HID class interface descriptor. */
static const uint8_t g_UsbHidTIfHidDesc[] =
{
/* .bLength = */ 0x09,
/* .bDescriptorType = */ 0x21, /* HID */
/* .bcdHID = */ 0x10, 0x01, /* 1.1 */
/* .bCountryCode = */ 0,
/* .bNumDescriptors = */ 1,
/* .bDescriptorType = */ 0x22, /* Report */
};
static const VUSBDESCINTERFACEEX g_UsbHidMInterfaceDesc =
{
{
/* .bLength = */ sizeof(VUSBDESCINTERFACE),
/* .bDescriptorType = */ VUSB_DT_INTERFACE,
/* .bInterfaceNumber = */ 0,
/* .bAlternateSetting = */ 0,
/* .bNumEndpoints = */ 1,
/* .bInterfaceClass = */ 3 /* HID */,
/* .bInterfaceSubClass = */ 1 /* Boot Interface */,
/* .bInterfaceProtocol = */ 2 /* Mouse */,
/* .iInterface = */ 0
},
/* .pvMore = */ NULL,
/* .pvClass = */ &g_UsbHidMIfHidDesc,
/* .cbClass = */ sizeof(g_UsbHidMIfHidDesc),
/* .pIAD = */ NULL,
/* .cbIAD = */ 0
};
static const VUSBDESCINTERFACEEX g_UsbHidTInterfaceDesc =
{
{
/* .bLength = */ sizeof(VUSBDESCINTERFACE),
/* .bDescriptorType = */ VUSB_DT_INTERFACE,
/* .bInterfaceNumber = */ 0,
/* .bAlternateSetting = */ 0,
/* .bNumEndpoints = */ 1,
/* .bInterfaceClass = */ 3 /* HID */,
/* .bInterfaceSubClass = */ 0 /* No subclass - no boot interface. */,
/* .bInterfaceProtocol = */ 0 /* No protocol - no boot interface. */,
/* .iInterface = */ 0
},
/* .pvMore = */ NULL,
/* .pvClass = */ &g_UsbHidTIfHidDesc,
/* .cbClass = */ sizeof(g_UsbHidTIfHidDesc),
/* .pIAD = */ NULL,
/* .cbIAD = */ 0
};
static const VUSBINTERFACE g_aUsbHidMInterfaces[] =
{
};
static const VUSBINTERFACE g_aUsbHidTInterfaces[] =
{
};
static const VUSBDESCCONFIGEX g_UsbHidMConfigDesc =
{
{
/* .bLength = */ sizeof(VUSBDESCCONFIG),
/* .bDescriptorType = */ VUSB_DT_CONFIG,
/* .wTotalLength = */ 0 /* recalculated on read */,
/* .bConfigurationValue =*/ 1,
/* .iConfiguration = */ 0,
/* .MaxPower = */ 50 /* 100mA */
},
NULL, /* pvMore */
&g_aUsbHidMInterfaces[0],
NULL /* pvOriginal */
};
static const VUSBDESCCONFIGEX g_UsbHidTConfigDesc =
{
{
/* .bLength = */ sizeof(VUSBDESCCONFIG),
/* .bDescriptorType = */ VUSB_DT_CONFIG,
/* .wTotalLength = */ 0 /* recalculated on read */,
/* .bConfigurationValue =*/ 1,
/* .iConfiguration = */ 0,
/* .MaxPower = */ 50 /* 100mA */
},
NULL, /* pvMore */
&g_aUsbHidTInterfaces[0],
NULL /* pvOriginal */
};
static const VUSBDESCDEVICE g_UsbHidMDeviceDesc =
{
/* .bLength = */ sizeof(g_UsbHidMDeviceDesc),
/* .bDescriptorType = */ VUSB_DT_DEVICE,
/* .bcdUsb = */ 0x110, /* 1.1 */
/* .bDeviceClass = */ 0 /* Class specified in the interface desc. */,
/* .bDeviceSubClass = */ 0 /* Subclass specified in the interface desc. */,
/* .bDeviceProtocol = */ 0 /* Protocol specified in the interface desc. */,
/* .bMaxPacketSize0 = */ 8,
/* .idVendor = */ VBOX_USB_VENDOR,
/* .idProduct = */ USBHID_PID_MOUSE,
/* .bcdDevice = */ 0x0100, /* 1.0 */
/* .iManufacturer = */ USBHID_STR_ID_MANUFACTURER,
/* .iProduct = */ USBHID_STR_ID_PRODUCT_M,
/* .iSerialNumber = */ 0,
/* .bNumConfigurations = */ 1
};
static const VUSBDESCDEVICE g_UsbHidTDeviceDesc =
{
/* .bLength = */ sizeof(g_UsbHidTDeviceDesc),
/* .bDescriptorType = */ VUSB_DT_DEVICE,
/* .bcdUsb = */ 0x110, /* 1.1 */
/* .bDeviceClass = */ 0 /* Class specified in the interface desc. */,
/* .bDeviceSubClass = */ 0 /* Subclass specified in the interface desc. */,
/* .bDeviceProtocol = */ 0 /* Protocol specified in the interface desc. */,
/* .bMaxPacketSize0 = */ 8,
/* .idVendor = */ VBOX_USB_VENDOR,
/* .idProduct = */ USBHID_PID_TABLET,
/* .bcdDevice = */ 0x0100, /* 1.0 */
/* .iManufacturer = */ USBHID_STR_ID_MANUFACTURER,
/* .iProduct = */ USBHID_STR_ID_PRODUCT_T,
/* .iSerialNumber = */ 0,
/* .bNumConfigurations = */ 1
};
static const PDMUSBDESCCACHE g_UsbHidMDescCache =
{
/* .pDevice = */ &g_UsbHidMDeviceDesc,
/* .paConfigs = */ &g_UsbHidMConfigDesc,
/* .paLanguages = */ g_aUsbHidLanguages,
/* .fUseCachedDescriptors = */ true,
/* .fUseCachedStringsDescriptors = */ true
};
static const PDMUSBDESCCACHE g_UsbHidTDescCache =
{
/* .pDevice = */ &g_UsbHidTDeviceDesc,
/* .paConfigs = */ &g_UsbHidTConfigDesc,
/* .paLanguages = */ g_aUsbHidLanguages,
/* .fUseCachedDescriptors = */ true,
/* .fUseCachedStringsDescriptors = */ true
};
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
/**
* Initializes an URB queue.
*
* @param pQueue The URB queue.
*/
{
}
/**
* Inserts an URB at the end of the queue.
*
* @param pQueue The URB queue.
* @param pUrb The URB to insert.
*/
{
}
/**
* Unlinks the head of the queue and returns it.
*
* @returns The head entry.
* @param pQueue The URB queue.
*/
{
if (pUrb)
{
if (!pNext)
else
}
return pUrb;
}
/**
* Removes an URB from anywhere in the queue.
*
* @returns true if found, false if not.
* @param pQueue The URB queue.
* @param pUrb The URB to remove.
*/
{
else
{
while (pCur)
{
{
break;
}
}
if (!pCur)
return false;
}
return true;
}
/**
* Checks if the queue is empty or not.
*
* @returns true if it is, false if it isn't.
* @param pQueue The URB queue.
*/
{
}
/**
* Links an URB into the done queue.
*
* @param pThis The HID instance.
* @param pUrb The URB.
*/
{
if (pThis->fHaveDoneQueueWaiter)
{
}
}
/**
* Completes the URB with a stalled state, halting the pipe.
*/
{
/** @todo figure out if the stall is global or pipe-specific or both. */
if (pEp)
else
{
}
return VINF_SUCCESS;
}
/**
* Completes the URB with a OK state.
*/
{
Log(("usbHidCompleteOk/#%u: pUrb=%p:%s cbData=%#zx\n", pThis->iInstance, pUrb, pUrb->pszDesc, cbData));
return VINF_SUCCESS;
}
/**
* Reset worker for usbHidUsbReset, usbHidUsbSetConfiguration and
* usbHidHandleDefaultPipe.
*
* @returns VBox status code.
* @param pThis The HID instance.
* @param pUrb Set when usbHidHandleDefaultPipe is the
* caller.
* @param fSetConfig Set when usbHidUsbSetConfiguration is the
* caller.
*/
{
/*
* Wait for the any command currently executing to complete before
* resetting. (We cannot cancel its execution.) How we do this depends
* on the reset method.
*/
/*
* Reset the device state.
*/
pThis->fHasPendingChanges = false;
/*
* Ditch all pending URBs.
*/
{
}
if (pUrb)
return VINF_SUCCESS;
}
{
if (val > 127) {
val = 127;
} else if (val < -127) {
val = -127;
}
return val;
}
/**
* Create a USB HID report report based on the currently accumulated data.
*/
static size_t usbHidFillReport(PUSBHIDTM_REPORT pReport, PUSBHIDM_ACCUM pAccumulated, bool isAbsolute)
{
if (isAbsolute)
{
// LogRel(("Abs movement, X=%d, Y=%d, dZ=%d, btn=%02x, report size %d\n", pReport->t.cx, pReport->t.cy, pReport->t.dz, pReport->t.btn, cbCopy));
}
else
{
// LogRel(("Rel movement, dX=%d, dY=%d, dZ=%d, btn=%02x, report size %d\n", pReport->m.dx, pReport->m.dy, pReport->m.dz, pReport->m.btn, cbCopy));
}
/* Clear the accumulated movement. */
return cbCopy;
}
/**
* Sends a state report to the host if there is a pending URB.
*/
{
if (pUrb)
{
pThis->fHasPendingChanges = false;
}
else
{
Log2(("No available URB for USB mouse\n"));
pThis->fHasPendingChanges = true;
}
return VINF_EOF;
}
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
return NULL;
}
/**
* Relative mouse event handler.
*
* @returns VBox status code.
* @param pInterface Pointer to the mouse port interface (KBDState::Mouse.iPort).
* @param i32DeltaX The X delta.
* @param i32DeltaY The Y delta.
* @param i32DeltaZ The Z delta.
* @param i32DeltaW The W delta.
* @param fButtonStates The button states.
*/
static DECLCALLBACK(int) usbHidMousePutEvent(PPDMIMOUSEPORT pInterface, int32_t i32DeltaX, int32_t i32DeltaY, int32_t i32DeltaZ, int32_t i32DeltaW, uint32_t fButtonStates)
{
/* Accumulate movement - the events from the front end may arrive
* at a much higher rate than USB can handle.
*/
/* Send a report if possible. */
return VINF_SUCCESS;
}
/**
* Absolute mouse event handler.
*
* @returns VBox status code.
* @param pInterface Pointer to the mouse port interface (KBDState::Mouse.iPort).
* @param u32X The X coordinate.
* @param u32Y The Y coordinate.
* @param i32DeltaZ The Z delta.
* @param i32DeltaW The W delta.
* @param fButtonStates The button states.
*/
static DECLCALLBACK(int) usbHidMousePutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t u32X, uint32_t u32Y, int32_t i32DeltaZ, int32_t i32DeltaW, uint32_t fButtonStates)
{
/* Accumulate movement - the events from the front end may arrive
* at a much higher rate than USB can handle. Probably not a real issue
* when only the Z axis is relative (X/Y movement isn't technically
* accumulated and only the last value is used).
*/
/* Send a report if possible. */
return VINF_SUCCESS;
}
{
{
/* Wait */
pThis->fHaveDoneQueueWaiter = true;
pThis->fHaveDoneQueueWaiter = false;
}
if (pUrb)
return pUrb;
}
/**
* @copydoc PDMUSBREG::pfnUrbReap
*/
{
}
{
/*
* Remove the URB from the to-host queue and move it onto the done queue.
*/
return VINF_SUCCESS;
}
/**
* @copydoc PDMUSBREG::pfnUrbCancel
*/
{
}
/**
* Handles request sent to the inbound (device to host) interrupt pipe. This is
* rather different from bulk requests because an interrupt read URB may complete
* after arbitrarily long time.
*/
{
/*
* Stall the request if the pipe is halted.
*/
/*
* Deal with the URB according to the state.
*/
{
/*
* We've data left to transfer to the host.
*/
{
AssertFailed();
Log(("usbHidHandleIntrDevToHost: Entering STATUS\n"));
}
/*
* Status transfer.
*/
case USBHIDREQSTATE_STATUS:
{
AssertFailed();
Log(("usbHidHandleIntrDevToHost: Entering READY\n"));
}
case USBHIDREQSTATE_READY:
/* If a report is pending, send it right away. */
if (pThis->fHasPendingChanges)
return VINF_SUCCESS;
/*
* Bad states, stall.
*/
default:
}
}
/**
* Handles request sent to the default control pipe.
*/
{
{
{
case VUSB_REQ_GET_DESCRIPTOR:
{
switch (pSetup->bmRequestType)
{
{
{
case VUSB_DT_STRING:
break;
default:
break;
}
break;
}
{
{
case DT_IF_HID_DESCRIPTOR:
{
if (pThis->isAbsolute)
{
cbDesc = sizeof(g_UsbHidTIfHidDesc);
}
else
{
cbDesc = sizeof(g_UsbHidMIfHidDesc);
}
/* Returned data is written after the setup message. */
Log(("usbHidMouse: GET_DESCRIPTOR DT_IF_HID_DESCRIPTOR wValue=%#x wIndex=%#x cbCopy=%#x\n", pSetup->wValue, pSetup->wIndex, cbCopy));
}
case DT_IF_HID_REPORT:
{
if (pThis->isAbsolute)
{
cbDesc = sizeof(g_UsbHidTReportDesc);
}
else
{
cbDesc = sizeof(g_UsbHidMReportDesc);
}
/* Returned data is written after the setup message. */
Log(("usbHid: GET_DESCRIPTOR DT_IF_HID_REPORT wValue=%#x wIndex=%#x cbCopy=%#x\n", pSetup->wValue, pSetup->wIndex, cbCopy));
}
default:
break;
}
break;
}
default:
}
break;
}
case VUSB_REQ_GET_STATUS:
{
{
break;
}
switch (pSetup->bmRequestType)
{
{
Log(("usbHid: GET_STATUS (device)\n"));
wRet = 0; /* Not self-powered, no remote wakeup. */
}
{
{
}
else
{
}
break;
}
{
{
}
else
{
}
break;
}
default:
}
break;
}
case VUSB_REQ_CLEAR_FEATURE:
break;
}
/** @todo implement this. */
Log(("usbHid: Implement standard request: bmRequestType=%#x bRequest=%#x wValue=%#x wIndex=%#x wLength=%#x\n",
}
/* 3.1 Bulk-Only Mass Storage Reset */
{
Log(("usbHidHandleDefaultPipe: Bulk-Only Mass Storage Reset\n"));
}
else
{
Log(("usbHid: Unknown control msg: bmRequestType=%#x bRequest=%#x wValue=%#x wIndex=%#x wLength=%#x\n",
}
return VINF_SUCCESS;
}
{
/*
* Parse on a per end-point basis.
*/
int rc;
{
case 0:
break;
case 0x81:
AssertFailed();
case 0x01:
break;
default:
break;
}
return rc;
}
/**
* @copydoc PDMUSBREG::pfnUrbQueue
*/
{
}
{
{
}
return VINF_SUCCESS;
}
/**
* @copydoc PDMUSBREG::pfnUsbClearHaltedEndpoint
*/
unsigned uEndpoint)
{
LogFlow(("usbHidUsbClearHaltedEndpoint/#%u: uEndpoint=%#x\n",
}
/**
* @copydoc PDMUSBREG::pfnUsbSetInterface
*/
{
LogFlow(("usbHidUsbSetInterface/#%u: bInterfaceNumber=%u bAlternateSetting=%u\n",
Assert(bAlternateSetting == 0);
return VINF_SUCCESS;
}
const void *pvOldCfgDesc,
const void *pvOldIfState,
const void *pvNewCfgDesc)
{
/*
* If the same config is applied more than once, it's a kind of reset.
*/
/** @todo figure out the exact difference */
/*
* Set received event type to absolute or relative.
*/
pThis->isAbsolute);
return VINF_SUCCESS;
}
/**
* @copydoc PDMUSBREG::pfnUsbSetConfiguration
*/
const void *pvOldCfgDesc,
const void *pvOldIfState,
const void *pvNewCfgDesc)
{
LogFlow(("usbHidUsbSetConfiguration/#%u: bConfigurationValue=%u\n",
}
/**
* @copydoc PDMUSBREG::pfnUsbGetDescriptorCache
*/
{
if (pThis->isAbsolute) {
return &g_UsbHidTDescCache;
} else {
return &g_UsbHidMDescCache;
}
}
/**
* @copydoc PDMUSBREG::pfnUsbGetDescriptorCache
*/
{
return usbHidUsbGetDescriptorCacheCore(pThis);
}
{
return rc;
}
/**
* @copydoc PDMUSBREG::pfnUsbReset
*/
{
return usbHidUsbResetCore(pThis);
}
{
{
}
{
}
}
/**
* @copydoc PDMUSBREG::pfnDestruct
*/
{
}
{
/*
* Perform the basic structure initialization first so the destructor
* will not misbehave.
*/
return VINF_SUCCESS;
}
{
}
/**
* @copydoc PDMUSBREG::pfnConstruct
*/
{
bool isAbsolute;
/*
* Validate and read the configuration.
*/
"UsbHid", iInstance);
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
N_("HID failed to query settings"));
if (RT_FAILURE(rc))
N_("HID failed to query shift factor"));
/*
* Attach the mouse driver.
*/
if (RT_FAILURE(rc))
N_("HID failed to attach mouse driver"));
if (!pDrv)
N_("HID failed to query mouse interface"));
return VINF_SUCCESS;
}
/**
* The USB Human Interface Device (HID) Mouse registration record.
*/
const PDMUSBREG g_UsbHidMou =
{
/* u32Version */
/* szName */
"HidMouse",
/* pszDescription */
"USB HID Mouse.",
/* fFlags */
0,
/* cMaxInstances */
~0U,
/* cbInstance */
sizeof(USBHID),
/* pfnConstruct */
/* pfnDestruct */
/* pfnVMInitComplete */
NULL,
/* pfnVMPowerOn */
NULL,
/* pfnVMReset */
NULL,
/* pfnVMSuspend */
NULL,
/* pfnVMResume */
NULL,
/* pfnVMPowerOff */
NULL,
/* pfnHotPlugged */
NULL,
/* pfnHotUnplugged */
NULL,
/* pfnDriverAttach */
NULL,
/* pfnDriverDetach */
NULL,
/* pfnQueryInterface */
NULL,
/* pfnUsbReset */
/* pfnUsbGetDescriptorCache */
/* pfnUsbSetConfiguration */
/* pfnUsbSetInterface */
/* pfnUsbClearHaltedEndpoint */
/* pfnUrbNew */
NULL/*usbHidUrbNew*/,
/* pfnUrbQueue */
/* pfnUrbCancel */
/* pfnUrbReap */
/* u32TheEnd */
};