Files
OpenVulkano/openVulkanoCpp/Host/SystemInfo.hpp
2024-12-20 16:46:13 +02:00

79 lines
2.5 KiB
C++

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "Base/Event.hpp"
#include <string>
namespace OpenVulkano
{
struct OsVersion
{
int major, minor, patch, build;
};
enum class DeviceType { Phone, Tablet, PC, TV, VR, Unknown };
enum class CpuThermalState { Normal, Fair, Serious, Critical };
enum class BatteryState { Unavailable, Unplugged, Charging, ChargingFull, NotCharging };
enum class DeviceOrientation { Portrait, PortraitUpsideDown, LandscapeLeft, LandscapeRight, FaceUp, FaceDown, Unknown };
enum class InterfaceOrientation { Portrait, PortraitUpsideDown, LandscapeLeft, LandscapeRight, Landscape = LandscapeLeft };
class SystemInfo
{
public:
static size_t GetSystemRam();
static size_t GetSystemRamAvailable();
static size_t GetAppRamMax();
static size_t GetAppVirtualMemoryMax();
static size_t GetAppRamAvailable();
static size_t GetAppRamUsed();
static const std::string& GetUserName();
static const std::string& GetHostName();
// Device name as given by the user
static const std::string& GetDeviceName();
static const std::string& GetDeviceVendorName();
static const std::string& GetDeviceModelName();
static const std::string& GetOsName();
static OsVersion GetOsVersion();
static const std::string& GetOsNameHumanReadable();
static DeviceType GetDeviceType();
static size_t GetCpuCoreCount();
static size_t GetCpuThreadCount();
static int32_t GetCpuTemperature();
static CpuThermalState GetCpuThermalState();
static bool IsDeviceInLowPowerMode();
static bool GetDeviceHasBattery() { return GetDeviceBatteryState() != BatteryState::Unavailable; }
static BatteryState GetDeviceBatteryState();
// 0 to 1; -1 not available
static float GetDeviceBatteryLevel();
static void EnableEnergyEvents();
/**
* Checks if device allows to run multiple applications at the same time.
* Will probably return true, for everything but smartphones.
* @return true if multiple applications can run at the same time, false if not
*/
static bool IsMultitaskingSupported();
static DeviceOrientation GetDeviceOrientation();
static void EnableDeviceOrientationEvents();
static InterfaceOrientation GetInterfaceOrientation();
static Event<> OnLowPowerModeChanged;
static Event<> OnBatteryStateChanged;
static Event<> OnBatteryLevelChanged;
static Event<> OnDeviceOrientationChanged;
};
}