Vеrsette
Vеrsette
Explore posts from servers
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
Attaching Interceptor to it with Module.findExportByName("hid.dll", 'HidD_GetFeature')
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
No description
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
I think I used ToastManager from Windows.UI.Notifications previously with success
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
I used a debugger and watched for calls to hidapi.dll (the library that the original program used)
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
I guess that's one way to do it)
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
You will need to read data from the original software and compare the values to see what changes in the mouse's response to indicate battery level, like I did here
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
What mouse are you using? There's no universal code for this, and my mouse is from a pretty small Chinese brand, so my code will for sure not work for yours
57 replies
CC#
Created by Vеrsette on 9/3/2023 in #help
✅ String search by user text input algorithm
Sometimes the simplest solutions are the best, I don't know how I didn't think of that but yes, why do I even need "fuzzy" search and I can just use Contains and keep the same order. Thank you all, solved <a:PI_HeartScribble:703853250264301609>
10 replies
CC#
Created by Vеrsette on 9/3/2023 in #help
✅ String search by user text input algorithm
Linear search as in just checking if x string is equal to the input one or not? That wouldn't work well since then it would only give exact matches
10 replies
CC#
Created by Vеrsette on 9/3/2023 in #help
✅ String search by user text input algorithm
Item names range from 5 characters to about 85
10 replies
CC#
Created by Vеrsette on 9/3/2023 in #help
✅ String search by user text input algorithm
Search speed is a priority since it's a mobile app. The dataset is ~150 items
10 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
Weird...
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
Maybe also try to close the device first before opening it again, I'm not quite sure if it can be "left open" somehow, but it might work
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
Are you on Linux or Windows? Does running your program as admin/superuser change anything?
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
Are you still getting the same data output from it? I have had an issue with there being different paths available for opening the same device after enumerating it And only one of those paths is the right one (at least in the case of my mouse)
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
For testing, I'm using https://github.com/mikeobrien/HidLibrary (that's why the function names are different, I had some issues with my hidapi wrapper that I am too lazy to fix for now), but I will switch back to hidapi after I get everything working and port to Avalonia UI for cross platform compatibility
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
I'm really sorry for not answering earlier, I didn't get a notification of your message... I sort of reverse engineered the original program, to be able to understand how it works and requests/sends data to and from the mouse. I found that the original program was using a pretty common HID library for communication, https://github.com/libusb/hidapi, and that the command and response byte arrays always were 65 bytes long (requirement of the mouse, I think). First I send the command with hid_send_feature_report, then I wait 70ms for the mouse to process everything and prepare a response (it's possible to use a lower value, but I found that it works best with about 70ms), and then I get the answer with hid_get_feature_report
private byte[] SendCommand(byte[] commandBytes)
{
if (commandBytes.Length != 65)
throw new ArgumentException("Wrong command length. Array has to be 65 bytes long.");

_hidMouseDevice.WriteFeatureData(commandBytes);
Thread.Sleep(70);
_hidMouseDevice.ReadFeatureData(out var result);

if (result == null || result.Length == 0)
throw new Exception("Received empty response. Likely wrong device or the mouse didn't respond.");
if (result[1] != 0xA1)
throw new Exception("Received empty response. Maybe transferring data too quickly...");

return result;
}
private byte[] SendCommand(byte[] commandBytes)
{
if (commandBytes.Length != 65)
throw new ArgumentException("Wrong command length. Array has to be 65 bytes long.");

_hidMouseDevice.WriteFeatureData(commandBytes);
Thread.Sleep(70);
_hidMouseDevice.ReadFeatureData(out var result);

if (result == null || result.Length == 0)
throw new Exception("Received empty response. Likely wrong device or the mouse didn't respond.");
if (result[1] != 0xA1)
throw new Exception("Received empty response. Maybe transferring data too quickly...");

return result;
}
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
I figured it out!
int batteryPercentage;
if (resultValue > 85)
batteryPercentage = (resultValue - 85) * 30 / 15 + 60;
else
batteryPercentage = resultValue * 60 / 85;
int batteryPercentage;
if (resultValue > 85)
batteryPercentage = (resultValue - 85) * 30 / 15 + 60;
else
batteryPercentage = resultValue * 60 / 85;
Not sure why they would do it like this, but I got many other questions about their software anyway... Thanks for trying to help, I also haven't expected it to be this weird
57 replies
CC#
Created by Vеrsette on 4/15/2023 in #help
❔ ✅ Trying to understand HID device response data
I was thinking the same... I will wait until it discharges until ~20%, get the data, and then charge and get the data of 100%
57 replies