From 8f818c2670838ff841c2979f13b787fff33c8654 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 19 Mar 2014 19:33:29 +0100 Subject: unifying: implement activity counters and rcvr reg B3 Signed-off-by: Peter Wu --- hw/usb/hid-logitech-dj.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'hw/usb/hid-logitech-dj.c') diff --git a/hw/usb/hid-logitech-dj.c b/hw/usb/hid-logitech-dj.c index dddc5027f4..551ed768ee 100644 --- a/hw/usb/hid-logitech-dj.c +++ b/hw/usb/hid-logitech-dj.c @@ -157,6 +157,7 @@ static bool hidpp_process_receiver_report(USBLtunifyState *s, HidppMsg *msg) } else if (msg->report_id == HIDPP_SHORT || msg->report_id == HIDPP_LONG) { LHidReceiver *rcvr = &s->receiver; HidppMsgShort *ms = &msg->hidpp_s; + HidppMsgLong *ml = &msg->hidpp_l; unsigned req = (ms->report_id << 16) | (ms->sub_id << 8) | ms->address; switch (req) { @@ -180,6 +181,16 @@ static bool hidpp_process_receiver_report(USBLtunifyState *s, HidppMsg *msg) } hidpp_queue_output_report(s, msg); break; + case GET_LONG_REG(0xB3): /* Device Activity */ + memset(ml->value, 0, sizeof(ml->value)); + ml->report_id = HIDPP_LONG; + for (i = 0; i < MAX_DEVICES; i++) { + if (s->devices[i].info.device_type) { + ml->value[i] = s->devices[i].activity_counter; + } + } + hidpp_queue_output_report(s, msg); + break; default: /* unknown request, return error */ switch (req & ~0xFF) { @@ -354,6 +365,11 @@ void usb_ltunify_handle_datain_hidpp(USBDevice *dev, USBPacket *p) if (msg != NULL) { len = msg_report_length(msg); assert(len > 0); + + if (hidpp_device_available(s, msg->device_index)) { + s->devices[msg->device_index - 1].activity_counter++; + } + usb_dump_complete_data(s->usb_dump_state, p, (uint8_t *) msg, len); usb_packet_copy(p, (uint8_t *) msg, len); usb_dump_submit(s->usb_dump_state, p); -- cgit v1.2.1