From e98d481a63ca2af2652427319ca4fab1c91aca07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 12 Feb 2025 11:07:24 -0600 Subject: [PATCH] Add support for displaying the battery percentage on Windows. --- Windows/main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Windows/main.cpp b/Windows/main.cpp index c39066d126..1cd48783ec 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -339,6 +339,15 @@ int64_t System_GetPropertyInt(SystemProperty prop) { return KEYBOARD_LAYOUT_QWERTY; } } + case SYSPROP_BATTERY_PERCENTAGE: + { + SYSTEM_POWER_STATUS status{}; + if (GetSystemPowerStatus(&status)) { + return status.BatteryLifePercent < 255 ? status.BatteryLifePercent : 100; + } else { + return 100; + } + } default: return -1; } @@ -395,6 +404,8 @@ bool System_GetPropertyBool(SystemProperty prop) { return IsDebuggerPresent(); case SYSPROP_OK_BUTTON_LEFT: return true; + case SYSPROP_CAN_READ_BATTERY_PERCENTAGE: + return true; default: return false; }