From d320b593b55739db798047b1623eaf228524f5ed Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 19 Mar 2014 21:56:09 +0100 Subject: unifying: fix mixup of reporting flags, HidppMsg tweaks The "address" and "value" split for short and long HID++ messages only make sense for HID++ 1.0 register accesses. For others, use "params". Also fix a mixup of reporting flags. Signed-off-by: Peter Wu --- hw/usb/hid-logitech-dj.c | 10 +++++----- hw/usb/hid-logitech-dj.h | 30 ++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/hw/usb/hid-logitech-dj.c b/hw/usb/hid-logitech-dj.c index 551ed768ee..d8bcbb06d7 100644 --- a/hw/usb/hid-logitech-dj.c +++ b/hw/usb/hid-logitech-dj.c @@ -73,10 +73,10 @@ static void hidpp_queue_error(USBLtunifyState *s, HidppMsg *msg, uint8_t err) report->report_id = HIDPP_SHORT; report->device_index = msg->device_index; report->sub_id = 0x8F; - report->address = msg->hidpp_s.sub_id; - report->value[0] = msg->hidpp_s.address; - report->value[1] = err; - report->value[2] = 0; + report->params[0] = msg->hidpp_s.sub_id; + report->params[1] = msg->hidpp_s.address; + report->params[2] = err; + report->params[3] = 0; } } @@ -168,7 +168,7 @@ static bool hidpp_process_receiver_report(USBLtunifyState *s, HidppMsg *msg) break; case SET_REG(0x00): /* Enable HID++ notifs */ rcvr->reporting_flags = ms->value[1]; - rcvr->reporting_flags &= REPORTING_FLAG_RECV_MASK; + rcvr->reporting_flags &= REPORTING_FLAG_RCV_MASK; memset(ms->value, 0, 3); hidpp_queue_output_report(s, msg); break; diff --git a/hw/usb/hid-logitech-dj.h b/hw/usb/hid-logitech-dj.h index 0ba7a5f61b..fae86b8d19 100644 --- a/hw/usb/hid-logitech-dj.h +++ b/hw/usb/hid-logitech-dj.h @@ -49,16 +49,26 @@ typedef struct { uint8_t report_id; uint8_t device_index; uint8_t sub_id; - uint8_t address; - uint8_t value[3]; + union { + uint8_t params[4]; + struct { + uint8_t address; + uint8_t value[3]; + }; /* for register queries */ + }; } HidppMsgShort; typedef struct { uint8_t report_id; uint8_t device_index; uint8_t sub_id; - uint8_t address; - uint8_t value[16]; + union { + uint8_t params[17]; + struct { + uint8_t address; + uint8_t value[16]; + }; /* for register queries */ + }; } HidppMsgLong; typedef struct { @@ -127,10 +137,8 @@ typedef struct { struct firmware_version version; } info; /* static information */ -#define REPORTING_FLAG_DEV_WIRELESS_NOTIFS 1 -#define REPORTING_FLAG_DEV_SOFTWARE_PRESENT (1 << 3) -#define REPORTING_FLAG_DEV_MASK (REPORTING_FLAG_WIRELESS_NOTIFS | \ - REPORTING_FLAG_SOFTWARE_PRESENT) +#define REPORTING_FLAG_DEV_BATTERY_STATUS (1 << 4) +#define REPORTING_FLAG_DEV_MASK REPORTING_FLAG_DEV_BATTERY_STATUS int reporting_flags; uint8_t activity_counter[MAX_DEVICES]; /* TODO: pairing lock open or closed (+ timeout) */ @@ -172,8 +180,10 @@ typedef struct { } mode; bool powered_on; uint8_t report_interval; -#define REPORTING_FLAG_RECV_BATTERY_STATUS (1 << 4) -#define REPORTING_FLAG_RECV_MASK REPORTING_FLAG_RECV_BATTERY_STATUS +#define REPORTING_FLAG_RCV_WIRELESS_NOTIFS 1 +#define REPORTING_FLAG_RCV_SOFTWARE_PRESENT (1 << 3) +#define REPORTING_FLAG_RCV_MASK (REPORTING_FLAG_RCV_WIRELESS_NOTIFS | \ + REPORTING_FLAG_RCV_SOFTWARE_PRESENT) int reporting_flags; /* TODO: status (device seen or not, encrypted link) */ -- cgit v1.2.1