From 505280bd9af458c712ec6d19afacdc192c6e02ab Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 1 Apr 2014 21:55:02 +0200 Subject: unifying: handle K800-specific HID++ 1.0 regs Add these regs to prevent reporting errors. Some of the regs are not implemented fully. Signed-off-by: Peter Wu --- hw/usb/hid-logitech-dj.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'hw') diff --git a/hw/usb/hid-logitech-dj.c b/hw/usb/hid-logitech-dj.c index 0ab09f332d..f5b736f6f3 100644 --- a/hw/usb/hid-logitech-dj.c +++ b/hw/usb/hid-logitech-dj.c @@ -344,6 +344,53 @@ static void hidpp_process_receiver_report(USBLtunifyState *s, HidppMsg *msg) } } +static bool hidpp_process_k800_regs(unsigned req, LHidDevice *hd, uint8_t *parms) +{ + switch (req) { + /* K800-specific */ + case GET_REG(0x01): /* hand detection */ + memset(parms, 0, 3); + return true; + case SET_REG(0x01): /* hand detection */ + /* not implemented */ + memset(parms, 0, 3); + return true; + case GET_REG(0x07): /* battery */ + parms[0] = hd->battery.level; + switch (hd->battery.status) { + case BAT_STS_RECHARGING: + parms[1] = 0x25; + break; + case BAT_STS_CHARGE_COMPLETE: + parms[1] = 0x22; + break; + default: + parms[1] = 0; /* discharging */ + } + parms[2] = 0; + return true; + case GET_REG(0x09): /* Fn key swap */ + memset(parms, 0, 3); + return true; + case SET_REG(0x09): /* Fn key swap */ + /* not implemented */ + memset(parms, 0, 3); + return true; + case GET_REG(0x17): /* Illumination info */ + parms[0] = 0x3C; + parms[1] = 0x00; + parms[2] = 0x01; + return true; + case SET_REG(0x17): /* Illumination info */ + /* not implemented */ + memset(parms, 0, 3); + return true; + default: + /* unhandled */ + return false; + } +} + /* called for HID++ reports targeted at devices */ static void hidpp_process_device_hidpp10(USBLtunifyState *s, HidppMsg *msg) { @@ -369,6 +416,12 @@ static void hidpp_process_device_hidpp10(USBLtunifyState *s, HidppMsg *msg) hidpp_process_version_request(s, &msg->hidpp_s, &hd->info.version); break; default: + if (hd->info.wireless_pid == WPID_K800) { + if (hidpp_process_k800_regs(req, hd, parms)) { + hidpp_queue_output_report(s, msg); + break; + } + } /* unknown request, return error */ switch (req & ~0xFF) { case SET_REG(0): @@ -601,6 +654,9 @@ static void hidpp_init_device(USBLtunifyState *s, int device_index, uint16_t pid memcpy(hd->info.name, "K800", 4); /* hd->info.device_name N/A for HID++ 1.0 */ hd->report_interval = 20; + hd->battery.nlevels = 7; /* valid values: 1, 3, 5, 7 */ + hd->battery.level = 7; /* Full - 90 % */ + hd->battery.critical_perc = 5; break; case WPID_M525: hd->info.device_type = DEVTYPE_MOUSE; -- cgit v1.2.1