diff --git a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp index b0af953cec..1ca32b6f4d 100644 --- a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp @@ -51,6 +51,10 @@ void fmt_class_string::format(std::string& out, u64 }); } +atomic_t g_osk_pointer_enabled = false; +atomic_t g_osk_pointer_x = 0.0f; +atomic_t g_osk_pointer_y = 0.0f; + OskDialogBase::~OskDialogBase() { } @@ -535,6 +539,11 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr dia Emu.BlockingCallFromMainThread([=, &info]() { + // Make sure to always have the latest pointer params + g_osk_pointer_enabled = info.pointer_enabled.load(); + g_osk_pointer_x = info.pointer_pos.x; + g_osk_pointer_y = info.pointer_pos.y; + osk->Create({ .title = get_localized_string(localized_string_id::CELL_OSK_DIALOG_TITLE), .message = message, @@ -802,7 +811,7 @@ error_code cellOskDialogSetInitialInputDevice(u32 inputDevice) error_code cellOskDialogSetInitialKeyLayout(u32 initialKeyLayout) { - cellOskDialog.todo("cellOskDialogSetInitialKeyLayout(initialKeyLayout=%d)", initialKeyLayout); + cellOskDialog.warning("cellOskDialogSetInitialKeyLayout(initialKeyLayout=%d)", initialKeyLayout); if (initialKeyLayout > CELL_OSKDIALOG_INITIAL_PANEL_LAYOUT_FULLKEY) { @@ -830,7 +839,7 @@ error_code cellOskDialogDisableDimmer() error_code cellOskDialogSetKeyLayoutOption(u32 option) { - cellOskDialog.todo("cellOskDialogSetKeyLayoutOption(option=0x%x)", option); + cellOskDialog.warning("cellOskDialogSetKeyLayoutOption(option=0x%x)", option); if (option == 0 || option > 3) // CELL_OSKDIALOG_10KEY_PANEL OR CELL_OSKDIALOG_FULLKEY_PANEL { @@ -844,7 +853,7 @@ error_code cellOskDialogSetKeyLayoutOption(u32 option) error_code cellOskDialogAddSupportLanguage(u32 supportLanguage) { - cellOskDialog.todo("cellOskDialogAddSupportLanguage(supportLanguage=0x%x)", supportLanguage); + cellOskDialog.warning("cellOskDialogAddSupportLanguage(supportLanguage=0x%x)", supportLanguage); // TODO: error checks @@ -855,7 +864,7 @@ error_code cellOskDialogAddSupportLanguage(u32 supportLanguage) error_code cellOskDialogSetLayoutMode(s32 layoutMode) { - cellOskDialog.todo("cellOskDialogSetLayoutMode(layoutMode=0x%x)", layoutMode); + cellOskDialog.warning("cellOskDialogSetLayoutMode(layoutMode=0x%x)", layoutMode); // TODO: error checks @@ -985,7 +994,7 @@ error_code cellOskDialogExtAddOptionDictionary(vm::cptr CELL_OSKDIALOG_SCALE_MAX) { @@ -1087,30 +1096,29 @@ error_code cellOskDialogExtUpdateInputText() error_code cellOskDialogExtSetPointerEnable(b8 enable) { - cellOskDialog.todo("cellOskDialogExtSetPointerEnable(enable=%d)", enable); + cellOskDialog.warning("cellOskDialogExtSetPointerEnable(enable=%d)", enable); // TODO: error checks g_fxo->get().pointer_enabled = enable; - - // TODO: Show/hide pointer at the specified position in the OSK overlay. + g_osk_pointer_enabled = enable; return CELL_OK; } error_code cellOskDialogExtUpdatePointerDisplayPos(vm::cptr pos) { - cellOskDialog.todo("cellOskDialogExtUpdatePointerDisplayPos(pos=0x%x, posX=%f, posY=%f)", pos->x, pos->y); + cellOskDialog.warning("cellOskDialogExtUpdatePointerDisplayPos(pos=0x%x, posX=%f, posY=%f)", pos->x, pos->y); // TODO: error checks if (pos) { g_fxo->get().pointer_pos = *pos; + g_osk_pointer_x = pos->x; + g_osk_pointer_y = pos->y; } - // TODO: Update pointer position in the OSK overlay. - return CELL_OK; } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_cursor.cpp b/rpcs3/Emu/RSX/Overlays/overlay_cursor.cpp index 3ad3d3b191..0a9f858c0d 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_cursor.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_cursor.cpp @@ -56,6 +56,11 @@ namespace rsx return m_visible; } + bool cursor_item::visible() const + { + return m_visible; + } + compiled_resource cursor_item::get_compiled() { if (!m_visible) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_cursor.h b/rpcs3/Emu/RSX/Overlays/overlay_cursor.h index ebf39a4fc9..25df0b5245 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_cursor.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_cursor.h @@ -23,6 +23,7 @@ namespace rsx bool set_color(color4f color); bool update_visibility(u64 time); + bool visible() const; compiled_resource get_compiled(); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp index b049670932..7829e3ff3d 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp @@ -7,6 +7,10 @@ LOG_CHANNEL(osk, "OSK"); +extern atomic_t g_osk_pointer_enabled; +extern atomic_t g_osk_pointer_x; +extern atomic_t g_osk_pointer_y; + namespace rsx { namespace overlays @@ -304,6 +308,8 @@ namespace rsx } }; + m_pointer.set_color(color4f{ 1.f, 1.f, 1.f, 1.f }); + m_background.set_size(virtual_width, virtual_height); m_title.set_unicode_text(title); @@ -876,6 +882,18 @@ namespace rsx fade_animation.update(rsx::get_current_renderer()->vblank_count); m_update = true; } + + if (g_osk_pointer_enabled != m_pointer.visible()) + { + m_pointer.set_expiration(g_osk_pointer_enabled ? u64{umax} : 0); + m_pointer.update_visibility(get_system_time()); + m_update = true; + } + + if (m_pointer.visible() && m_pointer.set_position(static_cast(g_osk_pointer_x), static_cast(g_osk_pointer_y))) + { + m_update = true; + } } compiled_resource osk_dialog::get_compiled() @@ -995,6 +1013,7 @@ namespace rsx } } + m_cached_resource.add(m_pointer.get_compiled()); m_reset_pulse = false; m_update = false; } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.h b/rpcs3/Emu/RSX/Overlays/overlay_osk.h index 7f27e33dc9..0c4007260f 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.h @@ -2,6 +2,7 @@ #include "overlays.h" #include "overlay_edit_text.hpp" +#include "overlay_cursor.h" #include "overlay_osk_panel.h" #include "Emu/Cell/Modules/cellOskDialog.h" @@ -51,6 +52,9 @@ namespace rsx image_button m_btn_space; image_button m_btn_delete; + // Pointer + cursor_item m_pointer{}; + // Grid u16 cell_size_x = 0; u16 cell_size_y = 0;