mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
Merge pull request #643 from Celegans12/feat/msgdialog-native-close
feat(msgdialog): implement sceMsgDialogClose in libSceMsgDialog.native
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
add_library(libSceMsgDialog.native SHARED EXCLUDE_FROM_ALL Export.cpp)
|
||||
target_include_directories(libSceMsgDialog.native PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
configure_windows_unwind(libSceMsgDialog.native)
|
||||
|
||||
if(MINGW)
|
||||
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
|
||||
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_test_executable(guest_msg_dialog_native_tests ${LIBS_INCLUDE_DIR}/tests/GuestMsgDialogNative.cpp)
|
||||
target_include_directories(guest_msg_dialog_native_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(guest_msg_dialog_native_tests PRIVATE libSceMsgDialog.native)
|
||||
add_test(NAME guest_msg_dialog_native COMMAND guest_msg_dialog_native_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_msg_dialog_native PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceMsgDialog.native>")
|
||||
endif()
|
||||
endif()
|
||||
@@ -8,10 +8,12 @@
|
||||
namespace {
|
||||
std::atomic<int> g_status{0};
|
||||
|
||||
constexpr int COMMON_DIALOG_STATUS_RUNNING = 2;
|
||||
constexpr int COMMON_DIALOG_STATUS_FINISHED = 3;
|
||||
constexpr int COMMON_DIALOG_RESULT_OK = 0;
|
||||
constexpr int COMMON_DIALOG_ERROR_NOT_INITIALIZED = static_cast<int>(0x80B80003u);
|
||||
constexpr int COMMON_DIALOG_ERROR_NOT_FINISHED = static_cast<int>(0x80B80005u);
|
||||
constexpr int COMMON_DIALOG_ERROR_NOT_RUNNING = static_cast<int>(0x80B8000Bu);
|
||||
constexpr int COMMON_DIALOG_ERROR_ARG_NULL = static_cast<int>(0x80B8000Du);
|
||||
constexpr int BUTTON_ID_OK = 1;
|
||||
}
|
||||
@@ -20,6 +22,12 @@ extern "C" {
|
||||
|
||||
int SceMsgDialogNativeModuleLoaded_nid_no_patch = 1;
|
||||
|
||||
int APS5_VABI sceMsgDialogClose(void) {
|
||||
int expected = COMMON_DIALOG_STATUS_RUNNING;
|
||||
if (!g_status.compare_exchange_strong(expected, COMMON_DIALOG_STATUS_FINISHED)) return COMMON_DIALOG_ERROR_NOT_RUNNING;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceMsgDialogGetResult(MsgDialogResult* result) {
|
||||
const int status = g_status.load();
|
||||
if (status == 0) return COMMON_DIALOG_ERROR_NOT_INITIALIZED;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/general/VabiMacros.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
extern "C" {
|
||||
int APS5_VABI sceMsgDialogInitialize(void);
|
||||
int APS5_VABI sceMsgDialogOpen(const void* param);
|
||||
int APS5_VABI sceMsgDialogUpdateStatus(void);
|
||||
int APS5_VABI sceMsgDialogGetResult(MsgDialogResult* result);
|
||||
int APS5_VABI sceMsgDialogClose(void);
|
||||
int APS5_VABI sceMsgDialogTerminate(void);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void Require(bool value) { if (!value) std::abort(); }
|
||||
|
||||
constexpr int kStatusInitialized = 1;
|
||||
constexpr int kStatusFinished = 3;
|
||||
constexpr int kErrNotRunning = static_cast<int>(0x80B8000Bu);
|
||||
constexpr int kButtonIdOk = 1;
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::uint8_t param[0x60]{};
|
||||
|
||||
Require(sceMsgDialogClose() == kErrNotRunning);
|
||||
Require(sceMsgDialogUpdateStatus() == 0);
|
||||
|
||||
Require(sceMsgDialogInitialize() == 0);
|
||||
Require(sceMsgDialogClose() == kErrNotRunning);
|
||||
Require(sceMsgDialogUpdateStatus() == kStatusInitialized);
|
||||
|
||||
Require(sceMsgDialogOpen(param) == 0);
|
||||
Require(sceMsgDialogUpdateStatus() == kStatusFinished);
|
||||
Require(sceMsgDialogClose() == kErrNotRunning);
|
||||
Require(sceMsgDialogUpdateStatus() == kStatusFinished);
|
||||
|
||||
MsgDialogResult result{};
|
||||
result.button_id = -1;
|
||||
Require(sceMsgDialogGetResult(&result) == 0);
|
||||
Require(result.result == 0);
|
||||
Require(result.button_id == kButtonIdOk);
|
||||
|
||||
Require(sceMsgDialogTerminate() == 0);
|
||||
Require(sceMsgDialogClose() == kErrNotRunning);
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
Throughout the project, every function at every stage either **does exactly what it's supposed to or throws an exception**. Everywhere... except:
|
||||
- [libSceSaveDataDialog.native](../../core/libs/prx/libSceSaveDataDialog.native/Export.cpp)
|
||||
- [libSceMsgDialog.native](../../core/libs/prx/libSceMsgDialog.native/Export.cpp) - dialogs finish at `sceMsgDialogOpen` without UI and answer with button 1, so `sceMsgDialogClose` returns `NOT_RUNNING`; its result before `sceMsgDialogInitialize` follows libSceMsgDialog
|
||||
- [libSceCommonDialog](../../core/libs/prx/libSceCommonDialog/Export.cpp)
|
||||
- [libSceErrorDialog](../../core/libs/prx/libSceErrorDialog/Export.cpp) - the error dialog runs the state machine but shows nothing; the error code passed to `sceErrorDialogOpen` is only logged
|
||||
- [libSceHmd](../../core/libs/prx/libSceHmd/Export.cpp) implements only the disconnected-headset path: initialization succeeds, device queries report `NotDetected`, and opening a device returns `DeviceDisconnected`. Headset support, tracking, rendering and additional HMD exports are not implemented; SDK-level ABI compatibility and in-game behaviour remain unverified.
|
||||
|
||||
Reference in New Issue
Block a user