overlays: implement osk panels

This commit is contained in:
Megamouse 2020-03-14 22:03:56 +01:00
parent 27367dc493
commit f1127f1894
13 changed files with 1057 additions and 197 deletions

View file

@ -396,6 +396,7 @@ target_sources(rpcs3_emu PRIVATE
RSX/Overlays/overlay_list_view.cpp
RSX/Overlays/overlay_message_dialog.cpp
RSX/Overlays/overlay_osk.cpp
RSX/Overlays/overlay_osk_panel.cpp
RSX/Overlays/overlay_perf_metrics.cpp
RSX/Overlays/overlay_progress_bar.cpp
RSX/Overlays/overlay_save_dialog.cpp

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/RSX/Overlays/overlay_osk.h"
#include "Input/pad_thread.h"
@ -62,8 +63,7 @@ std::shared_ptr<OskDialogBase> _get_osk_dialog(bool create = false)
if (auto manager = g_fxo->get<rsx::overlays::display_manager>())
{
auto dlg = std::make_shared<rsx::overlays::osk_latin>();
std::shared_ptr<rsx::overlays::osk_dialog> dlg = std::make_shared<rsx::overlays::osk_dialog>();
osk->dlg = manager->add(dlg);
}
else
@ -105,7 +105,9 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr<CellOskDialogParam> dia
// Get the OSK options
u32 maxLength = (inputFieldInfo->limit_length >= CELL_OSKDIALOG_STRING_SIZE) ? 511 : u32{inputFieldInfo->limit_length};
u32 options = dialogParam->prohibitFlgs;
const u32 prohibitFlgs = dialogParam->prohibitFlgs;
const u32 allowOskPanelFlg = dialogParam->allowOskPanelFlg;
const u32 firstViewPanel = dialogParam->firstViewPanel;
// Get init text and prepare return value
osk->osk_input_result = CELL_OSKDIALOG_INPUT_FIELD_RESULT_OK;
@ -242,7 +244,7 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr<CellOskDialogParam> dia
Emu.CallAfter([=, &result]()
{
osk->Create("On Screen Keyboard", message, osk->osk_text, maxLength, options);
osk->Create("On Screen Keyboard", message, osk->osk_text, maxLength, prohibitFlgs, allowOskPanelFlg, firstViewPanel);
result = true;
});

View file

@ -243,7 +243,7 @@ enum class OskDialogState
class OskDialogBase
{
public:
virtual void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 options) = 0;
virtual void 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) = 0;
virtual void Close(bool accepted) = 0;
virtual ~OskDialogBase();

View file

@ -1,6 +1,9 @@
#include "stdafx.h"
#include "overlay_osk.h"
#include "Emu/RSX/RSXThread.h"
#include "Emu/Cell/Modules/cellSysutil.h"
LOG_CHANNEL(osk, "OSK");
namespace rsx
{
@ -29,14 +32,69 @@ namespace rsx
fade_animation.active = true;
}
void osk_dialog::initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::u32string& title, const std::u32string& initial_text)
void osk_dialog::add_panel(const osk_panel& panel)
{
// On PS3 apparently only 7 panels are added, the rest is ignored
if (m_panels.size() < 7)
{
// Don't add this panel if there already exists one with the same panel mode
for (const auto& existing : m_panels)
{
if (existing.osk_panel_mode == panel.osk_panel_mode)
{
return;
}
}
m_panels.push_back(panel);
}
}
void osk_dialog::step_panel(bool next_panel)
{
const size_t num_panels = m_panels.size();
if (num_panels > 0)
{
if (next_panel)
{
m_panel_index = (m_panel_index + 1) % num_panels;
}
else if (m_panel_index > 0)
{
m_panel_index = (m_panel_index - 1) % num_panels;
}
else
{
m_panel_index = num_panels - 1;
}
}
update_panel();
}
void osk_dialog::update_panel()
{
ASSERT(m_panel_index < m_panels.size());
const auto panel = m_panels[m_panel_index];
num_rows = panel.num_rows;
num_columns = panel.num_columns;
cell_size_x = panel.cell_size_x;
cell_size_y = panel.cell_size_y;
update_layout();
const u32 cell_count = num_rows * num_columns;
m_grid.resize(cell_count);
num_shift_layers_by_charset.clear();
const position2u grid_origin = { m_frame.x, m_frame.y + 30u + m_preview.h };
u32 index = 0;
for (const auto& props : layout)
for (const auto& props : panel.layout)
{
for (u32 c = 0; c < props.num_cell_hz; ++c)
{
@ -44,22 +102,41 @@ namespace rsx
const auto col = (index % num_columns);
verify(HERE), row < num_rows && col < num_columns;
auto &_cell = m_grid[index++];
_cell.pos = { col * cell_size_x, row * cell_size_y };
auto& _cell = m_grid[index++];
_cell.button_flag = props.type_flags;
_cell.pos = { grid_origin.x + col * cell_size_x, grid_origin.y + row * cell_size_y };
_cell.backcolor = props.color;
_cell.callback = props.callback;
_cell.outputs = props.outputs;
_cell.selected = false;
for (u32 mode = 0; mode < layer_mode::mode_count && mode < _cell.outputs.size(); ++mode)
// Add shift layers
for (u32 layer = 0; layer < _cell.outputs.size(); ++layer)
{
if (mode >= num_layers.size())
// Only add a shift layer if at least one default button has content in a layer
if (props.type_flags != button_flags::_default)
{
num_layers.push_back(u32(_cell.outputs[mode].size()));
continue;
}
size_t cell_shift_layers = 0;
for (size_t i = 0; i < _cell.outputs[layer].size(); ++i)
{
if (_cell.outputs[layer][i].empty() == false)
{
cell_shift_layers = i + 1;
}
}
if (layer >= num_shift_layers_by_charset.size())
{
num_shift_layers_by_charset.push_back(u32(cell_shift_layers));
}
else
{
num_layers[mode] = std::max(num_layers[mode], u32(_cell.outputs[mode].size()));
num_shift_layers_by_charset[layer] = std::max(num_shift_layers_by_charset[layer], u32(cell_shift_layers));
}
}
@ -78,8 +155,8 @@ namespace rsx
case button_flags::_shift:
_cell.enabled |= !_cell.outputs.empty();
break;
case button_flags::_mode:
_cell.enabled |= !num_layers.empty();
case button_flags::_layer:
_cell.enabled |= !num_shift_layers_by_charset.empty();
break;
}
@ -105,21 +182,26 @@ namespace rsx
}
}
verify(HERE), num_layers.size();
verify(HERE), num_shift_layers_by_charset.size();
for (u32 mode = 0; mode < layer_mode::mode_count && mode < num_layers.size(); ++mode)
for (u32 layer = 0; layer < num_shift_layers_by_charset.size(); ++layer)
{
verify(HERE), num_layers[mode];
verify(HERE), num_shift_layers_by_charset[layer];
}
// TODO: Should just scan for the first enabled cell
selected_x = selected_y = selected_z = 0;
m_grid[0].selected = true;
m_selected_charset = 0;
m_background.set_size(1280, 720);
m_background.back_color.a = 0.8f;
update_controls();
const int preview_height = (flags & CELL_OSKDIALOG_NO_RETURN) ? 40 : 90;
m_update = true;
}
void osk_dialog::update_layout()
{
const u16 preview_height = (flags & CELL_OSKDIALOG_NO_RETURN) ? 40 : 90;
// Place elements with absolute positioning
u16 frame_w = u16(num_columns * cell_size_x);
@ -129,37 +211,15 @@ namespace rsx
m_frame.set_pos(frame_x, frame_y);
m_frame.set_size(frame_w, frame_h);
m_frame.back_color = { 0.2f, 0.2f, 0.2f, 1.f };
m_title.set_pos(frame_x, frame_y);
m_title.set_size(frame_w, 30);
m_title.set_text(title);
m_title.set_padding(15, 0, 5, 0);
m_title.back_color.a = 0.f;
m_preview.set_pos(frame_x, frame_y + 30);
m_preview.set_size(frame_w, preview_height);
m_preview.set_padding(15, 0, 10, 0);
if (initial_text.empty())
{
m_preview.set_text("[Enter Text]");
m_preview.caret_position = 0;
m_preview.fore_color.a = 0.5f; // Muted contrast for hint text
}
else
{
m_preview.set_text(initial_text);
m_preview.caret_position = ::narrow<u16>(initial_text.length());
m_preview.fore_color.a = 1.f;
}
position2u grid_origin = { frame_x, frame_y + 30u + preview_height };
for (auto &_cell : m_grid)
{
_cell.pos += grid_origin;
}
m_btn_cancel.set_pos(frame_x, frame_y + frame_h + 10);
m_btn_cancel.set_size(140, 30);
m_btn_cancel.set_text("Cancel");
@ -185,6 +245,32 @@ namespace rsx
m_btn_accept.set_text("Accept");
m_btn_accept.set_text_vertical_adjust(5);
m_update = true;
}
void osk_dialog::initialize_layout(const std::u32string & title, const std::u32string & initial_text)
{
m_background.set_size(1280, 720);
m_background.back_color.a = 0.8f;
m_frame.back_color = { 0.2f, 0.2f, 0.2f, 1.f };
m_title.set_text(title);
m_title.back_color.a = 0.f;
if (initial_text.empty())
{
m_preview.set_text(get_placeholder());
m_preview.caret_position = 0;
m_preview.fore_color.a = 0.5f; // Muted contrast for hint text
}
else
{
m_preview.set_text(initial_text);
m_preview.caret_position = ::narrow<u16>(initial_text.length());
m_preview.fore_color.a = 1.f;
}
m_btn_shift.set_image_resource(resource_config::standard_image_resource::select);
m_btn_accept.set_image_resource(resource_config::standard_image_resource::start);
m_btn_space.set_image_resource(resource_config::standard_image_resource::triangle);
@ -207,19 +293,29 @@ namespace rsx
fade_animation.end = color4f(1.f);
fade_animation.duration = 0.5f;
fade_animation.active = true;
}
g_fxo->init<named_thread>("OSK Thread", [this, tbit = alloc_thread_bit()]
void osk_dialog::update_controls()
{
const bool shift_enabled = num_shift_layers_by_charset[m_selected_charset] > 1;
const bool layer_enabled = num_shift_layers_by_charset.size() > 1;
for (auto& cell : m_grid)
{
g_thread_bit = tbit;
if (auto error = run_input_loop())
switch (cell.button_flag)
{
rsx_log.error("Osk input loop exited with error code=%d", error);
case button_flags::_shift:
cell.enabled = shift_enabled;
break;
case button_flags::_layer:
cell.enabled = layer_enabled;
break;
default:
break;
}
}
thread_bits &= ~tbit;
thread_bits.notify_all();
});
m_update = true;
}
void osk_dialog::on_button_pressed(pad_button button_press)
@ -284,15 +380,15 @@ namespace rsx
u32 output_count = 0;
if (m_selected_mode < layer_mode::mode_count && m_selected_mode < current_cell.outputs.size())
if (m_selected_charset < current_cell.outputs.size())
{
output_count = ::size32(current_cell.outputs[m_selected_mode]);
output_count = ::size32(current_cell.outputs[m_selected_charset]);
}
if (output_count)
{
const auto _z = std::clamp<u32>(selected_z, 0u, output_count - 1u);
const auto& str = current_cell.outputs[m_selected_mode][_z];
const auto& str = current_cell.outputs[m_selected_charset][_z];
if (current_cell.callback)
{
@ -431,6 +527,16 @@ namespace rsx
Close(false);
break;
}
case pad_button::L2:
{
step_panel(false);
break;
}
case pad_button::R2:
{
step_panel(true);
break;
}
default:
break;
}
@ -453,7 +559,7 @@ namespace rsx
void osk_dialog::on_default_callback(const std::u32string& str)
{
// Append to output text
if (m_preview.text == U"[Enter Text]")
if (m_preview.text == get_placeholder())
{
m_preview.caret_position = ::narrow<u16>(str.length());
m_preview.set_text(str);
@ -466,7 +572,7 @@ namespace rsx
return;
}
auto new_str = m_preview.text + str;
const auto new_str = m_preview.text + str;
if (new_str.length() <= char_limit)
{
m_preview.insert_text(str);
@ -478,24 +584,25 @@ namespace rsx
void osk_dialog::on_shift(const std::u32string&)
{
switch (m_selected_mode)
{
case layer_mode::alphanumeric:
case layer_mode::extended:
case layer_mode::special:
selected_z = (selected_z + 1) % num_layers[m_selected_mode];
break;
default:
selected_z = 0;
break;
}
const u32 max = num_shift_layers_by_charset[m_selected_charset];
selected_z = (selected_z + 1) % max;
m_update = true;
}
void osk_dialog::on_mode(const std::u32string&)
void osk_dialog::on_layer(const std::u32string&)
{
const u32 num_modes = std::clamp<u32>(::size32(num_layers), 1, layer_mode::mode_count);
m_selected_mode = static_cast<layer_mode>((m_selected_mode + 1u) % num_modes);
const u32 num_charsets = std::max<u32>(::size32(num_shift_layers_by_charset), 1);
m_selected_charset = (m_selected_charset + 1) % num_charsets;
const u32 max_z_layer = num_shift_layers_by_charset[m_selected_charset] - 1;
if (selected_z > max_z_layer)
{
selected_z = max_z_layer;
}
update_controls();
m_update = true;
}
@ -513,12 +620,13 @@ namespace rsx
void osk_dialog::on_backspace(const std::u32string&)
{
m_preview.erase();
if (m_preview.text.empty())
{
return;
m_preview.set_text(get_placeholder());
}
m_preview.erase();
on_text_changed();
}
@ -534,6 +642,16 @@ namespace rsx
}
}
std::u32string osk_dialog::get_placeholder()
{
if (m_password_mode)
{
return U"[Enter Password]";
}
return U"[Enter Text]";
}
void osk_dialog::update()
{
if (fade_animation.active)
@ -595,22 +713,22 @@ namespace rsx
u32 output_count = 0;
if (m_selected_mode < layer_mode::mode_count && m_selected_mode < c.outputs.size())
if (m_selected_charset < c.outputs.size())
{
output_count = ::size32(c.outputs[m_selected_mode]);
output_count = ::size32(c.outputs[m_selected_charset]);
}
if (output_count)
{
u16 offset_x = u16(buffered_cell_count * cell_size_x);
u16 full_width = u16(offset_x + cell_size_x);
const u16 offset_x = u16(buffered_cell_count * cell_size_x);
const u16 full_width = u16(offset_x + cell_size_x);
m_label.set_pos(x - offset_x, y);
m_label.set_size(full_width, cell_size_y);
m_label.fore_color = c.enabled ? normal_fore_color : disabled_fore_color;
auto _z = (selected_z < output_count) ? selected_z : output_count - 1u;
m_label.set_text(c.outputs[m_selected_mode][_z]);
const auto _z = (selected_z < output_count) ? selected_z : output_count - 1u;
m_label.set_text(c.outputs[m_selected_charset][_z]);
m_label.align_text(rsx::overlays::overlay_element::text_align::center);
render_label = true;
}
@ -650,87 +768,168 @@ namespace rsx
return m_cached_resource;
}
// Language specific implementations
void osk_latin::Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 options)
void osk_dialog::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;
flags = options;
flags = prohibit_flags;
char_limit = charlimit;
color4f default_bg = { 0.7f, 0.7f, 0.7f, 1.f };
color4f special_bg = { 0.2f, 0.7f, 0.7f, 1.f };
color4f special2_bg = { 0.83f, 0.81f, 0.57f, 1.f };
callback_t shift_cb = std::bind(&osk_dialog::on_shift, this, std::placeholders::_1);
callback_t layer_cb = std::bind(&osk_dialog::on_layer, this, std::placeholders::_1);
callback_t space_cb = std::bind(&osk_dialog::on_space, this, std::placeholders::_1);
callback_t delete_cb = std::bind(&osk_dialog::on_backspace, this, std::placeholders::_1);
callback_t enter_cb = std::bind(&osk_dialog::on_enter, this, std::placeholders::_1);
num_rows = 5;
num_columns = 10;
cell_size_x = 50;
cell_size_y = 40;
callback_t shift_callback = std::bind(&osk_dialog::on_shift, this, std::placeholders::_1);
callback_t mode_callback = std::bind(&osk_dialog::on_mode, this, std::placeholders::_1);
callback_t space_callback = std::bind(&osk_dialog::on_space, this, std::placeholders::_1);
callback_t delete_callback = std::bind(&osk_dialog::on_backspace, this, std::placeholders::_1);
callback_t enter_callback = std::bind(&osk_dialog::on_enter, this, std::placeholders::_1);
std::vector<osk_dialog::grid_entry_ctor> layout =
if (panel_flag & CELL_OSKDIALOG_PANELMODE_PASSWORD)
{
// Row 1
{{{U"1", U"!"}, {U"à", U"À"}, {U"!", U"¡"}}, default_bg, 1},
{{{U"2", U"@"}, {U"á", U"Á"}, {U"?", U"¿"}}, default_bg, 1},
{{{U"3", U"#"}, {U"â", U"Â"}, {U"#", U"~"}}, default_bg, 1},
{{{U"4", U"$"}, {U"ã", U"Ã"}, {U"$", U""}}, default_bg, 1},
{{{U"5", U"%"}, {U"ä", U"Ä"}, {U"%", U"´"}}, default_bg, 1},
{{{U"6", U"^"}, {U"å", U"Å"}, {U"&", U""}}, default_bg, 1},
{{{U"7", U"&"}, {U"æ", U"Æ"}, {U"'", U""}}, default_bg, 1},
{{{U"8", U"*"}, {U"ç", U"Ç"}, {U"(", U""}}, default_bg, 1},
{{{U"9", U"("}, {U"[", U"<"}, {U")", U""}}, default_bg, 1},
{{{U"0", U")"}, {U"]", U">"}, {U"*", U""}}, default_bg, 1},
// If password was requested, then password has to be the only osk panel mode available to the user
// first_view_panel can be ignored
// Row 2
{{{U"q", U"Q"}, {U"è", U"È"}, {U"/", U"¤"}}, default_bg, 1},
{{{U"w", U"W"}, {U"é", U"É"}, {U"\\", U"¢"}}, default_bg, 1},
{{{U"e", U"E"}, {U"ê", U"Ê"}, {U"[", U""}}, default_bg, 1},
{{{U"r", U"R"}, {U"ë", U"Ë"}, {U"]", U"£"}}, default_bg, 1},
{{{U"t", U"T"}, {U"ì", U"Ì"}, {U"^", U"¥"}}, default_bg, 1},
{{{U"y", U"Y"}, {U"í", U"Í"}, {U"_", U"§"}}, default_bg, 1},
{{{U"u", U"U"}, {U"î", U"Î"}, {U"`", U"¦"}}, default_bg, 1},
{{{U"i", U"I"}, {U"ï", U"Ï"}, {U"{", U"µ"}}, default_bg, 1},
{{{U"o", U"O"}, {U";", U"="}, {U"}", U""}}, default_bg, 1},
{{{U"p", U"P"}, {U":", U"+"}, {U"|", U""}}, default_bg, 1},
add_panel(osk_panel_password(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
// Row 3
{{{U"a", U"A"}, {U"ñ", U"Ñ"}, {U"@", U""}}, default_bg, 1},
{{{U"s", U"S"}, {U"ò", U"Ò"}, {U"°", U""}}, default_bg, 1},
{{{U"d", U"D"}, {U"ó", U"Ó"}, {U"", U""}}, default_bg, 1},
{{{U"f", U"F"}, {U"ô", U"Ô"}, {U"", U""}}, default_bg, 1},
{{{U"g", U"G"}, {U"õ", U"Õ"}, {U"«", U""}}, default_bg, 1},
{{{U"h", U"H"}, {U"ö", U"Ö"}, {U"»", U""}}, default_bg, 1},
{{{U"j", U"J"}, {U"ø", U"Ø"}, {U"ª", U""}}, default_bg, 1},
{{{U"k", U"K"}, {U"œ", U"Œ"}, {U"º", U""}}, default_bg, 1},
{{{U"l", U"L"}, {U"`", U"~"}, {U"×", U""}}, default_bg, 1},
{{{U"'", U"\""}, {U"¡", U"\""}, {U"÷", U""}}, default_bg, 1},
// TODO: hide entered text with *
// Row 4
{{{U"z", U"Z"}, {U"ß", U"ß"}, {U"+", U""}}, default_bg, 1},
{{{U"x", U"X"}, {U"ù", U"Ù"}, {U",", U""}}, default_bg, 1},
{{{U"c", U"C"}, {U"ú", U"Ú"}, {U"-", U""}}, default_bg, 1},
{{{U"v", U"V"}, {U"û", U"Û"}, {U".", U""}}, default_bg, 1},
{{{U"b", U"B"}, {U"ü", U"Ü"}, {U"\"", U""}}, default_bg, 1},
{{{U"n", U"N"}, {U"ý", U"Ý"}, {U":", U""}}, default_bg, 1},
{{{U"m", U"M"}, {U"ÿ", U"Ÿ"}, {U";", U""}}, default_bg, 1},
{{{U",", U"-"}, {U",", U"-"}, {U"<", U""}}, default_bg, 1},
{{{U".", U"_"}, {U".", U"_"}, {U"=", U""}}, default_bg, 1},
{{{U"?", U"/"}, {U"¿", U"/"}, {U">", U""}}, default_bg, 1},
m_password_mode = true;
}
else if (panel_flag == CELL_OSKDIALOG_PANELMODE_DEFAULT || panel_flag == CELL_OSKDIALOG_PANELMODE_DEFAULT_NO_JAPANESE)
{
// Prefer the systems settings
// first_view_panel is ignored
// Special
{{{U"Shift"}, {U"Shift"}, {U"Shift"}}, special2_bg, 2, button_flags::_default, shift_callback },
{{{U"ÖÑß"}, {U"@#:"}, {U"ABC"}}, special2_bg, 2, button_flags::_default, mode_callback },
{{{U"Space"}, {U"Space"}, {U"Space"}}, special_bg, 2, button_flags::_space, space_callback },
{{{U"Backspace"}, {U"Backspace"}, {U"Backspace"}}, special_bg, 2, button_flags::_default, delete_callback },
{{{U"Enter"}, {U"Enter"}, {U"Enter"}}, special2_bg, 2, button_flags::_return, enter_callback },
};
switch (g_cfg.sys.language)
{
case CELL_SYSUTIL_LANG_JAPANESE:
if (panel_flag == CELL_OSKDIALOG_PANELMODE_DEFAULT_NO_JAPANESE)
add_panel(osk_panel_english(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
else
add_panel(osk_panel_japanese(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
break;
case CELL_SYSUTIL_LANG_RUSSIAN:
case CELL_SYSUTIL_LANG_KOREAN:
case CELL_SYSUTIL_LANG_CHINESE_T:
case CELL_SYSUTIL_LANG_CHINESE_S:
case CELL_SYSUTIL_LANG_POLISH:
case CELL_SYSUTIL_LANG_TURKISH:
// TODO: Use proper panels
case CELL_SYSUTIL_LANG_FRENCH:
case CELL_SYSUTIL_LANG_SPANISH:
case CELL_SYSUTIL_LANG_GERMAN:
case CELL_SYSUTIL_LANG_ITALIAN:
case CELL_SYSUTIL_LANG_DUTCH:
case CELL_SYSUTIL_LANG_PORTUGUESE_PT:
case CELL_SYSUTIL_LANG_FINNISH:
case CELL_SYSUTIL_LANG_SWEDISH:
case CELL_SYSUTIL_LANG_DANISH:
case CELL_SYSUTIL_LANG_NORWEGIAN:
case CELL_SYSUTIL_LANG_PORTUGUESE_BR:
// TODO: They use the same characters as the english panel, but they might have a different layout.
case CELL_SYSUTIL_LANG_ENGLISH_US:
case CELL_SYSUTIL_LANG_ENGLISH_GB:
default:
add_panel(osk_panel_english(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
break;
}
}
else
{
// Append osk modes.
initialize_layout(layout, utf16_to_u32string(message), utf16_to_u32string(init_text));
// TODO: find out the exact order
if (panel_flag & CELL_OSKDIALOG_PANELMODE_ENGLISH)
{
add_panel(osk_panel_english(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
}
if (panel_flag & CELL_OSKDIALOG_PANELMODE_JAPANESE)
{
add_panel(osk_panel_japanese(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
}
if (panel_flag & CELL_OSKDIALOG_PANELMODE_JAPANESE_HIRAGANA)
{
add_panel(osk_panel_japanese_hiragana(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
}
if (panel_flag & CELL_OSKDIALOG_PANELMODE_JAPANESE_KATAKANA)
{
add_panel(osk_panel_japanese_katakana(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
}
if (panel_flag & CELL_OSKDIALOG_PANELMODE_ALPHABET)
{
add_panel(osk_panel_alphabet_half_width(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
}
if (panel_flag & CELL_OSKDIALOG_PANELMODE_ALPHABET_FULL_WIDTH)
{
add_panel(osk_panel_alphabet_full_width(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
}
if (panel_flag & CELL_OSKDIALOG_PANELMODE_NUMERAL)
{
add_panel(osk_panel_numeral_half_width(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
}
if (panel_flag & CELL_OSKDIALOG_PANELMODE_NUMERAL_FULL_WIDTH)
{
add_panel(osk_panel_numeral_full_width(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
}
if (panel_flag & CELL_OSKDIALOG_PANELMODE_URL)
{
add_panel(osk_panel_url(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
}
// TODO: Use proper panels for the following panel modes
if (panel_flag & CELL_OSKDIALOG_PANELMODE_LATIN ||
panel_flag & CELL_OSKDIALOG_PANELMODE_GERMAN ||
panel_flag & CELL_OSKDIALOG_PANELMODE_SPANISH ||
panel_flag & CELL_OSKDIALOG_PANELMODE_FRENCH ||
panel_flag & CELL_OSKDIALOG_PANELMODE_ITALIAN ||
panel_flag & CELL_OSKDIALOG_PANELMODE_DUTCH ||
panel_flag & CELL_OSKDIALOG_PANELMODE_PORTUGUESE ||
panel_flag & CELL_OSKDIALOG_PANELMODE_RUSSIAN ||
panel_flag & CELL_OSKDIALOG_PANELMODE_POLISH ||
panel_flag & CELL_OSKDIALOG_PANELMODE_KOREAN ||
panel_flag & CELL_OSKDIALOG_PANELMODE_TURKEY ||
panel_flag & CELL_OSKDIALOG_PANELMODE_TRADITIONAL_CHINESE ||
panel_flag & CELL_OSKDIALOG_PANELMODE_SIMPLIFIED_CHINESE ||
panel_flag & CELL_OSKDIALOG_PANELMODE_PORTUGUESE_BRAZIL ||
panel_flag & CELL_OSKDIALOG_PANELMODE_DANISH ||
panel_flag & CELL_OSKDIALOG_PANELMODE_SWEDISH ||
panel_flag & CELL_OSKDIALOG_PANELMODE_NORWEGIAN ||
panel_flag & CELL_OSKDIALOG_PANELMODE_FINNISH)
{
add_panel(osk_panel_latin(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
}
// Get initial panel based on first_view_panel
for (size_t i = 0; i < m_panels.size(); ++i)
{
if (first_view_panel == m_panels[i].osk_panel_mode)
{
m_panel_index = i;
break;
}
}
}
// Fallback to english in case we forgot something
if (m_panels.empty())
{
osk.error("No OSK panel found. Using english panel.");
add_panel(osk_panel_english(shift_cb, layer_cb, space_cb, delete_cb, enter_cb));
}
initialize_layout(utf16_to_u32string(message), utf16_to_u32string(init_text));
update_panel();
g_fxo->init<named_thread>("OSK Thread", [this, tbit = alloc_thread_bit()]
{
g_thread_bit = tbit;
if (auto error = run_input_loop())
{
rsx_log.error("Osk input loop exited with error code=%d", error);
}
thread_bits &= ~tbit;
thread_bits.notify_all();
});
}
}
}

View file

@ -1,6 +1,7 @@
#pragma once
#include "overlays.h"
#include "overlay_osk_panel.h"
#include "Emu/Cell/Modules/cellOskDialog.h"
namespace rsx
@ -9,8 +10,6 @@ namespace rsx
{
struct osk_dialog : public user_interface, public OskDialogBase
{
using callback_t = std::function<void(const std::u32string&)>;
enum border_flags
{
top = 1,
@ -24,47 +23,19 @@ namespace rsx
default_cell = top | bottom | left | right
};
enum button_flags
{
_default = 0,
_return = 1,
_space = 2,
_shift = 3,
_mode = 4
};
enum layer_mode : u32
{
alphanumeric = 0,
extended = 1,
special = 2,
mode_count
};
struct cell
{
position2u pos;
color4f backcolor{};
border_flags flags = default_cell;
button_flags button_flag = button_flags::_default;
bool selected = false;
bool enabled = false;
// TODO: change to array with layer_mode::layer_count
std::vector<std::vector<std::u32string>> outputs;
callback_t callback;
};
struct grid_entry_ctor
{
// TODO: change to array with layer_mode::layer_count
std::vector<std::vector<std::u32string>> outputs;
color4f color;
u32 num_cell_hz;
button_flags type_flags;
callback_t callback;
};
// Base UI
overlay_element m_frame;
overlay_element m_background;
@ -81,14 +52,17 @@ namespace rsx
u32 cell_size_y = 0;
u32 num_columns = 0;
u32 num_rows = 0;
std::vector<u32> num_layers;
std::vector<u32> num_shift_layers_by_charset;
u32 selected_x = 0;
u32 selected_y = 0;
u32 selected_z = 0;
layer_mode m_selected_mode = layer_mode::alphanumeric;
u32 m_selected_charset = 0;
std::vector<cell> m_grid;
// Password mode (****)
bool m_password_mode = false;
// Fade in/out
animation_color_interpolate fade_animation;
@ -98,33 +72,37 @@ namespace rsx
u32 flags = 0;
u32 char_limit = UINT32_MAX;
std::vector<osk_panel> m_panels;
size_t m_panel_index = 0;
osk_dialog() = default;
~osk_dialog() override = default;
void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 options) override = 0;
void 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) override;
void Close(bool ok) override;
void initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::u32string& title, const std::u32string& initial_text);
void initialize_layout(const std::u32string& title, const std::u32string& initial_text);
void add_panel(const osk_panel& panel);
void step_panel(bool next_panel);
void update_panel();
void update_layout();
void update() override;
void update_controls();
void on_button_pressed(pad_button button_press) override;
void on_text_changed();
void on_default_callback(const std::u32string&);
void on_default_callback(const std::u32string& str);
void on_shift(const std::u32string&);
void on_mode(const std::u32string&);
void on_layer(const std::u32string&);
void on_space(const std::u32string&);
void on_backspace(const std::u32string&);
void on_enter(const std::u32string&);
std::u32string get_placeholder();
compiled_resource get_compiled() override;
};
struct osk_latin : osk_dialog
{
using osk_dialog::osk_dialog;
void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 options) override;
};
}
}

View file

@ -0,0 +1,565 @@
#include "stdafx.h"
#include "overlay_osk_panel.h"
namespace rsx
{
namespace overlays
{
osk_panel::osk_panel(u32 panel_mode)
{
osk_panel_mode = panel_mode;
}
// Language specific implementations
osk_panel_latin::osk_panel_latin(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb, u32 osk_panel_mode)
: osk_panel(osk_panel_mode)
{
const color4f default_bg = { 0.7f, 0.7f, 0.7f, 1.f };
const color4f special_bg = { 0.2f, 0.7f, 0.7f, 1.f };
const color4f special2_bg = { 0.83f, 0.81f, 0.57f, 1.f };
num_rows = 5;
num_columns = 10;
cell_size_x = 50;
cell_size_y = 40;
layout =
{
// Row 1
{{{U"1", U"!"}, {U"à", U"À"}, {U"!", U"¡"}}, default_bg, 1},
{{{U"2", U"@"}, {U"á", U"Á"}, {U"?", U"¿"}}, default_bg, 1},
{{{U"3", U"#"}, {U"â", U"Â"}, {U"#", U"~"}}, default_bg, 1},
{{{U"4", U"$"}, {U"ã", U"Ã"}, {U"$", U""}}, default_bg, 1},
{{{U"5", U"%"}, {U"ä", U"Ä"}, {U"%", U"´"}}, default_bg, 1},
{{{U"6", U"^"}, {U"å", U"Å"}, {U"&", U""}}, default_bg, 1},
{{{U"7", U"&"}, {U"æ", U"Æ"}, {U"'", U""}}, default_bg, 1},
{{{U"8", U"*"}, {U"ç", U"Ç"}, {U"(", U""}}, default_bg, 1},
{{{U"9", U"("}, {U"[", U"<"}, {U")", U""}}, default_bg, 1},
{{{U"0", U")"}, {U"]", U">"}, {U"*", U""}}, default_bg, 1},
// Row 2
{{{U"q", U"Q"}, {U"è", U"È"}, {U"/", U"¤"}}, default_bg, 1},
{{{U"w", U"W"}, {U"é", U"É"}, {U"\\", U"¢"}}, default_bg, 1},
{{{U"e", U"E"}, {U"ê", U"Ê"}, {U"[", U""}}, default_bg, 1},
{{{U"r", U"R"}, {U"ë", U"Ë"}, {U"]", U"£"}}, default_bg, 1},
{{{U"t", U"T"}, {U"ì", U"Ì"}, {U"^", U"¥"}}, default_bg, 1},
{{{U"y", U"Y"}, {U"í", U"Í"}, {U"_", U"§"}}, default_bg, 1},
{{{U"u", U"U"}, {U"î", U"Î"}, {U"`", U"¦"}}, default_bg, 1},
{{{U"i", U"I"}, {U"ï", U"Ï"}, {U"{", U"µ"}}, default_bg, 1},
{{{U"o", U"O"}, {U";", U"="}, {U"}", U""}}, default_bg, 1},
{{{U"p", U"P"}, {U":", U"+"}, {U"|", U""}}, default_bg, 1},
// Row 3
{{{U"a", U"A"}, {U"ñ", U"Ñ"}, {U"@", U""}}, default_bg, 1},
{{{U"s", U"S"}, {U"ò", U"Ò"}, {U"°", U""}}, default_bg, 1},
{{{U"d", U"D"}, {U"ó", U"Ó"}, {U"", U""}}, default_bg, 1},
{{{U"f", U"F"}, {U"ô", U"Ô"}, {U"", U""}}, default_bg, 1},
{{{U"g", U"G"}, {U"õ", U"Õ"}, {U"«", U""}}, default_bg, 1},
{{{U"h", U"H"}, {U"ö", U"Ö"}, {U"»", U""}}, default_bg, 1},
{{{U"j", U"J"}, {U"ø", U"Ø"}, {U"ª", U""}}, default_bg, 1},
{{{U"k", U"K"}, {U"œ", U"Œ"}, {U"º", U""}}, default_bg, 1},
{{{U"l", U"L"}, {U"`", U"~"}, {U"×", U""}}, default_bg, 1},
{{{U"'", U"\""}, {U"¡", U"\""}, {U"÷", U""}}, default_bg, 1},
// Row 4
{{{U"z", U"Z"}, {U"ß", U"ß"}, {U"+", U""}}, default_bg, 1},
{{{U"x", U"X"}, {U"ù", U"Ù"}, {U",", U""}}, default_bg, 1},
{{{U"c", U"C"}, {U"ú", U"Ú"}, {U"-", U""}}, default_bg, 1},
{{{U"v", U"V"}, {U"û", U"Û"}, {U".", U""}}, default_bg, 1},
{{{U"b", U"B"}, {U"ü", U"Ü"}, {U"\"", U""}}, default_bg, 1},
{{{U"n", U"N"}, {U"ý", U"Ý"}, {U":", U""}}, default_bg, 1},
{{{U"m", U"M"}, {U"ÿ", U"Ÿ"}, {U";", U""}}, default_bg, 1},
{{{U",", U"-"}, {U",", U"-"}, {U"<", U""}}, default_bg, 1},
{{{U".", U"_"}, {U".", U"_"}, {U"=", U""}}, default_bg, 1},
{{{U"?", U"/"}, {U"¿", U"/"}, {U">", U""}}, default_bg, 1},
// Special
{{{U"A/a"}, {U"À/à"}, {U"!/¡"}}, special2_bg, 2, button_flags::_shift, shift_cb },
{{{U"ÖÑß"}, {U"@#:"}, {U"ABC"}}, special2_bg, 2, button_flags::_layer, layer_cb },
{{{U"Space"}, {U"Space"}, {U"Space"}}, special_bg, 2, button_flags::_space, space_cb },
{{{U"Backspace"}, {U"Backspace"}, {U"Backspace"}}, special_bg, 2, button_flags::_default, delete_cb },
{{{U"Enter"}, {U"Enter"}, {U"Enter"}}, special2_bg, 2, button_flags::_return, enter_cb },
};
}
osk_panel_english::osk_panel_english(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb)
: osk_panel_latin(shift_cb, layer_cb, space_cb, delete_cb, enter_cb, CELL_OSKDIALOG_PANELMODE_ENGLISH)
{
// English and latin should be mostly the same
}
osk_panel_japanese::osk_panel_japanese(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb)
: osk_panel(CELL_OSKDIALOG_PANELMODE_JAPANESE)
{
color4f default_bg = { 0.7f, 0.7f, 0.7f, 1.f };
color4f special_bg = { 0.2f, 0.7f, 0.7f, 1.f };
color4f special2_bg = { 0.83f, 0.81f, 0.57f, 1.f };
num_rows = 6;
num_columns = 10;
cell_size_x = 50;
cell_size_y = 40;
layout =
{
// Row 1
{{{U"", U""}, {U"1", U"!"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"2", U"@"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"3", U"#"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"4", U"$"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"5", U"%"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"6", U"^"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"7", U"&"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"8", U"*"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"9", U"("}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"0", U")"}, {U"", U""}, {U""}}, default_bg, 1},
// Row 2
{{{U"", U""}, {U"q", U"Q"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"w", U"W"}, {U"", U""}, {U"_"}}, default_bg, 1},
{{{U"", U""}, {U"e", U"E"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"r", U"R"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"t", U"T"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"y", U"Y"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"u", U"U"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"i", U"I"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"o", U"O"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"p", U"P"}, {U"", U""}, {U""}}, default_bg, 1},
// Row 3
{{{U"", U""}, {U"a", U"A"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"s", U"S"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"d", U"D"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"f", U"F"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"g", U"G"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"h", U"H"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"j", U"J"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"k", U"K"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"l", U"L"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"'", U"\""}, {U"", U""}, {U""}}, default_bg, 1},
// Row 4
{{{U"", U""}, {U"z", U"Z"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"x", U"X"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"c", U"C"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"v", U"V"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"b", U"B"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"n", U"N"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"m", U"M"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U",", U"-"}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U".", U"_"}, {U"", U"_"}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"?", U"/"}, {U"", U""}, {U""}}, default_bg, 1},
// Row 5
{{{U"", U""}, {U"", U""}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"", U""}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"", U""}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"", U""}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"", U""}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"", U""}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"", U""}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"", U""}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"", U""}, {U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"", U""}, {U"", U""}, {U""}}, default_bg, 1},
// Special
{{{U"あ/ア"}, {U"A/a"}, {U"全/半"}, {U""}}, special2_bg, 2, button_flags::_shift, shift_cb },
{{{U"abc"}, {U"全半"}, {U""}, {U"あア"}}, special2_bg, 2, button_flags::_layer, layer_cb},
{{{U"Space"}, {U"Space"}, {U"Space"}, {U"Space"}}, special_bg, 2, button_flags::_space, space_cb},
{{{U"Backspace"}, {U"Backspace"}, {U"Backspace"}, {U"Backspace"}}, special_bg, 2, button_flags::_default, delete_cb },
{{{U"Enter"}, {U"Enter"}, {U"Enter"}, {U"Enter"}}, special2_bg, 2, button_flags::_return, enter_cb },
};
}
osk_panel_japanese_hiragana::osk_panel_japanese_hiragana(callback_t /*shift_cb*/, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb)
: osk_panel(CELL_OSKDIALOG_PANELMODE_JAPANESE_HIRAGANA)
{
color4f default_bg = { 0.7f, 0.7f, 0.7f, 1.f };
color4f special_bg = { 0.2f, 0.7f, 0.7f, 1.f };
color4f special2_bg = { 0.83f, 0.81f, 0.57f, 1.f };
num_rows = 6;
num_columns = 10;
cell_size_x = 50;
cell_size_y = 40;
layout =
{
// Row 1
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
// Row 2
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U"_"}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
// Row 3
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
// Row 4
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
// Row 5
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
// Special
{{{U""}, {U""}}, special2_bg, 2, button_flags::_shift, nullptr },
{{{U""}, {U""}}, special2_bg, 2, button_flags::_layer, layer_cb},
{{{U"Space"}, {U"Space"}}, special_bg, 2, button_flags::_space, space_cb},
{{{U"Backspace"}, {U"Backspace"}}, special_bg, 2, button_flags::_default, delete_cb },
{{{U"Enter"}, {U"Enter"}}, special2_bg, 2, button_flags::_return, enter_cb },
};
}
osk_panel_japanese_katakana::osk_panel_japanese_katakana(callback_t /*shift_cb*/, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb)
: osk_panel(CELL_OSKDIALOG_PANELMODE_JAPANESE_KATAKANA)
{
color4f default_bg = { 0.7f, 0.7f, 0.7f, 1.f };
color4f special_bg = { 0.2f, 0.7f, 0.7f, 1.f };
color4f special2_bg = { 0.83f, 0.81f, 0.57f, 1.f };
num_rows = 6;
num_columns = 10;
cell_size_x = 50;
cell_size_y = 40;
layout =
{
// Row 1
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
// Row 2
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U"_"}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
// Row 3
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
// Row 4
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
// Row 5
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
{{{U""}, {U""}}, default_bg, 1},
// Special
{{{U""}, {U""}}, special2_bg, 2, button_flags::_shift, nullptr },
{{{U""}, {U""}}, special2_bg, 2, button_flags::_layer, layer_cb},
{{{U"Space"}, {U"Space"}}, special_bg, 2, button_flags::_space, space_cb},
{{{U"Backspace"}, {U"Backspace"}}, special_bg, 2, button_flags::_default, delete_cb },
{{{U"Enter"}, {U"Enter"}}, special2_bg, 2, button_flags::_return, enter_cb },
};
}
osk_panel_alphabet_half_width::osk_panel_alphabet_half_width(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb, u32 osk_panel_mode)
: osk_panel(osk_panel_mode)
{
const color4f default_bg = { 0.7f, 0.7f, 0.7f, 1.f };
const color4f special_bg = { 0.2f, 0.7f, 0.7f, 1.f };
const color4f special2_bg = { 0.83f, 0.81f, 0.57f, 1.f };
num_rows = 5;
num_columns = 10;
cell_size_x = 50;
cell_size_y = 40;
layout =
{
// Row 1
{{{U"1", U"!"}, {U"!"}}, default_bg, 1},
{{{U"2", U"@"}, {U"?"}}, default_bg, 1},
{{{U"3", U"#"}, {U"#"}}, default_bg, 1},
{{{U"4", U"$"}, {U"$"}}, default_bg, 1},
{{{U"5", U"%"}, {U"%"}}, default_bg, 1},
{{{U"6", U"^"}, {U"&"}}, default_bg, 1},
{{{U"7", U"&"}, {U"'"}}, default_bg, 1},
{{{U"8", U"*"}, {U"("}}, default_bg, 1},
{{{U"9", U"("}, {U")"}}, default_bg, 1},
{{{U"0", U")"}, {U"*"}}, default_bg, 1},
// Row 2
{{{U"q", U"Q"}, {U"/"}}, default_bg, 1},
{{{U"w", U"W"}, {U"\\"}}, default_bg, 1},
{{{U"e", U"E"}, {U"["}}, default_bg, 1},
{{{U"r", U"R"}, {U"]"}}, default_bg, 1},
{{{U"t", U"T"}, {U"^"}}, default_bg, 1},
{{{U"y", U"Y"}, {U"_"}}, default_bg, 1},
{{{U"u", U"U"}, {U"`"}}, default_bg, 1},
{{{U"i", U"I"}, {U"{"}}, default_bg, 1},
{{{U"o", U"O"}, {U"}"}}, default_bg, 1},
{{{U"p", U"P"}, {U"|"}}, default_bg, 1},
// Row 3
{{{U"a", U"A"}, {U"@"}}, default_bg, 1},
{{{U"s", U"S"}, {U"°"}}, default_bg, 1},
{{{U"d", U"D"}, {U""}}, default_bg, 1},
{{{U"f", U"F"}, {U""}}, default_bg, 1},
{{{U"g", U"G"}, {U"«"}}, default_bg, 1},
{{{U"h", U"H"}, {U"»"}}, default_bg, 1},
{{{U"j", U"J"}, {U"ª"}}, default_bg, 1},
{{{U"k", U"K"}, {U"º"}}, default_bg, 1},
{{{U"l", U"L"}, {U"×"}}, default_bg, 1},
{{{U"'", U"\""}, {U"÷"}}, default_bg, 1},
// Row 4
{{{U"z", U"Z"}, {U"+"}}, default_bg, 1},
{{{U"x", U"X"}, {U","}}, default_bg, 1},
{{{U"c", U"C"}, {U"-"}}, default_bg, 1},
{{{U"v", U"V"}, {U"."}}, default_bg, 1},
{{{U"b", U"B"}, {U"\""}}, default_bg, 1},
{{{U"n", U"N"}, {U":"}}, default_bg, 1},
{{{U"m", U"M"}, {U";"}}, default_bg, 1},
{{{U",", U"-"}, {U"<"}}, default_bg, 1},
{{{U".", U"_"}, {U"="}}, default_bg, 1},
{{{U"?", U"/"}, {U">"}}, default_bg, 1},
// Special
{{{U"A/a"}, {U""}}, special2_bg, 2, button_flags::_shift, shift_cb },
{{{U"@#:"}, {U"ABC"}}, special2_bg, 2, button_flags::_layer, layer_cb },
{{{U"Space"}, {U"Space"}}, special_bg, 2, button_flags::_space, space_cb },
{{{U"Backspace"}, {U"Backspace"}}, special_bg, 2, button_flags::_default, delete_cb },
{{{U"Enter"}, {U"Enter"}}, special2_bg, 2, button_flags::_return, enter_cb },
};
}
osk_panel_alphabet_full_width::osk_panel_alphabet_full_width(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb)
: osk_panel(CELL_OSKDIALOG_PANELMODE_ALPHABET_FULL_WIDTH)
{
const color4f default_bg = { 0.7f, 0.7f, 0.7f, 1.f };
const color4f special_bg = { 0.2f, 0.7f, 0.7f, 1.f };
const color4f special2_bg = { 0.83f, 0.81f, 0.57f, 1.f };
num_rows = 5;
num_columns = 10;
cell_size_x = 50;
cell_size_y = 40;
layout =
{
// Row 1
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
// Row 2
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U"_"}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
// Row 3
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
// Row 4
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
{{{U"", U"_"}, {U""}}, default_bg, 1},
{{{U"", U""}, {U""}}, default_bg, 1},
// Special
{{{U"/"}, {U""}}, special2_bg, 2, button_flags::_shift, shift_cb },
{{{U"@#:"}, {U"ABC"}}, special2_bg, 2, button_flags::_layer, layer_cb },
{{{U"Space"}, {U"Space"}}, special_bg, 2, button_flags::_space, space_cb },
{{{U"Backspace"}, {U"Backspace"}}, special_bg, 2, button_flags::_default, delete_cb },
{{{U"Enter"}, {U"Enter"}}, special2_bg, 2, button_flags::_return, enter_cb },
};
}
osk_panel_numeral_half_width::osk_panel_numeral_half_width(callback_t /*shift_cb*/, callback_t /*layer_cb*/, callback_t space_cb, callback_t delete_cb, callback_t enter_cb)
: osk_panel(CELL_OSKDIALOG_PANELMODE_NUMERAL)
{
const color4f default_bg = { 0.7f, 0.7f, 0.7f, 1.f };
const color4f special_bg = { 0.2f, 0.7f, 0.7f, 1.f };
const color4f special2_bg = { 0.83f, 0.81f, 0.57f, 1.f };
num_rows = 2;
num_columns = 10;
cell_size_x = 50;
cell_size_y = 40;
layout =
{
// Row 1
{{{U"1"}}, default_bg, 1},
{{{U"2"}}, default_bg, 1},
{{{U"3"}}, default_bg, 1},
{{{U"4"}}, default_bg, 1},
{{{U"5"}}, default_bg, 1},
{{{U"6"}}, default_bg, 1},
{{{U"7"}}, default_bg, 1},
{{{U"8"}}, default_bg, 1},
{{{U"9"}}, default_bg, 1},
{{{U"0"}}, default_bg, 1},
// Special
{{{U""}}, special2_bg, 2, button_flags::_shift, nullptr },
{{{U""}}, special2_bg, 2, button_flags::_layer, nullptr },
{{{U"Space"}}, special_bg, 2, button_flags::_space, space_cb },
{{{U"Backspace"}}, special_bg, 2, button_flags::_default, delete_cb },
{{{U"Enter"}}, special2_bg, 2, button_flags::_return, enter_cb },
};
}
osk_panel_numeral_full_width::osk_panel_numeral_full_width(callback_t /*shift_cb*/, callback_t /*layer_cb*/, callback_t space_cb, callback_t delete_cb, callback_t enter_cb)
: osk_panel(CELL_OSKDIALOG_PANELMODE_NUMERAL_FULL_WIDTH)
{
const color4f default_bg = { 0.7f, 0.7f, 0.7f, 1.f };
const color4f special_bg = { 0.2f, 0.7f, 0.7f, 1.f };
const color4f special2_bg = { 0.83f, 0.81f, 0.57f, 1.f };
num_rows = 2;
num_columns = 10;
cell_size_x = 50;
cell_size_y = 40;
layout =
{
// Row 1
{{{U""}}, default_bg, 1},
{{{U""}}, default_bg, 1},
{{{U""}}, default_bg, 1},
{{{U""}}, default_bg, 1},
{{{U""}}, default_bg, 1},
{{{U""}}, default_bg, 1},
{{{U""}}, default_bg, 1},
{{{U""}}, default_bg, 1},
{{{U""}}, default_bg, 1},
{{{U""}}, default_bg, 1},
// Special
{{{U""}}, special2_bg, 2, button_flags::_shift, nullptr },
{{{U""}}, special2_bg, 2, button_flags::_layer, nullptr },
{{{U"Space"}}, special_bg, 2, button_flags::_space, space_cb },
{{{U"Backspace"}}, special_bg, 2, button_flags::_default, delete_cb },
{{{U"Enter"}}, special2_bg, 2, button_flags::_return, enter_cb },
};
}
osk_panel_url::osk_panel_url(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb)
: osk_panel_alphabet_half_width(shift_cb, layer_cb, space_cb, delete_cb, enter_cb, CELL_OSKDIALOG_PANELMODE_URL)
{
// Roughly the same as the half-width alphanumeric character panel.
}
osk_panel_password::osk_panel_password(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb)
: osk_panel_alphabet_half_width(shift_cb, layer_cb, space_cb, delete_cb, enter_cb, CELL_OSKDIALOG_PANELMODE_PASSWORD)
{
// Same as the half-width alphanumeric character panel.
}
}
}

View file

@ -0,0 +1,99 @@
#pragma once
#include "Emu/Cell/Modules/cellOskDialog.h"
#include "Utilities/geometry.h"
namespace rsx
{
namespace overlays
{
using callback_t = std::function<void(const std::u32string&)>;
enum button_flags
{
_default = 0,
_return = 1,
_space = 2,
_shift = 3,
_layer = 4
};
struct grid_entry_ctor
{
// TODO: change to array with layer_mode::layer_count
std::vector<std::vector<std::u32string>> outputs;
color4f color;
u32 num_cell_hz;
button_flags type_flags;
callback_t callback;
};
struct osk_panel
{
u32 osk_panel_mode = 0;
u32 num_rows = 0;
u32 num_columns = 0;
u32 cell_size_x = 0;
u32 cell_size_y = 0;
std::vector<grid_entry_ctor> layout;
osk_panel(u32 panel_mode = 0);
};
struct osk_panel_latin : public osk_panel
{
osk_panel_latin(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb, u32 osk_panel_mode = CELL_OSKDIALOG_PANELMODE_LATIN);
};
struct osk_panel_english : public osk_panel_latin
{
osk_panel_english(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb);
};
struct osk_panel_japanese : public osk_panel
{
osk_panel_japanese(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb);
};
struct osk_panel_japanese_hiragana : public osk_panel
{
osk_panel_japanese_hiragana(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb);
};
struct osk_panel_japanese_katakana : public osk_panel
{
osk_panel_japanese_katakana(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb);
};
struct osk_panel_alphabet_half_width : public osk_panel
{
osk_panel_alphabet_half_width(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb, u32 osk_panel_mode = CELL_OSKDIALOG_PANELMODE_ALPHABET);
};
struct osk_panel_alphabet_full_width : public osk_panel
{
osk_panel_alphabet_full_width(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb);
};
struct osk_panel_numeral_half_width : public osk_panel
{
osk_panel_numeral_half_width(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb);
};
struct osk_panel_numeral_full_width : public osk_panel
{
osk_panel_numeral_full_width(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb);
};
struct osk_panel_url : public osk_panel_alphabet_half_width
{
osk_panel_url(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb);
};
struct osk_panel_password : public osk_panel_alphabet_half_width
{
osk_panel_password(callback_t shift_cb, callback_t layer_cb, callback_t space_cb, callback_t delete_cb, callback_t enter_cb);
};
}
}

View file

@ -136,6 +136,12 @@ namespace rsx
case CELL_PAD_CTRL_R1:
button_id = pad_button::R1;
break;
case CELL_PAD_CTRL_L2:
button_id = pad_button::L2;
break;
case CELL_PAD_CTRL_R2:
button_id = pad_button::R2;
break;
}
}

View file

@ -65,6 +65,8 @@ namespace rsx
cross,
L1,
R1,
L2,
R2,
pad_button_max_enum
};

View file

@ -74,6 +74,7 @@
<ClCompile Include="Emu\Io\KeyboardHandler.cpp" />
<ClCompile Include="Emu\Io\pad_config.cpp" />
<ClCompile Include="Emu\Io\pad_config_types.cpp" />
<ClCompile Include="Emu\RSX\Overlays\overlay_osk_panel.cpp" />
<ClCompile Include="Emu\RSX\Overlays\overlay_utils.cpp" />
<ClCompile Include="Emu\RSX\Overlays\Shaders\shader_loading_dialog.cpp" />
<ClCompile Include="Emu\RSX\Overlays\Shaders\shader_loading_dialog_native.cpp" />
@ -439,6 +440,7 @@
<ClInclude Include="Emu\RSX\Overlays\overlay_fonts.h" />
<ClInclude Include="Emu\RSX\Overlays\overlay_message_dialog.h" />
<ClInclude Include="Emu\RSX\Overlays\overlay_osk.h" />
<ClInclude Include="Emu\RSX\Overlays\overlay_osk_panel.h" />
<ClInclude Include="Emu\RSX\Overlays\overlay_perf_metrics.h" />
<ClInclude Include="Emu\RSX\Overlays\overlay_save_dialog.h" />
<ClInclude Include="Emu\RSX\Overlays\overlay_shader_compile_notification.h" />

View file

@ -926,6 +926,9 @@
<ClCompile Include="Emu\NP\np_handler.cpp">
<Filter>Emu\NP</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Overlays\overlay_osk_panel.cpp">
<Filter>Emu\GPU\RSX\Overlays</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Crypto\aes.h">
@ -1759,5 +1762,8 @@
<ClInclude Include="Emu\NP\np_handler.h">
<Filter>Emu\NP</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Overlays\overlay_osk_panel.h">
<Filter>Emu\GPU\RSX\Overlays</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -24,7 +24,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 options)
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;
@ -64,7 +64,7 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me
inputLayout->setAlignment(Qt::AlignHCenter);
// Text Input
if (options & CELL_OSKDIALOG_NO_RETURN)
if (prohibit_flags & CELL_OSKDIALOG_NO_RETURN)
{
QLineEdit* input = new QLineEdit(m_dialog);
input->setFixedWidth(lineEditWidth());
@ -72,7 +72,7 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me
input->setText(text);
input->setFocus();
if (options & CELL_OSKDIALOG_NO_SPACE)
if (prohibit_flags & CELL_OSKDIALOG_NO_SPACE)
{
input->setValidator(new QRegExpValidator(QRegExp("^\\S*$"), this));
}
@ -123,7 +123,7 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me
int cursor_pos = cursor.position();
// Clear text of spaces if necessary
if (options & CELL_OSKDIALOG_NO_SPACE)
if (prohibit_flags & CELL_OSKDIALOG_NO_SPACE)
{
int trim_len = text.length();
text.remove(QRegExp("\\s+"));

View file

@ -14,7 +14,7 @@ class osk_dialog_frame : public QObject, public OskDialogBase
public:
osk_dialog_frame();
~osk_dialog_frame();
virtual void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 options) override;
virtual void 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) override;
virtual void Close(bool accepted) override;
private: