mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add facility to run callbacks on the window thread
This commit is contained in:
parent
616ee81f84
commit
9ec5efdcc5
6 changed files with 31 additions and 2 deletions
|
@ -144,3 +144,9 @@ void System_ShowFileInFolder(const Path &path) {
|
|||
void System_BrowseForFolder(RequesterToken token, std::string_view title, const Path &initialPath, RequestCallback callback, RequestFailedCallback failedCallback) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::BROWSE_FOR_FOLDER, token, callback, failedCallback, title, initialPath.ToCString(), 0);
|
||||
}
|
||||
|
||||
void System_RunCallbackInWndProc(void (*callback)(void *, void *), void *userdata) {
|
||||
int64_t castPtr = (int64_t)callback;
|
||||
int64_t castUserData = (int64_t)userdata;
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::RUN_CALLBACK_IN_WNDPROC, NO_REQUESTER_TOKEN, nullptr, nullptr, "", "", castPtr, castUserData);
|
||||
}
|
||||
|
|
|
@ -176,6 +176,8 @@ inline void System_SendDebugScreenshot(std::string_view data, int height) {
|
|||
g_requestManager.MakeSystemRequest(SystemRequestType::SEND_DEBUG_SCREENSHOT, NO_REQUESTER_TOKEN, nullptr, nullptr, data, "", height);
|
||||
}
|
||||
|
||||
void System_RunCallbackInWndProc(void (*callback)(void *, void *), void *userdata);
|
||||
|
||||
// Non-inline to avoid including Path.h
|
||||
void System_CreateGameShortcut(const Path &path, std::string_view title);
|
||||
void System_ShowFileInFolder(const Path &path);
|
||||
|
|
|
@ -86,6 +86,8 @@ enum class SystemRequestType {
|
|||
GPS_COMMAND,
|
||||
INFRARED_COMMAND,
|
||||
MICROPHONE_COMMAND,
|
||||
|
||||
RUN_CALLBACK_IN_WNDPROC,
|
||||
};
|
||||
|
||||
// Implementations are supposed to process the request, and post the response to the g_RequestManager (see Message.h).
|
||||
|
|
|
@ -764,6 +764,13 @@ namespace MainWindow
|
|||
}
|
||||
break;
|
||||
|
||||
case WM_USER_RUN_CALLBACK:
|
||||
{
|
||||
auto callback = reinterpret_cast<void (*)(void *window, void *userdata)>(wParam);
|
||||
void *userdata = reinterpret_cast<void *>(lParam);
|
||||
callback(hWnd, userdata);
|
||||
break;
|
||||
}
|
||||
case WM_USER_GET_BASE_POINTER:
|
||||
Reporting::NotifyDebugger();
|
||||
switch (lParam) {
|
||||
|
@ -1135,4 +1142,8 @@ namespace MainWindow
|
|||
return g_isFullscreen;
|
||||
}
|
||||
|
||||
void RunCallbackInWndProc(void (*callback)(void *, void *), void *userdata) {
|
||||
PostMessage(hwndMain, WM_USER_RUN_CALLBACK, reinterpret_cast<WPARAM>(callback), reinterpret_cast<LPARAM>(userdata));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -18,7 +18,8 @@ namespace MainWindow
|
|||
WM_USER_WINDOW_TITLE_CHANGED = WM_USER + 103,
|
||||
WM_USER_TOGGLE_FULLSCREEN = WM_USER + 105,
|
||||
WM_USER_RESTART_EMUTHREAD = WM_USER + 106,
|
||||
WM_USER_SWITCHUMD_UPDATED = WM_USER + 107
|
||||
WM_USER_SWITCHUMD_UPDATED = WM_USER + 107,
|
||||
WM_USER_RUN_CALLBACK = WM_USER + 108,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -79,6 +80,7 @@ namespace MainWindow
|
|||
void ToggleDebugConsoleVisibility();
|
||||
void SetInternalResolution(int res = -1);
|
||||
void SetWindowSize(int zoom);
|
||||
void RunCallbackInWndProc(void (*callback)(void *window, void *userdata), void *userdata);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -636,7 +636,13 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
|||
}
|
||||
case SystemRequestType::CREATE_GAME_SHORTCUT:
|
||||
return W32Util::CreateDesktopShortcut(param1, param2);
|
||||
|
||||
case SystemRequestType::RUN_CALLBACK_IN_WNDPROC:
|
||||
{
|
||||
auto func = reinterpret_cast<void (*)(void *window, void *userdata)>(param3);
|
||||
void *userdata = reinterpret_cast<void *>(param4);
|
||||
MainWindow::RunCallbackInWndProc(func, userdata);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue