diff --git a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp index c9afb6995a..6c547f1230 100644 --- a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp @@ -513,6 +513,7 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr dia // Set device mask and event lock osk->ignore_input_events = info.lock_ext_input.load(); + osk->input_device = info.initial_input_device.load(); if (info.use_separate_windows) { @@ -812,7 +813,7 @@ error_code cellOskDialogSetSeparateWindowOption(vm::ptr CELL_OSKDIALOG_INPUT_DEVICE_KEYBOARD) { @@ -821,9 +822,6 @@ error_code cellOskDialogSetInitialInputDevice(u32 inputDevice) g_fxo->get().initial_input_device = static_cast(inputDevice); - // TODO: use initial_input_device - // TODO: Signal CELL_SYSUTIL_OSKDIALOG_INPUT_DEVICE_CHANGED if the input device changed (probably only when the dialog is already open) - return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/cellOskDialog.h b/rpcs3/Emu/Cell/Modules/cellOskDialog.h index 6a925f7807..90814358ca 100644 --- a/rpcs3/Emu/Cell/Modules/cellOskDialog.h +++ b/rpcs3/Emu/Cell/Modules/cellOskDialog.h @@ -311,6 +311,7 @@ public: std::function on_osk_key_input_entered; atomic_t state{ OskDialogState::Unloaded }; + atomic_t input_device{ CELL_OSKDIALOG_INPUT_DEVICE_PAD }; // The current input device. atomic_t pad_input_enabled{ true }; // Determines if the OSK consumes the device's events. atomic_t mouse_input_enabled{ true }; // Determines if the OSK consumes the device's events. atomic_t keyboard_input_enabled{ true }; // Determines if the OSK consumes the device's events. diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp index 6a0beda88f..b766472fb5 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp @@ -507,6 +507,18 @@ namespace rsx if (!pad_input_enabled || ignore_input_events) return; + if (input_device.exchange(CELL_OSKDIALOG_INPUT_DEVICE_PAD) != CELL_OSKDIALOG_INPUT_DEVICE_PAD) + { + sysutil_send_system_cmd(CELL_SYSUTIL_OSKDIALOG_INPUT_DEVICE_CHANGED, CELL_OSKDIALOG_INPUT_DEVICE_PAD); + } + + // Always show the pad input panel if the pad is enabled and in use. + if (!m_show_panel) + { + m_show_panel = true; + update_panel(); + } + const u32 grid_size = num_columns * num_rows; const auto on_accept = [this]() @@ -739,9 +751,21 @@ namespace rsx if (!pressed || !keyboard_input_enabled || ignore_input_events) return; + if (input_device.exchange(CELL_OSKDIALOG_INPUT_DEVICE_KEYBOARD) != CELL_OSKDIALOG_INPUT_DEVICE_KEYBOARD) + { + sysutil_send_system_cmd(CELL_SYSUTIL_OSKDIALOG_INPUT_DEVICE_CHANGED, CELL_OSKDIALOG_INPUT_DEVICE_KEYBOARD); + } + + if (m_use_separate_windows && m_show_panel) + { + // Hide the pad input panel if the keyboard is in use during separate windows. + m_show_panel = false; + update_panel(); + } + const bool use_key_string_fallback = !key.empty(); - osk.error("osk_dialog::on_key_pressed(led=%d, mkey=%d, key_code=%d, out_key_code=%d, pressed=%d, use_key_string_fallback=%d)", led, mkey, key_code, out_key_code, pressed, use_key_string_fallback); + osk.notice("osk_dialog::on_key_pressed(led=%d, mkey=%d, key_code=%d, out_key_code=%d, pressed=%d, use_key_string_fallback=%d)", led, mkey, key_code, out_key_code, pressed, use_key_string_fallback); if (!use_key_string_fallback) { @@ -1153,10 +1177,8 @@ namespace rsx if (m_use_separate_windows) { - // When using separate windows, we show the text field, but hide the pad input panel if the device mask contains CELL_OSKDIALOG_DEVICE_MASK_PAD. - // TODO: If controller input is allowed and the user presses a button, show the pad input panel. - // TODO: If keyboard input is allowed and the user presses a key, hide the pad input panel. - m_show_panel = pad_input_enabled; + // When using separate windows, we show the text field, but hide the pad input panel if the input device is a pad. + m_show_panel = pad_input_enabled && input_device == CELL_OSKDIALOG_INPUT_DEVICE_PAD; m_title.back_color.a = std::clamp(params.input_field_background_transparency, 0.0f, 1.0f); m_preview.back_color.a = std::clamp(params.input_field_background_transparency, 0.0f, 1.0f); }