andyvorld / LGSTrayBattery

A tray app used to track battery levels of wireless Logitech mouse.
GNU General Public License v3.0
393 stars 33 forks source link

G Pro X Superlight #18

Closed CKraft11 closed 2 years ago

CKraft11 commented 3 years ago

Here is the XML output from GHUB DevTools for the Logitech G Pro X Superlight. Currently it doesn't work and the data looks significantly different than that of other mice.

https://pastebin.com/SRSqgj9G

I also found that you can get the battery xml file simply from

C:\ProgramData\LGHUB\depots\84225\pro_x_wireless_mouse\battery\battery.xml

andyvorld commented 3 years ago

Try this powermodel, 46D_4093.zip

This is taken from the G Pro mice. As they both use a 3.8 nominal voltage battery pack. The difference is just in capacity and discharge time, which is not reported nor used. As battery percentage estimation comes from the nominal capacity left.

Further, I just compared the G Pro's power model to my G403's which both uses a 3.8 V nominal battery pack against each other with a normalised discharged capacity, image

It seems like they are within a margin of error until the last 5%.

CKraft11 commented 3 years ago

Sadly that still does not seem to work. I also tried removing the lighting section and changing the voltages under the block section to the ones my XML reported to no avail.

andyvorld commented 3 years ago

Could you make a copy of the xml file with the name 46D_C094.xml and try again? It seems like the mouse may have different variants on its serial number.

CKraft11 commented 3 years ago

Sorry for the late reply. I did check in device manager and my mouse seems to be the C094 version which is odd because the xml I got from ghub DevTools says it is 4093. I tried changing the filename and xml header to C094 and it still does not work.

andyvorld commented 3 years ago

I finally had time to look at the problem again. Is your problem that the program crashes on launch, or does it just give N/A for battery values.

I have attached a build with extra debugging, as a sanity check if you are still interested. From the looks of https://github.com/libratbag/piper/issues/624, it seems like your mouse isnt reporting the ability to show battery levels.

Could you please share the debug_trace.txt from running the program and leaving it for a 10 seconds, and the http webserver is also turned on, so could you please provide the list of devices from localhost:12321/devices

Debug.zip

andyvorld commented 3 years ago

After diving deeper into lghub_agent.exe I found out that it is indeed correct that Logitech has implemented a new method of querying battery charge.

If you are interested, currently I am looking for feature id 0x1000 (Battery Level Status) or 0x1001 (Battery Voltage). But from what I can see G Pro X has 0x1004 (Unified Battery).

I could try to copy how the Linux kernel interacts with the mouse (https://elixir.bootlin.com/linux/latest/source/drivers/hid/hid-logitech-hidpp.c#L1387, https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git/commit/?h=for-next&id=e037acf0b1aed31cb5f3b09ccb602b4768c133d5), but I would just be coding in the dark as I would have no hardware to test it with.

While https://github.com/andyvorld/LGSTrayBattery_GHUB did recently break due to some changes in the websocket api, I should have a new version pushed with the fixes soon. This program is more robust in the sense that the low level communications are handled by Logitech, rather than me directly interfacing with the devices.

CKraft11 commented 3 years ago

I finally had time to look at the problem again. Is your problem that the program crashes on launch, or does it just give N/A for battery values.

I have attached a build with extra debugging, as a sanity check if you are still interested. From the looks of libratbag/piper#624, it seems like your mouse isnt reporting the ability to show battery levels.

Could you please share the debug_trace.txt from running the program and leaving it for a 10 seconds, and the http webserver is also turned on, so could you please provide the list of devices from localhost:12321/devices

Debug.zip

Hopefully you can make something of this. There was multiple debug files created when I ran it and I also attached the xml readout from the local server. DebugGPX.zip

CKraft11 commented 3 years ago

After diving deeper into lghub_agent.exe I found out that it is indeed correct that Logitech has implemented a new method of querying battery charge.

If you are interested, currently I am looking for feature id 0x1000 (Battery Level Status) or 0x1001 (Battery Voltage). But from what I can see G Pro X has 0x1004 (Unified Battery).

I could try to copy how the Linux kernel interacts with the mouse (https://elixir.bootlin.com/linux/latest/source/drivers/hid/hid-logitech-hidpp.c#L1387, https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git/commit/?h=for-next&id=e037acf0b1aed31cb5f3b09ccb602b4768c133d5), but I would just be coding in the dark as I would have no hardware to test it with.

While https://github.com/andyvorld/LGSTrayBattery_GHUB did recently break due to some changes in the websocket api, I should have a new version pushed with the fixes soon. This program is more robust in the sense that the low level communications are handled by Logitech, rather than me directly interfacing with the devices.

How would I go about finding the 0x1000 or 0x1001 values?

andyvorld commented 3 years ago

Judging from debug_trace.txt, it does show that your mouse does not support 0x1000 or x1001 for battery values. These numbers are the featureID of Logitech's hid++ protocol, you can refer to them here https://drive.google.com/drive/u/0/folders/0BxbRzx7vEV7eWmgwazJ3NUFfQ28. The document only shows bit values of 0x1000.

The steps to properly get these values are, assuming you have found the correct HID device.

  1. Query 0x0000 IRoot for the existant of the featureID and featureIndex
  2. Query the featureIndex for the battery values
  3. Parse the return for voltage or capacity.
andyvorld commented 3 years ago

I forgot to mention that I managed to fix up the other tool, https://github.com/andyvorld/LGSTrayBattery_GHUB so you can try that first if you wish.

CKraft11 commented 3 years ago

I forgot to mention that I managed to fix up the other tool, https://github.com/andyvorld/LGSTrayBattery_GHUB so you can try that first if you wish.

Just downloaded the new build and it works!! One minor bug though is that although the percentages are correct in the server config and the icon shows the battery perfectly, when hovering over the icon it reads NaN%.

andyvorld commented 3 years ago

I should have it updated and hopefully fixed now.