better err msg

This commit is contained in:
Mylloon 2024-04-03 14:10:02 +02:00
parent 074c8ceb1d
commit afe6a93eb7
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -6,25 +6,28 @@
int main(void) {
char device_path[2048];
int min_len = 10;
// Try wired
find_device_path(USB_DEVICE_ID_RAZER_VIPER_ULTIMATE_WIRED, device_path);
if (strlen(device_path) < 10) {
if (strlen(device_path) < min_len) {
// Try wireless
find_device_path(USB_DEVICE_ID_RAZER_VIPER_ULTIMATE_WIRELESS, device_path);
if (strlen(device_path) < 10) {
fprintf_s(stderr, "Can't find any compatible device.\n");
if (strlen(device_path) < min_len) {
fprintf_s(stderr, "Can't find the Razer Viper Ultimate mouse.\n");
return 1;
}
}
printf("Device: %s\n", device_path);
printf("Mouse found: %s\n", device_path);
bool is_charging;
int battery_level;
if ((battery_level = get_battery_level(device_path, &is_charging)) < 0) {
fprintf_s(stderr, "Failed to get battery level.\n");
return 1;
}