From 189e148829922bc235cb0f63bce43778d98a1a11 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 3 Apr 2024 14:06:18 +0200 Subject: [PATCH] minor changes --- includes/helper.h | 4 ++-- src/battery.c | 8 ++++---- src/main.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/helper.h b/includes/helper.h index b136156..2873bad 100644 --- a/includes/helper.h +++ b/includes/helper.h @@ -1,7 +1,7 @@ #pragma once -#define PID_WIRED 0x007A -#define PID_WIRELESS 0x007B +#define USB_DEVICE_ID_RAZER_VIPER_ULTIMATE_WIRED 0x007A +#define USB_DEVICE_ID_RAZER_VIPER_ULTIMATE_WIRELESS 0x007B // Enumerate through HID devices and find device path void find_device_path(int pid, char *device_path); diff --git a/src/battery.c b/src/battery.c index b965708..2d731bb 100644 --- a/src/battery.c +++ b/src/battery.c @@ -5,8 +5,8 @@ #include #include +#define RAZER_REPORT_LEN 0x5A #define RAZER_REPORT_ID_BATTERY 0x03 -#define RAZER_BATTERY_REPORT_SIZE 64 #define RAZER_BATTERY_LEVEL_INDEX 3 #define RAZER_CHARGING_STATUS_INDEX 4 @@ -26,14 +26,14 @@ int get_battery_level(const char *device_path, bool *is_charging) { return -1; } - unsigned char report[RAZER_BATTERY_REPORT_SIZE] = {0}; + unsigned char report[RAZER_REPORT_LEN] = {0}; DWORD bytesReturned; // Prepare the report to request battery information report[0] = RAZER_REPORT_ID_BATTERY; // Send the report - if (!HidD_SetFeature(hDevice, report, RAZER_BATTERY_REPORT_SIZE)) { + if (!HidD_SetFeature(hDevice, report, RAZER_REPORT_LEN)) { fprintf_s(stderr, "Failed to send report to device.\n"); CloseHandle(hDevice); @@ -41,7 +41,7 @@ int get_battery_level(const char *device_path, bool *is_charging) { } // Read the response - if (!HidD_GetFeature(hDevice, report, RAZER_BATTERY_REPORT_SIZE)) { + if (!HidD_GetFeature(hDevice, report, RAZER_REPORT_LEN)) { fprintf_s(stderr, "Failed to read report from device.\n"); CloseHandle(hDevice); diff --git a/src/main.c b/src/main.c index 1896904..6847971 100644 --- a/src/main.c +++ b/src/main.c @@ -8,11 +8,11 @@ int main(void) { char device_path[2048]; // Try wired - find_device_path(PID_WIRED, device_path); + find_device_path(USB_DEVICE_ID_RAZER_VIPER_ULTIMATE_WIRED, device_path); if (strlen(device_path) < 10) { // Try wireless - find_device_path(PID_WIRELESS, device_path); + 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");