Polyphase Game Engine
Loading...
Searching...
No Matches
SystemTypes.h
Go to the documentation of this file.
1#pragma once
2
3#include "Constants.h"
4#include "Maths.h"
5#include <string>
6
7// Variant 2 platform-extension arm. When an addon-provided build target sets
8// POLYPHASE_PLATFORM_ADDON, ActionManager has written a bridge header at
9// Generated/PolyphasePlatform_SystemTypes.h that forwards to the addon's own
10// SystemTypes_Platform.h. The addon's Makefile is expected to put Generated/
11// on the include path. This arm takes precedence over the PLATFORM_* arms
12// below so a build that sets BOTH (e.g. basePlatform=Linux + addon override)
13// resolves to the addon's typedefs rather than Linux's.
14#if defined(POLYPHASE_PLATFORM_ADDON)
15#include "PolyphasePlatform_SystemTypes.h"
16#elif PLATFORM_WINDOWS
17#include <Windows.h>
18#elif PLATFORM_LINUX
19#include <stdio.h>
20#include <dirent.h>
21#include <sys/types.h>
22#include <sys/stat.h>
23#include <unistd.h>
24#include <xcb/xcb.h>
25#include <pthread.h>
26#elif PLATFORM_MAC
27#include <stdio.h>
28#include <dirent.h>
29#include <sys/types.h>
30#include <sys/stat.h>
31#include <unistd.h>
32#include <pthread.h>
33#elif PLATFORM_ANDROID
34#include <stdio.h>
35#include <dirent.h>
36#include <sys/types.h>
37#include <sys/stat.h>
38#include <unistd.h>
39#include <pthread.h>
40#include <android/native_window.h>
41#include <android/native_activity.h>
42#include <android_native_app_glue.h>
43#elif PLATFORM_DOLPHIN
44#include <gccore.h>
45#include <dirent.h>
46#include <sys/types.h>
47#include <sys/stat.h>
48#elif PLATFORM_3DS
49#include <3ds.h>
50#include <dirent.h>
51#include <sys/types.h>
52#include <sys/stat.h>
53#endif
54
55// Threading typedefs — the addon-provided header above is expected to
56// declare ThreadObject / MutexObject / ThreadFuncRet itself, so the arm
57// short-circuits this block too.
58#if defined(POLYPHASE_PLATFORM_ADDON)
59// Provided by Generated/PolyphasePlatform_SystemTypes.h above.
60#elif PLATFORM_WINDOWS
61typedef HANDLE ThreadObject;
62typedef HANDLE MutexObject;
63typedef DWORD ThreadFuncRet;
64#elif (PLATFORM_LINUX || PLATFORM_ANDROID || PLATFORM_MAC)
65typedef pthread_t ThreadObject;
66typedef pthread_mutex_t MutexObject;
67typedef void* ThreadFuncRet;
68#elif PLATFORM_DOLPHIN
69typedef lwp_t ThreadObject;
70typedef mutex_t MutexObject;
71typedef void* ThreadFuncRet;
72#elif PLATFORM_3DS
73typedef Thread ThreadObject;
74typedef uint32_t MutexObject;
75typedef void ThreadFuncRet;
76#endif
77
78typedef ThreadFuncRet(*ThreadFuncFP)(void*);
79
80// THREAD_RETURN is `return;` if the platform's ThreadFuncRet is void, else `return 0;`.
81// Addon-provided platforms whose ThreadFuncRet is void should #define
82// POLYPHASE_PLATFORM_ADDON_VOID_THREAD_RETURN in their SystemTypes_Platform.h.
83#if PLATFORM_3DS || defined(POLYPHASE_PLATFORM_ADDON_VOID_THREAD_RETURN)
84#define THREAD_RETURN() return;
85#else
86#define THREAD_RETURN() return 0;
87#endif
88
89enum class ScreenOrientation : uint8_t
90{
93 Auto,
94
95 Count
96};
97
99{
101 char mFilename[MAX_PATH_SIZE + 1] = { };
102 bool mDirectory = false;
103 bool mValid = false;
104
105#if defined(POLYPHASE_PLATFORM_ADDON)
106 // Addon may inject members here via POLYPHASE_PLATFORM_ADDON_DIRENTRY_MEMBERS
107 // — e.g. `#define POLYPHASE_PLATFORM_ADDON_DIRENTRY_MEMBERS SceUID mDir;`
108 // in SystemTypes_Platform.h. Stays empty if the addon doesn't need any.
109#ifdef POLYPHASE_PLATFORM_ADDON_DIRENTRY_MEMBERS
110 POLYPHASE_PLATFORM_ADDON_DIRENTRY_MEMBERS
111#endif
112#elif PLATFORM_WINDOWS
113 WIN32_FIND_DATA mFindData = { };
114 HANDLE mFindHandle = nullptr;
115#elif (PLATFORM_LINUX || PLATFORM_ANDROID || PLATFORM_MAC)
116 DIR* mDir = nullptr;
117#elif PLATFORM_DOLPHIN
118 DIR* mDir = nullptr;
119#elif PLATFORM_3DS
120 DIR* mDir = nullptr;
121#endif
122};
123
125{
126#if defined(POLYPHASE_PLATFORM_ADDON)
127 // Addon may inject members here via POLYPHASE_PLATFORM_ADDON_SYSTEMSTATE_MEMBERS
128 // — a single macro that expands to one or more `Type mName;` declarations.
129#ifdef POLYPHASE_PLATFORM_ADDON_SYSTEMSTATE_MEMBERS
130 POLYPHASE_PLATFORM_ADDON_SYSTEMSTATE_MEMBERS
131#endif
132#elif PLATFORM_WINDOWS
133 HINSTANCE mConnection = nullptr;
134 HWND mWindow = nullptr;
135 POINT mMinSize = {};
136 bool mWindowHasFocus = true;
137 bool mFullscreen = false;
138#elif PLATFORM_LINUX
139 xcb_connection_t* mXcbConnection = nullptr;
140 xcb_screen_t* mXcbScreen = nullptr;
141 xcb_window_t mXcbWindow = 0;
142 xcb_intern_atom_reply_t* mAtomDeleteWindow = nullptr;
143 xcb_cursor_t mNullCursor = XCB_NONE;
144 bool mWindowHasFocus = false;
145 bool mFullscreen = false;
146#elif PLATFORM_MAC
147 // Opaque so this header stays ObjC-free; System_Mac.mm bridge-casts them
148 // (NSWindow*, NSView*, CAMetalLayer*).
149 void* mNsWindow = nullptr;
150 void* mNsView = nullptr;
151 void* mMetalLayer = nullptr;
152 float mBackingScale = 1.0f;
153 bool mWindowHasFocus = false;
154 bool mFullscreen = false;
155#elif PLATFORM_ANDROID
156 android_app* mState = nullptr;
157 ANativeWindow* mWindow = nullptr;
158 ANativeActivity* mActivity = nullptr;
159 //EGLDisplay mDisplay = ??? is this a pointer?;
160 //EGLSurface mSurface = ???;
161 //EGLContext mContext = ???;
162 std::string mInternalDataPath;
163 int32_t mWidth= 100;
164 int32_t mHeight = 100;
165 bool mWindowInitialized = false;
166 bool mWindowHasFocus = false;
167 bool mOrientationChanged = false;
170#elif PLATFORM_DOLPHIN
171 void* mFrameBuffers[2] = { };
172 void* mConsoleBuffer = nullptr;
173 GXRModeObj mGxRmode = { };
174 uint32_t mFrameIndex = 0;
175 void* mMemoryCardMountArea = nullptr;
176 bool mMemoryCardMounted = false;
177#elif PLATFORM_3DS
178 PrintConsole mPrintConsole = {};
179 float mSlider = 0.0f;
180 bool mNew3DS = false;
181#endif
182};
183
184enum class LogSeverity : uint32_t
185{
186 Debug,
187 Warning,
188 Error,
189
190 Count
191};
192
194{
195 std::string mName;
196 uint64_t mBytesFree = 0;
197 uint64_t mBytesAllocated = 0;
198};
#define MAX_PATH_SIZE
Definition Constants.h:8
ThreadFuncRet(* ThreadFuncFP)(void *)
Definition SystemTypes.h:78
LogSeverity
Definition SystemTypes.h:185
ScreenOrientation
Definition SystemTypes.h:90
Definition SystemTypes.h:99
bool mDirectory
Definition SystemTypes.h:102
bool mValid
Definition SystemTypes.h:103
char mFilename[MAX_PATH_SIZE+1]
Definition SystemTypes.h:101
char mDirectoryPath[MAX_PATH_SIZE+1]
Definition SystemTypes.h:100
Definition SystemTypes.h:194
uint64_t mBytesFree
Definition SystemTypes.h:196
std::string mName
Definition SystemTypes.h:195
uint64_t mBytesAllocated
Definition SystemTypes.h:197
Definition SystemTypes.h:125