summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-03-15 12:46:43 +0100
committerPeter Wu <peter@lekensteyn.nl>2014-03-16 00:10:06 +0100
commit5a0107638d07e287001d69a786591162dc62e5e2 (patch)
tree8ad64f79b5450314c92958adf9d06656e7ae1c8c
parent291bcc09e3818fb138304663945c94f81a4101ad (diff)
downloadqemu-5a0107638d07e287001d69a786591162dc62e5e2.tar.gz
unifying: remove unused leftover from dev-wacom
To make a tidy ship, remove unused parts that were taken from dev-wacom. Also enable a handle_data callback (currently empty), handle_reset (currently sets the device mode to HID instead of DJ). This is incomplete, the handle_data callback must contain something. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r--hw/usb/dev-unifying.c193
1 files changed, 7 insertions, 186 deletions
diff --git a/hw/usb/dev-unifying.c b/hw/usb/dev-unifying.c
index 97c8bb3458..48479a07f4 100644
--- a/hw/usb/dev-unifying.c
+++ b/hw/usb/dev-unifying.c
@@ -34,35 +34,14 @@
#include "hw/usb/desc.h"
#include "dump.h"
-#if 0
-/* Interface requests */
-#define LTUNIFY_GET_REPORT 0x2101
-#define LTUNIFY_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
-#endif
-
typedef struct USBLtunifyState {
USBDevice dev;
USBEndpoint *intr;
UsbDumpState *usb_dump_state;
-#if 0
- QEMUPutMouseEntry *eh_entry;
- int dx, dy, dz, buttons_state;
- int x, y;
- int mouse_grabbed;
enum {
LTUNIFY_MODE_HID = 1,
- LTUNIFY_MODE_LTUNIFY = 2,
+ LTUNIFY_MODE_DJ = 2
} mode;
- uint8_t idle;
- int changed;
-#endif
} USBLtunifyState;
/* descriptors are retrieved with usbhid-dump (need to unbind interfaces from
@@ -369,132 +348,12 @@ static const USBDesc desc_ltunify = {
.str = desc_strings,
};
-#if 0
-static void usb_mouse_event(void *opaque,
- int dx1, int dy1, int dz1, int buttons_state)
-{
- USBLtunifyState *s = opaque;
-
- s->dx += dx1;
- s->dy += dy1;
- s->dz += dz1;
- s->buttons_state = buttons_state;
- s->changed = 1;
- usb_wakeup(s->intr, 0);
-}
-
-static void usb_ltunify_event(void *opaque,
- int x, int y, int dz, int buttons_state)
-{
- USBLtunifyState *s = opaque;
-
- /* scale to Penpartner resolution */
- s->x = (x * 5040 / 0x7FFF);
- s->y = (y * 3780 / 0x7FFF);
- s->dz += dz;
- s->buttons_state = buttons_state;
- s->changed = 1;
- usb_wakeup(s->intr, 0);
-}
-
-static inline int int_clamp(int val, int vmin, int vmax)
-{
- if (val < vmin)
- return vmin;
- else if (val > vmax)
- return vmax;
- else
- return val;
-}
-
-static int usb_mouse_poll(USBLtunifyState *s, uint8_t *buf, int len)
-{
- int dx, dy, dz, b, l;
-
- if (!s->mouse_grabbed) {
- s->eh_entry = qemu_add_mouse_event_handler(usb_mouse_event, s, 0,
- "QEMU PenPartner tablet");
- qemu_activate_mouse_event_handler(s->eh_entry);
- s->mouse_grabbed = 1;
- }
-
- dx = int_clamp(s->dx, -128, 127);
- dy = int_clamp(s->dy, -128, 127);
- dz = int_clamp(s->dz, -128, 127);
-
- s->dx -= dx;
- s->dy -= dy;
- s->dz -= dz;
-
- b = 0;
- if (s->buttons_state & MOUSE_EVENT_LBUTTON)
- b |= 0x01;
- if (s->buttons_state & MOUSE_EVENT_RBUTTON)
- b |= 0x02;
- if (s->buttons_state & MOUSE_EVENT_MBUTTON)
- b |= 0x04;
-
- buf[0] = b;
- buf[1] = dx;
- buf[2] = dy;
- l = 3;
- if (len >= 4) {
- buf[3] = dz;
- l = 4;
- }
- return l;
-}
-
-static int usb_ltunify_poll(USBLtunifyState *s, uint8_t *buf, int len)
-{
- int b;
-
- if (!s->mouse_grabbed) {
- s->eh_entry = qemu_add_mouse_event_handler(usb_ltunify_event, s, 1,
- "QEMU PenPartner tablet");
- qemu_activate_mouse_event_handler(s->eh_entry);
- s->mouse_grabbed = 1;
- }
-
- b = 0;
- if (s->buttons_state & MOUSE_EVENT_LBUTTON)
- b |= 0x01;
- if (s->buttons_state & MOUSE_EVENT_RBUTTON)
- b |= 0x40;
- if (s->buttons_state & MOUSE_EVENT_MBUTTON)
- b |= 0x20; /* eraser */
-
- if (len < 7)
- return 0;
-
- buf[0] = s->mode;
- buf[5] = 0x00 | (b & 0xf0);
- buf[1] = s->x & 0xff;
- buf[2] = s->x >> 8;
- buf[3] = s->y & 0xff;
- buf[4] = s->y >> 8;
- if (b & 0x3f) {
- buf[6] = 0;
- } else {
- buf[6] = (unsigned char) -127;
- }
-
- return 7;
-}
-
static void usb_ltunify_handle_reset(USBDevice *dev)
{
USBLtunifyState *s = (USBLtunifyState *) dev;
- s->dx = 0;
- s->dy = 0;
- s->dz = 0;
- s->x = 0;
- s->y = 0;
- s->buttons_state = 0;
s->mode = LTUNIFY_MODE_HID;
}
-#endif
static void usb_ltunify_handle_control(USBDevice *dev, USBPacket *p,
int request, int value, int index, int length, uint8_t *data)
@@ -544,34 +403,6 @@ static void usb_ltunify_handle_control(USBDevice *dev, USBPacket *p,
}
}
break;
-#if 0
- case LTUNIFY_SET_REPORT:
- if (s->mouse_grabbed) {
- qemu_remove_mouse_event_handler(s->eh_entry);
- s->mouse_grabbed = 0;
- }
- s->mode = data[0];
- break;
- case LTUNIFY_GET_REPORT:
- data[0] = 0;
- data[1] = s->mode;
- p->actual_length = 2;
- break;
- /* USB HID requests */
- case HID_GET_REPORT:
- if (s->mode == LTUNIFY_MODE_HID)
- p->actual_length = usb_mouse_poll(s, data, length);
- else if (s->mode == LTUNIFY_MODE_LTUNIFY)
- p->actual_length = usb_ltunify_poll(s, data, length);
- break;
- case HID_GET_IDLE:
- data[0] = s->idle;
- p->actual_length = 1;
- break;
- case HID_SET_IDLE:
- s->idle = (uint8_t) (value >> 8);
- break;
-#endif
default:
p->status = USB_RET_STALL;
break;
@@ -583,9 +414,10 @@ data_ready:
}
}
-#if 0
+/* handle interrupt transfers (this device does not have a bulk/iso endpoint */
static void usb_ltunify_handle_data(USBDevice *dev, USBPacket *p)
{
+#if 0
USBLtunifyState *s = (USBLtunifyState *) dev;
uint8_t buf[p->iov.size];
int len = 0;
@@ -610,20 +442,13 @@ static void usb_ltunify_handle_data(USBDevice *dev, USBPacket *p)
default:
p->status = USB_RET_STALL;
}
-}
#endif
+}
static void usb_ltunify_handle_destroy(USBDevice *dev)
{
USBLtunifyState *s = (USBLtunifyState *) dev;
-#if 0
- if (s->mouse_grabbed) {
- qemu_remove_mouse_event_handler(s->eh_entry);
- s->mouse_grabbed = 0;
- }
-#endif
-
if (s->usb_dump_state) {
usb_dump_cleanup(s->usb_dump_state);
g_free(s->usb_dump_state);
@@ -638,10 +463,11 @@ static int usb_ltunify_initfn(USBDevice *dev)
// available). Since we hard-code one, do not use it.
//usb_desc_create_serial(dev);
+ // init device descriptors, etc.
usb_desc_init(dev);
+
+ // TODO: is EP1 really wanted here? What about EP2 or EP3?
s->intr = usb_ep_get(dev, USB_TOKEN_IN, 1);
- // WTF is this for:
- //s->changed = 1;
// TODO: API sucks...
s->usb_dump_state = usb_dump_init_alloc("/tmp/usbdump.pcap");
@@ -661,17 +487,12 @@ static void usb_ltunify_class_init(ObjectClass *klass, void *data)
uc->product_desc = "QEMU Logitech Unifying Receiver";
uc->usb_desc = &desc_ltunify;
uc->init = usb_ltunify_initfn;
-#if 0
uc->handle_reset = usb_ltunify_handle_reset;
-#endif
uc->handle_control = usb_ltunify_handle_control;
-#if 0
uc->handle_data = usb_ltunify_handle_data;
-#endif
uc->handle_destroy = usb_ltunify_handle_destroy;
// uc->handle_attach = usb_desc_attach; ?? found in dev-hid.c
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
- // TODO: is this mecessary?
dc->desc = "QEMU Logitech Unifying Receiver";
dc->vmsd = &vmstate_usb_ltunify;
}