* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "hw/hw.h"
+
+#include "qemu/osdep.h"
#include "ui/console.h"
#include "hw/usb.h"
-#include "hw/usb/desc.h"
+#include "hw/usb/hid.h"
+#include "migration/vmstate.h"
+#include "qemu/module.h"
+#include "desc.h"
+#include "qom/object.h"
/* Interface requests */
#define WACOM_GET_REPORT 0x2101
#define WACOM_SET_REPORT 0x2109
-/* HID interface requests */
-#define HID_GET_REPORT 0xa101
-#define HID_GET_IDLE 0xa102
-#define HID_GET_PROTOCOL 0xa103
-#define HID_SET_IDLE 0x210a
-#define HID_SET_PROTOCOL 0x210b
-
-typedef struct USBWacomState {
+struct USBWacomState {
USBDevice dev;
USBEndpoint *intr;
QEMUPutMouseEntry *eh_entry;
} mode;
uint8_t idle;
int changed;
-} USBWacomState;
+};
+
+#define TYPE_USB_WACOM "usb-wacom-tablet"
+OBJECT_DECLARE_SIMPLE_TYPE(USBWacomState, USB_WACOM)
enum {
STR_MANUFACTURER = 1,
/* HID descriptor */
.data = (uint8_t[]) {
0x09, /* u8 bLength */
- 0x21, /* u8 bDescriptorType */
+ USB_DT_HID, /* u8 bDescriptorType */
0x01, 0x10, /* u16 HID_class */
0x00, /* u8 country_code */
0x01, /* u8 num_descriptors */
- 0x22, /* u8 type: Report */
+ USB_DT_REPORT, /* u8 type: Report */
0x6e, 0, /* u16 len */
},
},
{
.bNumInterfaces = 1,
.bConfigurationValue = 1,
- .bmAttributes = 0x80,
+ .bmAttributes = USB_CFG_ATT_ONE,
.bMaxPower = 40,
.nif = 1,
.ifs = &desc_iface_wacom,
s->dz += dz1;
s->buttons_state = buttons_state;
s->changed = 1;
- usb_wakeup(s->intr);
+ usb_wakeup(s->intr, 0);
}
static void usb_wacom_event(void *opaque,
s->dz += dz;
s->buttons_state = buttons_state;
s->changed = 1;
- usb_wakeup(s->intr);
+ usb_wakeup(s->intr, 0);
}
static inline int int_clamp(int val, int vmin, int vmax)
}
}
-static void usb_wacom_handle_destroy(USBDevice *dev)
+static void usb_wacom_unrealize(USBDevice *dev)
{
USBWacomState *s = (USBWacomState *) dev;
}
}
-static int usb_wacom_initfn(USBDevice *dev)
+static void usb_wacom_realize(USBDevice *dev, Error **errp)
{
- USBWacomState *s = DO_UPCAST(USBWacomState, dev, dev);
+ USBWacomState *s = USB_WACOM(dev);
usb_desc_create_serial(dev);
usb_desc_init(dev);
s->intr = usb_ep_get(dev, USB_TOKEN_IN, 1);
s->changed = 1;
- return 0;
}
static const VMStateDescription vmstate_usb_wacom = {
uc->product_desc = "QEMU PenPartner Tablet";
uc->usb_desc = &desc_wacom;
- uc->init = usb_wacom_initfn;
+ uc->realize = usb_wacom_realize;
uc->handle_reset = usb_wacom_handle_reset;
uc->handle_control = usb_wacom_handle_control;
uc->handle_data = usb_wacom_handle_data;
- uc->handle_destroy = usb_wacom_handle_destroy;
+ uc->unrealize = usb_wacom_unrealize;
+ set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
dc->desc = "QEMU PenPartner Tablet";
dc->vmsd = &vmstate_usb_wacom;
}
-static TypeInfo wacom_info = {
- .name = "usb-wacom-tablet",
+static const TypeInfo wacom_info = {
+ .name = TYPE_USB_WACOM,
.parent = TYPE_USB_DEVICE,
.instance_size = sizeof(USBWacomState),
.class_init = usb_wacom_class_init,
static void usb_wacom_register_types(void)
{
type_register_static(&wacom_info);
- usb_legacy_register("usb-wacom-tablet", "wacom-tablet", NULL);
+ usb_legacy_register(TYPE_USB_WACOM, "wacom-tablet", NULL);
}
type_init(usb_wacom_register_types)