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_ANDROID
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#include <android/native_window.h>
34#include <android/native_activity.h>
35#include <android_native_app_glue.h>
36#elif PLATFORM_DOLPHIN
37#include <gccore.h>
38#include <dirent.h>
39#include <sys/types.h>
40#include <sys/stat.h>
41#elif PLATFORM_3DS
42#include <3ds.h>
43#include <dirent.h>
44#include <sys/types.h>
45#include <sys/stat.h>
46#endif
47
48// Threading typedefs — the addon-provided header above is expected to
49// declare ThreadObject / MutexObject / ThreadFuncRet itself, so the arm
50// short-circuits this block too.
51#if defined(POLYPHASE_PLATFORM_ADDON)
52// Provided by Generated/PolyphasePlatform_SystemTypes.h above.
53#elif PLATFORM_WINDOWS
54typedef HANDLE ThreadObject;
55typedef HANDLE MutexObject;
56typedef DWORD ThreadFuncRet;
57#elif (PLATFORM_LINUX || PLATFORM_ANDROID)
58typedef pthread_t ThreadObject;
59typedef pthread_mutex_t MutexObject;
60typedef void* ThreadFuncRet;
61#elif PLATFORM_DOLPHIN
62typedef lwp_t ThreadObject;
63typedef mutex_t MutexObject;
64typedef void* ThreadFuncRet;
65#elif PLATFORM_3DS
66typedef Thread ThreadObject;
67typedef uint32_t MutexObject;
68typedef void ThreadFuncRet;
69#endif
70
71typedef ThreadFuncRet(*ThreadFuncFP)(void*);
72
73// THREAD_RETURN is `return;` if the platform's ThreadFuncRet is void, else `return 0;`.
74// Addon-provided platforms whose ThreadFuncRet is void should #define
75// POLYPHASE_PLATFORM_ADDON_VOID_THREAD_RETURN in their SystemTypes_Platform.h.
76#if PLATFORM_3DS || defined(POLYPHASE_PLATFORM_ADDON_VOID_THREAD_RETURN)
77#define THREAD_RETURN() return;
78#else
79#define THREAD_RETURN() return 0;
80#endif
81
82enum class ScreenOrientation : uint8_t
83{
86 Auto,
87
88 Count
89};
90
92{
94 char mFilename[MAX_PATH_SIZE + 1] = { };
95 bool mDirectory = false;
96 bool mValid = false;
97
98#if defined(POLYPHASE_PLATFORM_ADDON)
99 // Addon may inject members here via POLYPHASE_PLATFORM_ADDON_DIRENTRY_MEMBERS
100 // — e.g. `#define POLYPHASE_PLATFORM_ADDON_DIRENTRY_MEMBERS SceUID mDir;`
101 // in SystemTypes_Platform.h. Stays empty if the addon doesn't need any.
102#ifdef POLYPHASE_PLATFORM_ADDON_DIRENTRY_MEMBERS
103 POLYPHASE_PLATFORM_ADDON_DIRENTRY_MEMBERS
104#endif
105#elif PLATFORM_WINDOWS
106 WIN32_FIND_DATA mFindData = { };
107 HANDLE mFindHandle = nullptr;
108#elif (PLATFORM_LINUX || PLATFORM_ANDROID)
109 DIR* mDir = nullptr;
110#elif PLATFORM_DOLPHIN
111 DIR* mDir = nullptr;
112#elif PLATFORM_3DS
113 DIR* mDir = nullptr;
114#endif
115};
116
118{
119#if defined(POLYPHASE_PLATFORM_ADDON)
120 // Addon may inject members here via POLYPHASE_PLATFORM_ADDON_SYSTEMSTATE_MEMBERS
121 // — a single macro that expands to one or more `Type mName;` declarations.
122#ifdef POLYPHASE_PLATFORM_ADDON_SYSTEMSTATE_MEMBERS
123 POLYPHASE_PLATFORM_ADDON_SYSTEMSTATE_MEMBERS
124#endif
125#elif PLATFORM_WINDOWS
126 HINSTANCE mConnection = nullptr;
127 HWND mWindow = nullptr;
128 POINT mMinSize = {};
129 bool mWindowHasFocus = true;
130 bool mFullscreen = false;
131#elif PLATFORM_LINUX
132 xcb_connection_t* mXcbConnection = nullptr;
133 xcb_screen_t* mXcbScreen = nullptr;
134 xcb_window_t mXcbWindow = 0;
135 xcb_intern_atom_reply_t* mAtomDeleteWindow = nullptr;
136 xcb_cursor_t mNullCursor = XCB_NONE;
137 bool mWindowHasFocus = false;
138 bool mFullscreen = false;
139#elif PLATFORM_ANDROID
140 android_app* mState = nullptr;
141 ANativeWindow* mWindow = nullptr;
142 ANativeActivity* mActivity = nullptr;
143 //EGLDisplay mDisplay = ??? is this a pointer?;
144 //EGLSurface mSurface = ???;
145 //EGLContext mContext = ???;
146 std::string mInternalDataPath;
147 int32_t mWidth= 100;
148 int32_t mHeight = 100;
149 bool mWindowInitialized = false;
150 bool mWindowHasFocus = false;
151 bool mOrientationChanged = false;
154#elif PLATFORM_DOLPHIN
155 void* mFrameBuffers[2] = { };
156 void* mConsoleBuffer = nullptr;
157 GXRModeObj mGxRmode = { };
158 uint32_t mFrameIndex = 0;
159 void* mMemoryCardMountArea = nullptr;
160 bool mMemoryCardMounted = false;
161#elif PLATFORM_3DS
162 PrintConsole mPrintConsole = {};
163 float mSlider = 0.0f;
164 bool mNew3DS = false;
165#endif
166};
167
168enum class LogSeverity : uint32_t
169{
170 Debug,
171 Warning,
172 Error,
173
174 Count
175};
176
178{
179 std::string mName;
180 uint64_t mBytesFree = 0;
181 uint64_t mBytesAllocated = 0;
182};
#define MAX_PATH_SIZE
Definition Constants.h:8
ThreadFuncRet(* ThreadFuncFP)(void *)
Definition SystemTypes.h:71
LogSeverity
Definition SystemTypes.h:169
ScreenOrientation
Definition SystemTypes.h:83
Definition SystemTypes.h:92
bool mDirectory
Definition SystemTypes.h:95
bool mValid
Definition SystemTypes.h:96
char mFilename[MAX_PATH_SIZE+1]
Definition SystemTypes.h:94
char mDirectoryPath[MAX_PATH_SIZE+1]
Definition SystemTypes.h:93
Definition SystemTypes.h:178
uint64_t mBytesFree
Definition SystemTypes.h:180
std::string mName
Definition SystemTypes.h:179
uint64_t mBytesAllocated
Definition SystemTypes.h:181
Definition SystemTypes.h:118