Merge branch 'jb-perrier-batteryinfo'
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "Engine/Engine/CommandLine.h"
|
||||
#include "Engine/Engine/Engine.h"
|
||||
#include "Engine/Utilities/StringConverter.h"
|
||||
#include "Engine/Platform/BatteryInfo.h"
|
||||
#include <iostream>
|
||||
|
||||
// Check types sizes
|
||||
@@ -381,6 +382,11 @@ void PlatformBase::SetHighDpiAwarenessEnabled(bool enable)
|
||||
{
|
||||
}
|
||||
|
||||
BatteryInfo PlatformBase::GetBatteryInfo()
|
||||
{
|
||||
return BatteryInfo();
|
||||
}
|
||||
|
||||
int32 PlatformBase::GetDpi()
|
||||
{
|
||||
return 96;
|
||||
|
||||
@@ -11,6 +11,7 @@ struct CPUInfo;
|
||||
struct MemoryStats;
|
||||
struct ProcessMemoryStats;
|
||||
struct CreateWindowSettings;
|
||||
struct BatteryInfo;
|
||||
|
||||
// ReSharper disable CppFunctionIsNotImplemented
|
||||
|
||||
@@ -548,6 +549,11 @@ public:
|
||||
/// </summary>
|
||||
static void SetHighDpiAwarenessEnabled(bool enable);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the battery information.
|
||||
/// </summary>
|
||||
API_PROPERTY() static BatteryInfo GetBatteryInfo();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the screen DPI setting.
|
||||
/// </summary>
|
||||
|
||||
47
Source/Engine/Platform/BatteryInfo.h
Normal file
47
Source/Engine/Platform/BatteryInfo.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Core/Types/BaseTypes.h"
|
||||
|
||||
/// <summary>
|
||||
/// Power supply status.
|
||||
/// </summary>
|
||||
API_ENUM() enum class ACLineStatus : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Power supply is not connected.
|
||||
/// </summary>
|
||||
Offline = 0,
|
||||
/// <summary>
|
||||
/// Power supply is connected.
|
||||
/// </summary>
|
||||
Online = 1,
|
||||
/// <summary>
|
||||
/// Unknown status.
|
||||
/// </summary>
|
||||
Unknown = 255
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Contains information about power supply (Battery).
|
||||
/// </summary>
|
||||
API_STRUCT() struct BatteryInfo
|
||||
{
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(BatteryInfo);
|
||||
|
||||
/// <summary>
|
||||
/// Power supply status.
|
||||
/// </summary>
|
||||
API_FIELD() ACLineStatus ACLineStatus;
|
||||
|
||||
/// <summary>
|
||||
/// Battery percentage left.
|
||||
/// </summary>
|
||||
API_FIELD() byte BatteryLifePercent;
|
||||
|
||||
/// <summary>
|
||||
/// Remaining battery life time in second.
|
||||
/// </summary>
|
||||
API_FIELD() uint32 BatteryLifeTime;
|
||||
};
|
||||
@@ -5,6 +5,7 @@
|
||||
#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"
|
||||
@@ -15,6 +16,7 @@
|
||||
#include <WinSock2.h>
|
||||
#include <IPHlpApi.h>
|
||||
#include <oleauto.h>
|
||||
#include <WinBase.h>
|
||||
#pragma comment(lib, "Iphlpapi.lib")
|
||||
|
||||
namespace
|
||||
@@ -308,6 +310,17 @@ bool Win32Platform::Is64BitPlatform()
|
||||
#endif
|
||||
}
|
||||
|
||||
BatteryInfo Win32Platform::GetBatteryInfo()
|
||||
{
|
||||
BatteryInfo info;
|
||||
SYSTEM_POWER_STATUS status;
|
||||
GetSystemPowerStatus(&status);
|
||||
info.ACLineStatus = (ACLineStatus)status.ACLineStatus;
|
||||
info.BatteryLifePercent = status.BatteryLifePercent;
|
||||
info.BatteryLifeTime = status.BatteryLifeTime;
|
||||
return info;
|
||||
}
|
||||
|
||||
CPUInfo Win32Platform::GetCPUInfo()
|
||||
{
|
||||
return CpuInfo;
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
_aligned_free(ptr);
|
||||
}
|
||||
static bool Is64BitPlatform();
|
||||
static BatteryInfo GetBatteryInfo();
|
||||
static CPUInfo GetCPUInfo();
|
||||
static int32 GetCacheLineSize();
|
||||
static MemoryStats GetMemoryStats();
|
||||
|
||||
Reference in New Issue
Block a user