mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-15 03:38:37 +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) {
|
inline void System_MicrophoneCommand(const std::string &command) {
|
||||||
g_requestManager.MakeSystemRequest(SystemRequestType::MICROPHONE_COMMAND, nullptr, command, "", 0);
|
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,
|
CAMERA_COMMAND,
|
||||||
GPS_COMMAND,
|
GPS_COMMAND,
|
||||||
MICROPHONE_COMMAND,
|
MICROPHONE_COMMAND,
|
||||||
|
|
||||||
|
SHARE_TEXT,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Implementations are supposed to process the request, and post the response to the g_RequestManager (see Message.h).
|
// 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!
|
BOOT_DONE, // this is sent from EMU thread! Make sure that Host handles it properly!
|
||||||
SYMBOL_MAP_UPDATED,
|
SYMBOL_MAP_UPDATED,
|
||||||
SWITCH_UMD_UPDATED,
|
SWITCH_UMD_UPDATED,
|
||||||
|
ROTATE_UPDATED,
|
||||||
|
FORCE_RECREATE_ACTIVITY,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string System_GetProperty(SystemProperty prop);
|
std::string System_GetProperty(SystemProperty prop);
|
||||||
|
@ -718,7 +718,17 @@ void TouchTestScreen::render() {
|
|||||||
ui_context->Flush();
|
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) {
|
UI::EventReturn TouchTestScreen::OnImmersiveModeChange(UI::EventParams &e) {
|
||||||
System_SendMessage("immersive", "");
|
System_SendMessage("immersive", "");
|
||||||
|
@ -1193,23 +1193,11 @@ UI::EventReturn GameSettingsScreen::OnAutoFrameskip(UI::EventParams &e) {
|
|||||||
UI::EventReturn GameSettingsScreen::OnScreenRotation(UI::EventParams &e) {
|
UI::EventReturn GameSettingsScreen::OnScreenRotation(UI::EventParams &e) {
|
||||||
INFO_LOG(SYSTEM, "New display rotation: %d", g_Config.iScreenRotation);
|
INFO_LOG(SYSTEM, "New display rotation: %d", g_Config.iScreenRotation);
|
||||||
INFO_LOG(SYSTEM, "Sending rotate");
|
INFO_LOG(SYSTEM, "Sending rotate");
|
||||||
System_SendMessage("rotate", "");
|
System_Notify(SystemNotification::ROTATE_UPDATED);
|
||||||
INFO_LOG(SYSTEM, "Got back from rotate");
|
INFO_LOG(SYSTEM, "Got back from rotate");
|
||||||
return UI::EVENT_DONE;
|
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) {
|
UI::EventReturn GameSettingsScreen::OnAdhocGuides(UI::EventParams &e) {
|
||||||
auto n = GetI18NCategory("Networking");
|
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"));
|
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::Enable(enableReports_, "report.ppsspp.org");
|
||||||
Reporting::UpdateConfig();
|
Reporting::UpdateConfig();
|
||||||
if (!g_Config.Save("GameSettingsScreen::onFinish")) {
|
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_) {
|
if (editThenRestore_) {
|
||||||
|
@ -1428,7 +1428,7 @@ UI::EventReturn MainScreen::OnForums(UI::EventParams &e) {
|
|||||||
UI::EventReturn MainScreen::OnExit(UI::EventParams &e) {
|
UI::EventReturn MainScreen::OnExit(UI::EventParams &e) {
|
||||||
// Let's make sure the config was saved, since it may not have been.
|
// Let's make sure the config was saved, since it may not have been.
|
||||||
if (!g_Config.Save("MainScreen::OnExit")) {
|
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.
|
// Request the framework to exit cleanly.
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "Common/System/Display.h"
|
#include "Common/System/Display.h"
|
||||||
#include "Common/System/NativeApp.h"
|
#include "Common/System/NativeApp.h"
|
||||||
#include "Common/System/System.h"
|
#include "Common/System/System.h"
|
||||||
|
#include "Common/System/Request.h"
|
||||||
#include "Common/Math/curves.h"
|
#include "Common/Math/curves.h"
|
||||||
#include "Common/File/VFS/VFS.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) {
|
UI::EventReturn CreditsScreen::OnShare(UI::EventParams &e) {
|
||||||
auto cr = GetI18NCategory("PSPCredits");
|
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;
|
return UI::EVENT_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,9 +539,6 @@ bool System_GetPropertyBool(SystemProperty prop) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void System_Notify(SystemNotification notification) {
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Android_GetInputDeviceDebugString() {
|
std::string Android_GetInputDeviceDebugString() {
|
||||||
if (!nativeActivity) {
|
if (!nativeActivity) {
|
||||||
return "(N/A)";
|
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) {
|
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SystemRequestType::EXIT_APP:
|
case SystemRequestType::EXIT_APP:
|
||||||
@ -1061,6 +1069,9 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
|||||||
case SystemRequestType::MICROPHONE_COMMAND:
|
case SystemRequestType::MICROPHONE_COMMAND:
|
||||||
PushCommand("microphone_command", param1);
|
PushCommand("microphone_command", param1);
|
||||||
break;
|
break;
|
||||||
|
case SystemRequestType::SHARE_TEXT:
|
||||||
|
PushCommand("share_text", param1);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
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 msg = GetJavaString(env, message);
|
||||||
std::string prm = GetJavaString(env, param);
|
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") {
|
if (msg == "moga") {
|
||||||
mogaVersion = prm;
|
mogaVersion = prm;
|
||||||
} else if (msg == "permission_pending") {
|
} else if (msg == "permission_pending") {
|
||||||
|
@ -1403,18 +1403,7 @@ public abstract class NativeActivity extends Activity {
|
|||||||
Log.e(TAG, e.toString());
|
Log.e(TAG, e.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (command.equals("sharejpeg")) {
|
} else if (command.equals("share_text")) {
|
||||||
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")) {
|
|
||||||
try {
|
try {
|
||||||
Intent sendIntent = new Intent();
|
Intent sendIntent = new Intent();
|
||||||
sendIntent.setType("text/plain");
|
sendIntent.setType("text/plain");
|
||||||
|
@ -165,10 +165,10 @@ static LocationHelper *locationHelper;
|
|||||||
[super viewSafeAreaInsetsDidChange];
|
[super viewSafeAreaInsetsDidChange];
|
||||||
char safeArea[100];
|
char safeArea[100];
|
||||||
// we use 0.0f instead of safeAreaInsets.bottom because the bottom overlay isn't disturbing (for now)
|
// 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",
|
g_safeInsetLeft = self.view.safeAreaInsets.left;
|
||||||
self.view.safeAreaInsets.left, self.view.safeAreaInsets.right,
|
g_safeInsetRight = self.view.safeAreaInsets.right;
|
||||||
self.view.safeAreaInsets.top, 0.0f);
|
g_safeInsetTop = self.view.safeAreaInsets.top;
|
||||||
System_SendMessage("safe_insets", safeArea);
|
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) {
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) {
|
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -244,6 +231,12 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
|||||||
stopLocation();
|
stopLocation();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case SystemRequestType::SHARE_TEXT:
|
||||||
|
{
|
||||||
|
NSString *text = [NSString stringWithUTF8String:param1.c_str()];
|
||||||
|
[sharedViewController shareText:text];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user