On Fri, Feb 05, 2021 at 10:36:34AM +0100, Landry Breuil wrote:
> On Fri, Jan 22, 2021 at 08:18:51AM +0100, Anton Lindqvist wrote:
> > Hi,
> > Here's a new driver for Logitech HID++ devices, currently limited to
> > exposing battery sensors. Here's an example using a Logitech M330 mouse:
> > 
> >     $ dmesg | grep uhidpp
> >     uhidpp0 at uhidev1 device 1 mouse "B330/M330/M3" serial c7-2f-a8-33
> >     $ sysctl hw.sensors.uhidpp0
> >     hw.sensors.uhidpp0.raw0=2 (battery levels)
> >     hw.sensors.uhidpp0.percent0=70.00% (battery level), OK
> 
> thanks anton, now that this got commited i realize i have a pair of
> devices:
> 
> device 1 (M235 according to bottom) previously reported this in dmesg:
> 
> uhidev0 at uhub0 port 2 configuration 1 interface 0 "Logitech USB Receiver" 
> rev 2.00/12.03 addr 2
> uhidev0: iclass 3/1
> ukbd0 at uhidev0: 8 variable keys, 6 key codes
> wskbd1 at ukbd0 mux 1
> uhidev1 at uhub0 port 2 configuration 1 interface 1 "Logitech USB Receiver" 
> rev 2.00/12.03 addr 2
> uhidev1: iclass 3/1, 8 report ids
> ums0 at uhidev1 reportid 2: 16 buttons, Z and W dir
> wsmouse2 at ums0 mux 0
> uhid0 at uhidev1 reportid 3: input=4, output=0, feature=0
> uhid1 at uhidev1 reportid 4: input=1, output=0, feature=0
> uhid2 at uhidev1 reportid 8: input=1, output=0, feature=0
> uhidev2 at uhub0 port 2 configuration 1 interface 2 "Logitech USB Receiver" 
> rev 2.00/12.03 addr 2
> uhidev2: iclass 3/0, 33 report ids
> uhid3 at uhidev2 reportid 16: input=6, output=6, feature=0
> uhid4 at uhidev2 reportid 17: input=19, output=19, feature=0
> uhid5 at uhidev2 reportid 32: input=14, output=14, feature=0
> uhid6 at uhidev2 reportid 33: input=31, output=31, feature=0
> 
> device 2 (M235 2nd gen according to bottom) previously reported this in dmesg
> (same thing, but the rev/addr values):
> 
> uhidev1 at uhub0 port 4 configuration 1 interface 0 "Logitech USB Receiver" 
> rev 2.00/24.07 addr 3
> uhidev1: iclass 3/1
> ukbd1 at uhidev1: 8 variable keys, 6 key codes
> wskbd2 at ukbd1 mux 1
> uhidev2 at uhub0 port 4 configuration 1 interface 1 "Logitech USB Receiver" 
> rev 2.00/24.07 addr 3
> uhidev2: iclass 3/1, 8 report ids
> ums0 at uhidev2 reportid 2: 16 buttons, Z and W dir
> wsmouse2 at ums0 mux 0
> uhid0 at uhidev2 reportid 3: input=4, output=0, feature=0
> uhid1 at uhidev2 reportid 4: input=1, output=0, feature=0
> uhid2 at uhidev2 reportid 8: input=1, output=0, feature=0
> uhidev3 at uhub0 port 4 configuration 1 interface 2 "Logitech USB Receiver" 
> rev 2.00/24.07 addr 3
> uhidev3: iclass 3/0, 33 report ids
> uhid3 at uhidev3 reportid 16: input=6, output=6, feature=0
> uhid4 at uhidev3 reportid 17: input=19, output=19, feature=0
> uhid5 at uhidev3 reportid 32: input=14, output=14, feature=0
> uhid6 at uhidev3 reportid 33: input=31, output=31, feature=0
> 
> now device 1/uhidev2 is properly identified by uhidpp:
> 
> uhidev2 at uhub0 port 2 configuration 1 interface 2 "Logitech USB Receiver" 
> rev 2.00/12.03 addr 2
> uhidev2: iclass 3/0, 33 report ids
> uhidpp0 at uhidev2 device 1 mouse "M325" serial 69-b1-af-84
> 
> and properly reports sensors:
> hw.sensors.uhidpp0.raw0=2 (battery levels)
> hw.sensors.uhidpp0.percent0=70.00% (battery level), OK
> 
> and device2 (plugged on the same laptop so device renumbered) also works with 
> uhidpp:
> 
> uhidev2 at uhub0 port 2 configuration 1 interface 2 "Logitech USB Receiver" 
> rev 2.00/24.07 addr 2
> uhidev2: iclass 3/0, 33 report ids
> uhidpp0 at uhidev2 device 1 mouse "Wireless Mouse" serial f3-94-18-8c
> 
> same level reported in sensors for a different mouse (?):
> hw.sensors.uhidpp0.raw0=2 (battery levels)
> hw.sensors.uhidpp0.percent0=70.00% (battery level), OK
> 
> let me know if you need more details/infos from those devices (usbdevs dumps 
> etc..)

As both your devices only are capable of reporting two battery levels,
as given by hw.sensors.uhidpp0.raw0, it's quite likely that they will
report the same level.

> i'll eventually look at adding support for uhidpp to upower so mouse battery
> levels can be reported in xfce4-power-manager and gnome, like it does on
> linux..

There has been some work on this from a Linux perspective[1], not sure
if there's anything you could piggy back on there. Let me know if any
more data needs to be expsoed in order to satisfy upower.

[1] https://julien.danjou.info/logitech-unifying-upower/

Reply via email to