todo: find battery level
This commit is contained in:
parent
2130555931
commit
18b70e6ced
1 changed files with 24 additions and 0 deletions
24
src/battery.c
Normal file
24
src/battery.c
Normal 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;
|
||||||
|
}
|
Loading…
Reference in a new issue