UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AndroidEventManager.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Containers/Queue.h"
7#include "Templates/Atomic.h"
8
9#if USE_ANDROID_EVENTS
10
11struct ANativeWindow;
12
14
16{
36};
37
38struct FAppEventData
39{
40 FAppEventData() : WindowWidth(-1), WindowHeight(-1)
41 {}
42 FAppEventData(TFunction<void(void)> CallbackFuncIN) : WindowWidth(-1), WindowHeight(-1), CallbackFunc(MoveTemp(CallbackFuncIN))
43 {}
44
45
47
48 int32 WindowWidth;
49 int32 WindowHeight;
50
52};
53
54struct FAppEventPacket
55{
58
61 { }
62};
63
65{
66public:
67 static FAppEventManager* GetInstance();
68
69 void Tick();
72 // These are called directly from the android event thread.
75 bool IsGamePaused();
76 bool IsGameInFocus();
78
80 void TriggerEmptyQueue();
81
82 void SetAppIsActive(bool bIsActive);
83
84 void PauseAudio();
85 void ResumeAudio();
86 static void ReleaseMicrophone(bool shuttingDown);
87
88 // When the game thread is stalled by operations like switching to background,
89 // GameThreadTicker can be used to resume the game thread for 1 frame and
90 // stall it again in the subsequent frame.
91 // If a wait call is behind a GameThreadTicker object on another thread, the GT will
92 // be resumed until the wait returns and the life time of the object ends.
93 class GameThreadTicker
94 {
95 public:
96
97 GameThreadTicker()
98 {
99 FAppEventManager::GetInstance()->ResumePausedGameThread();
100 }
101
103 {
104 FAppEventManager::GetInstance()->KeepGameThreadPaused();
105 }
106 };
107
108 friend class GameThreadTicker;
109
110protected:
112
115
116private:
118
119 void ExecWindowCreated();
120 void ExecWindowResized();
121
122 static void OnScaleFactorChanged(IConsoleVariable* CVar);
123
125
126 pthread_mutex_t QueueMutex; //@todo android: can probably get rid of this now that we're using an mpsc queue
128
129 FEvent* EventHandlerEvent; // triggered every time the event handler thread fires off an event
130 FEvent* EmptyQueueHandlerEvent; // triggered every time the queue is emptied
131
132 //states
133 bool FirstInitialized;
134 bool bCreateWindow;
135
136 bool bWindowInFocus;
137 bool bSaveState;
138 bool bAudioPaused;
139
140 bool bHaveWindow;
141 bool bHaveGame;
143
144 TAtomic<bool> bTempRunningTriggered;// Flag to identify if the temporary running has been trigged so that APP_EVENT_STATE_APP_ACTIVATED will be only enqueued once.
145 TAtomic<bool> bAppIsActive; // Synced with bAppIsActive_EventThread in LaunchAndroid
146};
147
149
150#endif
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
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 DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
bool IsInAndroidEventThread()
Definition Event.h:21
Definition IConsoleManager.h:558
Definition Atomic.h:538
Definition AndroidPlatformMisc.h:14
Definition Queue.h:48
GeometryCollection::Facades::FMuscleActivationData Data
Definition MuscleActivationConstraints.h:15
State
Definition PacketHandler.h:88