Since commit b1f12feb1f ("Factor out the
Logitech Unifying support to support other devices"), the battery status
would always be reported as 1% for the K750 keyboard. Besides that, the
luminosity level was removed. This patch fixes the battery level and
re-adds the luminosity level.
To avoid negativity issues when reading light level into a double type,
make the HidppMessage params unsigned.
Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Before this, history files were saved as history-rate-M525.dat. Since
multiple devices of the same model might be connected, this name is not
unique enough.
The serial number gives a more reliable path for the history files and
allows clients to distinguish their devices (an object path like
/org/freedesktop/UPower/devices/mouse_0003o046DoC52Bx0018 does not stay
the same).
Note: if a serial number cannot be read, instead of reverting this
patch, consider splitting the serial refresh from the version, kind and
model refresh.
- v2: Fix invalid return value when an invalid parameter is passed to
hidpp_device_get_serial.
Signed-off-by: Peter Wu <lekensteyn@gmail.com>
This includes "is-present" and "state" (which will be marked "unknown").
"percentage" is not touched since it is still an indication of the
battery level, changing it to zero is not helpful.
Previously, properties were never updated because the refresh would
fail when the battery refresh request failed.
- v2: fix invalid return value when an invalid parameter is passed to
hidpp_device_is_reachable.
Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Do not assume HID++ 1.0 when device is unreachable. This allows
up_device_unifying_refresh() to be optimized to stop sending a ping
message at every refresh for HID++ 1.0 devices.
priv->version will now always contain 0 when the real HID++ version of
a device is not (yet) known, comments are updated to reflect this.
Also fix an uninitialised msg variable that might confuse the error
handler in hidpp_device_refresh.
Signed-off-by: Peter Wu <lekensteyn@gmail.com>
When sending a ping request right after a device got paired, the ping
message gets lost (there is no response). Work around that by delaying
the initial packet exchange. 10 milliseconds seems to work, but let's
choose 30 ms to be fully safe.
Signed-off-by: Peter Wu <lekensteyn@gmail.com>
For non unifying receiver we were trying to locate receiver hiddraw
device by looking into INTERFACES property. This doesn't work well
for non-unifying devices from keyboard+mouse sets (which use single
dongle for 2 devices but are still non-unifying).
The only thing that's different between hiddraw receiver and other
devices (mouse, keyboard etc) is that receiver also exposes hiddev
interface.
Use that fact to reliably locate receiver.
Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
Protocol version detection isn't very reliable (especially for
hid++ v1).
Version 1 checking was potentially happening in every hidpp_device_cmd()
call and not only when requested. Improve that to do version checking
and priv->version manipulation only when requested by using
HIDPP_REFRESH_FLAGS_VERSION.
When doing version checking first try v2 protocol command and if it
succeeds assume version 2 device. Otherwise try v1 protocol query
and if that successds assume version 1 device.
v2 devices in unreachable/sleep mode seem to do not respond to v2
queries but they respond to v1 queries! Still we want best protocol
possible. To do that we are rechecking version when current protocol
version is below 2 and we are doing up_device_unifying_refresh() and if
recheck succeeds we upgrade protocol to v2.
Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
There are Logitech Wireless devices similar to Unifying ones with the
difference that device is paired with single dongle and dongle doesn't
support pairing multiple devices.
Add support for these. Tested with Wireless Mouse M187 and M185/M225.
Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
Set proper vendor via udev rules for unifying devices and handle
that in code.
Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
udev v196 libraries changed behaviour of g_udev_device_get_sysfs_attr()
by stopping following symlinks for "device" attribute [1]. That change
broke hiddev finding for unifying devices. Fix that by getting sysfs
path from parent hiddev device.
1. http://cgit.freedesktop.org/systemd/systemd/commit/?id=5ae18ddc0d86673520c0dd6b59ccac8afc8aa605
Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>