todo: find battery level

This commit is contained in:
Mylloon 2024-04-03 13:49:31 +02:00
parent 2130555931
commit 18b70e6ced
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

24
src/battery.c Normal file
View file

@ -0,0 +1,24 @@
#include "../includes/battery.h"
#include <windows.h>
#include <hidsdi.h>
#include <stdio.h>
int get_battery_level(const char *device_path, bool *is_charging) {
HANDLE hDevice =
CreateFile(device_path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);
if (hDevice == INVALID_HANDLE_VALUE) {
fprintf_s(stderr, "Failed to open device.\n");
return -1;
}
int batteryLevel;
// TODO
CloseHandle(hDevice);
return batteryLevel;
}