minor changes
This commit is contained in:
parent
fde1e7ccc7
commit
189e148829
3 changed files with 8 additions and 8 deletions
|
@ -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);
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include <hidsdi.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#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);
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue