Re: [PATCH 1/2] HID: logitech-hidpp: add battery support for HID++ 2.0 devices

From: Bastien Nocera
Date: Thu Jan 26 2017 - 10:02:19 EST

On Wed, 2016-06-29 at 19:28 +1000, Peter Hutterer wrote:
> If the 0x1000 Unified Battery Level Status feature exists, expose the battery
> level.
> The main drawback is that while a device is plugged in its battery level is 0.
> To avoid exposing that as 0% charge we make up a number based on the charging
> status.

The reason why you don't get a proper state for the K750 is because it
doesn't export a battery status of its own. The UPower code uses a
heuristic based on the status of the solar panel:
if (priv->lux > 200) {
} else {

This is the code in UPower:

The heuristics seem to be fairly consistent with the light level button
on the keyboard, which shows green or red depending on whether the
device is charging or discharging.

This hunk of code is also the reason why the battery percentage doesn't

kernel hidpp code:
Device: /org/freedesktop/UPower/devices/keyboard_hidpp_battery_4

UPower's hidpp code:
Device: /org/freedesktop/UPower/devices/keyboard_0003o046Do4002x000F