Supporting Battery Strength from my Bluetooth Mouse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My Bluetooth mouse (HP branded, but some generic Taiwanese innards)
supports reporting its battery level.

The data appears in its HID descriptor as:

  INPUT(3)[INPUT]
    Field(0)
      Usage(1)
        0006.0020
      Logical Minimum(0)
      Logical Maximum(255)
      Report Size(8)
      Report Count(1)
      Report Offset(0)
      Flags( Variable Absolute )

which is consistent with the USB HID Usage Tables 1.12 spec, which lists
Usage Page 6 as Generic Device Controls and Usage ID 0x20 as Battery
Strength.  I'm assuming that this is commonplace on battery-powered
mice, but I only have one to check.

I've written an (untested) patch to display this correctly in debugfs.
(below)

My real question is how to get this out to somewhere useful, where
(ultimately) some GUI could show the battery information if its available?

Is the next step to define a new ABS_BATTERY_STRENGTH type for it (and
likewise for the other values, though I have no idea what the Security
stuff is about)?  Then at least it will appear in evdev in a useful way,
and becomes usermode's problem to deal with it.

(Hm, and I wonder what makes the mouse actually report the battery
level; I guess I'll only ever see a report if it actually changes.)

Any guidance?

Thanks,
    J

Subject: [PATCH] hid: decode Generic Device Controls Usage Page

The USB HID Usage Tables spec defines page 6 for Generic Device
Controls, the most useful of which (to me) is Battery Strength.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xxxxxxxx>

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index ee80d73..01dd9a7 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -114,6 +114,14 @@ static const struct hid_usage_entry hid_usage_table[] = {
       {0, 0xbd, "FlareRelease"},
       {0, 0xbe, "LandingGear"},
       {0, 0xbf, "ToeBrake"},
+  {  6, 0, "GenericDeviceControls" },
+      {0, 0x20, "BatteryStrength" },
+      {0, 0x21, "WirelessChannel" },
+      {0, 0x22, "WirelessID" },
+      {0, 0x23, "DiscoverWirelessControl" },
+      {0, 0x24, "SecurityCodeCharacterEntered" },
+      {0, 0x25, "SecurityCodeCharactedErased" },
+      {0, 0x26, "SecurityCodeCleared" },
   {  7, 0, "Keyboard" },
   {  8, 0, "LED" },
       {0, 0x01, "NumLock"},


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux