From f2ba41af468cfbd09683b78b5cb6689b7f4a3726 Mon Sep 17 00:00:00 2001 From: al0xf Date: Wed, 18 Jan 2017 23:01:25 +0100 Subject: [PATCH] Stub cellOsk (#2264) * Stub cellOsk Returns the word "rpcs3" as OSK input for now. Tested and working in Terraria, Nier, and some homebrew. The next step would be to hook it up to the GUI so the user can enter any text. * Fix commit * Fix formatting * cellOsk improvements * cellOsk improvements --- rpcs3/Emu/Cell/Modules/cellOskDialog.cpp | 126 ++++++++++++------- rpcs3/Emu/Cell/Modules/cellOskDialog.h | 153 +++++++++++++++++++++++ 2 files changed, 234 insertions(+), 45 deletions(-) create mode 100644 rpcs3/Emu/Cell/Modules/cellOskDialog.h diff --git a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp index e9f65134f2..1105cf9a41 100644 --- a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp @@ -1,77 +1,100 @@ #include "stdafx.h" #include "Emu/Cell/PPUModule.h" +#include "cellSysutil.h" +#include "cellOskDialog.h" logs::channel cellOskDialog("cellOskDialog", logs::level::notice); -s32 cellOskDialogLoadAsync() +s32 cellOskDialogLoadAsync(u32 container, vm::ptr dialogParam, vm::ptr inputFieldInfo) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.warning("cellOskDialogLoadAsync(container=0x%x, dialogParam=*0x%x, inputFieldInfo=*0x%x)", container, dialogParam, inputFieldInfo); + sysutil_send_system_cmd(CELL_SYSUTIL_OSKDIALOG_FINISHED, 0); //Immediately signal that input is finished. TODO: Get actual input. + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogUnloadAsync() +s32 cellOskDialogUnloadAsync(vm::ptr OutputInfo) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.warning("cellOskDialogUnloadAsync(OutputInfo=*0x%x)", OutputInfo); + OutputInfo->result = CELL_OSKDIALOG_INPUT_FIELD_RESULT_OK; + + be_t input[6] = { 'r', 'p', 'c', 's', '3', 0x0 }; //TODO: Get actual input instead. + std::memcpy(OutputInfo->pResultString.get_ptr(), input, sizeof(input)); + + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogGetSize() +s32 cellOskDialogGetSize(vm::ptr width, vm::ptr height, vm::ptr dialogType) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.warning("cellOskDialogGetSize(width=*0x%x, height=*0x%x, dialogType=*0x%x)", width, height, dialogType); + *width = 1; + *height = 1; + return CELL_OSKDIALOG_OK; } s32 cellOskDialogAbort() { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogAbort()"); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogSetDeviceMask() +s32 cellOskDialogSetDeviceMask(u32 deviceMask) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogSetDeviceMask(deviceMask=0x%x)", deviceMask); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogSetSeparateWindowOption() +s32 cellOskDialogSetSeparateWindowOption(vm::ptr windowOption) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogSetSeparateWindowOption(windowOption=*0x%x)", windowOption); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogSetInitialInputDevice() +s32 cellOskDialogSetInitialInputDevice(vm::ptr inputDevice) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogSetInitialInputDevice(inputDevice=*0x%x)", inputDevice); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogSetInitialKeyLayout() +s32 cellOskDialogSetInitialKeyLayout(vm::ptr initialKeyLayout) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogSetInitialKeyLayout(initialKeyLayout=*0x%x)", initialKeyLayout); + return CELL_OSKDIALOG_OK; } s32 cellOskDialogDisableDimmer() { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogDisableDimmer()"); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogSetKeyLayoutOption() +s32 cellOskDialogSetKeyLayoutOption(u32 option) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogSetKeyLayoutOption(option=0x%x)", option); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogAddSupportLanguage() +s32 cellOskDialogAddSupportLanguage(u32 supportLanguage) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogAddSupportLanguage(supportLanguage=0x%x)", supportLanguage); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogSetLayoutMode() +s32 cellOskDialogSetLayoutMode(s32 layoutMode) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogSetLayoutMode(layoutMode=%d)", layoutMode); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogGetInputText() +s32 cellOskDialogGetInputText(vm::ptr OutputInfo) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.warning("cellOskDialogGetInputText(OutputInfo=*0x%x)", OutputInfo); + return cellOskDialogUnloadAsync(OutputInfo); //Same but for use with cellOskDialogSetSeparateWindowOption(). TODO. } - s32 cellOskDialogExtInputDeviceUnlock() { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtInputDeviceUnlock()"); + return CELL_OSKDIALOG_OK; } s32 cellOskDialogExtRegisterKeyboardEventHookCallback() @@ -79,39 +102,46 @@ s32 cellOskDialogExtRegisterKeyboardEventHookCallback() fmt::throw_exception("Unimplemented" HERE); } -s32 cellOskDialogExtAddJapaneseOptionDictionary() +s32 cellOskDialogExtAddJapaneseOptionDictionary(vm::cptr filePath) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtAddJapaneseOptionDictionary(filePath=*0x%0x)", filePath); + return CELL_OSKDIALOG_OK; } s32 cellOskDialogExtEnableClipboard() { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtEnableClipboard()"); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogExtSendFinishMessage() +s32 cellOskDialogExtSendFinishMessage(vm::ptr finishReason) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtSendFinishMessage(finishReason=*0x%x)", finishReason); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogExtAddOptionDictionary() +s32 cellOskDialogExtAddOptionDictionary(vm::cptr dictionaryInfo) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtAddOptionDictionary(dictionaryInfo=*0x%x)", dictionaryInfo); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogExtSetInitialScale() +s32 cellOskDialogExtSetInitialScale(f32 initialScale) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtSetInitialScale(initialScale=0x%x)", initialScale); + return CELL_OSKDIALOG_OK; } s32 cellOskDialogExtInputDeviceLock() { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtInputDeviceLock()"); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogExtSetBaseColor() +s32 cellOskDialogExtSetBaseColor(f32 red, f32 blue, f32 green, f32 alpha) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.warning("cellOskDialogExtSetBaseColor(red=0x%x, blue=0x%x, green=0x%x, alpha=0x%x)", red, blue, green, alpha); + return CELL_OSKDIALOG_OK; } s32 cellOskDialogExtRegisterConfirmWordFilterCallback() @@ -121,32 +151,38 @@ s32 cellOskDialogExtRegisterConfirmWordFilterCallback() s32 cellOskDialogExtUpdateInputText() { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtUpdateInputText"); + return CELL_OSKDIALOG_OK; } s32 cellOskDialogExtDisableHalfByteKana() { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtDisableHalfByteKana"); + return CELL_OSKDIALOG_OK; } -s32 cellOskDialogExtSetPointerEnable() +s32 cellOskDialogExtSetPointerEnable(b8 enable) { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtSetPointerEnable(enable=%d)", enable); + return CELL_OSKDIALOG_OK; } s32 cellOskDialogExtUpdatePointerDisplayPos() { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtUpdatePointerDisplayPos()"); + return CELL_OSKDIALOG_OK; } s32 cellOskDialogExtEnableHalfByteKana() { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtEnableHalfByteKana()"); + return CELL_OSKDIALOG_OK; } s32 cellOskDialogExtRegisterForceFinishCallback() { - fmt::throw_exception("Unimplemented" HERE); + cellOskDialog.todo("cellOskDialogExtRegisterForceFinishCallback()"); + return CELL_OSKDIALOG_OK; } diff --git a/rpcs3/Emu/Cell/Modules/cellOskDialog.h b/rpcs3/Emu/Cell/Modules/cellOskDialog.h new file mode 100644 index 0000000000..2f938382c6 --- /dev/null +++ b/rpcs3/Emu/Cell/Modules/cellOskDialog.h @@ -0,0 +1,153 @@ +#pragma once + +namespace vm { using namespace ps3; } + +//error codes +enum +{ + CELL_OSKDIALOG_OK = 0x0, + CELL_OSKDIALOG_ERROR_IME_ALREADY_IN_USE = 0x8002b501, + CELL_OSKDIALOG_ERROR_GET_SIZE_ERROR = 0x8002b502, + CELL_OSKDIALOG_ERROR_UNKNOWN = 0x8002b503, + CELL_OSKDIALOG_ERROR_PARAM = 0x8002b504, +}; + +//OSK status for the callback +enum +{ + CELL_SYSUTIL_OSKDIALOG_LOADED = 0x0502, + CELL_SYSUTIL_OSKDIALOG_FINISHED = 0x0503, + CELL_SYSUTIL_OSKDIALOG_UNLOADED = 0x0504, + CELL_SYSUTIL_OSKDIALOG_INPUT_ENTERED = 0x0505, + CELL_SYSUTIL_OSKDIALOG_INPUT_CANCELED = 0x0506, + CELL_SYSUTIL_OSKDIALOG_INPUT_DEVICE_CHANGED = 0x0507, + CELL_SYSUTIL_OSKDIALOG_DISPLAY_CHANGED = 0x0508, +}; + +enum CellOskDialogInputFieldResult +{ + CELL_OSKDIALOG_INPUT_FIELD_RESULT_OK = 0, + CELL_OSKDIALOG_INPUT_FIELD_RESULT_CANCELED = 1, + CELL_OSKDIALOG_INPUT_FIELD_RESULT_ABORT = 2, + CELL_OSKDIALOG_INPUT_FIELD_RESULT_NO_INPUT_TEXT = 3, +}; + +enum CellOskDialogInitialKeyLayout +{ + CELL_OSKDIALOG_INITIAL_PANEL_LAYOUT_SYSTEM = 0, + CELL_OSKDIALOG_INITIAL_PANEL_LAYOUT_10KEY = 1, + CELL_OSKDIALOG_INITIAL_PANEL_LAYOUT_FULLKEY = 2, +}; + +enum CellOskDialogInputDevice +{ + CELL_OSKDIALOG_INPUT_DEVICE_PAD = 0, + CELL_OSKDIALOG_INPUT_DEVICE_KEYBOARD = 1, +}; + +enum CellOskDialogContinuousMode +{ + CELL_OSKDIALOG_CONTINUOUS_MODE_NONE = 0, + CELL_OSKDIALOG_CONTINUOUS_MODE_REMAIN_OPEN = 1, + CELL_OSKDIALOG_CONTINUOUS_MODE_HIDE = 2, + CELL_OSKDIALOG_CONTINUOUS_MODE_SHOW = 3, +}; + +enum CellOskDialogDisplayStatus +{ + CELL_OSKDIALOG_DISPLAY_STATUS_HIDE = 0, + CELL_OSKDIALOG_DISPLAY_STATUS_SHOW = 1, +}; + +enum CellOskDialogFilterCallbackReturnValue +{ + CELL_OSKDIALOG_NOT_CHANGE = 0, + CELL_OSKDIALOG_CHANGE_WORD = 1, +}; + +enum CellOskDialogActionValue +{ + CELL_OSKDIALOG_CHANGE_NO_EVENT = 0, + CELL_OSKDIALOG_CHANGE_EVENT_CANCEL = 1, + CELL_OSKDIALOG_CHANGE_WORDS_INPUT = 3, + CELL_OSKDIALOG_CHANGE_WORDS_INSERT = 4, + CELL_OSKDIALOG_CHANGE_WORDS_REPLACE_ALL = 6, +}; + +enum CellOskDialogFinishReason +{ + CELL_OSKDIALOG_CLOSE_CONFIRM = 0, + CELL_OSKDIALOG_CLOSE_CANCEL = 1, +}; + +enum CellOskDialogType +{ + CELL_OSKDIALOG_TYPE_SINGLELINE_OSK = 0, + CELL_OSKDIALOG_TYPE_MULTILINE_OSK = 1, + CELL_OSKDIALOG_TYPE_FULL_KEYBOARD_SINGLELINE_OSK = 2, + CELL_OSKDIALOG_TYPE_FULL_KEYBOARD_MULTILINE_OSK = 3, + CELL_OSKDIALOG_TYPE_SEPARATE_SINGLELINE_TEXT_WINDOW = 4, + CELL_OSKDIALOG_TYPE_SEPARATE_MULTILINE_TEXT_WINDOW = 5, + CELL_OSKDIALOG_TYPE_SEPARATE_INPUT_PANEL_WINDOW = 6, + CELL_OSKDIALOG_TYPE_SEPARATE_FULL_KEYBOARD_INPUT_PANEL_WINDOW = 7, + CELL_OSKDIALOG_TYPE_SEPARATE_CANDIDATE_WINDOW = 8, +}; + +struct CellOskDialogInputFieldInfo +{ + vm::bptr message; + vm::bptr init_text; + be_t limit_length; +}; + +struct CellOskDialogPoint +{ + be_t x; + be_t y; +}; + +struct CellOskDialogParam +{ + be_t allowOskPanelFlg; + be_t firstViewPanel; + CellOskDialogPoint controlPoint; + be_t prohibitFlgs; +}; + +//Actual input data +struct CellOskDialogCallbackReturnParam +{ + be_t result; //CellOskDialogInputFieldResult + be_t numCharsResultString; + vm::bptr pResultString; +}; + +struct CellOskDialogLayoutInfo +{ + be_t layoutMode; + CellOskDialogPoint position; +}; + +struct CellOskDialogSeparateWindowOption +{ + be_t continuousMode; //CellOskDialogContinuousMode + be_t deviceMask; + be_t inputFieldWindowWidth; + be_t inputFieldBackgroundTrans; + vm::bptr inputFieldLayoutInfo; + vm::bptr inputPanelLayoutInfo; + vm::bptr reserved; +}; + +struct CellOskDialogKeyMessage +{ + be_t led; + be_t mkey; + be_t keycode; +}; + +struct CellOskDialogImeDictionaryInfo +{ + be_t targetLanguage; + vm::bcptr dictionaryPath; +};