2020-10-04 08:30:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <functional>
|
2023-04-09 20:47:34 +00:00
|
|
|
#include <cstdint>
|
2023-06-20 12:40:46 +00:00
|
|
|
#include <mutex>
|
2020-10-04 08:30:18 +00:00
|
|
|
|
2023-03-21 09:42:23 +00:00
|
|
|
// Platform integration
|
|
|
|
|
2023-03-26 00:47:25 +00:00
|
|
|
// To run the PPSSPP core, a platform needs to implement all the System_ functions in this file.
|
2023-03-21 09:42:23 +00:00
|
|
|
// Failure to implement all of these will simply cause linker failures. There are a few that are
|
|
|
|
// only implemented on specific platforms, but they're also only called on those platforms.
|
|
|
|
|
|
|
|
// The platform then calls the entry points from NativeApp.h as appropriate. That's basically it,
|
|
|
|
// disregarding build system complexities.
|
|
|
|
|
2020-10-04 08:30:18 +00:00
|
|
|
enum SystemPermission {
|
|
|
|
SYSTEM_PERMISSION_STORAGE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum PermissionStatus {
|
|
|
|
PERMISSION_STATUS_UNKNOWN,
|
|
|
|
PERMISSION_STATUS_DENIED,
|
|
|
|
PERMISSION_STATUS_PENDING,
|
|
|
|
PERMISSION_STATUS_GRANTED,
|
|
|
|
};
|
|
|
|
|
|
|
|
// These APIs must be implemented by every port (for example app-android.cpp, SDLMain.cpp).
|
|
|
|
// Ideally these should be safe to call from any thread.
|
2022-07-10 20:34:44 +00:00
|
|
|
void System_Toast(const char *text);
|
2023-03-21 09:42:23 +00:00
|
|
|
void System_ShowKeyboard();
|
2020-10-04 08:30:18 +00:00
|
|
|
|
|
|
|
// Vibrate either takes a number of milliseconds to vibrate unconditionally,
|
|
|
|
// or you can specify these constants for "standard" feedback. On Android,
|
|
|
|
// these will only be performed if haptic feedback is enabled globally.
|
|
|
|
// Also, on Android, these will work even if you don't have the VIBRATE permission,
|
|
|
|
// while generic vibration will not if you don't have it.
|
|
|
|
enum {
|
|
|
|
HAPTIC_SOFT_KEYBOARD = -1,
|
|
|
|
HAPTIC_VIRTUAL_KEY = -2,
|
|
|
|
HAPTIC_LONG_PRESS_ACTIVATED = -3,
|
|
|
|
};
|
2023-03-21 09:42:23 +00:00
|
|
|
|
|
|
|
enum class LaunchUrlType {
|
|
|
|
BROWSER_URL,
|
|
|
|
MARKET_URL,
|
|
|
|
EMAIL_ADDRESS,
|
|
|
|
};
|
|
|
|
|
|
|
|
void System_Vibrate(int length_ms);
|
|
|
|
void System_LaunchUrl(LaunchUrlType urlType, const char *url);
|
2023-03-22 11:26:14 +00:00
|
|
|
|
2023-03-22 21:07:29 +00:00
|
|
|
// It's sometimes a little unclear what should be a request, and what should be a separate function.
|
|
|
|
// Going forward, "optional" things (PPSSPP will still function alright without it) will be requests,
|
|
|
|
// to make implementations simpler in the default case.
|
|
|
|
|
2023-03-22 11:26:14 +00:00
|
|
|
enum class SystemRequestType {
|
|
|
|
INPUT_TEXT_MODAL,
|
2023-06-19 21:22:44 +00:00
|
|
|
ASK_USERNAME_PASSWORD,
|
2023-03-22 12:43:44 +00:00
|
|
|
BROWSE_FOR_IMAGE,
|
2023-03-22 14:21:03 +00:00
|
|
|
BROWSE_FOR_FILE,
|
2023-03-22 15:09:33 +00:00
|
|
|
BROWSE_FOR_FOLDER,
|
2023-03-22 21:07:29 +00:00
|
|
|
|
|
|
|
EXIT_APP,
|
2023-03-22 21:17:53 +00:00
|
|
|
RESTART_APP, // For graphics backend changes
|
2023-05-17 07:37:15 +00:00
|
|
|
RECREATE_ACTIVITY, // Android
|
2023-03-22 21:07:29 +00:00
|
|
|
COPY_TO_CLIPBOARD,
|
2023-03-24 16:40:03 +00:00
|
|
|
SHARE_TEXT,
|
|
|
|
SET_WINDOW_TITLE,
|
2023-03-22 21:17:53 +00:00
|
|
|
TOGGLE_FULLSCREEN_STATE,
|
|
|
|
GRAPHICS_BACKEND_FAILED_ALERT,
|
2023-03-24 19:05:48 +00:00
|
|
|
CREATE_GAME_SHORTCUT,
|
2023-08-24 11:04:41 +00:00
|
|
|
SHOW_FILE_IN_FOLDER,
|
2023-03-22 21:49:38 +00:00
|
|
|
|
2023-03-26 00:34:29 +00:00
|
|
|
// Commonly ignored, used when automated tests generate output.
|
|
|
|
SEND_DEBUG_OUTPUT,
|
|
|
|
// Note: height specified as param3, width based on param1.size() / param3.
|
|
|
|
SEND_DEBUG_SCREENSHOT,
|
|
|
|
|
2023-03-24 16:40:03 +00:00
|
|
|
NOTIFY_UI_STATE, // Used on Android only. Not a SystemNotification since it takes a parameter.
|
|
|
|
|
2023-03-22 21:49:38 +00:00
|
|
|
// High-level hardware control
|
|
|
|
CAMERA_COMMAND,
|
|
|
|
GPS_COMMAND,
|
2024-01-12 15:34:50 +00:00
|
|
|
INFRARED_COMMAND,
|
2023-03-22 21:49:38 +00:00
|
|
|
MICROPHONE_COMMAND,
|
2023-03-22 11:26:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Implementations are supposed to process the request, and post the response to the g_RequestManager (see Message.h).
|
|
|
|
// This is not to be used directly by applications, instead use the g_RequestManager to make the requests.
|
|
|
|
// This can return false if it's known that the platform doesn't support the request, the app is supposed to handle
|
|
|
|
// or ignore that cleanly.
|
2023-03-22 21:07:29 +00:00
|
|
|
// Some requests don't use responses.
|
2023-03-22 14:21:03 +00:00
|
|
|
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3);
|
2023-03-22 11:26:14 +00:00
|
|
|
|
2020-10-04 08:30:18 +00:00
|
|
|
PermissionStatus System_GetPermissionStatus(SystemPermission permission);
|
|
|
|
void System_AskForPermission(SystemPermission permission);
|
|
|
|
|
|
|
|
// This will get muddy with multi-screen support :/ But this will always be the type of the main device.
|
|
|
|
enum SystemDeviceType {
|
|
|
|
DEVICE_TYPE_MOBILE = 0, // phones and pads
|
|
|
|
DEVICE_TYPE_TV = 1, // Android TV and similar
|
|
|
|
DEVICE_TYPE_DESKTOP = 2, // Desktop computer
|
2022-07-24 13:38:30 +00:00
|
|
|
DEVICE_TYPE_VR = 3, // VR headset
|
2020-10-04 08:30:18 +00:00
|
|
|
};
|
|
|
|
|
2022-01-10 00:11:08 +00:00
|
|
|
enum SystemKeyboardLayout {
|
|
|
|
KEYBOARD_LAYOUT_QWERTY = 0,
|
|
|
|
KEYBOARD_LAYOUT_QWERTZ = 1,
|
|
|
|
KEYBOARD_LAYOUT_AZERTY = 2,
|
|
|
|
};
|
|
|
|
|
2020-10-04 08:30:18 +00:00
|
|
|
enum SystemProperty {
|
|
|
|
SYSPROP_NAME,
|
|
|
|
SYSPROP_LANGREGION,
|
|
|
|
SYSPROP_CPUINFO,
|
|
|
|
SYSPROP_BOARDNAME,
|
|
|
|
SYSPROP_CLIPBOARD_TEXT,
|
|
|
|
SYSPROP_GPUDRIVER_VERSION,
|
2023-07-20 07:56:51 +00:00
|
|
|
SYSPROP_BUILD_VERSION,
|
2020-10-04 08:30:18 +00:00
|
|
|
|
2021-01-06 15:37:04 +00:00
|
|
|
// Separate SD cards or similar.
|
|
|
|
// Need hacky solutions to get at this.
|
|
|
|
SYSPROP_HAS_ADDITIONAL_STORAGE,
|
|
|
|
SYSPROP_ADDITIONAL_STORAGE_DIRS,
|
2021-01-09 22:45:49 +00:00
|
|
|
SYSPROP_TEMP_DIRS,
|
2021-01-06 15:37:04 +00:00
|
|
|
|
2020-10-04 08:30:18 +00:00
|
|
|
SYSPROP_HAS_FILE_BROWSER,
|
2020-12-20 00:28:43 +00:00
|
|
|
SYSPROP_HAS_FOLDER_BROWSER,
|
2020-10-04 08:30:18 +00:00
|
|
|
SYSPROP_HAS_IMAGE_BROWSER,
|
|
|
|
SYSPROP_HAS_BACK_BUTTON,
|
2021-04-26 05:54:28 +00:00
|
|
|
SYSPROP_HAS_KEYBOARD,
|
2023-11-06 23:44:43 +00:00
|
|
|
SYSPROP_HAS_ACCELEROMETER, // Used to enable/disable tilt input settings
|
2023-02-02 13:54:50 +00:00
|
|
|
SYSPROP_HAS_OPEN_DIRECTORY,
|
2023-06-19 21:22:44 +00:00
|
|
|
SYSPROP_HAS_LOGIN_DIALOG,
|
2023-06-21 22:00:08 +00:00
|
|
|
SYSPROP_HAS_TEXT_INPUT_DIALOG, // Indicates that System_InputBoxGetString is available.
|
2020-10-04 08:30:18 +00:00
|
|
|
|
2023-03-21 09:54:43 +00:00
|
|
|
SYSPROP_CAN_CREATE_SHORTCUT,
|
2023-08-24 11:04:41 +00:00
|
|
|
SYSPROP_CAN_SHOW_FILE,
|
2023-03-21 09:54:43 +00:00
|
|
|
|
2023-07-20 09:25:27 +00:00
|
|
|
SYSPROP_SUPPORTS_HTTPS,
|
|
|
|
|
2023-10-11 21:40:07 +00:00
|
|
|
SYSPROP_DEBUGGER_PRESENT,
|
|
|
|
|
2020-10-04 08:30:18 +00:00
|
|
|
// Available as Int:
|
|
|
|
SYSPROP_SYSTEMVERSION,
|
|
|
|
SYSPROP_DISPLAY_XRES,
|
|
|
|
SYSPROP_DISPLAY_YRES,
|
|
|
|
SYSPROP_DISPLAY_REFRESH_RATE,
|
|
|
|
SYSPROP_DISPLAY_LOGICAL_DPI,
|
|
|
|
SYSPROP_DISPLAY_DPI,
|
|
|
|
SYSPROP_DISPLAY_COUNT,
|
|
|
|
SYSPROP_MOGA_VERSION,
|
|
|
|
|
|
|
|
// Float only:
|
|
|
|
SYSPROP_DISPLAY_SAFE_INSET_LEFT,
|
|
|
|
SYSPROP_DISPLAY_SAFE_INSET_RIGHT,
|
|
|
|
SYSPROP_DISPLAY_SAFE_INSET_TOP,
|
|
|
|
SYSPROP_DISPLAY_SAFE_INSET_BOTTOM,
|
|
|
|
|
|
|
|
SYSPROP_DEVICE_TYPE,
|
|
|
|
SYSPROP_APP_GOLD, // To avoid having #ifdef GOLD other than in main.cpp and similar.
|
|
|
|
|
|
|
|
// Exposed on Android. Choosing the optimal sample rate for audio
|
|
|
|
// will result in lower latencies. Buffer size is automatically matched
|
|
|
|
// by the OpenSL audio backend, only exposed here for debugging/info.
|
|
|
|
SYSPROP_AUDIO_SAMPLE_RATE,
|
|
|
|
SYSPROP_AUDIO_FRAMES_PER_BUFFER,
|
|
|
|
SYSPROP_AUDIO_OPTIMAL_SAMPLE_RATE,
|
|
|
|
SYSPROP_AUDIO_OPTIMAL_FRAMES_PER_BUFFER,
|
|
|
|
|
|
|
|
// Exposed on SDL.
|
|
|
|
SYSPROP_AUDIO_DEVICE_LIST,
|
|
|
|
|
|
|
|
SYSPROP_SUPPORTS_PERMISSIONS,
|
|
|
|
SYSPROP_SUPPORTS_SUSTAINED_PERF_MODE,
|
2022-07-10 20:34:44 +00:00
|
|
|
SYSPROP_SUPPORTS_OPEN_FILE_IN_EDITOR, // See FileUtil.cpp: OpenFileInEditor
|
2021-02-21 21:02:11 +00:00
|
|
|
|
2021-02-27 10:49:38 +00:00
|
|
|
// Android-specific.
|
|
|
|
SYSPROP_ANDROID_SCOPED_STORAGE,
|
|
|
|
|
2021-02-21 21:02:11 +00:00
|
|
|
SYSPROP_CAN_JIT,
|
2022-01-10 00:11:08 +00:00
|
|
|
|
2023-03-24 17:08:31 +00:00
|
|
|
SYSPROP_HAS_DEBUGGER,
|
|
|
|
|
2022-01-10 00:11:08 +00:00
|
|
|
SYSPROP_KEYBOARD_LAYOUT,
|
2023-03-21 10:42:55 +00:00
|
|
|
|
|
|
|
SYSPROP_SKIP_UI,
|
2023-08-18 13:04:20 +00:00
|
|
|
|
|
|
|
SYSPROP_USER_DOCUMENTS_DIR,
|
2023-12-05 13:17:14 +00:00
|
|
|
|
|
|
|
SYSPROP_OK_BUTTON_LEFT,
|
2020-10-04 08:30:18 +00:00
|
|
|
};
|
|
|
|
|
2023-03-21 10:10:09 +00:00
|
|
|
enum class SystemNotification {
|
|
|
|
UI,
|
|
|
|
MEM_VIEW,
|
|
|
|
DISASSEMBLY,
|
2023-03-21 10:40:48 +00:00
|
|
|
DEBUG_MODE_CHANGE,
|
2023-03-21 10:10:09 +00:00
|
|
|
BOOT_DONE, // this is sent from EMU thread! Make sure that Host handles it properly!
|
|
|
|
SYMBOL_MAP_UPDATED,
|
|
|
|
SWITCH_UMD_UPDATED,
|
2023-03-22 21:55:53 +00:00
|
|
|
ROTATE_UPDATED,
|
|
|
|
FORCE_RECREATE_ACTIVITY,
|
2023-03-22 22:15:08 +00:00
|
|
|
IMMERSIVE_MODE_CHANGE,
|
|
|
|
AUDIO_RESET_DEVICE,
|
2023-03-22 22:25:00 +00:00
|
|
|
SUSTAINED_PERF_CHANGE,
|
2023-03-24 18:57:24 +00:00
|
|
|
POLL_CONTROLLERS,
|
2023-03-24 20:43:45 +00:00
|
|
|
TOGGLE_DEBUG_CONSOLE, // TODO: Kinda weird, just ported forward.
|
2023-07-06 17:06:27 +00:00
|
|
|
TEST_JAVA_EXCEPTION,
|
2023-08-10 11:21:36 +00:00
|
|
|
KEEP_SCREEN_AWAKE,
|
|
|
|
ACTIVITY,
|
2023-03-21 10:10:09 +00:00
|
|
|
};
|
|
|
|
|
2023-09-30 09:21:22 +00:00
|
|
|
// I guess it's not super great architecturally to centralize this, since it's not general - but same with a lot of
|
|
|
|
// the other stuff, and this is only used by PPSSPP, so... better this than ugly strings.
|
|
|
|
enum class UIMessage {
|
|
|
|
PERMISSION_GRANTED,
|
|
|
|
POWER_SAVING,
|
|
|
|
RECREATE_VIEWS,
|
|
|
|
CONFIG_LOADED,
|
|
|
|
REQUEST_GAME_BOOT,
|
|
|
|
REQUEST_GAME_RUN, // or continue?
|
|
|
|
REQUEST_GAME_PAUSE,
|
|
|
|
REQUEST_GAME_RESET,
|
|
|
|
REQUEST_GAME_STOP,
|
2023-12-10 20:57:05 +00:00
|
|
|
GAME_SELECTED,
|
2023-09-30 09:21:22 +00:00
|
|
|
SHOW_CONTROL_MAPPING,
|
|
|
|
SHOW_CHAT_SCREEN,
|
|
|
|
SHOW_DISPLAY_LAYOUT_EDITOR,
|
|
|
|
SHOW_SETTINGS,
|
|
|
|
SHOW_LANGUAGE_SCREEN,
|
|
|
|
REQUEST_GPU_DUMP_NEXT_FRAME,
|
|
|
|
REQUEST_CLEAR_JIT,
|
|
|
|
APP_RESUMED,
|
|
|
|
REQUEST_PLAY_SOUND,
|
|
|
|
WINDOW_MINIMIZED,
|
|
|
|
LOST_FOCUS,
|
|
|
|
GOT_FOCUS,
|
|
|
|
GPU_CONFIG_CHANGED,
|
|
|
|
GPU_RENDER_RESIZED,
|
|
|
|
GPU_DISPLAY_RESIZED,
|
|
|
|
POSTSHADER_UPDATED,
|
|
|
|
ACHIEVEMENT_LOGIN_STATE_CHANGE,
|
|
|
|
SAVESTATE_DISPLAY_SLOT,
|
|
|
|
GAMESETTINGS_SEARCH,
|
|
|
|
SAVEDATA_SEARCH,
|
2024-01-18 16:57:14 +00:00
|
|
|
RESTART_GRAPHICS,
|
2023-09-30 09:21:22 +00:00
|
|
|
};
|
|
|
|
|
2020-10-04 08:30:18 +00:00
|
|
|
std::string System_GetProperty(SystemProperty prop);
|
2021-01-06 15:37:04 +00:00
|
|
|
std::vector<std::string> System_GetPropertyStringVec(SystemProperty prop);
|
2020-10-04 08:30:18 +00:00
|
|
|
int System_GetPropertyInt(SystemProperty prop);
|
|
|
|
float System_GetPropertyFloat(SystemProperty prop);
|
|
|
|
bool System_GetPropertyBool(SystemProperty prop);
|
|
|
|
|
2023-03-21 10:10:09 +00:00
|
|
|
void System_Notify(SystemNotification notification);
|
|
|
|
|
2023-03-21 09:42:23 +00:00
|
|
|
std::vector<std::string> System_GetCameraDeviceList();
|
2023-03-24 16:19:57 +00:00
|
|
|
|
2023-03-21 09:42:23 +00:00
|
|
|
bool System_AudioRecordingIsAvailable();
|
|
|
|
bool System_AudioRecordingState();
|
2023-03-24 16:19:57 +00:00
|
|
|
|
2023-07-06 15:18:46 +00:00
|
|
|
// This will be changed to take an enum. Replacement for the old NativeMessageReceived.
|
2023-09-30 09:21:22 +00:00
|
|
|
void System_PostUIMessage(UIMessage message, const std::string ¶m = "");
|
2023-03-24 20:39:02 +00:00
|
|
|
|
2023-03-24 16:19:57 +00:00
|
|
|
// For these functions, most platforms will use the implementation provided in UI/AudioCommon.cpp,
|
|
|
|
// no need to implement separately.
|
|
|
|
void System_AudioGetDebugStats(char *buf, size_t bufSize);
|
|
|
|
void System_AudioClear();
|
2023-07-08 08:45:22 +00:00
|
|
|
|
2023-03-24 16:19:57 +00:00
|
|
|
// These samples really have 16 bits of value, but can be a little out of range.
|
2023-07-08 08:45:22 +00:00
|
|
|
// This is for pushing rate-controlled 44khz audio from emulation.
|
|
|
|
// If you push a little too fast, we'll pitch up to a limit, for example.
|
2023-03-24 16:19:57 +00:00
|
|
|
void System_AudioPushSamples(const int32_t *audio, int numSamples);
|
|
|
|
|
|
|
|
inline void System_AudioResetStatCounters() {
|
|
|
|
return System_AudioGetDebugStats(nullptr, 0);
|
|
|
|
}
|