From e9f72dbbbffbc6d12569a31bd9268ee81f15e10d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Perrier Date: Sat, 2 Jan 2021 13:15:15 +0100 Subject: [PATCH] Adding ACLineStatus enum. --- Source/Engine/Platform/BatteryInfo.h | 33 ++++++++++++++++++- .../Engine/Platform/Win32/Win32Platform.cpp | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Platform/BatteryInfo.h b/Source/Engine/Platform/BatteryInfo.h index c46bde59e..ba05d7992 100644 --- a/Source/Engine/Platform/BatteryInfo.h +++ b/Source/Engine/Platform/BatteryInfo.h @@ -4,13 +4,44 @@ #include "Engine/Core/Types/BaseTypes.h" +/// +/// Power supply status. +/// +API_ENUM() enum class ACLineStatus : byte +{ + /// + /// Power supply is not connected. + /// + Offline = 0, + /// + /// Power supply is connected. + /// + Online = 1, + /// + /// Unknown status. + /// + Unknown = 255 +}; + +/// +/// Contains information about power supply (Battery). +/// API_STRUCT() struct BatteryInfo { DECLARE_SCRIPTING_TYPE_MINIMAL(BatteryInfo); - API_FIELD() byte ACLineStatus; + /// + /// Power supply status. + /// + API_FIELD() ACLineStatus ACLineStatus; + /// + /// Battery percentage left. + /// API_FIELD() byte BatteryLifePercent; + /// + /// Remaining battery life time in second. + /// API_FIELD() uint32 BatteryLifeTime; }; diff --git a/Source/Engine/Platform/Win32/Win32Platform.cpp b/Source/Engine/Platform/Win32/Win32Platform.cpp index 317b6f232..ee73ffac2 100644 --- a/Source/Engine/Platform/Win32/Win32Platform.cpp +++ b/Source/Engine/Platform/Win32/Win32Platform.cpp @@ -315,7 +315,7 @@ BatteryInfo Win32Platform::GetBatteryInfo() BatteryInfo info; SYSTEM_POWER_STATUS status; GetSystemPowerStatus(&status); - info.ACLineStatus = status.ACLineStatus; + info.ACLineStatus = (ACLineStatus)status.ACLineStatus; info.BatteryLifePercent = status.BatteryLifePercent; info.BatteryLifeTime = status.BatteryLifeTime; return info;