From 5817de3fcf4f70c1d23cfcecd01c854272eb97da Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 19 Mar 2014 17:13:07 +0100 Subject: unifying: pass pointer to msg, handle kbd LED request It is not dangerous to modify the original data buffer, so just pass a pointer for the message instead. Also implement DJ report type 0x0E (LEDS). Signed-off-by: Peter Wu --- hw/usb/hid-logitech-dj.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'hw') diff --git a/hw/usb/hid-logitech-dj.c b/hw/usb/hid-logitech-dj.c index 9ff049ff86..77e7f20202 100644 --- a/hw/usb/hid-logitech-dj.c +++ b/hw/usb/hid-logitech-dj.c @@ -94,17 +94,20 @@ static bool hidpp_device_available(USBLtunifyState *s, uint8_t device_index) s->devices[device_index - 1].powered_on; } -static bool hidpp_process_receiver_report(USBLtunifyState *s, HidppMsg msg) +static bool hidpp_process_receiver_report(USBLtunifyState *s, HidppMsg *msg) { LHidDevice *hd; int i; - uint8_t *parms = msg.dj_s.payload; + uint8_t *parms = msg->dj_s.payload; - assert(msg.device_index == 0xFF); + assert(msg->device_index == 0xFF); - if (msg.report_id == DJ_SHORT) { + if (msg->report_id == DJ_SHORT) { /* DJ reports */ - switch (msg.dj_s.report_type) { + switch (msg->dj_s.report_type) { + case 0x0E: /* Keyboard LEDs */ + /* ignored */ + break; case 0x80: /* Switch and Keep-Alive */ for (i = 0; i < MAX_DEVICES; i++) { hd = &s->devices[i]; @@ -117,9 +120,9 @@ static bool hidpp_process_receiver_report(USBLtunifyState *s, HidppMsg msg) // not implemented: keep-alive timeout params[1]; break; case 0x81: /* Get Paired Devices */ - memset(&msg, 0, sizeof(msg)); - msg.report_id = DJ_SHORT; - msg.dj_s.report_type = 0x41; /* Device Paired notif */ + memset(msg, 0, sizeof(*msg)); + msg->report_id = DJ_SHORT; + msg->dj_s.report_type = 0x41; /* Device Paired notif */ parms[0] = 1; /* more notifications will follow bit. */ for (i = 0; i < MAX_DEVICES; i++) { hd = &s->devices[i]; @@ -127,25 +130,25 @@ static bool hidpp_process_receiver_report(USBLtunifyState *s, HidppMsg msg) continue; } - msg.device_index = i + 1; + msg->device_index = i + 1; parms[1] = (uint8_t) hd->info.wireless_pid; parms[2] = (uint8_t) (hd->info.wireless_pid >> 8); parms[3] = (uint8_t) hd->info.report_types; parms[4] = (uint8_t) (hd->info.report_types >> 8); parms[5] = (uint8_t) (hd->info.report_types >> 16); parms[6] = (uint8_t) (hd->info.report_types >> 24); - hidpp_queue_output_report(s, &msg); + hidpp_queue_output_report(s, msg); } /* end of notifications list */ - msg.device_index = 0x00; + msg->device_index = 0x00; parms[0] = 2; memset(parms + 1, 0, 6); - hidpp_queue_output_report(s, &msg); + hidpp_queue_output_report(s, msg); break; default: - hidpp_queue_error(s, &msg, HIDPP_ERR_INVALID_SUBID); + hidpp_queue_error(s, msg, HIDPP_ERR_INVALID_SUBID); } - } else if (msg.report_id == HIDPP_SHORT || msg.report_id == HIDPP_LONG) { + } else if (msg->report_id == HIDPP_SHORT || msg->report_id == HIDPP_LONG) { /* TODO: handle requests */ } else { /* DJ_LONG is unhandled */ @@ -184,7 +187,7 @@ static void hidpp_set_report(USBDevice *dev, USBPacket *p, uint8_t *data, size_t if (report_len > 0 && len >= report_len) { if (msg->device_index == 0xFF) { /* receiver messages can be processed immediately */ - if (!hidpp_process_receiver_report(s, *msg)) { + if (!hidpp_process_receiver_report(s, msg)) { goto fail; } } else if (s->input_queue.n < LQUEUE_SIZE(s->input_queue)) { -- cgit v1.2.1