UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GenericPlatformApplicationMisc.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "CoreTypes.h"
10#include "Math/Color.h"
11#include "Math/Vector2D.h"
14#include "Templates/Function.h"
15#include "Misc/EnumClassFlags.h"
16
22
27{
28 Unknown,
30 Truth
31};
32
42
52
53/*
54 * Options for ShowPlatformUserSelector. Not all platforms will support all flags
55 */
57{
58 None = 0,
59 RequiresOnlineEnabledProfile = (1 << 1), // whether to only show profiles that have an online account
60 ShowSkipButton = (1 << 2), // display a 'skip' button UI to be closed & return the initiating user
61 AllowGuests = (1 << 3), // temporary guest accounts, throwaways etc.
62 ShowNewUsersOnly = (1 << 4), // do not show profiles that are already in-use by the title
63
64 Default = ShowSkipButton, // most commonly used options
65};
67
68
70{
71 static APPLICATIONCORE_API void PreInit();
72
73 static APPLICATIONCORE_API void Init();
74
75 static APPLICATIONCORE_API void PostInit();
76
77 static APPLICATIONCORE_API void TearDown();
78
82 static void LoadPreInitModules()
83 {
84 }
85
89 static void LoadStartupModules()
90 {
91 }
92
97
102
107
112
117
120
123
128
133 inline static void PumpMessages(bool bFromMainLoop)
134 {
135 }
136
141 static void PreventScreenSaver()
142 {
143 }
144
150
158 {
159 return false;
160 }
161
169 {
170 return false;
171 }
172
181
192 {
193 return false;
194 }
195
199 static void SetHighDPIMode()
200 {
201
202 }
203
208 static float GetDPIScaleFactorAtPoint(float X, float Y)
209 {
210 return 1.0f;
211 }
212
213
217
218 /*
219 * UE expects mouse coordinates in screen space. Some platforms provides in client space.
220 * Return true to anchor the window at the top/left corner to make sure client space coordinates and screen space coordinates match up.
221 */
223 {
224 return false;
225 }
226
227 /*
228 * Set whether gamepads are allowed at the platform level.
229 */
230 static void SetGamepadsAllowed(bool bAllowed)
231 {}
232
233 /*
234 * Set whether gamepads are allowed at the platform level.
235 */
237 {}
238
239 /*
240 * Resets the gamepad to player controller id assignments
241 */
243 {}
244
245 /*
246 * Resets the gamepad assignment to player controller id
247 */
249 {}
250
251 /*
252 * Returns true if controller id assigned to a gamepad
253 */
254 static bool IsControllerAssignedToGamepad(int32 ControllerId)
255 {
256 return (ControllerId == 0);
257 }
258
259 /*
260 * Returns name of gamepad if controller id assigned to a gamepad
261 */
262 static FString GetGamepadControllerName(int32 ControllerId)
263 {
264 if (IsControllerAssignedToGamepad(ControllerId))
265 {
266 return FString(TEXT("Generic"));
267 }
268 return FString(TEXT("None"));
269 }
270
271 /*
272 * Returns a texture of the glyph representing the specified button on the specified controller, or nullptr if not supported.
273 */
275 {
276 return nullptr;
277 }
278
279 /*
280 * Whether to enable controller motion data polling (by default motion data is enabled)
281 * Some platforms may want to disable it to reduce battery drain
282 */
283 static void EnableMotionData(bool bEnable)
284 {}
285
286 /*
287 * Whether controller motion data polling is enabled (by default motion data is enabled)
288 */
290 {
291 return true;
292 }
293
295 static APPLICATIONCORE_API void ClipboardCopy(const TCHAR* Str);
296
298 static APPLICATIONCORE_API void ClipboardPaste(class FString& Dest);
299
304
306
308
313
315
316 static void ComputePhysicalScreenData();
317
322 template<typename T, typename T2 UE_REQUIRES(std::is_floating_point_v<T> && std::is_floating_point_v<T2>)>
324 {
327
328 if (ScreenDensity != 0)
329 {
330 OutPixels = static_cast<T2>(Inches * ScreenDensity);
331 }
332 else
333 {
334 OutPixels = 0;
335 }
336
337 return Accuracy;
338 }
339
344 template<typename T, typename T2 UE_REQUIRES(std::is_floating_point_v<T> && std::is_floating_point_v<T2>)>
346 {
349
350 if (ScreenDensity != 0)
351 {
352 OutInches = static_cast<T2>(Pixels / ScreenDensity);
353 }
354 else
355 {
356 OutInches = 0;
357 }
358
359 return Accuracy;
360 }
361
371 {
372 // no default implementation
373 return false;
374 }
375
390
391
392protected:
398
402
403};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
#define X(Name, Desc)
Definition FormatStringSan.h:47
EScreenPhysicalAccuracy
Definition GenericPlatformApplicationMisc.h:27
TFunction< void(const FShowInputDeviceSelectorParams &)> FShowInputDeviceSelectorComplete
Definition GenericPlatformApplicationMisc.h:41
EPlatformUserSelectorFlags
Definition GenericPlatformApplicationMisc.h:57
TFunction< void(const FPlatformUserSelectionCompleteParams &Params)> FPlatformUserSelectionComplete
Definition GenericPlatformApplicationMisc.h:51
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition IConsoleManager.h:1580
Definition FeedbackContext.h:30
Definition NameTypes.h:617
Definition OutputDeviceConsole.h:14
Definition OutputDeviceError.h:10
Definition GenericApplication.h:437
Definition GenericPlatformInputDeviceMapper.h:28
Definition AndroidPlatformMisc.h:14
Definition Texture2D.h:26
Definition GenericPlatformApplicationMisc.h:70
static APPLICATIONCORE_API void ClipboardPaste(class FString &Dest)
Definition GenericPlatformApplicationMisc.cpp:117
static void ResetGamepadAssignments()
Definition GenericPlatformApplicationMisc.h:242
static FString GetGamepadControllerName(int32 ControllerId)
Definition GenericPlatformApplicationMisc.h:262
static APPLICATIONCORE_API FFeedbackContext * GetFeedbackContext()
Definition GenericPlatformApplicationMisc.cpp:73
static APPLICATIONCORE_API int32 CachedPhysicalScreenDensity
Definition GenericPlatformApplicationMisc.h:395
static APPLICATIONCORE_API EScreenPhysicalAccuracy ComputePhysicalScreenDimensions(FVector2f &OutScreenDimensions, float &OutScreenSize)
Definition GenericPlatformApplicationMisc.cpp:143
static void LoadStartupModules()
Definition GenericPlatformApplicationMisc.h:89
static void SetHighDPIMode()
Definition GenericPlatformApplicationMisc.h:199
static APPLICATIONCORE_API void PreInit()
Definition GenericPlatformApplicationMisc.cpp:43
static bool GetWindowTitleMatchingText(const TCHAR *TitleStartsWith, FString &OutTitle)
Definition GenericPlatformApplicationMisc.h:191
static bool IsScreensaverEnabled()
Definition GenericPlatformApplicationMisc.h:157
static APPLICATIONCORE_API EScreenPhysicalAccuracy GetPhysicalScreenSize(float &OutScreenSize)
Definition GenericPlatformApplicationMisc.cpp:172
static APPLICATIONCORE_API void Init()
Definition GenericPlatformApplicationMisc.cpp:47
static bool IsControllerAssignedToGamepad(int32 ControllerId)
Definition GenericPlatformApplicationMisc.h:254
static bool IsMotionDataEnabled()
Definition GenericPlatformApplicationMisc.h:289
static APPLICATIONCORE_API FVector2f CachedPhysicalScreenDimensions
Definition GenericPlatformApplicationMisc.h:400
static APPLICATIONCORE_API FOutputDeviceConsole * CreateConsoleOutputDevice()
Definition GenericPlatformApplicationMisc.cpp:63
static class UTexture2D * GetGamepadButtonGlyph(const FGamepadKeyNames::Type &ButtonKey, uint32 ControllerIndex)
Definition GenericPlatformApplicationMisc.h:274
EScreenSaverAction
Definition GenericPlatformApplicationMisc.h:146
@ Enable
Definition GenericPlatformApplicationMisc.h:148
@ Disable
Definition GenericPlatformApplicationMisc.h:147
static APPLICATIONCORE_API EScreenPhysicalAccuracy GetPhysicalScreenDensity(int32 &OutScreenDensity)
Definition GenericPlatformApplicationMisc.cpp:150
static APPLICATIONCORE_API FAutoConsoleVariableRef CVarAllowVirtualKeyboard
Definition GenericPlatformApplicationMisc.h:397
static APPLICATIONCORE_API class GenericApplication * CreateApplication()
Definition GenericPlatformApplicationMisc.cpp:83
static bool ShowPlatformUserSelector(FInputDeviceId InitiatingInputDeviceId, EPlatformUserSelectorFlags Flags, FPlatformUserSelectionComplete OnUserSelectionComplete)
Definition GenericPlatformApplicationMisc.h:385
static APPLICATIONCORE_API EScreenPhysicalAccuracy CachedPhysicalScreenDimensionsAccuracy
Definition GenericPlatformApplicationMisc.h:399
static APPLICATIONCORE_API void ClipboardCopy(const TCHAR *Str)
Definition GenericPlatformApplicationMisc.cpp:113
static APPLICATIONCORE_API bool RequiresVirtualKeyboard()
Definition GenericPlatformApplicationMisc.cpp:98
static APPLICATIONCORE_API EScreenPhysicalAccuracy CachedPhysicalScreenAccuracy
Definition GenericPlatformApplicationMisc.h:394
static EScreenPhysicalAccuracy ConvertPixelsToInches(T Pixels, T2 &OutInches)
Definition GenericPlatformApplicationMisc.h:345
static APPLICATIONCORE_API struct FLinearColor GetScreenPixelColor(const FVector2D &InScreenPos, float InGamma=1.0f)
Definition GenericPlatformApplicationMisc.cpp:103
static APPLICATIONCORE_API float CachedPhysicalScreenSize
Definition GenericPlatformApplicationMisc.h:401
static APPLICATIONCORE_API FAutoConsoleVariableRef CVarEnableHighDPIAwareness
Definition GenericPlatformApplicationMisc.h:396
static APPLICATIONCORE_API bool IsThisApplicationForeground()
Definition GenericPlatformApplicationMisc.cpp:92
static APPLICATIONCORE_API EScreenPhysicalAccuracy ComputePhysicalScreenDensity(int32 &OutScreenDensity)
Definition GenericPlatformApplicationMisc.cpp:137
static void PreventScreenSaver()
Definition GenericPlatformApplicationMisc.h:141
static void SetGamepadsAllowed(bool bAllowed)
Definition GenericPlatformApplicationMisc.h:230
static APPLICATIONCORE_API bool IsHighDPIAwarenessEnabled()
Definition GenericPlatformApplicationMisc.cpp:108
static APPLICATIONCORE_API void PostInit()
Definition GenericPlatformApplicationMisc.cpp:53
static bool AnchorWindowWindowPositionTopLeft()
Definition GenericPlatformApplicationMisc.h:222
static APPLICATIONCORE_API EScreenPhysicalAccuracy GetPhysicalScreenDimensions(FVector2f &OutScreenDimensions)
Definition GenericPlatformApplicationMisc.cpp:161
static float GetDPIScaleFactorAtPoint(float X, float Y)
Definition GenericPlatformApplicationMisc.h:208
static bool ControlScreensaver(EScreenSaverAction Action)
Definition GenericPlatformApplicationMisc.h:168
static void ResetGamepadAssignmentToController(int32 ControllerId)
Definition GenericPlatformApplicationMisc.h:248
static APPLICATIONCORE_API IPlatformInputDeviceMapper * CreatePlatformInputDeviceManager()
Definition GenericPlatformApplicationMisc.cpp:78
static void LoadPreInitModules()
Definition GenericPlatformApplicationMisc.h:82
static void SetGamepadsBlockDeviceFeedback(bool bAllowed)
Definition GenericPlatformApplicationMisc.h:236
static APPLICATIONCORE_API void RequestMinimize()
Definition GenericPlatformApplicationMisc.cpp:88
static APPLICATIONCORE_API FOutputDeviceError * GetErrorOutputDevice()
Definition GenericPlatformApplicationMisc.cpp:68
static EScreenPhysicalAccuracy ConvertInchesToPixels(T Inches, T2 &OutPixels)
Definition GenericPlatformApplicationMisc.h:323
static APPLICATIONCORE_API bool CachedPhysicalScreenData
Definition GenericPlatformApplicationMisc.h:393
static void ComputePhysicalScreenData()
Definition GenericPlatformApplicationMisc.cpp:122
static void EnableMotionData(bool bEnable)
Definition GenericPlatformApplicationMisc.h:283
static APPLICATIONCORE_API void TearDown()
Definition GenericPlatformApplicationMisc.cpp:57
static void PumpMessages(bool bFromMainLoop)
Definition GenericPlatformApplicationMisc.h:133
static bool ShowInputDeviceSelector(FPlatformUserId InitiatingUserId, FShowInputDeviceSelectorComplete OnShowInputDeviceSelectorComplete)
Definition GenericPlatformApplicationMisc.h:370
Definition CoreMiscDefines.h:524
Definition Color.h:48
Definition CoreMiscDefines.h:470
Definition GenericPlatformApplicationMisc.h:47
FPlatformUserId SelectedUserId
Definition GenericPlatformApplicationMisc.h:48
bool bSuccess
Definition GenericPlatformApplicationMisc.h:49
Definition GenericPlatformApplicationMisc.h:37
FPlatformUserId PlatformUserId
Definition GenericPlatformApplicationMisc.h:39
FInputDeviceId InputDeviceId
Definition GenericPlatformApplicationMisc.h:38