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) {
|
inline void System_GraphicsBackendFailedAlert(const std::string ¶m) {
|
||||||
g_requestManager.MakeSystemRequest(SystemRequestType::GRAPHICS_BACKEND_FAILED_ALERT, nullptr, param, "", 0);
|
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,
|
COPY_TO_CLIPBOARD,
|
||||||
TOGGLE_FULLSCREEN_STATE,
|
TOGGLE_FULLSCREEN_STATE,
|
||||||
GRAPHICS_BACKEND_FAILED_ALERT,
|
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).
|
// 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 "ppsspp_config.h"
|
||||||
|
|
||||||
#include "Common/System/System.h"
|
#include "Common/System/System.h"
|
||||||
|
#include "Common/System/Request.h"
|
||||||
#include "Common/Serialize/Serializer.h"
|
#include "Common/Serialize/Serializer.h"
|
||||||
#include "Common/Serialize/SerializeFuncs.h"
|
#include "Common/Serialize/SerializeFuncs.h"
|
||||||
#include "Core/HLE/HLE.h"
|
#include "Core/HLE/HLE.h"
|
||||||
@ -360,7 +361,7 @@ int Camera::startCapture() {
|
|||||||
#elif PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS) || defined(USING_QT_UI)
|
#elif PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS) || defined(USING_QT_UI)
|
||||||
char command[40] = {0};
|
char command[40] = {0};
|
||||||
snprintf(command, sizeof(command), "startVideo_%dx%d", width, height);
|
snprintf(command, sizeof(command), "startVideo_%dx%d", width, height);
|
||||||
System_SendMessage("camera_command", command);
|
System_CameraCommand(command);
|
||||||
#elif PPSSPP_PLATFORM(LINUX)
|
#elif PPSSPP_PLATFORM(LINUX)
|
||||||
__v4l_startCapture(width, height);
|
__v4l_startCapture(width, height);
|
||||||
#else
|
#else
|
||||||
@ -376,7 +377,7 @@ int Camera::stopCapture() {
|
|||||||
winCamera->sendMessage({ CAPTUREDEVIDE_COMMAND::STOP, nullptr });
|
winCamera->sendMessage({ CAPTUREDEVIDE_COMMAND::STOP, nullptr });
|
||||||
}
|
}
|
||||||
#elif PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS) || defined(USING_QT_UI)
|
#elif PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS) || defined(USING_QT_UI)
|
||||||
System_SendMessage("camera_command", "stopVideo");
|
System_CameraCommand("stopVideo");
|
||||||
#elif PPSSPP_PLATFORM(LINUX)
|
#elif PPSSPP_PLATFORM(LINUX)
|
||||||
__v4l_stopCapture();
|
__v4l_stopCapture();
|
||||||
#else
|
#else
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#include "Common/System/System.h"
|
#include "Common/System/System.h"
|
||||||
|
#include "Common/System/Request.h"
|
||||||
#include "Common/Serialize/Serializer.h"
|
#include "Common/Serialize/Serializer.h"
|
||||||
#include "Common/Serialize/SerializeFuncs.h"
|
#include "Common/Serialize/SerializeFuncs.h"
|
||||||
#include "Core/HLE/HLE.h"
|
#include "Core/HLE/HLE.h"
|
||||||
@ -51,7 +52,7 @@ void __UsbGpsDoState(PointerWrap &p) {
|
|||||||
|
|
||||||
void __UsbGpsShutdown() {
|
void __UsbGpsShutdown() {
|
||||||
gpsStatus = GPS_STATE_OFF;
|
gpsStatus = GPS_STATE_OFF;
|
||||||
System_SendMessage("gps_command", "close");
|
System_GPSCommand("close");
|
||||||
};
|
};
|
||||||
|
|
||||||
static int sceUsbGpsGetInitDataLocation(u32 addr) {
|
static int sceUsbGpsGetInitDataLocation(u32 addr) {
|
||||||
@ -69,14 +70,14 @@ static int sceUsbGpsOpen() {
|
|||||||
ERROR_LOG(HLE, "UNIMPL sceUsbGpsOpen");
|
ERROR_LOG(HLE, "UNIMPL sceUsbGpsOpen");
|
||||||
GPS::init();
|
GPS::init();
|
||||||
gpsStatus = GPS_STATE_ON;
|
gpsStatus = GPS_STATE_ON;
|
||||||
System_SendMessage("gps_command", "open");
|
System_GPSCommand("open");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sceUsbGpsClose() {
|
static int sceUsbGpsClose() {
|
||||||
ERROR_LOG(HLE, "UNIMPL sceUsbGpsClose");
|
ERROR_LOG(HLE, "UNIMPL sceUsbGpsClose");
|
||||||
gpsStatus = GPS_STATE_OFF;
|
gpsStatus = GPS_STATE_OFF;
|
||||||
System_SendMessage("gps_command", "close");
|
System_GPSCommand("close");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "Common/Serialize/Serializer.h"
|
#include "Common/Serialize/Serializer.h"
|
||||||
#include "Common/Serialize/SerializeFuncs.h"
|
#include "Common/Serialize/SerializeFuncs.h"
|
||||||
#include "Common/System/System.h"
|
#include "Common/System/System.h"
|
||||||
|
#include "Common/System/Request.h"
|
||||||
#include "Core/HLE/HLE.h"
|
#include "Core/HLE/HLE.h"
|
||||||
#include "Core/HLE/FunctionWrappers.h"
|
#include "Core/HLE/FunctionWrappers.h"
|
||||||
#include "Core/HLE/sceKernelThread.h"
|
#include "Core/HLE/sceKernelThread.h"
|
||||||
@ -328,7 +329,7 @@ int Microphone::startMic(void *param) {
|
|||||||
int sampleRate = micParam->at(0);
|
int sampleRate = micParam->at(0);
|
||||||
int channels = micParam->at(1);
|
int channels = micParam->at(1);
|
||||||
INFO_LOG(HLE, "microphone_command : sr = %d", sampleRate);
|
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
|
#endif
|
||||||
micState = 1;
|
micState = 1;
|
||||||
return 0;
|
return 0;
|
||||||
@ -339,7 +340,7 @@ int Microphone::stopMic() {
|
|||||||
if (winMic)
|
if (winMic)
|
||||||
winMic->sendMessage({ CAPTUREDEVIDE_COMMAND::STOP, nullptr });
|
winMic->sendMessage({ CAPTUREDEVIDE_COMMAND::STOP, nullptr });
|
||||||
#elif PPSSPP_PLATFORM(ANDROID)
|
#elif PPSSPP_PLATFORM(ANDROID)
|
||||||
System_SendMessage("microphone_command", "stopRecording");
|
System_MicrophoneCommand("stopRecording");
|
||||||
#endif
|
#endif
|
||||||
micState = 0;
|
micState = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -366,13 +366,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
|||||||
g_param2 = param2;
|
g_param2 = param2;
|
||||||
QCoreApplication::postEvent(emugl, new QEvent((QEvent::Type)browseFolderEvent));
|
QCoreApplication::postEvent(emugl, new QEvent((QEvent::Type)browseFolderEvent));
|
||||||
return true;
|
return true;
|
||||||
default:
|
case SystemRequestType::CAMERA_COMMAND:
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void System_SendMessage(const char *command, const char *parameter) {
|
|
||||||
if (!strcmp(command, "camera_command")) {
|
|
||||||
if (!strncmp(parameter, "startVideo", 10)) {
|
if (!strncmp(parameter, "startVideo", 10)) {
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
sscanf(parameter, "startVideo_%dx%d", &width, &height);
|
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")) {
|
} else if (!strcmp(parameter, "stopVideo")) {
|
||||||
emit(qtcamera->onStopCamera());
|
emit(qtcamera->onStopCamera());
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void System_SendMessage(const char *command, const char *parameter) {
|
||||||
#if defined(SDL)
|
#if defined(SDL)
|
||||||
} else if (!strcmp(command, "audio_resetDevice")) {
|
if (!strcmp(command, "audio_resetDevice")) {
|
||||||
StopSDLAudioDevice();
|
StopSDLAudioDevice();
|
||||||
InitSDLAudioDevice();
|
InitSDLAudioDevice();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
void System_Toast(const char *text) {}
|
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:
|
case SystemRequestType::BROWSE_FOR_FOLDER:
|
||||||
PushCommand("browse_folder", StringFromFormat("%d", requestId));
|
PushCommand("browse_folder", StringFromFormat("%d", requestId));
|
||||||
return true;
|
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:
|
default:
|
||||||
return false;
|
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")) {
|
if (!strcmp(command, "sharetext")) {
|
||||||
NSString *text = [NSString stringWithUTF8String:parameter];
|
NSString *text = [NSString stringWithUTF8String:parameter];
|
||||||
[sharedViewController shareText:text];
|
[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")) {
|
} else if (!strcmp(command, "safe_insets")) {
|
||||||
float left, right, top, bottom;
|
float left, right, top, bottom;
|
||||||
if (4 == sscanf(parameter, "%f:%f:%f:%f", &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);
|
services.presentDirectoryPanel(callback, /* allowFiles = */ false, /* allowDirectories = */ true);
|
||||||
return 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) {}
|
void System_Toast(const char *text) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user