diff --git a/src/battery.c b/src/battery.c new file mode 100644 index 0000000..f4ec1d6 --- /dev/null +++ b/src/battery.c @@ -0,0 +1,24 @@ +#include "../includes/battery.h" + +#include + +#include +#include + +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; +}