UsbMouse.cpp revision 5bce4261f4ea22150d84982d69d5786b96aacdde
/** @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
#define USBHID_STR_ID_PRODUCT_MT 4
/** @} */
/** @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
#define USBHID_PID_MULTI_TOUCH 0x0022
/** @} */
/*******************************************************************************
* 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. */
/**
* The device reporting mode.
* @todo Use an interface instead of an enum and switches.
*/
typedef enum USBHIDMODE
{
/** Relative. */
USBHIDMODE_RELATIVE = 0,
/** Absolute. */
/** Multi-touch. */
} USBHIDMODE;
/**
* 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
{
union
{
struct
{
} Relative;
struct
{
uint32_t x;
uint32_t y;
} Absolute;
} u;
#define MT_CONTACTS_PER_REPORT 5
#define MT_CONTACT_MAX_COUNT 10
#define MT_CONTACT_F_IN_CONTACT 0x01
#define MT_CONTACT_F_IN_RANGE 0x02
#define MT_CONTACT_S_REUSED 0x04 /* Report contact loss for the oldId and then new contact for the id. */
typedef struct MTCONTACT
{
uint16_t x;
uint16_t y;
} MTCONTACT;
/**
* The USB HID instance data.
*/
typedef struct USBHID
{
/** Pointer back to the PDM USB Device instance structure. */
/** 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 a relative, absolute or multi-touch pointing device? */
/** 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;
bool fTouchReporting;
bool fTouchStateUpdated;
} USBHID;
/** Pointer to the USB HID instance data. */
#pragma pack(1)
/**
* The USB HID report structure for relative device.
*/
typedef struct USBHIDM_REPORT
{
/**
* The USB HID report structure for absolute device.
*/
typedef struct USBHIDT_REPORT
{
uint16_t x;
uint16_t y;
/**
* The combined USB HID report union for relative and absolute
* devices.
*/
typedef union USBHIDTM_REPORT
{
/**
* The USB HID report structure for the multi-touch device.
*/
typedef struct USBHIDMT_REPORT
{
struct
{
uint16_t x;
uint16_t y;
typedef struct USBHIDMT_REPORT_POINTER
{
uint16_t x;
uint16_t y;
#pragma pack()
/*******************************************************************************
* 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" },
{ USBHID_STR_ID_PRODUCT_MT, "USB Multi-Touch" },
};
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
},
};
static const VUSBDESCENDPOINTEX g_aUsbHidMTEndpointDescs[] =
{
{
{
/* .bLength = */ sizeof(VUSBDESCENDPOINT),
/* .bDescriptorType = */ VUSB_DT_ENDPOINT,
/* .bEndpointAddress = */ 0x81 /* ep=1, in */,
/* .bmAttributes = */ 3 /* interrupt */,
/* .wMaxPacketSize = */ 64,
/* .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) */
/* Usage Page */ 0x05, 0x0C, /* Consumer Devices */
/* Usage */ 0x0A, 0x38, 0x02,/* AC Pan (horizontal wheel) */
/* Logical Minimum */ 0x15, 0x81, /* -127 */
/* Logical Maximum */ 0x25, 0x7F, /* +127 */
/* Report Size */ 0x75, 0x08, /* 8 */
/* Report Count */ 0x95, 0x04, /* 4 */
/* 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
#define REPORTID_MAX_COUNT 2
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 */
/* Report Size */ 0x75, 0x08, /* 8 (padding byte) */
/* Report Count */ 0x95, 0x01, /* 1 */
/* 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,
};
/*
* Multi-touch device implementation based on "Windows Pointer Device Data Delivery Protocol"
* specification.
*/
#define REPORTID_TOUCH_POINTER 1
#define REPORTID_TOUCH_EVENT 2
#define REPORTID_TOUCH_MAX_COUNT 3
#define REPORTID_TOUCH_QABLOB 4
#define REPORTID_TOUCH_DEVCONFIG 5
static const uint8_t g_UsbHidMTReportDesc[] =
{
/* Usage Page (Digitizer) */ 0x05, 0x0D,
/* Usage (Touch Screen) */ 0x09, 0x04,
/* Collection (Application) */ 0xA1, 0x01,
/* Usage Page (Digitizer) */ 0x05, 0x0D,
/* Usage (Contact count) */ 0x09, 0x54,
/* Report Size (8) */ 0x75, 0x08,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (12) */ 0x25, 0x0C,
/* Report Count (1) */ 0x95, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* MT_CONTACTS_PER_REPORT structs u8TipSwitch, u8ContactIdentifier, u16X, u16Y */
/* 1 of 5 */
/* Usage (Finger) */ 0x09, 0x22,
/* Collection (Logical) */ 0xA1, 0x02,
/* Usage (Tip Switch) */ 0x09, 0x42,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (1) */ 0x25, 0x01,
/* Report Size (1) */ 0x75, 0x01,
/* Report Count (1) */ 0x95, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* Usage (In Range) */ 0x09, 0x32,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (1) */ 0x25, 0x01,
/* Report Size (1) */ 0x75, 0x01,
/* Report Count (1) */ 0x95, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* Report Count (6) */ 0x95, 0x06,
/* Input (Cnst,Var) */ 0x81, 0x03,
/* Report Size (8) */ 0x75, 0x08,
/* Usage (Contact identifier) */ 0x09, 0x51,
/* Report Count (1) */ 0x95, 0x01,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (32) */ 0x25, 0x20,
/* Input (Var) */ 0x81, 0x02,
/* Usage Page (Generic Desktop) */ 0x05, 0x01,
/* Logical Maximum (32K) */ 0x26, 0xFF, 0x7F,
/* Report Size (16) */ 0x75, 0x10,
/* Usage (X) */ 0x09, 0x30,
/* Input (Var) */ 0x81, 0x02,
/* Usage (Y) */ 0x09, 0x31,
/* Input (Var) */ 0x81, 0x02,
/* End Collection */ 0xC0,
/* 2 of 5 */
/* Usage Page (Digitizer) */ 0x05, 0x0D,
/* Usage (Finger) */ 0x09, 0x22,
/* Collection (Logical) */ 0xA1, 0x02,
/* Usage (Tip Switch) */ 0x09, 0x42,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (1) */ 0x25, 0x01,
/* Report Size (1) */ 0x75, 0x01,
/* Report Count (1) */ 0x95, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* Usage (In Range) */ 0x09, 0x32,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (1) */ 0x25, 0x01,
/* Report Size (1) */ 0x75, 0x01,
/* Report Count (1) */ 0x95, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* Report Count (6) */ 0x95, 0x06,
/* Input (Cnst,Var) */ 0x81, 0x03,
/* Report Size (8) */ 0x75, 0x08,
/* Usage (Contact identifier) */ 0x09, 0x51,
/* Report Count (1) */ 0x95, 0x01,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (32) */ 0x25, 0x20,
/* Input (Var) */ 0x81, 0x02,
/* Usage Page (Generic Desktop) */ 0x05, 0x01,
/* Logical Maximum (32K) */ 0x26, 0xFF, 0x7F,
/* Report Size (16) */ 0x75, 0x10,
/* Usage (X) */ 0x09, 0x30,
/* Input (Var) */ 0x81, 0x02,
/* Usage (Y) */ 0x09, 0x31,
/* Input (Var) */ 0x81, 0x02,
/* End Collection */ 0xC0,
/* 3 of 5 */
/* Usage Page (Digitizer) */ 0x05, 0x0D,
/* Usage (Finger) */ 0x09, 0x22,
/* Collection (Logical) */ 0xA1, 0x02,
/* Usage (Tip Switch) */ 0x09, 0x42,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (1) */ 0x25, 0x01,
/* Report Size (1) */ 0x75, 0x01,
/* Report Count (1) */ 0x95, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* Usage (In Range) */ 0x09, 0x32,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (1) */ 0x25, 0x01,
/* Report Size (1) */ 0x75, 0x01,
/* Report Count (1) */ 0x95, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* Report Count (6) */ 0x95, 0x06,
/* Input (Cnst,Var) */ 0x81, 0x03,
/* Report Size (8) */ 0x75, 0x08,
/* Usage (Contact identifier) */ 0x09, 0x51,
/* Report Count (1) */ 0x95, 0x01,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (32) */ 0x25, 0x20,
/* Input (Var) */ 0x81, 0x02,
/* Usage Page (Generic Desktop) */ 0x05, 0x01,
/* Logical Maximum (32K) */ 0x26, 0xFF, 0x7F,
/* Report Size (16) */ 0x75, 0x10,
/* Usage (X) */ 0x09, 0x30,
/* Input (Var) */ 0x81, 0x02,
/* Usage (Y) */ 0x09, 0x31,
/* Input (Var) */ 0x81, 0x02,
/* End Collection */ 0xC0,
/* 4 of 5 */
/* Usage Page (Digitizer) */ 0x05, 0x0D,
/* Usage (Finger) */ 0x09, 0x22,
/* Collection (Logical) */ 0xA1, 0x02,
/* Usage (Tip Switch) */ 0x09, 0x42,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (1) */ 0x25, 0x01,
/* Report Size (1) */ 0x75, 0x01,
/* Report Count (1) */ 0x95, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* Usage (In Range) */ 0x09, 0x32,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (1) */ 0x25, 0x01,
/* Report Size (1) */ 0x75, 0x01,
/* Report Count (1) */ 0x95, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* Report Count (6) */ 0x95, 0x06,
/* Input (Cnst,Var) */ 0x81, 0x03,
/* Report Size (8) */ 0x75, 0x08,
/* Usage (Contact identifier) */ 0x09, 0x51,
/* Report Count (1) */ 0x95, 0x01,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (32) */ 0x25, 0x20,
/* Input (Var) */ 0x81, 0x02,
/* Usage Page (Generic Desktop) */ 0x05, 0x01,
/* Logical Maximum (32K) */ 0x26, 0xFF, 0x7F,
/* Report Size (16) */ 0x75, 0x10,
/* Usage (X) */ 0x09, 0x30,
/* Input (Var) */ 0x81, 0x02,
/* Usage (Y) */ 0x09, 0x31,
/* Input (Var) */ 0x81, 0x02,
/* End Collection */ 0xC0,
/* 5 of 5 */
/* Usage Page (Digitizer) */ 0x05, 0x0D,
/* Usage (Finger) */ 0x09, 0x22,
/* Collection (Logical) */ 0xA1, 0x02,
/* Usage (Tip Switch) */ 0x09, 0x42,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (1) */ 0x25, 0x01,
/* Report Size (1) */ 0x75, 0x01,
/* Report Count (1) */ 0x95, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* Usage (In Range) */ 0x09, 0x32,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (1) */ 0x25, 0x01,
/* Report Size (1) */ 0x75, 0x01,
/* Report Count (1) */ 0x95, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* Report Count (6) */ 0x95, 0x06,
/* Input (Cnst,Var) */ 0x81, 0x03,
/* Report Size (8) */ 0x75, 0x08,
/* Usage (Contact identifier) */ 0x09, 0x51,
/* Report Count (1) */ 0x95, 0x01,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (32) */ 0x25, 0x20,
/* Input (Var) */ 0x81, 0x02,
/* Usage Page (Generic Desktop) */ 0x05, 0x01,
/* Logical Maximum (32K) */ 0x26, 0xFF, 0x7F,
/* Report Size (16) */ 0x75, 0x10,
/* Usage (X) */ 0x09, 0x30,
/* Input (Var) */ 0x81, 0x02,
/* Usage (Y) */ 0x09, 0x31,
/* Input (Var) */ 0x81, 0x02,
/* End Collection */ 0xC0,
/* Note: "Scan time" usage is required for all touch devices (in 100microseconds units). */
/* Usage Page (Digitizer) */ 0x05, 0x0D,
/* Logical Minimum (0) */ 0x17, 0x00, 0x00, 0x00, 0x00,
/* Logical Maximum (2147483647) */ 0x27, 0xFF, 0xFF, 0xFF, 0x7F,
/* Report Size (32) */ 0x75, 0x20,
/* Report Count (1) */ 0x95, 0x01,
/* Unit Exponent (0) */ 0x55, 0x00,
/* Unit (None) */ 0x65, 0x00,
/* Usage (Scan time) */ 0x09, 0x56,
/* Input (Var) */ 0x81, 0x02,
/* Usage (Contact count maximum) */ 0x09, 0x55,
/* Usage (Device identifier) */ 0x09, 0x53,
/* Report Size (8) */ 0x75, 0x08,
/* Report Count (2) */ 0x95, 0x02,
/* Logical Maximum (255) */ 0x26, 0xFF, 0x00,
/* Feature (Var) */ 0xB1, 0x02,
/* Usage Page (Vendor-Defined 1) */ 0x06, 0x00, 0xFF,
/* Usage (QA blob) */ 0x09, 0xC5,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (255) */ 0x26, 0xFF, 0x00,
/* Report Size (8) */ 0x75, 0x08,
/* Report Count (256) */ 0x96, 0x00, 0x01,
/* Feature (Var) */ 0xB1, 0x02,
/* End Collection */ 0xC0,
/* Note: the pointer report is required by specification:
* "The report descriptor for a multiple input device must include at least
* one top-level collection for the primary device and a separate top-level
* collection for the mouse."
*/
/* Usage Page (Generic Desktop) */ 0x05, 0x01,
/* Usage (Pointer) */ 0x09, 0x01,
/* Collection (Application) */ 0xA1, 0x01,
/* Usage (Pointer) */ 0x09, 0x01,
/* Collection (Logical) */ 0xA1, 0x02,
/* Usage Page (Button) */ 0x05, 0x09,
/* Usage Minimum (Button 1) */ 0x19, 0x01,
/* Usage Maximum (Button 2) */ 0x29, 0x02,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (1) */ 0x25, 0x01,
/* Report Count (2) */ 0x95, 0x02,
/* Report Size (1) */ 0x75, 0x01,
/* Input (Var) */ 0x81, 0x02,
/* Report Count (1) */ 0x95, 0x01,
/* Report Size (6) */ 0x75, 0x06,
/* Input (Cnst,Ary,Abs) */ 0x81, 0x01,
/* Usage Page (Generic Desktop) */ 0x05, 0x01,
/* Usage (X) */ 0x09, 0x30,
/* Usage (Y) */ 0x09, 0x31,
/* Logical Minimum (0) */ 0x16, 0x00, 0x00,
/* Logical Maximum (32K) */ 0x26, 0xFF, 0x7F,
/* Physical Minimum (0) */ 0x36, 0x00, 0x00,
/* Physical Maximum (32K) */ 0x46, 0xFF, 0x7F,
/* Unit (None) */ 0x66, 0x00, 0x00,
/* Report Size (16) */ 0x75, 0x10,
/* Report Count (2) */ 0x95, 0x02,
/* Input (Var) */ 0x81, 0x02,
/* End Collection */ 0xC0,
/* End Collection */ 0xC0,
/* Usage Page (Digitizer) */ 0x05, 0x0D,
/* Usage (Device configuration) */ 0x09, 0x0E,
/* Collection (Application) */ 0xA1, 0x01,
/* Usage (Device settings) */ 0x09, 0x23,
/* Collection (Logical) */ 0xA1, 0x02,
/* Usage (Device mode) */ 0x09, 0x52,
/* Usage (Device identifier) */ 0x09, 0x53,
/* Logical Minimum (0) */ 0x15, 0x00,
/* Logical Maximum (10) */ 0x25, 0x0A,
/* Report Size (8) */ 0x75, 0x08,
/* Report Count (2) */ 0x95, 0x02,
/* Feature (Var) */ 0xB1, 0x02,
/* End Collection */ 0xC0,
/* End Collection */ 0xC0
};
/** @todo Do these really have to all be duplicated three times? */
/* 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 */
};
/* Additional HID class interface descriptor. */
static const uint8_t g_UsbHidMTIfHidDesc[] =
{
/* .bLength = */ 0x09,
/* .bDescriptorType = */ 0x21, /* HID */
/* .bcdHID = */ 0x10, 0x02, /* 2.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 VUSBDESCINTERFACEEX g_UsbHidMTInterfaceDesc =
{
{
/* .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_UsbHidMTIfHidDesc,
/* .cbClass = */ sizeof(g_UsbHidMTIfHidDesc),
/* .pIAD = */ NULL,
/* .cbIAD = */ 0
};
static const VUSBINTERFACE g_aUsbHidMInterfaces[] =
{
};
static const VUSBINTERFACE g_aUsbHidTInterfaces[] =
{
};
static const VUSBINTERFACE g_aUsbHidMTInterfaces[] =
{
};
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 VUSBDESCCONFIGEX g_UsbHidMTConfigDesc =
{
{
/* .bLength = */ sizeof(VUSBDESCCONFIG),
/* .bDescriptorType = */ VUSB_DT_CONFIG,
/* .wTotalLength = */ 0 /* recalculated on read */,
/* .bConfigurationValue =*/ 1,
/* .iConfiguration = */ 0,
/* .MaxPower = */ 50 /* 100mA */
},
NULL, /* pvMore */
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 VUSBDESCDEVICE g_UsbHidMTDeviceDesc =
{
/* .bLength = */ sizeof(g_UsbHidMTDeviceDesc),
/* .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_MULTI_TOUCH,
/* .bcdDevice = */ 0x0100, /* 1.0 */
/* .iManufacturer = */ USBHID_STR_ID_MANUFACTURER,
/* .iProduct = */ USBHID_STR_ID_PRODUCT_MT,
/* .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
};
static const PDMUSBDESCCACHE g_UsbHidMTDescCache =
{
/* .pDevice = */ &g_UsbHidMTDeviceDesc,
/* .paConfigs = */ &g_UsbHidMTConfigDesc,
/* .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.
*/
{
LogRelFlow(("usbHidCompleteStall/#%u: pUrb=%p:%s: %s\n",
/** @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.
*/
{
LogRelFlow(("usbHidCompleteOk/#%u: pUrb=%p:%s cbData=%#zx\n",
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;
pThis->fTouchStateUpdated = 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.
*/
{
switch (enmMode)
{
case USBHIDMODE_ABSOLUTE:
LogRel3(("Abs event, x=%d, y=%d, fButtons=%02x, report size %d\n",
cbCopy));
break;
case USBHIDMODE_RELATIVE:
LogRel3(("Rel event, dx=%d, dy=%d, dz=%d, dw=%d, fButtons=%02x, report size %d\n",
break;
default:
AssertFailed(); /* Unexpected here. */
cbCopy = 0;
break;
}
/* Clear the accumulated movement. */
return cbCopy;
}
{
size_t i;
for (i = 0; i < cContacts; i++)
{
{
return &paContacts[i];
}
}
return NULL;
}
{
uint8_t i;
/* Number of contacts to be reported. In hybrid mode the first report contains
* total number of contacts and subsequent reports contain 0.
*/
if (!pThis->fTouchReporting)
{
pThis->fTouchReporting = true;
pThis->fTouchStateUpdated = false;
/* Update the reporting state with the new current state.
* Also mark all active contacts in reporting state as dirty,
* that is they must be reported to the guest.
*/
for (i = 0; i < MT_CONTACT_MAX_COUNT; i++)
{
{
{
/* Keep x,y. Will report lost contact at this point. */
pRepContact->flags = 0;
}
{
/* Keep x,y. Will report lost contact at this point. */
pRepContact->flags = 0;
pRepContact->status = 0;
}
else
{
if (pCurContact->flags == 0)
{
}
pRepContact->x = pCurContact->x;
pRepContact->y = pCurContact->y;
pRepContact->status = 0;
}
cContacts++;
}
else
{
pRepContact->status = 0;
}
}
}
/* Report current state. */
RT_ZERO(*p);
p->idReport = REPORTID_TOUCH_EVENT;
{
/* Find the next not reported contact. */
pRepContact = usbHidFindMTContact(pThis->aReportingContactState, RT_ELEMENTS(pThis->aReportingContactState),
if (!pRepContact)
{
LogRel3(("usbHid: no more touch contacts to report\n"));
break;
}
{
/* Do not clear DIRTY flag for contacts which were reused.
* Because two reports must be generated:
* one for old contact off, and the second for new contact on.
*/
}
else
{
}
}
Assert(iReportedContact > 0);
/* Reset TouchReporting if all contacts reported. */
pRepContact = usbHidFindMTContact(pThis->aReportingContactState, RT_ELEMENTS(pThis->aReportingContactState),
if (!pRepContact)
{
LogRel3(("usbHid: all touch contacts reported\n"));
pThis->fTouchReporting = false;
}
else
{
pThis->fHasPendingChanges = true;
}
}
/**
* Sends a state report to the host if there is a pending URB.
*/
{
{
/* This device uses a different reporting method and fHasPendingChanges maintenance. */
if (pUrb)
return VINF_SUCCESS;
}
if (pUrb)
{
pThis->fHasPendingChanges = false;
}
else
{
LogRelFlow(("No available URB for USB mouse\n"));
pThis->fHasPendingChanges = true;
}
return VINF_EOF;
}
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
return NULL;
}
/**
* @interface_method_impl{PDMIMOUSEPORT,pfnPutEvent}
*/
{
/* 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;
}
/**
* @interface_method_impl{PDMIMOUSEPORT,pfnPutEventAbs}
*/
{
/* 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;
}
/**
* @interface_method_impl{PDMIMOUSEPORT,pfnPutEventMultiTouch}
*/
const uint64_t *pau64Contacts,
{
uint8_t i;
uint8_t j;
/* Make a copy of new contacts */
if (!paNewContacts)
return VERR_NO_MEMORY;
for (i = 0; i < cContacts; i++)
{
{
}
}
/* Maintain a state of all current contacts.
* Intr URBs will be completed according to the state.
*/
/* Mark all existing contacts as dirty. */
/* Update existing contacts and mark new contacts. */
for (i = 0; i < cContacts; i++)
{
pNewContact = &paNewContacts[i];
/* Find existing contact with the same id. */
pCurContact = NULL;
{
{
break;
}
}
if (pCurContact)
{
pCurContact->x = pNewContact->x;
pCurContact->y = pNewContact->y;
{
{
pCurContact->status |= MT_CONTACT_S_REUSED; /* Report to the guest that the contact not in touch. */
}
}
}
}
/* Append new contacts (the dirty one in the paNewContacts). */
for (i = 0; i < cContacts; i++)
{
pNewContact = &paNewContacts[i];
{
/* It is a new contact, copy is to one of not ACTIVE or not updated existing contacts. */
pCurContact = usbHidFindMTContact(pThis->aCurrentContactState, RT_ELEMENTS(pThis->aCurrentContactState),
MT_CONTACT_S_ACTIVE, 0);
if (pCurContact)
{
*pCurContact = *pNewContact;
}
else
{
/* Dirty existing contacts can be reused. */
pCurContact = usbHidFindMTContact(pThis->aCurrentContactState, RT_ELEMENTS(pThis->aCurrentContactState),
if (pCurContact)
{
pCurContact->x = pNewContact->x;
pCurContact->y = pNewContact->y;
{
pCurContact->status |= MT_CONTACT_S_REUSED; /* Report to the guest that the contact not in touch. */
}
}
else
{
LogRel3(("usbHid: dropped new contact: %d,%d id %d flags %RX8 status %RX8 oldId %d\n",
pNewContact->x,
pNewContact->y,
));
}
}
}
}
/* Mark still dirty existing contacts as cancelled, because a new set of contacts does not include them. */
{
{
}
}
{
LogRel3(("usbHid: contact state[%d]: %d,%d id %d flags %RX8 status %RX8 oldId %d\n",
i,
pThis->aCurrentContactState[i].x,
pThis->aCurrentContactState[i].y,
));
}
pThis->fTouchStateUpdated = true;
pThis->fHasPendingChanges = true;
/* Send a report if possible. */
return VINF_SUCCESS;
}
/**
* @copydoc PDMUSBREG::pfnUrbReap
*/
{
{
/* Wait */
pThis->fHaveDoneQueueWaiter = true;
pThis->fHaveDoneQueueWaiter = false;
}
if (pUrb)
return pUrb;
}
/**
* @copydoc PDMUSBREG::pfnUrbCancel
*/
{
/*
* Remove the URB from the to-host queue and move it onto the done queue.
*/
return VINF_SUCCESS;
}
/**
* 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();
LogRelFlow(("usbHidHandleIntrDevToHost: Entering STATUS\n"));
}
/*
* Status transfer.
*/
case USBHIDREQSTATE_STATUS:
{
AssertFailed();
LogRelFlow(("usbHidHandleIntrDevToHost: Entering READY\n"));
}
case USBHIDREQSTATE_READY:
LogRelFlow(("usbHidHandleIntrDevToHost: Added %p:%s to the queue\n",
/* If a report is pending, send it right away. */
if (pThis->fHasPendingChanges)
return VINF_SUCCESS;
/*
* Bad states, stall.
*/
default:
LogRelFlow(("usbHidHandleIntrDevToHost: enmState=%d cbData=%#x\n",
}
}
#define GET_REPORT 0x01
#define GET_IDLE 0x02
#define GET_PROTOCOL 0x03
#define SET_REPORT 0x09
#define SET_IDLE 0x0A
#define SET_PROTOCOL 0x0B
{
0xfc, 0x28, 0xfe, 0x84, 0x40, 0xcb, 0x9a, 0x87,
0x0d, 0xbe, 0x57, 0x3c, 0xb6, 0x70, 0x09, 0x88,
0x07, 0x97, 0x2d, 0x2b, 0xe3, 0x38, 0x34, 0xb6,
0x6c, 0xed, 0xb0, 0xf7, 0xe5, 0x9c, 0xf6, 0xc2,
0x2e, 0x84, 0x1b, 0xe8, 0xb4, 0x51, 0x78, 0x43,
0x1f, 0x28, 0x4b, 0x7c, 0x2d, 0x53, 0xaf, 0xfc,
0x47, 0x70, 0x1b, 0x59, 0x6f, 0x74, 0x43, 0xc4,
0xf3, 0x47, 0x18, 0x53, 0x1a, 0xa2, 0xa1, 0x71,
0xc7, 0x95, 0x0e, 0x31, 0x55, 0x21, 0xd3, 0xb5,
0x1e, 0xe9, 0x0c, 0xba, 0xec, 0xb8, 0x89, 0x19,
0x3e, 0xb3, 0xaf, 0x75, 0x81, 0x9d, 0x53, 0xb9,
0x41, 0x57, 0xf4, 0x6d, 0x39, 0x25, 0x29, 0x7c,
0x87, 0xd9, 0xb4, 0x98, 0x45, 0x7d, 0xa7, 0x26,
0x9c, 0x65, 0x3b, 0x85, 0x68, 0x89, 0xd7, 0x3b,
0xbd, 0xff, 0x14, 0x67, 0xf2, 0x2b, 0xf0, 0x2a,
0x41, 0x54, 0xf0, 0xfd, 0x2c, 0x66, 0x7c, 0xf8,
0xc0, 0x8f, 0x33, 0x13, 0x03, 0xf1, 0xd3, 0xc1,
0x0b, 0x89, 0xd9, 0x1b, 0x62, 0xcd, 0x51, 0xb7,
0x80, 0xb8, 0xaf, 0x3a, 0x10, 0xc1, 0x8a, 0x5b,
0xe8, 0x8a, 0x56, 0xf0, 0x8c, 0xaa, 0xfa, 0x35,
0xe9, 0x42, 0xc4, 0xd8, 0x55, 0xc3, 0x38, 0xcc,
0x2b, 0x53, 0x5c, 0x69, 0x52, 0xd5, 0xc8, 0x73,
0x02, 0x38, 0x7c, 0x73, 0xb6, 0x41, 0xe7, 0xff,
0x05, 0xd8, 0x2b, 0x79, 0x9a, 0xe2, 0x34, 0x60,
0x8f, 0xa3, 0x32, 0x1f, 0x09, 0x78, 0x62, 0xbc,
0x80, 0xe3, 0x0f, 0xbd, 0x65, 0x20, 0x08, 0x13,
0xc1, 0xe2, 0xee, 0x53, 0x2d, 0x86, 0x7e, 0xa7,
0x5a, 0xc5, 0xd3, 0x7d, 0x98, 0xbe, 0x31, 0x48,
0x1f, 0xfb, 0xda, 0xaf, 0xa2, 0xa8, 0x6a, 0x89,
0xd6, 0xbf, 0xf2, 0xd3, 0x32, 0x2a, 0x9a, 0xe4,
0xcf, 0x17, 0xb7, 0xb8, 0xf4, 0xe1, 0x33, 0x08,
0x24, 0x8b, 0xc4, 0x43, 0xa5, 0xe5, 0x24, 0xc2
};
{
{
LogRelFlow(("usbHid: bmRequestType=%#x bRequest=%#x wValue=%#x wIndex=%#x wLength=%#x\n",
}
int rc = VINF_SUCCESS;
{
case SET_REPORT:
case GET_REPORT:
{
LogRelFlow(("usbHid: %s: type %d, ID %d, data\n%.*Rhxd\n",
{
{
/* The actual state should be reported here. */
p->fButtons = 0;
p->x = 0;
p->y = 0;
cbData = sizeof(USBHIDMT_REPORT_POINTER);
}
{
/* The actual state should be reported here. */
RT_ZERO(*p);
p->idReport = REPORTID_TOUCH_EVENT;
cbData = sizeof(USBHIDMT_REPORT);
}
{
cbData = 3;
}
{
sau8QASampleBlob, sizeof(sau8QASampleBlob));
}
{
* "HID touch device supporting contact
* identifier and contact count maximum."
*/
cbData = 3;
}
if (cbData > 0)
{
}
else
{
}
}
else
{
/* SET_REPORT */
}
} break;
default:
{
LogRelFlow(("usbHid: bmRequestType=%#x bRequest=%#x wValue=%#x wIndex=%#x wLength=%#x\n",
}
}
return rc;
}
/**
* Handles request sent to the default control pipe.
*/
{
{
{
case VUSB_REQ_GET_DESCRIPTOR:
{
switch (pSetup->bmRequestType)
{
{
{
case VUSB_DT_STRING:
LogRelFlow(("usbHid: GET_DESCRIPTOR DT_STRING wValue=%#x wIndex=%#x\n",
break;
default:
LogRelFlow(("usbHid: GET_DESCRIPTOR, huh? wValue=%#x wIndex=%#x\n",
break;
}
break;
}
{
{
case DT_IF_HID_DESCRIPTOR:
{
{
case USBHIDMODE_ABSOLUTE:
cbDesc = sizeof(g_UsbHidTIfHidDesc);
break;
case USBHIDMODE_RELATIVE:
cbDesc = sizeof(g_UsbHidMIfHidDesc);
break;
case USBHIDMODE_MULTI_TOUCH:
cbDesc = sizeof(g_UsbHidMTIfHidDesc);
break;
default:
cbDesc = 0;
pDesc = 0;
break;
}
/* Returned data is written after the setup message. */
LogRelFlow(("usbHidMouse: GET_DESCRIPTOR DT_IF_HID_DESCRIPTOR wValue=%#x wIndex=%#x cbCopy=%#x\n",
cbCopy));
}
case DT_IF_HID_REPORT:
{
{
case USBHIDMODE_ABSOLUTE:
cbDesc = sizeof(g_UsbHidTReportDesc);
break;
case USBHIDMODE_RELATIVE:
cbDesc = sizeof(g_UsbHidMReportDesc);
break;
case USBHIDMODE_MULTI_TOUCH:
cbDesc = sizeof(g_UsbHidMTReportDesc);
break;
default:
cbDesc = 0;
pDesc = 0;
break;
}
/* Returned data is written after the setup message. */
LogRelFlow(("usbHid: GET_DESCRIPTOR DT_IF_HID_REPORT wValue=%#x wIndex=%#x cbCopy=%#x\n",
cbCopy));
}
default:
LogRelFlow(("usbHid: GET_DESCRIPTOR, huh? wValue=%#x wIndex=%#x\n",
break;
}
break;
}
default:
LogRelFlow(("usbHid: Bad GET_DESCRIPTOR req: bmRequestType=%#x\n",
pSetup->bmRequestType));
}
break;
}
case VUSB_REQ_GET_STATUS:
{
{
LogRelFlow(("usbHid: Bad GET_STATUS req: wLength=%#x\n",
break;
}
switch (pSetup->bmRequestType)
{
{
LogRelFlow(("usbHid: GET_STATUS (device)\n"));
wRet = 0; /* Not self-powered, no remote wakeup. */
}
{
{
}
else
{
LogRelFlow(("usbHid: GET_STATUS (interface) invalid, wIndex=%#x\n",
}
break;
}
{
{
}
else
{
LogRelFlow(("usbHid: GET_STATUS (endpoint) invalid, wIndex=%#x\n",
}
break;
}
default:
LogRelFlow(("usbHid: Bad GET_STATUS req: bmRequestType=%#x\n",
pSetup->bmRequestType));
}
break;
}
case VUSB_REQ_CLEAR_FEATURE:
break;
}
/** @todo implement this. */
LogRelFlow(("usbHid: Implement standard request: bmRequestType=%#x bRequest=%#x wValue=%#x wIndex=%#x wLength=%#x\n",
}
{
/* Only VUSB_TO_INTERFACE is allowed. */
{
}
LogRelFlow(("usbHid: invalid recipient of class req: bmRequestType=%#x bRequest=%#x wValue=%#x wIndex=%#x wLength=%#x\n",
}
else
{
LogRelFlow(("usbHid: Unknown control msg: bmRequestType=%#x bRequest=%#x wValue=%#x wIndex=%#x wLength=%#x\n",
}
return VINF_SUCCESS;
}
/**
* @copydoc PDMUSBREG::pfnUrbQueue
*/
{
/*
* Parse on a per end-point basis.
*/
int rc;
{
case 0:
break;
case 0x81:
AssertFailed();
case 0x01:
break;
default:
break;
}
return rc;
}
/**
* @copydoc PDMUSBREG::pfnUsbClearHaltedEndpoint
*/
{
LogRelFlow(("usbHidUsbClearHaltedEndpoint/#%u: uEndpoint=%#x\n",
{
}
return VINF_SUCCESS;
}
/**
* @copydoc PDMUSBREG::pfnUsbSetInterface
*/
static DECLCALLBACK(int) usbHidUsbSetInterface(PPDMUSBINS pUsbIns, uint8_t bInterfaceNumber, uint8_t bAlternateSetting)
{
LogRelFlow(("usbHidUsbSetInterface/#%u: bInterfaceNumber=%u bAlternateSetting=%u\n",
Assert(bAlternateSetting == 0);
return VINF_SUCCESS;
}
/**
* @copydoc PDMUSBREG::pfnUsbSetConfiguration
*/
{
LogRelFlow(("usbHidUsbSetConfiguration/#%u: bConfigurationValue=%u\n",
/*
* If the same config is applied more than once, it's a kind of reset.
*/
/*
* Set received event type to absolute or relative.
*/
return VINF_SUCCESS;
}
/**
* @copydoc PDMUSBREG::pfnUsbGetDescriptorCache
*/
{
{
case USBHIDMODE_ABSOLUTE:
return &g_UsbHidTDescCache;
case USBHIDMODE_RELATIVE:
return &g_UsbHidMDescCache;
case USBHIDMODE_MULTI_TOUCH:
return &g_UsbHidMTDescCache;
default:
return NULL;
}
}
/**
* @copydoc PDMUSBREG::pfnUsbReset
*/
{
return rc;
}
/**
* @copydoc PDMUSBREG::pfnDestruct
*/
{
{
}
{
}
}
/**
* @copydoc PDMUSBREG::pfnConstruct
*/
static DECLCALLBACK(int) usbHidConstruct(PPDMUSBINS pUsbIns, int iInstance, PCFGMNODE pCfg, PCFGMNODE pCfgGlobal)
{
char szMode[64];
/*
* Perform the basic structure initialization first so the destructor
* will not misbehave.
*/
/*
* Validate and read the configuration.
*/
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
else
N_("Invalid HID device mode"));
/*
* Attach the mouse driver.
*/
rc = PDMUsbHlpDriverAttach(pUsbIns, 0 /*iLun*/, &pThis->Lun0.IBase, &pThis->Lun0.pDrvBase, "Mouse Port");
if (RT_FAILURE(rc))
return PDMUsbHlpVMSetError(pUsbIns, VERR_PDM_MISSING_INTERFACE, RT_SRC_POS, N_("HID failed to query mouse interface"));
if (RT_FAILURE(rc))
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 */
};