cvuchener / hidpp

Collection of HID++ tools
GNU General Public License v3.0
90 stars 23 forks source link

Device fails when writing a profile with <=2 dpi modes and DPI index <=2 #8

Closed dslul closed 5 years ago

dslul commented 5 years ago

Hi, I encountered this strange problem when using the library, I replicated it using hidpp-persistent-profiles on a g402: make sure to have at least 3 or more dpi modes in your profile (and make a backup of the page, I managed to recover the mouse only this way) select the first (or second) dpi mode rewrite the profile and leave only the first two dpi modes (I used ./hidpp-persistent-profiles /dev/hidraw3 read > profile.xml, removed those modes, saved and then ./hidpp-persistent-profiles /dev/hidraw3 write profile.xml) Now the mouse behaves strangely, dpi index cannot be changed anymore (neither with IOnboardProfiles::setCurrentDPIIndex nor using the mouse buttons). If I try to write the previous xml profile and then read the profile again, this error appears:

terminate called after throwing an instance of 'std::range_error' what(): wstring_convert::to_bytes

The only way I found to restore the original behaviour is to write the page from a previous dump.

Does this also happen to you?

cvuchener commented 5 years ago

I only have a g502, the g402 was never tested. I'll test with mine later. In the meantime, could you give the output of the hidpp20-onboard-profiles-get-description command. The dumps for the good and faulty profiles could help too.

terminate called after throwing an instance of 'std::range_error' what(): wstring_convert::to_bytes

I should catch this one, but it simply mean the string data for the profile name is invalid. Not surprising given the other issues.

dslul commented 5 years ago

I understood what the problem was. "default_dpi" needs to be updated to an existing value (I had it set to 2 before, so with only two modes the mouse had problems because it couldn't find the third one), but I completely forgot to do it. Thanks for your help!

cvuchener commented 5 years ago

There is still the wstring_convert error to fix. It is not related to your dpi issue after all.

cvuchener commented 5 years ago

I pushed several fixes including catching the wstring_convert exception (ecdd5e9). I had to update a tinyxml2 method name in bafd6a6, if you weren't bothered by that, it means you were using an older version of tinyxml2, you may have to ignore this commit.