mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Make proper requests for the external hardware commands (gps, microphone, camera)
This commit is contained in:
parent
2c9787643d
commit
87d0c21f14
@ -100,3 +100,15 @@ inline void System_ToggleFullscreenState(const std::string ¶m) {
|
||||
inline void System_GraphicsBackendFailedAlert(const std::string ¶m) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::GRAPHICS_BACKEND_FAILED_ALERT, nullptr, param, "", 0);
|
||||
}
|
||||
|
||||
inline void System_CameraCommand(const std::string &command) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::CAMERA_COMMAND, nullptr, command, "", 0);
|
||||
}
|
||||
|
||||
inline void System_GPSCommand(const std::string &command) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::GPS_COMMAND, nullptr, command, "", 0);
|
||||
}
|
||||
|
||||
inline void System_MicrophoneCommand(const std::string &command) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::MICROPHONE_COMMAND, nullptr, command, "", 0);
|
||||
}
|
||||
|
@ -66,6 +66,11 @@ enum class SystemRequestType {
|
||||
COPY_TO_CLIPBOARD,
|
||||
TOGGLE_FULLSCREEN_STATE,
|
||||
GRAPHICS_BACKEND_FAILED_ALERT,
|
||||
|
||||
// High-level hardware control
|
||||
CAMERA_COMMAND,
|
||||
GPS_COMMAND,
|
||||
MICROPHONE_COMMAND,
|
||||
};
|
||||
|
||||
// Implementations are supposed to process the request, and post the response to the g_RequestManager (see Message.h).
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "ppsspp_config.h"
|
||||
|
||||
#include "Common/System/System.h"
|
||||
#include "Common/System/Request.h"
|
||||
#include "Common/Serialize/Serializer.h"
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
#include "Core/HLE/HLE.h"
|
||||
@ -360,7 +361,7 @@ int Camera::startCapture() {
|
||||
#elif PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS) || defined(USING_QT_UI)
|
||||
char command[40] = {0};
|
||||
snprintf(command, sizeof(command), "startVideo_%dx%d", width, height);
|
||||
System_SendMessage("camera_command", command);
|
||||
System_CameraCommand(command);
|
||||
#elif PPSSPP_PLATFORM(LINUX)
|
||||
__v4l_startCapture(width, height);
|
||||
#else
|
||||
@ -376,7 +377,7 @@ int Camera::stopCapture() {
|
||||
winCamera->sendMessage({ CAPTUREDEVIDE_COMMAND::STOP, nullptr });
|
||||
}
|
||||
#elif PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS) || defined(USING_QT_UI)
|
||||
System_SendMessage("camera_command", "stopVideo");
|
||||
System_CameraCommand("stopVideo");
|
||||
#elif PPSSPP_PLATFORM(LINUX)
|
||||
__v4l_stopCapture();
|
||||
#else
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <ctime>
|
||||
|
||||
#include "Common/System/System.h"
|
||||
#include "Common/System/Request.h"
|
||||
#include "Common/Serialize/Serializer.h"
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
#include "Core/HLE/HLE.h"
|
||||
@ -51,7 +52,7 @@ void __UsbGpsDoState(PointerWrap &p) {
|
||||
|
||||
void __UsbGpsShutdown() {
|
||||
gpsStatus = GPS_STATE_OFF;
|
||||
System_SendMessage("gps_command", "close");
|
||||
System_GPSCommand("close");
|
||||
};
|
||||
|
||||
static int sceUsbGpsGetInitDataLocation(u32 addr) {
|
||||
@ -69,14 +70,14 @@ static int sceUsbGpsOpen() {
|
||||
ERROR_LOG(HLE, "UNIMPL sceUsbGpsOpen");
|
||||
GPS::init();
|
||||
gpsStatus = GPS_STATE_ON;
|
||||
System_SendMessage("gps_command", "open");
|
||||
System_GPSCommand("open");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sceUsbGpsClose() {
|
||||
ERROR_LOG(HLE, "UNIMPL sceUsbGpsClose");
|
||||
gpsStatus = GPS_STATE_OFF;
|
||||
System_SendMessage("gps_command", "close");
|
||||
System_GPSCommand("close");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "Common/Serialize/Serializer.h"
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
#include "Common/System/System.h"
|
||||
#include "Common/System/Request.h"
|
||||
#include "Core/HLE/HLE.h"
|
||||
#include "Core/HLE/FunctionWrappers.h"
|
||||
#include "Core/HLE/sceKernelThread.h"
|
||||
@ -328,7 +329,7 @@ int Microphone::startMic(void *param) {
|
||||
int sampleRate = micParam->at(0);
|
||||
int channels = micParam->at(1);
|
||||
INFO_LOG(HLE, "microphone_command : sr = %d", sampleRate);
|
||||
System_SendMessage("microphone_command", ("startRecording:" + std::to_string(sampleRate)).c_str());
|
||||
System_MicrophoneCommand("startRecording:" + std::to_string(sampleRate));
|
||||
#endif
|
||||
micState = 1;
|
||||
return 0;
|
||||
@ -339,7 +340,7 @@ int Microphone::stopMic() {
|
||||
if (winMic)
|
||||
winMic->sendMessage({ CAPTUREDEVIDE_COMMAND::STOP, nullptr });
|
||||
#elif PPSSPP_PLATFORM(ANDROID)
|
||||
System_SendMessage("microphone_command", "stopRecording");
|
||||
System_MicrophoneCommand("stopRecording");
|
||||
#endif
|
||||
micState = 0;
|
||||
return 0;
|
||||
|
@ -366,13 +366,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
g_param2 = param2;
|
||||
QCoreApplication::postEvent(emugl, new QEvent((QEvent::Type)browseFolderEvent));
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void System_SendMessage(const char *command, const char *parameter) {
|
||||
if (!strcmp(command, "camera_command")) {
|
||||
case SystemRequestType::CAMERA_COMMAND:
|
||||
if (!strncmp(parameter, "startVideo", 10)) {
|
||||
int width = 0, height = 0;
|
||||
sscanf(parameter, "startVideo_%dx%d", &width, &height);
|
||||
@ -380,12 +374,19 @@ void System_SendMessage(const char *command, const char *parameter) {
|
||||
} else if (!strcmp(parameter, "stopVideo")) {
|
||||
emit(qtcamera->onStopCamera());
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void System_SendMessage(const char *command, const char *parameter) {
|
||||
#if defined(SDL)
|
||||
} else if (!strcmp(command, "audio_resetDevice")) {
|
||||
if (!strcmp(command, "audio_resetDevice")) {
|
||||
StopSDLAudioDevice();
|
||||
InitSDLAudioDevice();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void System_Toast(const char *text) {}
|
||||
|
||||
|
@ -1051,6 +1051,16 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
case SystemRequestType::BROWSE_FOR_FOLDER:
|
||||
PushCommand("browse_folder", StringFromFormat("%d", requestId));
|
||||
return true;
|
||||
|
||||
case SystemRequestType::CAMERA_COMMAND:
|
||||
PushCommand("camera_command", param1);
|
||||
break;
|
||||
case SystemRequestType::GPS_COMMAND:
|
||||
PushCommand("gps_command", param1);
|
||||
break;
|
||||
case SystemRequestType::MICROPHONE_COMMAND:
|
||||
PushCommand("microphone_command", param1);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
35
ios/main.mm
35
ios/main.mm
@ -180,21 +180,6 @@ 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, "camera_command")) {
|
||||
if (!strncmp(parameter, "startVideo", 10)) {
|
||||
int width = 0, height = 0;
|
||||
sscanf(parameter, "startVideo_%dx%d", &width, &height);
|
||||
setCameraSize(width, height);
|
||||
startVideo();
|
||||
} else if (!strcmp(parameter, "stopVideo")) {
|
||||
stopVideo();
|
||||
}
|
||||
} else if (!strcmp(command, "gps_command")) {
|
||||
if (!strcmp(parameter, "open")) {
|
||||
startLocation();
|
||||
} else if (!strcmp(parameter, "close")) {
|
||||
stopLocation();
|
||||
}
|
||||
} else if (!strcmp(command, "safe_insets")) {
|
||||
float left, right, top, bottom;
|
||||
if (4 == sscanf(parameter, "%f:%f:%f:%f", &left, &right, &top, &bottom)) {
|
||||
@ -242,8 +227,26 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
services.presentDirectoryPanel(callback, /* allowFiles = */ false, /* allowDirectories = */ true);
|
||||
return true;
|
||||
}
|
||||
case SystemRequestType::CAMERA_COMMAND:
|
||||
if (!strncmp(param1.c_str(), "startVideo", 10)) {
|
||||
int width = 0, height = 0;
|
||||
sscanf(param1.c_str(), "startVideo_%dx%d", &width, &height);
|
||||
setCameraSize(width, height);
|
||||
startVideo();
|
||||
} else if (!strcmp(param1.c_str(), "stopVideo")) {
|
||||
stopVideo();
|
||||
}
|
||||
return true;
|
||||
case SystemRequestType::GPS_COMMAND:
|
||||
if (param1 == "open") {
|
||||
startLocation();
|
||||
} else if (param1 == "close")) {
|
||||
stopLocation();
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void System_Toast(const char *text) {}
|
||||
|
Loading…
Reference in New Issue
Block a user