From bdc5ed094b0fe3e4d95e4c9a096282e2f119e7b5 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Mon, 12 Apr 2021 19:28:39 +0200 Subject: [PATCH] overlays: implement OSK password mode --- rpcs3/Emu/RSX/Overlays/overlay_controls.h | 1 + rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp | 4 ++++ rpcs3/Emu/RSX/Overlays/overlay_osk.cpp | 3 +-- rpcs3/rpcs3qt/osk_dialog_frame.cpp | 7 ++++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_controls.h b/rpcs3/Emu/RSX/Overlays/overlay_controls.h index 12e5b4bc91..c1ca8cdbcf 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_controls.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_controls.h @@ -1102,6 +1102,7 @@ namespace rsx u16 vertical_scroll_offset = 0; bool m_reset_caret_pulse = false; + bool password_mode = false; std::u32string value; std::u32string placeholder; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp b/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp index 7ee0130fd8..efcce9743e 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp @@ -108,6 +108,10 @@ namespace rsx { overlay_element::set_unicode_text(placeholder); } + else if (password_mode) + { + overlay_element::set_unicode_text(std::u32string(value.size(), U"*"[0])); + } else { overlay_element::set_unicode_text(value); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp index c6c9479080..f3c1874694 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp @@ -260,6 +260,7 @@ namespace rsx m_title.set_unicode_text(title); m_title.back_color.a = 0.f; + m_preview.password_mode = m_password_mode; m_preview.set_placeholder(get_placeholder()); m_preview.set_unicode_text(initial_text); @@ -814,8 +815,6 @@ namespace rsx add_panel(osk_panel_password(shift_cb, layer_cb, space_cb, delete_cb, enter_cb)); - // TODO: hide entered text with * - m_password_mode = true; } else if (panel_flag == CELL_OSKDIALOG_PANELMODE_DEFAULT || panel_flag == CELL_OSKDIALOG_PANELMODE_DEFAULT_NO_JAPANESE) diff --git a/rpcs3/rpcs3qt/osk_dialog_frame.cpp b/rpcs3/rpcs3qt/osk_dialog_frame.cpp index 6019d10e24..18615f1e47 100644 --- a/rpcs3/rpcs3qt/osk_dialog_frame.cpp +++ b/rpcs3/rpcs3qt/osk_dialog_frame.cpp @@ -22,7 +22,7 @@ osk_dialog_frame::~osk_dialog_frame() } } -void osk_dialog_frame::Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 /*panel_flag*/, u32 /*first_view_panel*/) +void osk_dialog_frame::Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 /*first_view_panel*/) { state = OskDialogState::Open; @@ -63,6 +63,11 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me input->setText(input_text); input->setFocus(); + if (panel_flag & CELL_OSKDIALOG_PANELMODE_PASSWORD) + { + input->setEchoMode(QLineEdit::Password); // Let's assume that games only use the password mode with single-line edit fields + } + if (prohibit_flags & CELL_OSKDIALOG_NO_SPACE) { input->setValidator(new QRegExpValidator(QRegExp("^\\S*$"), this));