From d5303b0b647e3825e66b9d2deee48c1d69b6de49 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 4 Jan 2019 14:45:32 +0100 Subject: [PATCH] add error_code to cellOskDialog and cellMsgDialog --- rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp | 35 +++++++--- rpcs3/Emu/Cell/Modules/cellMsgDialog.h | 2 +- rpcs3/Emu/Cell/Modules/cellOskDialog.cpp | 85 +++++++++++++----------- rpcs3/Emu/Cell/Modules/cellOskDialog.h | 2 +- rpcs3/Emu/Cell/Modules/cellSysutil.cpp | 20 ++++++ rpcs3/Emu/Cell/Modules/cellSysutil.h | 2 +- 6 files changed, 96 insertions(+), 50 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp index 8184d6db56..061d5e8a37 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp @@ -11,12 +11,27 @@ extern logs::channel cellSysutil; +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_MSGDIALOG_ERROR_PARAM); + STR_CASE(CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED); + } + + return unknown; + }); +} + MsgDialogBase::~MsgDialogBase() { } // forward declaration for open_msg_dialog -s32 cellMsgDialogOpen2(u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam); +error_code cellMsgDialogOpen2(u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam); // wrapper to call for other hle dialogs s32 open_msg_dialog(u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam) @@ -25,7 +40,7 @@ s32 open_msg_dialog(u32 type, vm::cptr msgString, vm::ptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam) +error_code cellMsgDialogOpen2(u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam) { cellSysutil.warning("cellMsgDialogOpen2(type=0x%x, msgString=%s, callback=*0x%x, userData=*0x%x, extParam=*0x%x)", type, msgString, callback, userData, extParam); @@ -156,14 +171,14 @@ s32 cellMsgDialogOpen2(u32 type, vm::cptr msgString, vm::ptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam) +error_code cellMsgDialogOpen(u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam) { // Note: This function needs proper implementation, solve first argument "type" conflict with MsgDialogOpen2 in cellMsgDialog.h. cellSysutil.todo("cellMsgDialogOpen(type=0x%x, msgString=%s, callback=*0x%x, userData=*0x%x, extParam=*0x%x)", type, msgString, callback, userData, extParam); return cellMsgDialogOpen2(type, msgString, callback, userData, extParam); } -s32 cellMsgDialogOpenErrorCode(u32 errorCode, vm::ptr callback, vm::ptr userData, vm::ptr extParam) +error_code cellMsgDialogOpenErrorCode(u32 errorCode, vm::ptr callback, vm::ptr userData, vm::ptr extParam) { cellSysutil.warning("cellMsgDialogOpenErrorCode(errorCode=0x%x, callback=*0x%x, userData=*0x%x, extParam=*0x%x)", errorCode, callback, userData, extParam); @@ -240,7 +255,7 @@ s32 cellMsgDialogOpenErrorCode(u32 errorCode, vm::ptr cal return cellMsgDialogOpen2(CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK, vm::make_str(error), callback, userData, extParam); } -s32 cellMsgDialogClose(f32 delay) +error_code cellMsgDialogClose(f32 delay) { cellSysutil.warning("cellMsgDialogClose(delay=%f)", delay); @@ -293,7 +308,7 @@ s32 cellMsgDialogClose(f32 delay) return CELL_OK; } -s32 cellMsgDialogAbort() +error_code cellMsgDialogAbort() { cellSysutil.warning("cellMsgDialogAbort()"); @@ -322,7 +337,7 @@ s32 cellMsgDialogAbort() return CELL_OK; } -s32 cellMsgDialogOpenSimulViewWarning(vm::ptr callback, vm::ptr userData, vm::ptr extParam) +error_code cellMsgDialogOpenSimulViewWarning(vm::ptr callback, vm::ptr userData, vm::ptr extParam) { cellSysutil.todo("cellMsgDialogOpenSimulViewWarning(callback=*0x%x, userData=*0x%x, extParam=*0x%x)", callback, userData, extParam); @@ -335,7 +350,7 @@ s32 cellMsgDialogOpenSimulViewWarning(vm::ptr callback, v return ret; } -s32 cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::cptr msgString) +error_code cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::cptr msgString) { cellSysutil.warning("cellMsgDialogProgressBarSetMsg(progressBarIndex=%d, msgString=%s)", progressBarIndex, msgString); @@ -372,7 +387,7 @@ s32 cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::cptr msgStrin return CELL_OK; } -s32 cellMsgDialogProgressBarReset(u32 progressBarIndex) +error_code cellMsgDialogProgressBarReset(u32 progressBarIndex) { cellSysutil.warning("cellMsgDialogProgressBarReset(progressBarIndex=%d)", progressBarIndex); @@ -404,7 +419,7 @@ s32 cellMsgDialogProgressBarReset(u32 progressBarIndex) return CELL_OK; } -s32 cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta) +error_code cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta) { cellSysutil.warning("cellMsgDialogProgressBarInc(progressBarIndex=%d, delta=%d)", progressBarIndex, delta); diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h index 315a9c0dd1..cba0035725 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h @@ -8,7 +8,7 @@ enum CELL_MSGDIALOG_STRING_SIZE = 512, }; -enum +enum CellMsgDialogError : u32 { CELL_MSGDIALOG_ERROR_PARAM = 0x8002b301, CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED = 0x8002b302, diff --git a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp index f3399a85cb..19701aecc6 100644 --- a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp @@ -10,17 +10,33 @@ LOG_CHANNEL(cellOskDialog); +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_OSKDIALOG_ERROR_IME_ALREADY_IN_USE); + STR_CASE(CELL_OSKDIALOG_ERROR_GET_SIZE_ERROR); + STR_CASE(CELL_OSKDIALOG_ERROR_UNKNOWN); + STR_CASE(CELL_OSKDIALOG_ERROR_PARAM); + } + + return unknown; + }); +} + static CellOskDialogInputFieldResult s_osk_input_result; static char16_t s_osk_text[CELL_OSKDIALOG_STRING_SIZE]; static char16_t s_osk_text_old[CELL_OSKDIALOG_STRING_SIZE]; -s32 cellOskDialogLoadAsync(u32 container, vm::ptr dialogParam, vm::ptr inputFieldInfo) +error_code cellOskDialogLoadAsync(u32 container, vm::ptr dialogParam, vm::ptr inputFieldInfo) { cellOskDialog.warning("cellOskDialogLoadAsync(container=0x%x, dialogParam=*0x%x, inputFieldInfo=*0x%x)", container, dialogParam, inputFieldInfo); if (!inputFieldInfo || !inputFieldInfo->message || !inputFieldInfo->init_text || inputFieldInfo->limit_length > CELL_OSKDIALOG_STRING_SIZE) { - cellOskDialog.error("cellOskDialogLoadAsync: CELL_OSKDIALOG_ERROR_PARAM"); return CELL_OSKDIALOG_ERROR_PARAM; } @@ -29,7 +45,6 @@ s32 cellOskDialogLoadAsync(u32 container, vm::ptr dialogPara // Can't open another dialog if this one is already open. if (!osk || osk->state.load() == MsgDialogState::Open) { - cellOskDialog.error("cellOskDialogLoadAsync: CELL_SYSUTIL_ERROR_BUSY"); return CELL_SYSUTIL_ERROR_BUSY; } @@ -123,11 +138,10 @@ s32 cellOskDialogLoadAsync(u32 container, vm::ptr dialogPara return CELL_OK; } -s32 getText(vm::ptr OutputInfo, bool is_unload) +error_code getText(vm::ptr OutputInfo, bool is_unload) { if (!OutputInfo || OutputInfo->numCharsResultString < 0) { - cellOskDialog.error("%s: CELL_OSKDIALOG_ERROR_PARAM", is_unload ? "cellOskDialogUnloadAsync" : "cellOskDialogGetInputText"); return CELL_OSKDIALOG_ERROR_PARAM; } @@ -164,19 +178,18 @@ s32 getText(vm::ptr OutputInfo, bool is_unload return CELL_OK; } -s32 cellOskDialogUnloadAsync(vm::ptr OutputInfo) +error_code cellOskDialogUnloadAsync(vm::ptr OutputInfo) { cellOskDialog.warning("cellOskDialogUnloadAsync(OutputInfo=*0x%x)", OutputInfo); return getText(OutputInfo, true); } -s32 cellOskDialogGetSize(vm::ptr width, vm::ptr height, u32 /*CellOskDialogType*/ dialogType) +error_code cellOskDialogGetSize(vm::ptr width, vm::ptr height, u32 /*CellOskDialogType*/ dialogType) { cellOskDialog.warning("cellOskDialogGetSize(width=*0x%x, height=*0x%x, dialogType=*0x%x)", width, height, dialogType); if (!width || !height) { - cellOskDialog.error("cellOskDialogGetSize: CELL_OSKDIALOG_ERROR_PARAM"); return CELL_OSKDIALOG_ERROR_PARAM; } @@ -194,7 +207,7 @@ s32 cellOskDialogGetSize(vm::ptr width, vm::ptr height, u32 /*CellOskD return CELL_OK; } -s32 cellOskDialogAbort() +error_code cellOskDialogAbort() { cellOskDialog.warning("cellOskDialogAbort()"); @@ -203,14 +216,12 @@ s32 cellOskDialogAbort() // Check for open dialog. In this case the dialog is only "Open" if it was not aborted before. if (!dlg || dlg->state.load() == MsgDialogState::Abort) { - cellOskDialog.error("cellOskDialogAbort: CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED"); return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED; } // If the dialog has the Open state then it is in use. Only dialogs with the Close state can be aborted. if (!dlg->state.compare_and_swap_test(MsgDialogState::Open, MsgDialogState::Abort)) { - cellOskDialog.error("cellOskDialogAbort: CELL_SYSUTIL_ERROR_BUSY"); return CELL_SYSUTIL_ERROR_BUSY; } @@ -222,13 +233,13 @@ s32 cellOskDialogAbort() return CELL_OK; } -s32 cellOskDialogSetDeviceMask(u32 deviceMask) +error_code cellOskDialogSetDeviceMask(u32 deviceMask) { cellOskDialog.todo("cellOskDialogSetDeviceMask(deviceMask=0x%x)", deviceMask); return CELL_OK; } -s32 cellOskDialogSetSeparateWindowOption(vm::ptr windowOption) +error_code cellOskDialogSetSeparateWindowOption(vm::ptr windowOption) { cellOskDialog.todo("cellOskDialogSetSeparateWindowOption(windowOption=*0x%x)", windowOption); @@ -237,145 +248,145 @@ s32 cellOskDialogSetSeparateWindowOption(vm::ptr inputDevice) +error_code cellOskDialogSetInitialInputDevice(vm::ptr inputDevice) { cellOskDialog.todo("cellOskDialogSetInitialInputDevice(inputDevice=*0x%x)", inputDevice); return CELL_OK; } -s32 cellOskDialogSetInitialKeyLayout(vm::ptr initialKeyLayout) +error_code cellOskDialogSetInitialKeyLayout(vm::ptr initialKeyLayout) { cellOskDialog.todo("cellOskDialogSetInitialKeyLayout(initialKeyLayout=*0x%x)", initialKeyLayout); return CELL_OK; } -s32 cellOskDialogDisableDimmer() +error_code cellOskDialogDisableDimmer() { cellOskDialog.todo("cellOskDialogDisableDimmer()"); return CELL_OK; } -s32 cellOskDialogSetKeyLayoutOption(u32 option) +error_code cellOskDialogSetKeyLayoutOption(u32 option) { cellOskDialog.todo("cellOskDialogSetKeyLayoutOption(option=0x%x)", option); return CELL_OK; } -s32 cellOskDialogAddSupportLanguage(u32 supportLanguage) +error_code cellOskDialogAddSupportLanguage(u32 supportLanguage) { cellOskDialog.todo("cellOskDialogAddSupportLanguage(supportLanguage=0x%x)", supportLanguage); return CELL_OK; } -s32 cellOskDialogSetLayoutMode(s32 layoutMode) +error_code cellOskDialogSetLayoutMode(s32 layoutMode) { cellOskDialog.todo("cellOskDialogSetLayoutMode(layoutMode=%d)", layoutMode); return CELL_OK; } -s32 cellOskDialogGetInputText(vm::ptr OutputInfo) +error_code cellOskDialogGetInputText(vm::ptr OutputInfo) { cellOskDialog.warning("cellOskDialogGetInputText(OutputInfo=*0x%x)", OutputInfo); return getText(OutputInfo, false); } -s32 cellOskDialogExtInputDeviceUnlock() +error_code cellOskDialogExtInputDeviceUnlock() { cellOskDialog.todo("cellOskDialogExtInputDeviceUnlock()"); return CELL_OK; } -s32 cellOskDialogExtRegisterKeyboardEventHookCallback(u16 hookEventMode, vm::ptr pCallback) +error_code cellOskDialogExtRegisterKeyboardEventHookCallback(u16 hookEventMode, vm::ptr pCallback) { cellOskDialog.todo("cellOskDialogExtRegisterKeyboardEventHookCallback(hookEventMode=%u, pCallback=*0x%x)", hookEventMode, pCallback); return CELL_OK; } -s32 cellOskDialogExtRegisterKeyboardEventHookCallbackEx(u16 hookEventMode, vm::ptr pCallback) +error_code cellOskDialogExtRegisterKeyboardEventHookCallbackEx(u16 hookEventMode, vm::ptr pCallback) { cellOskDialog.todo("cellOskDialogExtRegisterKeyboardEventHookCallbackEx(hookEventMode=%u, pCallback=*0x%x)", hookEventMode, pCallback); return CELL_OK; } -s32 cellOskDialogExtAddJapaneseOptionDictionary(vm::cpptr filePath) +error_code cellOskDialogExtAddJapaneseOptionDictionary(vm::cpptr filePath) { cellOskDialog.todo("cellOskDialogExtAddJapaneseOptionDictionary(filePath=**0x%0x)", filePath); return CELL_OK; } -s32 cellOskDialogExtEnableClipboard() +error_code cellOskDialogExtEnableClipboard() { cellOskDialog.todo("cellOskDialogExtEnableClipboard()"); return CELL_OK; } -s32 cellOskDialogExtSendFinishMessage(s32 /*CellOskDialogFinishReason*/ finishReason) +error_code cellOskDialogExtSendFinishMessage(s32 /*CellOskDialogFinishReason*/ finishReason) { cellOskDialog.todo("cellOskDialogExtSendFinishMessage(finishReason=%d)", finishReason); return CELL_OK; } -s32 cellOskDialogExtAddOptionDictionary(vm::cptr dictionaryInfo) +error_code cellOskDialogExtAddOptionDictionary(vm::cptr dictionaryInfo) { cellOskDialog.todo("cellOskDialogExtAddOptionDictionary(dictionaryInfo=*0x%x)", dictionaryInfo); return CELL_OK; } -s32 cellOskDialogExtSetInitialScale(f32 initialScale) +error_code cellOskDialogExtSetInitialScale(f32 initialScale) { cellOskDialog.todo("cellOskDialogExtSetInitialScale(initialScale=%f)", initialScale); return CELL_OK; } -s32 cellOskDialogExtInputDeviceLock() +error_code cellOskDialogExtInputDeviceLock() { cellOskDialog.todo("cellOskDialogExtInputDeviceLock()"); return CELL_OK; } -s32 cellOskDialogExtSetBaseColor(f32 red, f32 blue, f32 green, f32 alpha) +error_code cellOskDialogExtSetBaseColor(f32 red, f32 blue, f32 green, f32 alpha) { cellOskDialog.warning("cellOskDialogExtSetBaseColor(red=%f, blue=%f, green=%f, alpha=%f)", red, blue, green, alpha); return CELL_OK; } -s32 cellOskDialogExtRegisterConfirmWordFilterCallback(vm::ptr pCallback) +error_code cellOskDialogExtRegisterConfirmWordFilterCallback(vm::ptr pCallback) { cellOskDialog.todo("cellOskDialogExtRegisterConfirmWordFilterCallback(pCallback=*0x%x)", pCallback); return CELL_OK; } -s32 cellOskDialogExtUpdateInputText() +error_code cellOskDialogExtUpdateInputText() { cellOskDialog.todo("cellOskDialogExtUpdateInputText()"); return CELL_OK; } -s32 cellOskDialogExtDisableHalfByteKana() +error_code cellOskDialogExtDisableHalfByteKana() { cellOskDialog.todo("cellOskDialogExtDisableHalfByteKana()"); return CELL_OK; } -s32 cellOskDialogExtSetPointerEnable(b8 enable) +error_code cellOskDialogExtSetPointerEnable(b8 enable) { cellOskDialog.todo("cellOskDialogExtSetPointerEnable(enable=%d)", enable); return CELL_OK; } -s32 cellOskDialogExtUpdatePointerDisplayPos(/*const CellOskDialogPoint pos*/) +error_code cellOskDialogExtUpdatePointerDisplayPos(/*const CellOskDialogPoint pos*/) { cellOskDialog.todo("cellOskDialogExtUpdatePointerDisplayPos(posX=%f, posY=%f)"/*, pos.x, pos.y*/); return CELL_OK; } -s32 cellOskDialogExtEnableHalfByteKana() +error_code cellOskDialogExtEnableHalfByteKana() { cellOskDialog.todo("cellOskDialogExtEnableHalfByteKana()"); return CELL_OK; } -s32 cellOskDialogExtRegisterForceFinishCallback(vm::ptr pCallback) +error_code cellOskDialogExtRegisterForceFinishCallback(vm::ptr pCallback) { cellOskDialog.todo("cellOskDialogExtRegisterForceFinishCallback(pCallback=*0x%x)", pCallback); return CELL_OK; diff --git a/rpcs3/Emu/Cell/Modules/cellOskDialog.h b/rpcs3/Emu/Cell/Modules/cellOskDialog.h index 260c6bd023..3e017c2374 100644 --- a/rpcs3/Emu/Cell/Modules/cellOskDialog.h +++ b/rpcs3/Emu/Cell/Modules/cellOskDialog.h @@ -3,7 +3,7 @@ // error codes -enum +enum CellOskDialogError : u32 { CELL_OSKDIALOG_ERROR_IME_ALREADY_IN_USE = 0x8002b501, CELL_OSKDIALOG_ERROR_GET_SIZE_ERROR = 0x8002b502, diff --git a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp index 7cb9d370bf..9818efcb31 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp @@ -10,6 +10,26 @@ LOG_CHANNEL(cellSysutil); +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_SYSUTIL_ERROR_TYPE); + STR_CASE(CELL_SYSUTIL_ERROR_VALUE); + STR_CASE(CELL_SYSUTIL_ERROR_SIZE); + STR_CASE(CELL_SYSUTIL_ERROR_NUM); + STR_CASE(CELL_SYSUTIL_ERROR_BUSY); + STR_CASE(CELL_SYSUTIL_ERROR_STATUS); + STR_CASE(CELL_SYSUTIL_ERROR_MEMORY); + } + + return unknown; + }); +} + struct sysutil_cb_manager { struct alignas(8) registered_cb diff --git a/rpcs3/Emu/Cell/Modules/cellSysutil.h b/rpcs3/Emu/Cell/Modules/cellSysutil.h index 1430c51c0a..a65461899f 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutil.h +++ b/rpcs3/Emu/Cell/Modules/cellSysutil.h @@ -2,7 +2,7 @@ -enum +enum CellSysutilError : u32 { CELL_SYSUTIL_ERROR_TYPE = 0x8002b101, CELL_SYSUTIL_ERROR_VALUE = 0x8002b102,