mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-14 19:08:08 +00:00
And share_text, toast, recreate
This commit is contained in:
parent
87d0c21f14
commit
ac47476253
@ -112,3 +112,7 @@ inline void System_GPSCommand(const std::string &command) {
|
||||
inline void System_MicrophoneCommand(const std::string &command) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::MICROPHONE_COMMAND, nullptr, command, "", 0);
|
||||
}
|
||||
|
||||
inline void System_ShareText(const std::string &text) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::SHARE_TEXT, nullptr, text, "", 0);
|
||||
}
|
||||
|
@ -71,6 +71,8 @@ enum class SystemRequestType {
|
||||
CAMERA_COMMAND,
|
||||
GPS_COMMAND,
|
||||
MICROPHONE_COMMAND,
|
||||
|
||||
SHARE_TEXT,
|
||||
};
|
||||
|
||||
// Implementations are supposed to process the request, and post the response to the g_RequestManager (see Message.h).
|
||||
@ -175,6 +177,8 @@ enum class SystemNotification {
|
||||
BOOT_DONE, // this is sent from EMU thread! Make sure that Host handles it properly!
|
||||
SYMBOL_MAP_UPDATED,
|
||||
SWITCH_UMD_UPDATED,
|
||||
ROTATE_UPDATED,
|
||||
FORCE_RECREATE_ACTIVITY,
|
||||
};
|
||||
|
||||
std::string System_GetProperty(SystemProperty prop);
|
||||
|
@ -718,7 +718,17 @@ void TouchTestScreen::render() {
|
||||
ui_context->Flush();
|
||||
}
|
||||
|
||||
void RecreateActivity();
|
||||
void RecreateActivity() {
|
||||
const int SYSTEM_JELLYBEAN = 16;
|
||||
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= SYSTEM_JELLYBEAN) {
|
||||
INFO_LOG(SYSTEM, "Sending recreate");
|
||||
System_Notify(SystemNotification::FORCE_RECREATE_ACTIVITY);
|
||||
INFO_LOG(SYSTEM, "Got back from recreate");
|
||||
} else {
|
||||
auto gr = GetI18NCategory("Graphics");
|
||||
System_Toast(gr->T("Must Restart", "You must restart PPSSPP for this change to take effect"));
|
||||
}
|
||||
}
|
||||
|
||||
UI::EventReturn TouchTestScreen::OnImmersiveModeChange(UI::EventParams &e) {
|
||||
System_SendMessage("immersive", "");
|
||||
|
@ -1193,23 +1193,11 @@ UI::EventReturn GameSettingsScreen::OnAutoFrameskip(UI::EventParams &e) {
|
||||
UI::EventReturn GameSettingsScreen::OnScreenRotation(UI::EventParams &e) {
|
||||
INFO_LOG(SYSTEM, "New display rotation: %d", g_Config.iScreenRotation);
|
||||
INFO_LOG(SYSTEM, "Sending rotate");
|
||||
System_SendMessage("rotate", "");
|
||||
System_Notify(SystemNotification::ROTATE_UPDATED);
|
||||
INFO_LOG(SYSTEM, "Got back from rotate");
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
void RecreateActivity() {
|
||||
const int SYSTEM_JELLYBEAN = 16;
|
||||
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= SYSTEM_JELLYBEAN) {
|
||||
INFO_LOG(SYSTEM, "Sending recreate");
|
||||
System_SendMessage("recreate", "");
|
||||
INFO_LOG(SYSTEM, "Got back from recreate");
|
||||
} else {
|
||||
auto gr = GetI18NCategory("Graphics");
|
||||
System_SendMessage("toast", gr->T("Must Restart", "You must restart PPSSPP for this change to take effect"));
|
||||
}
|
||||
}
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnAdhocGuides(UI::EventParams &e) {
|
||||
auto n = GetI18NCategory("Networking");
|
||||
System_LaunchUrl(LaunchUrlType::BROWSER_URL, n->T("MultiplayerHowToURL", "https://github.com/hrydgard/ppsspp/wiki/How-to-play-multiplayer-games-with-PPSSPP"));
|
||||
@ -1348,7 +1336,7 @@ void GameSettingsScreen::onFinish(DialogResult result) {
|
||||
Reporting::Enable(enableReports_, "report.ppsspp.org");
|
||||
Reporting::UpdateConfig();
|
||||
if (!g_Config.Save("GameSettingsScreen::onFinish")) {
|
||||
System_SendMessage("toast", "Failed to save settings!\nCheck permissions, or try to restart the device.");
|
||||
System_Toast("Failed to save settings!\nCheck permissions, or try to restart the device.");
|
||||
}
|
||||
|
||||
if (editThenRestore_) {
|
||||
|
@ -1428,7 +1428,7 @@ UI::EventReturn MainScreen::OnForums(UI::EventParams &e) {
|
||||
UI::EventReturn MainScreen::OnExit(UI::EventParams &e) {
|
||||
// Let's make sure the config was saved, since it may not have been.
|
||||
if (!g_Config.Save("MainScreen::OnExit")) {
|
||||
System_SendMessage("toast", "Failed to save settings!\nCheck permissions, or try to restart the device.");
|
||||
System_Toast("Failed to save settings!\nCheck permissions, or try to restart the device.");
|
||||
}
|
||||
|
||||
// Request the framework to exit cleanly.
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/System/NativeApp.h"
|
||||
#include "Common/System/System.h"
|
||||
#include "Common/System/Request.h"
|
||||
#include "Common/Math/curves.h"
|
||||
#include "Common/File/VFS/VFS.h"
|
||||
|
||||
@ -872,7 +873,7 @@ UI::EventReturn CreditsScreen::OnDiscord(UI::EventParams &e) {
|
||||
|
||||
UI::EventReturn CreditsScreen::OnShare(UI::EventParams &e) {
|
||||
auto cr = GetI18NCategory("PSPCredits");
|
||||
System_SendMessage("sharetext", cr->T("CheckOutPPSSPP", "Check out PPSSPP, the awesome PSP emulator: https://www.ppsspp.org/"));
|
||||
System_ShareText(cr->T("CheckOutPPSSPP", "Check out PPSSPP, the awesome PSP emulator: https://www.ppsspp.org/"));
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
|
@ -539,9 +539,6 @@ bool System_GetPropertyBool(SystemProperty prop) {
|
||||
}
|
||||
}
|
||||
|
||||
void System_Notify(SystemNotification notification) {
|
||||
}
|
||||
|
||||
std::string Android_GetInputDeviceDebugString() {
|
||||
if (!nativeActivity) {
|
||||
return "(N/A)";
|
||||
@ -1028,6 +1025,17 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_backbufferResize(JNIEnv
|
||||
}
|
||||
}
|
||||
|
||||
void System_Notify(SystemNotification notification) {
|
||||
switch (notification) {
|
||||
case SystemNotification::ROTATE_UPDATED:
|
||||
PushCommand("rotate", "");
|
||||
break;
|
||||
case SystemNotification::FORCE_RECREATE_ACTIVITY:
|
||||
PushCommand("recreate", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) {
|
||||
switch (type) {
|
||||
case SystemRequestType::EXIT_APP:
|
||||
@ -1061,6 +1069,9 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
case SystemRequestType::MICROPHONE_COMMAND:
|
||||
PushCommand("microphone_command", param1);
|
||||
break;
|
||||
case SystemRequestType::SHARE_TEXT:
|
||||
PushCommand("share_text", param1);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -1226,7 +1237,7 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendMessage(JNIEnv *env
|
||||
std::string msg = GetJavaString(env, message);
|
||||
std::string prm = GetJavaString(env, param);
|
||||
|
||||
// Some messages are caught by app-android.
|
||||
// Some messages are caught by app-android. TODO: Should be all.
|
||||
if (msg == "moga") {
|
||||
mogaVersion = prm;
|
||||
} else if (msg == "permission_pending") {
|
||||
|
@ -1403,18 +1403,7 @@ public abstract class NativeActivity extends Activity {
|
||||
Log.e(TAG, e.toString());
|
||||
return false;
|
||||
}
|
||||
} else if (command.equals("sharejpeg")) {
|
||||
try {
|
||||
Intent share = new Intent(Intent.ACTION_SEND);
|
||||
share.setType("image/jpeg");
|
||||
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + params));
|
||||
startActivity(Intent.createChooser(share, "Share Picture"));
|
||||
return true;
|
||||
} catch (Exception e) { // For example, android.content.ActivityNotFoundException
|
||||
Log.e(TAG, e.toString());
|
||||
return false;
|
||||
}
|
||||
} else if (command.equals("sharetext")) {
|
||||
} else if (command.equals("share_text")) {
|
||||
try {
|
||||
Intent sendIntent = new Intent();
|
||||
sendIntent.setType("text/plain");
|
||||
|
@ -165,10 +165,10 @@ static LocationHelper *locationHelper;
|
||||
[super viewSafeAreaInsetsDidChange];
|
||||
char safeArea[100];
|
||||
// we use 0.0f instead of safeAreaInsets.bottom because the bottom overlay isn't disturbing (for now)
|
||||
snprintf(safeArea, sizeof(safeArea), "%f:%f:%f:%f",
|
||||
self.view.safeAreaInsets.left, self.view.safeAreaInsets.right,
|
||||
self.view.safeAreaInsets.top, 0.0f);
|
||||
System_SendMessage("safe_insets", safeArea);
|
||||
g_safeInsetLeft = self.view.safeAreaInsets.left;
|
||||
g_safeInsetRight = self.view.safeAreaInsets.right;
|
||||
g_safeInsetTop = self.view.safeAreaInsets.top;
|
||||
g_safeInsetBottom = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
21
ios/main.mm
21
ios/main.mm
@ -176,20 +176,7 @@ void System_Notify(SystemNotification notification) {
|
||||
}
|
||||
}
|
||||
|
||||
void System_SendMessage(const char *command, const char *parameter) {
|
||||
if (!strcmp(command, "sharetext")) {
|
||||
NSString *text = [NSString stringWithUTF8String:parameter];
|
||||
[sharedViewController shareText:text];
|
||||
} else if (!strcmp(command, "safe_insets")) {
|
||||
float left, right, top, bottom;
|
||||
if (4 == sscanf(parameter, "%f:%f:%f:%f", &left, &right, &top, &bottom)) {
|
||||
g_safeInsetLeft = left;
|
||||
g_safeInsetRight = right;
|
||||
g_safeInsetTop = top;
|
||||
g_safeInsetBottom = bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
void System_SendMessage(const char *command, const char *parameter) {}
|
||||
|
||||
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) {
|
||||
switch (type) {
|
||||
@ -244,6 +231,12 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
stopLocation();
|
||||
}
|
||||
return true;
|
||||
case SystemRequestType::SHARE_TEXT:
|
||||
{
|
||||
NSString *text = [NSString stringWithUTF8String:param1.c_str()];
|
||||
[sharedViewController shareText:text];
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user