minor changes

This commit is contained in:
Mylloon 2024-04-03 14:06:18 +02:00
parent fde1e7ccc7
commit 189e148829
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 8 additions and 8 deletions

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#define PID_WIRED 0x007A #define USB_DEVICE_ID_RAZER_VIPER_ULTIMATE_WIRED 0x007A
#define PID_WIRELESS 0x007B #define USB_DEVICE_ID_RAZER_VIPER_ULTIMATE_WIRELESS 0x007B
// Enumerate through HID devices and find device path // Enumerate through HID devices and find device path
void find_device_path(int pid, char *device_path); void find_device_path(int pid, char *device_path);

View file

@ -5,8 +5,8 @@
#include <hidsdi.h> #include <hidsdi.h>
#include <stdio.h> #include <stdio.h>
#define RAZER_REPORT_LEN 0x5A
#define RAZER_REPORT_ID_BATTERY 0x03 #define RAZER_REPORT_ID_BATTERY 0x03
#define RAZER_BATTERY_REPORT_SIZE 64
#define RAZER_BATTERY_LEVEL_INDEX 3 #define RAZER_BATTERY_LEVEL_INDEX 3
#define RAZER_CHARGING_STATUS_INDEX 4 #define RAZER_CHARGING_STATUS_INDEX 4
@ -26,14 +26,14 @@ int get_battery_level(const char *device_path, bool *is_charging) {
return -1; return -1;
} }
unsigned char report[RAZER_BATTERY_REPORT_SIZE] = {0}; unsigned char report[RAZER_REPORT_LEN] = {0};
DWORD bytesReturned; DWORD bytesReturned;
// Prepare the report to request battery information // Prepare the report to request battery information
report[0] = RAZER_REPORT_ID_BATTERY; report[0] = RAZER_REPORT_ID_BATTERY;
// Send the report // 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"); fprintf_s(stderr, "Failed to send report to device.\n");
CloseHandle(hDevice); CloseHandle(hDevice);
@ -41,7 +41,7 @@ int get_battery_level(const char *device_path, bool *is_charging) {
} }
// Read the response // 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"); fprintf_s(stderr, "Failed to read report from device.\n");
CloseHandle(hDevice); CloseHandle(hDevice);

View file

@ -8,11 +8,11 @@ int main(void) {
char device_path[2048]; char device_path[2048];
// Try wired // 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) { if (strlen(device_path) < 10) {
// Try wireless // 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) { if (strlen(device_path) < 10) {
fprintf_s(stderr, "Can't find any compatible device.\n"); fprintf_s(stderr, "Can't find any compatible device.\n");