Move Win32 GetBatteryInfo into Windows and UWP platforms impl
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "Engine/Engine/Engine.h"
|
||||
#include "Engine/Platform/MessageBox.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Platform/BatteryInfo.h"
|
||||
#include "Engine/Input/Input.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "UWPWindow.h"
|
||||
@@ -114,6 +115,21 @@ void UWPPlatform::Exit()
|
||||
Win32Platform::Exit();
|
||||
}
|
||||
|
||||
BatteryInfo UWPPlatform::GetBatteryInfo()
|
||||
{
|
||||
BatteryInfo info;
|
||||
SYSTEM_POWER_STATUS status;
|
||||
GetSystemPowerStatus(&status);
|
||||
info.BatteryLifePercent = (float)status.BatteryLifePercent / 255.0f;
|
||||
if (status.BatteryFlag & 8)
|
||||
info.State = BatteryInfo::States::BatteryCharging;
|
||||
else if (status.BatteryFlag & 1 || status.BatteryFlag & 2 || status.BatteryFlag & 4)
|
||||
info.State = BatteryInfo::States::BatteryDischarging;
|
||||
else if (status.ACLineStatus == 1 || status.BatteryFlag & 128)
|
||||
info.State = BatteryInfo::States::Connected;
|
||||
return info;
|
||||
}
|
||||
|
||||
int32 UWPPlatform::GetDpi()
|
||||
{
|
||||
return SystemDpi;
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
static void Tick();
|
||||
static void BeforeExit();
|
||||
static void Exit();
|
||||
static BatteryInfo GetBatteryInfo();
|
||||
static int32 GetDpi();
|
||||
static String GetUserLocaleName();
|
||||
static String GetComputerName();
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "Engine/Platform/Platform.h"
|
||||
#include "Engine/Platform/MemoryStats.h"
|
||||
#include "Engine/Platform/CPUInfo.h"
|
||||
#include "Engine/Platform/BatteryInfo.h"
|
||||
#include "Engine/Core/Types/Guid.h"
|
||||
#include "Engine/Core/Types/String.h"
|
||||
#include "Engine/Core/Math/Math.h"
|
||||
@@ -341,21 +340,6 @@ bool Win32Platform::Is64BitPlatform()
|
||||
#endif
|
||||
}
|
||||
|
||||
BatteryInfo Win32Platform::GetBatteryInfo()
|
||||
{
|
||||
BatteryInfo info;
|
||||
SYSTEM_POWER_STATUS status;
|
||||
GetSystemPowerStatus(&status);
|
||||
info.BatteryLifePercent = (float)status.BatteryLifePercent / 255.0f;
|
||||
if (status.BatteryFlag & 8)
|
||||
info.State = BatteryInfo::States::BatteryCharging;
|
||||
else if (status.BatteryFlag & 1 || status.BatteryFlag & 2 || status.BatteryFlag & 4)
|
||||
info.State = BatteryInfo::States::BatteryDischarging;
|
||||
else if (status.ACLineStatus == 1 || status.BatteryFlag & 128)
|
||||
info.State = BatteryInfo::States::Connected;
|
||||
return info;
|
||||
}
|
||||
|
||||
CPUInfo Win32Platform::GetCPUInfo()
|
||||
{
|
||||
return CpuInfo;
|
||||
|
||||
@@ -33,7 +33,6 @@ public:
|
||||
static void* AllocatePages(uint64 numPages, uint64 pageSize);
|
||||
static void FreePages(void* ptr);
|
||||
static bool Is64BitPlatform();
|
||||
static BatteryInfo GetBatteryInfo();
|
||||
static CPUInfo GetCPUInfo();
|
||||
static int32 GetCacheLineSize();
|
||||
static MemoryStats GetMemoryStats();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Engine/Platform/CreateWindowSettings.h"
|
||||
#include "Engine/Platform/WindowsManager.h"
|
||||
#include "Engine/Platform/MemoryStats.h"
|
||||
#include "Engine/Platform/BatteryInfo.h"
|
||||
#include "Engine/Engine/Globals.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Collections/Dictionary.h"
|
||||
@@ -680,6 +681,21 @@ void WindowsPlatform::SetHighDpiAwarenessEnabled(bool enable)
|
||||
FreeLibrary(shCoreDll);
|
||||
}
|
||||
|
||||
BatteryInfo WindowsPlatform::GetBatteryInfo()
|
||||
{
|
||||
BatteryInfo info;
|
||||
SYSTEM_POWER_STATUS status;
|
||||
GetSystemPowerStatus(&status);
|
||||
info.BatteryLifePercent = (float)status.BatteryLifePercent / 255.0f;
|
||||
if (status.BatteryFlag & 8)
|
||||
info.State = BatteryInfo::States::BatteryCharging;
|
||||
else if (status.BatteryFlag & 1 || status.BatteryFlag & 2 || status.BatteryFlag & 4)
|
||||
info.State = BatteryInfo::States::BatteryDischarging;
|
||||
else if (status.ACLineStatus == 1 || status.BatteryFlag & 128)
|
||||
info.State = BatteryInfo::States::Connected;
|
||||
return info;
|
||||
}
|
||||
|
||||
int32 WindowsPlatform::GetDpi()
|
||||
{
|
||||
return SystemDpi;
|
||||
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
static bool IsDebuggerPresent();
|
||||
#endif
|
||||
static void SetHighDpiAwarenessEnabled(bool enable);
|
||||
static BatteryInfo GetBatteryInfo();
|
||||
static int32 GetDpi();
|
||||
static String GetUserLocaleName();
|
||||
static String GetComputerName();
|
||||
|
||||
Reference in New Issue
Block a user