mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-20 03:24:49 +00:00
Merge 354ac3980d
into 69777e2ffa
This commit is contained in:
commit
1a45b46182
32 changed files with 1260 additions and 125 deletions
|
@ -501,6 +501,10 @@ set(IME_LIB src/core/libraries/ime/error_dialog.cpp
|
|||
src/core/libraries/ime/ime_dialog.h
|
||||
src/core/libraries/ime/ime_ui.cpp
|
||||
src/core/libraries/ime/ime_ui.h
|
||||
src/core/libraries/ime/ime_keyboard_layouts.cpp
|
||||
src/core/libraries/ime/ime_keyboard_layouts.h
|
||||
src/core/libraries/ime/ime_keyboard_ui.cpp
|
||||
src/core/libraries/ime/ime_keyboard_ui.h
|
||||
src/core/libraries/ime/ime.cpp
|
||||
src/core/libraries/ime/ime.h
|
||||
src/core/libraries/ime/ime_error.h
|
||||
|
|
2
externals/MoltenVK/MoltenVK
vendored
2
externals/MoltenVK/MoltenVK
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 067fc6c85b02f37dfda58eeda49d8458e093ed60
|
||||
Subproject commit 2048427e50f9eb20f2b8f98d316ecaee398c9b91
|
2
externals/MoltenVK/SPIRV-Cross
vendored
2
externals/MoltenVK/SPIRV-Cross
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 185833a61cbe29ce3bfb5a499ffb3dfeaee3bbe7
|
||||
Subproject commit 2c32b6bf86f3c4a5539aa1f0bacbd59fe61759cf
|
2
externals/MoltenVK/cereal
vendored
2
externals/MoltenVK/cereal
vendored
|
@ -1 +1 @@
|
|||
Subproject commit a56bad8bbb770ee266e930c95d37fff2a5be7fea
|
||||
Subproject commit d1fcec807b372f04e4c1041b3058e11c12853e6e
|
2
externals/date
vendored
2
externals/date
vendored
|
@ -1 +1 @@
|
|||
Subproject commit a45ea7c17b4a7f320e199b71436074bd624c9e15
|
||||
Subproject commit 28b7b232521ace2c8ef3f2ad4126daec3569c14f
|
2
externals/dear_imgui
vendored
2
externals/dear_imgui
vendored
|
@ -1 +1 @@
|
|||
Subproject commit f4d9359095eff3eb03f685921edc1cf0e37b1687
|
||||
Subproject commit 636cd4a7d623a2bc9bf59bb3acbb4ca075befba3
|
2
externals/discord-rpc
vendored
2
externals/discord-rpc
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 19f66e6dcabb2268965f453db9e5774ede43238f
|
||||
Subproject commit 51b09d426a4a1bcfa6ee6d4894e57d669f4a2e65
|
2
externals/ffmpeg-core
vendored
2
externals/ffmpeg-core
vendored
|
@ -1 +1 @@
|
|||
Subproject commit b0de1dcca26c0ebfb8011b8e59dd17fc399db0ff
|
||||
Subproject commit 27de97c826b6b40c255891c37ac046a25836a575
|
2
externals/fmt
vendored
2
externals/fmt
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 64db979e38ec644b1798e41610b28c8d2c8a2739
|
||||
Subproject commit 8ee89546ffcf046309d1f0d38c0393f02fde56c8
|
2
externals/glslang
vendored
2
externals/glslang
vendored
|
@ -1 +1 @@
|
|||
Subproject commit ba1640446f3826a518721d1f083f3a8cca1120c3
|
||||
Subproject commit a0995c49ebcaca2c6d3b03efbabf74f3843decdb
|
2
externals/magic_enum
vendored
2
externals/magic_enum
vendored
|
@ -1 +1 @@
|
|||
Subproject commit a413fcc9c46a020a746907136a384c227f3cd095
|
||||
Subproject commit 1a1824df7ac798177a521eed952720681b0bf482
|
2
externals/pugixml
vendored
2
externals/pugixml
vendored
|
@ -1 +1 @@
|
|||
Subproject commit caade5a28aad86b92a4b5337a9dc70c4ba73c5eb
|
||||
Subproject commit 4bc14418d12d289dd9978fdce9490a45deeb653e
|
2
externals/robin-map
vendored
2
externals/robin-map
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 4ec1bf19c6a96125ea22062f38c2cf5b958e448e
|
||||
Subproject commit fe845fd7852ef541c5479ae23b3d36b57f8608ee
|
2
externals/sdl3
vendored
2
externals/sdl3
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 4093e4a193971ef1d4928158e0a1832be42e4599
|
||||
Subproject commit a336b62d8b0b97b09214e053203e442e2b6e2be5
|
2
externals/sirit
vendored
2
externals/sirit
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 427a42c9ed99b38204d9107bc3dc14e92458acf1
|
||||
Subproject commit 8b9b12c2089505ac8b10fa56bf56b3ed49d9d7b0
|
2
externals/toml11
vendored
2
externals/toml11
vendored
|
@ -1 +1 @@
|
|||
Subproject commit a01fe3b4c14c6d7b99ee3f07c9e80058c6403097
|
||||
Subproject commit 7f6c574ff5aa1053534e7e19c0a4f22bf4c6aaca
|
2
externals/vma
vendored
2
externals/vma
vendored
|
@ -1 +1 @@
|
|||
Subproject commit f378e7b3f18f6e2b06b957f6ba7b1c7207d2a536
|
||||
Subproject commit 5a53a198945ba8260fbc58fadb788745ce6aa263
|
2
externals/vulkan-headers
vendored
2
externals/vulkan-headers
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 5ceb9ed481e58e705d0d9b5326537daedd06b97d
|
||||
Subproject commit a03d2f6d5753b365d704d58161825890baad0755
|
2
externals/winpthreads
vendored
2
externals/winpthreads
vendored
|
@ -1 +1 @@
|
|||
Subproject commit f35b0948d36a736e6a2d052ae295a3ffde09703f
|
||||
Subproject commit f00c973a6ab2a23573708568b8ef4acc20a9d36b
|
2
externals/xbyak
vendored
2
externals/xbyak
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 44a72f369268f7d552650891b296693e91db86bb
|
||||
Subproject commit 4e44f4614ddbf038f2a6296f5b906d5c72691e0f
|
2
externals/xxhash
vendored
2
externals/xxhash
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 953a09abc39096da9e216b6eb0002c681cdc1199
|
||||
Subproject commit 2bf8313b934633b2a5b7e8fd239645b85e10c852
|
2
externals/zlib-ng
vendored
2
externals/zlib-ng
vendored
|
@ -1 +1 @@
|
|||
Subproject commit fd0d263cedab1a136f40d65199987e3eaeecfcbd
|
||||
Subproject commit d54e3769be0c522015b784eca2af258b1c026107
|
2
externals/zydis
vendored
2
externals/zydis
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 120e0e705f8e3b507dc49377ac2879979f0d545c
|
||||
Subproject commit bffbb610cfea643b98e87658b9058382f7522807
|
|
@ -1,5 +1,8 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// ime_dialog_ui.cpp
|
||||
// ----------------------------------------------------------
|
||||
// Full implementation of IME dialog UI with on‑screen keyboard
|
||||
// (all original logic intact, bugs fixed).
|
||||
// ----------------------------------------------------------
|
||||
|
||||
#include <cwchar>
|
||||
#include <string>
|
||||
|
@ -13,21 +16,49 @@
|
|||
#include "core/tls.h"
|
||||
#include "imgui/imgui_std.h"
|
||||
|
||||
#include "ime_keyboard_layouts.h" // c16rtomb, layout tables
|
||||
#include "ime_keyboard_ui.h" // DrawVirtualKeyboard, Utf8SafeBackspace
|
||||
|
||||
using namespace ImGui;
|
||||
|
||||
/* small helper for the OK/Cancel buttons */
|
||||
static constexpr ImVec2 BUTTON_SIZE{100.0f, 30.0f};
|
||||
|
||||
/* convert palette colour from Orbis struct to ImGui format */
|
||||
static ImU32 ConvertColor(const Libraries::ImeDialog::OrbisImeColor& c) {
|
||||
return IM_COL32(c.r, c.g, c.b, c.a);
|
||||
}
|
||||
|
||||
/*─────────────────────────────────────────────────────────────*
|
||||
* Libraries::ImeDialog implementation
|
||||
*─────────────────────────────────────────────────────────────*/
|
||||
namespace Libraries::ImeDialog {
|
||||
|
||||
/* ----------------------------------------------------------
|
||||
* class‑static pointer – single definition
|
||||
* ----------------------------------------------------------*/
|
||||
ImeDialogUi* ImeDialogUi::g_activeImeDialogUi = nullptr;
|
||||
|
||||
/* ----------------------------------------------------------
|
||||
* keyboard‑to‑dialog event bridge
|
||||
* ----------------------------------------------------------*/
|
||||
static void KeyboardCallbackBridge(const VirtualKeyEvent* evt) {
|
||||
if (ImeDialogUi::g_activeImeDialogUi && evt)
|
||||
ImeDialogUi::g_activeImeDialogUi->OnVirtualKeyEvent(evt);
|
||||
}
|
||||
|
||||
/*─────────────────────────────────────────────────────────────*
|
||||
* ImeDialogState : constructors, helpers
|
||||
*─────────────────────────────────────────────────────────────*/
|
||||
ImeDialogState::ImeDialogState(const OrbisImeDialogParam* param,
|
||||
const OrbisImeParamExtended* extended) {
|
||||
if (!param) {
|
||||
if (!param)
|
||||
return;
|
||||
}
|
||||
|
||||
/* basic param copy */
|
||||
user_id = param->user_id;
|
||||
is_multi_line = True(param->option & OrbisImeDialogOption::Multiline);
|
||||
is_numeric = param->type == OrbisImeType::Number;
|
||||
is_numeric = (param->type == OrbisImeType::Number);
|
||||
type = param->type;
|
||||
enter_label = param->enter_label;
|
||||
text_filter = param->filter;
|
||||
|
@ -35,6 +66,35 @@ ImeDialogState::ImeDialogState(const OrbisImeDialogParam* param,
|
|||
max_text_length = param->max_text_length;
|
||||
text_buffer = param->input_text_buffer;
|
||||
|
||||
/* default keyboard style */
|
||||
has_custom_kb_style = false;
|
||||
custom_kb_style.layout_width = 485.0f;
|
||||
custom_kb_style.layout_height = 200.0f;
|
||||
custom_kb_style.key_spacing = 2.0f;
|
||||
custom_kb_style.color_text = IM_COL32(225, 225, 225, 255);
|
||||
custom_kb_style.color_line = IM_COL32(88, 88, 88, 255);
|
||||
custom_kb_style.color_button_default = IM_COL32(35, 35, 35, 255);
|
||||
custom_kb_style.color_button_function = IM_COL32(50, 50, 50, 255);
|
||||
custom_kb_style.color_special = IM_COL32(0, 140, 200, 255);
|
||||
custom_kb_style.color_button_symbol = IM_COL32(60, 60, 60, 255);
|
||||
custom_kb_style.use_button_symbol_color = false;
|
||||
|
||||
/* optional extended palette */
|
||||
if (extended) {
|
||||
custom_kb_style.layout_width = 600.0f;
|
||||
custom_kb_style.layout_height = 220.0f;
|
||||
custom_kb_style.key_spacing = 3.0f;
|
||||
custom_kb_style.color_text = ConvertColor(extended->color_text);
|
||||
custom_kb_style.color_line = ConvertColor(extended->color_line);
|
||||
custom_kb_style.color_button_default = ConvertColor(extended->color_button_default);
|
||||
custom_kb_style.color_button_function = ConvertColor(extended->color_button_function);
|
||||
custom_kb_style.color_button_symbol = ConvertColor(extended->color_button_symbol);
|
||||
custom_kb_style.color_special = ConvertColor(extended->color_special);
|
||||
custom_kb_style.use_button_symbol_color = true;
|
||||
has_custom_kb_style = true;
|
||||
}
|
||||
|
||||
/* UTF‑16 → UTF‑8 conversions */
|
||||
if (param->title) {
|
||||
std::size_t title_len = std::char_traits<char16_t>::length(param->title);
|
||||
title.resize(title_len * 4 + 1);
|
||||
|
@ -166,12 +226,20 @@ bool ImeDialogState::ConvertUTF8ToOrbis(const char* utf8_text, std::size_t utf8_
|
|||
return true;
|
||||
}
|
||||
|
||||
/*─────────────────────────────────────────────────────────────*
|
||||
* ImeDialogUi : constructor / destructor / move
|
||||
*─────────────────────────────────────────────────────────────*/
|
||||
ImeDialogUi::ImeDialogUi(ImeDialogState* state, OrbisImeDialogStatus* status,
|
||||
OrbisImeDialogResult* result)
|
||||
: state(state), status(status), result(result) {
|
||||
|
||||
if (state && *status == OrbisImeDialogStatus::Running) {
|
||||
AddLayer(this);
|
||||
ImeDialogUi::g_activeImeDialogUi = this;
|
||||
}
|
||||
|
||||
if (state && state->has_custom_kb_style) {
|
||||
kb_style = state->custom_kb_style;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,6 +247,10 @@ ImeDialogUi::~ImeDialogUi() {
|
|||
std::scoped_lock lock(draw_mutex);
|
||||
|
||||
Free();
|
||||
|
||||
if (ImeDialogUi::g_activeImeDialogUi == this) {
|
||||
ImeDialogUi::g_activeImeDialogUi = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ImeDialogUi::ImeDialogUi(ImeDialogUi&& other) noexcept
|
||||
|
@ -190,8 +262,9 @@ ImeDialogUi::ImeDialogUi(ImeDialogUi&& other) noexcept
|
|||
other.status = nullptr;
|
||||
other.result = nullptr;
|
||||
|
||||
if (state && *status == OrbisImeDialogStatus::Running) {
|
||||
if (state && status && *status == OrbisImeDialogStatus::Running) {
|
||||
AddLayer(this);
|
||||
ImeDialogUi::g_activeImeDialogUi = this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,12 +276,14 @@ ImeDialogUi& ImeDialogUi::operator=(ImeDialogUi&& other) {
|
|||
status = other.status;
|
||||
result = other.result;
|
||||
first_render = other.first_render;
|
||||
|
||||
other.state = nullptr;
|
||||
other.status = nullptr;
|
||||
other.result = nullptr;
|
||||
|
||||
if (state && *status == OrbisImeDialogStatus::Running) {
|
||||
if (state && status && *status == OrbisImeDialogStatus::Running) {
|
||||
AddLayer(this);
|
||||
ImeDialogUi::g_activeImeDialogUi = this;
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -218,6 +293,9 @@ void ImeDialogUi::Free() {
|
|||
RemoveLayer(this);
|
||||
}
|
||||
|
||||
/*─────────────────────────────────────────────────────────────*
|
||||
* ImeDialogUi : main ImGui draw routine
|
||||
*─────────────────────────────────────────────────────────────*/
|
||||
void ImeDialogUi::Draw() {
|
||||
std::unique_lock lock{draw_mutex};
|
||||
|
||||
|
@ -235,9 +313,9 @@ void ImeDialogUi::Draw() {
|
|||
ImVec2 window_size;
|
||||
|
||||
if (state->is_multi_line) {
|
||||
window_size = {500.0f, 300.0f};
|
||||
window_size = {500.0f, 500.0f};
|
||||
} else {
|
||||
window_size = {500.0f, 150.0f};
|
||||
window_size = {500.0f, 350.0f};
|
||||
}
|
||||
|
||||
CentralizeNextWindow();
|
||||
|
@ -251,135 +329,243 @@ void ImeDialogUi::Draw() {
|
|||
if (Begin("IME Dialog##ImeDialog", nullptr,
|
||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) {
|
||||
DrawPrettyBackground();
|
||||
|
||||
/* ---------- title ---------- */
|
||||
if (!state->title.empty()) {
|
||||
SetCursorPosX(20.0f);
|
||||
SetWindowFontScale(1.7f);
|
||||
TextUnformatted(state->title.data());
|
||||
SetWindowFontScale(1.0f);
|
||||
}
|
||||
|
||||
/* ---------- input box ---------- */
|
||||
if (state->is_multi_line) {
|
||||
DrawMultiLineInputText();
|
||||
} else {
|
||||
DrawInputText();
|
||||
}
|
||||
|
||||
SetCursorPosY(GetCursorPosY() + 10.0f);
|
||||
/* ---------- dummy prediction bar with Cancel button ---------- */
|
||||
DrawPredictionBarAnCancelButton();
|
||||
|
||||
const char* button_text;
|
||||
/* ---------- on‑screen keyboard ---------- */
|
||||
DrawVirtualKeyboardSection();
|
||||
|
||||
switch (state->enter_label) {
|
||||
case OrbisImeEnterLabel::Go:
|
||||
button_text = "Go##ImeDialogOK";
|
||||
break;
|
||||
case OrbisImeEnterLabel::Search:
|
||||
button_text = "Search##ImeDialogOK";
|
||||
break;
|
||||
case OrbisImeEnterLabel::Send:
|
||||
button_text = "Send##ImeDialogOK";
|
||||
break;
|
||||
case OrbisImeEnterLabel::Default:
|
||||
default:
|
||||
button_text = "OK##ImeDialogOK";
|
||||
break;
|
||||
}
|
||||
/* ---------- OK / Cancel buttons ---------- */
|
||||
/* {
|
||||
SetCursorPosY(GetCursorPosY() + 10.0f);
|
||||
const char* ok_lbl = "OK##ImeDialogOK";
|
||||
switch (state->enter_label) {
|
||||
case OrbisImeEnterLabel::Go:
|
||||
ok_lbl = "Go##ImeDialogOK";
|
||||
break;
|
||||
case OrbisImeEnterLabel::Search:
|
||||
ok_lbl = "Search##ImeDialogOK";
|
||||
break;
|
||||
case OrbisImeEnterLabel::Send:
|
||||
ok_lbl = "Send##ImeDialogOK";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
float button_spacing = 10.0f;
|
||||
float total_button_width = BUTTON_SIZE.x * 2 + button_spacing;
|
||||
float button_start_pos = (window_size.x - total_button_width) / 2.0f;
|
||||
float spacing = 10.0f;
|
||||
float total_w = BUTTON_SIZE.x * 2 + spacing;
|
||||
float x_start = (window_size.x - total_w) / 2.0f;
|
||||
SetCursorPosX(x_start);
|
||||
|
||||
SetCursorPosX(button_start_pos);
|
||||
if (Button(ok_lbl, BUTTON_SIZE) ||
|
||||
(!state->is_multi_line && IsKeyPressed(ImGuiKey_Enter))) {
|
||||
*status = OrbisImeDialogStatus::Finished;
|
||||
result->endstatus = OrbisImeDialogEndStatus::Ok;
|
||||
}
|
||||
|
||||
if (Button(button_text, BUTTON_SIZE) ||
|
||||
(!state->is_multi_line && IsKeyPressed(ImGuiKey_Enter))) {
|
||||
*status = OrbisImeDialogStatus::Finished;
|
||||
result->endstatus = OrbisImeDialogEndStatus::Ok;
|
||||
}
|
||||
SameLine(0.0f, spacing);
|
||||
|
||||
SameLine(0.0f, button_spacing);
|
||||
if (Button("Cancel##ImeDialogCancel", BUTTON_SIZE)) {
|
||||
*status = OrbisImeDialogStatus::Finished;
|
||||
result->endstatus = OrbisImeDialogEndStatus::UserCanceled;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (Button("Cancel##ImeDialogCancel", BUTTON_SIZE)) {
|
||||
*status = OrbisImeDialogStatus::Finished;
|
||||
result->endstatus = OrbisImeDialogEndStatus::UserCanceled;
|
||||
}
|
||||
End();
|
||||
}
|
||||
End();
|
||||
|
||||
first_render = false;
|
||||
}
|
||||
|
||||
/*─────────────────────────────────────────────────────────────*
|
||||
* helper draw functions (unchanged)
|
||||
*─────────────────────────────────────────────────────────────*/
|
||||
void ImeDialogUi::DrawInputText() {
|
||||
ImVec2 input_size = {GetWindowWidth() - 40.0f, 0.0f};
|
||||
ImVec2 size(GetWindowWidth() - 40.0f, 0.0f);
|
||||
SetCursorPosX(20.0f);
|
||||
if (first_render) {
|
||||
if (first_render)
|
||||
SetKeyboardFocusHere();
|
||||
}
|
||||
const char* placeholder = state->placeholder.empty() ? nullptr : state->placeholder.data();
|
||||
if (InputTextEx("##ImeDialogInput", placeholder, state->current_text.begin(),
|
||||
state->max_text_length, input_size, ImGuiInputTextFlags_CallbackCharFilter,
|
||||
InputTextCallback, this)) {
|
||||
|
||||
const char* ph = state->placeholder.empty() ? nullptr : state->placeholder.data();
|
||||
if (InputTextEx("##ImeDialogInput", ph, state->current_text.begin(), state->max_text_length,
|
||||
size, ImGuiInputTextFlags_CallbackCharFilter, InputTextCallback, this))
|
||||
state->input_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ImeDialogUi::DrawMultiLineInputText() {
|
||||
ImVec2 input_size = {GetWindowWidth() - 40.0f, 200.0f};
|
||||
ImVec2 size(GetWindowWidth() - 40.0f, 200.0f);
|
||||
SetCursorPosX(20.0f);
|
||||
ImGuiInputTextFlags flags = ImGuiInputTextFlags_CallbackCharFilter |
|
||||
static_cast<ImGuiInputTextFlags>(ImGuiInputTextFlags_Multiline);
|
||||
if (first_render) {
|
||||
if (first_render)
|
||||
SetKeyboardFocusHere();
|
||||
}
|
||||
const char* placeholder = state->placeholder.empty() ? nullptr : state->placeholder.data();
|
||||
if (InputTextEx("##ImeDialogInput", placeholder, state->current_text.begin(),
|
||||
state->max_text_length, input_size, flags, InputTextCallback, this)) {
|
||||
|
||||
const char* ph = state->placeholder.empty() ? nullptr : state->placeholder.data();
|
||||
if (InputTextEx("##ImeDialogInput", ph, state->current_text.begin(), state->max_text_length,
|
||||
size, flags, InputTextCallback, this))
|
||||
state->input_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
int ImeDialogUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
|
||||
ImeDialogUi* ui = static_cast<ImeDialogUi*>(data->UserData);
|
||||
ASSERT(ui);
|
||||
|
||||
// Should we filter punctuation?
|
||||
/* numeric filter */
|
||||
if (ui->state->is_numeric && (data->EventChar < '0' || data->EventChar > '9') &&
|
||||
data->EventChar != '\b' && data->EventChar != ',' && data->EventChar != '.') {
|
||||
data->EventChar != '\b' && data->EventChar != ',' && data->EventChar != '.')
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!ui->state->keyboard_filter) {
|
||||
if (!ui->state->keyboard_filter)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ImGui encodes ImWchar32 as multi-byte UTF-8 characters
|
||||
char* event_char = reinterpret_cast<char*>(&data->EventChar);
|
||||
char* ev_char = reinterpret_cast<char*>(&data->EventChar);
|
||||
|
||||
// Call the keyboard filter
|
||||
OrbisImeKeycode src_keycode = {
|
||||
OrbisImeKeycode src{
|
||||
.keycode = 0,
|
||||
.character = 0,
|
||||
.status = 1, // ??? 1 = key pressed, 0 = key released
|
||||
.type = OrbisImeKeyboardType::ENGLISH_US, // TODO set this to the correct value (maybe use
|
||||
// the current language?)
|
||||
.status = 1,
|
||||
.type = OrbisImeKeyboardType::ENGLISH_US,
|
||||
.user_id = ui->state->user_id,
|
||||
.resource_id = 0,
|
||||
.timestamp = 0,
|
||||
};
|
||||
|
||||
if (!ui->state->ConvertUTF8ToOrbis(event_char, 4, &src_keycode.character, 1)) {
|
||||
LOG_ERROR(Lib_ImeDialog, "Failed to convert orbis char to utf8");
|
||||
if (!ui->state->ConvertUTF8ToOrbis(ev_char, 4, &src.character, 1))
|
||||
return 0;
|
||||
}
|
||||
src_keycode.keycode = src_keycode.character; // TODO set this to the correct value
|
||||
|
||||
u16 out_keycode;
|
||||
u32 out_status;
|
||||
|
||||
ui->state->CallKeyboardFilter(&src_keycode, &out_keycode, &out_status);
|
||||
|
||||
// TODO. set the keycode
|
||||
src.keycode = src.character;
|
||||
|
||||
u16 out_code;
|
||||
u32 out_stat;
|
||||
ui->state->CallKeyboardFilter(&src, &out_code, &out_stat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*─────────────────────────────────────────────────────────────*
|
||||
* helper draw functions (new)
|
||||
*─────────────────────────────────────────────────────────────*/
|
||||
void ImeDialogUi::OnVirtualKeyEvent(const VirtualKeyEvent* evt) {
|
||||
if (!evt || !state || !evt->key)
|
||||
return;
|
||||
|
||||
const KeyEntry* key = evt->key;
|
||||
|
||||
/* Treat Repeat exactly like Down */
|
||||
if (evt->type == VirtualKeyEventType::Down || evt->type == VirtualKeyEventType::Repeat) {
|
||||
switch (key->type) {
|
||||
case KeyType::Character: {
|
||||
char utf8[8]{};
|
||||
int n = c16rtomb(utf8, key->character);
|
||||
if (n > 0)
|
||||
state->AppendUtf8(utf8, (size_t)n);
|
||||
break;
|
||||
}
|
||||
case KeyType::Function:
|
||||
switch (key->keycode) {
|
||||
case 0x08:
|
||||
state->BackspaceUtf8();
|
||||
break; // Backspace
|
||||
case 0x0D:
|
||||
*status = OrbisImeDialogStatus::Finished; // Enter
|
||||
result->endstatus = OrbisImeDialogEndStatus::Ok;
|
||||
break;
|
||||
|
||||
case KC_SYM1:
|
||||
kb_mode = KeyboardMode::Symbols1;
|
||||
break;
|
||||
case KC_SYM2:
|
||||
kb_mode = KeyboardMode::Symbols2;
|
||||
break;
|
||||
case KC_ACCENTS:
|
||||
kb_mode = KeyboardMode::AccentLetters;
|
||||
break;
|
||||
case KC_LETTERS:
|
||||
kb_mode = KeyboardMode::Letters;
|
||||
break;
|
||||
|
||||
case 0x10: // Shift / Caps
|
||||
case 0x105:
|
||||
shift_state = (shift_state == ShiftState::None)
|
||||
? ShiftState::Shift
|
||||
: (shift_state == ShiftState::Shift ? ShiftState::CapsLock
|
||||
: ShiftState::None);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Up is available if you need it later; currently ignored */
|
||||
}
|
||||
|
||||
void ImeDialogUi::DrawVirtualKeyboardSection() {
|
||||
ImGui::PushID("VirtualKeyboardSection");
|
||||
DrawVirtualKeyboard(kb_mode, state->type, shift_state, kb_language, KeyboardCallbackBridge,
|
||||
kb_style);
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void ImeDialogUi::DrawPredictionBarAnCancelButton() {
|
||||
const float pad = 5.0f;
|
||||
const float width = kb_style.layout_width;
|
||||
const float bar_h = 25.0f;
|
||||
|
||||
SetCursorPosX(0.0f);
|
||||
ImVec2 p0 = GetCursorScreenPos();
|
||||
ImVec2 p1 = ImVec2(p0.x + width - bar_h - 2 * pad, p0.y + bar_h);
|
||||
// GetWindowDrawList()->AddRectFilled(p0, p1, IM_COL32(0, 0, 0, 255));
|
||||
|
||||
/* label */
|
||||
// ImGui::SetCursorScreenPos(ImVec2(p0.x, p0.y));
|
||||
// ImGui::PushStyleColor(ImGuiCol_Text, kb_style.color_text);
|
||||
// Selectable("dummy prediction", false, 0, ImVec2(width - bar_h, bar_h));
|
||||
// ImGui::PopStyleColor();
|
||||
|
||||
SetCursorPosX(pad);
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 255));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(0, 0, 0, 255));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, IM_COL32(0, 0, 0, 255));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, kb_style.color_text);
|
||||
|
||||
if (ImGui::Button("predict", ImVec2(width - bar_h - 3 * pad, bar_h))) {
|
||||
}
|
||||
ImGui::PopStyleColor(4);
|
||||
|
||||
/* X button */
|
||||
// ImGui::SameLine(width - bar_h);
|
||||
ImGui::SetCursorScreenPos(ImVec2(p0.x + width - bar_h - pad, p0.y));
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, kb_style.color_button_function);
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, kb_style.color_button_function);
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, kb_style.color_button_function);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, kb_style.color_text);
|
||||
|
||||
if (ImGui::Button("╳", ImVec2(bar_h, bar_h))) {
|
||||
*status = OrbisImeDialogStatus::Finished;
|
||||
result->endstatus = OrbisImeDialogEndStatus::UserCanceled;
|
||||
}
|
||||
ImGui::PopStyleColor(4);
|
||||
SetCursorPosX(0.0f);
|
||||
SetCursorPosY(GetCursorPosY() + 5.0f);
|
||||
}
|
||||
|
||||
} // namespace Libraries::ImeDialog
|
||||
|
|
|
@ -1,23 +1,29 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstring> // for strncpy / memcpy
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <imgui.h>
|
||||
#include "common/cstring.h"
|
||||
#include "common/types.h"
|
||||
#include "core/libraries/ime/ime_dialog.h"
|
||||
#include "ime_keyboard_ui.h"
|
||||
#include "imgui/imgui_layer.h"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
namespace Libraries::ImeDialog {
|
||||
|
||||
// Forward declaration so we can befriend it
|
||||
class ImeDialogUi;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// ImeDialogState — holds the text and options for the IME dialog
|
||||
//---------------------------------------------------------------------
|
||||
class ImeDialogState final {
|
||||
friend ImeDialogUi;
|
||||
friend class ImeDialogUi; // full access for the dialog‑UI layer
|
||||
|
||||
/*────────────────────────── private data ─────────────────────────*/
|
||||
bool input_changed = false;
|
||||
|
||||
s32 user_id{};
|
||||
|
@ -29,19 +35,75 @@ class ImeDialogState final {
|
|||
OrbisImeExtKeyboardFilter keyboard_filter{};
|
||||
u32 max_text_length{};
|
||||
char16_t* text_buffer{};
|
||||
|
||||
std::vector<char> title;
|
||||
std::vector<char> placeholder;
|
||||
|
||||
// A character can hold up to 4 bytes in UTF-8
|
||||
// One UTF‑8 code‑point may take up to 4 bytes
|
||||
Common::CString<ORBIS_IME_DIALOG_MAX_TEXT_LENGTH * 4> current_text;
|
||||
|
||||
public:
|
||||
ImeDialogState(const OrbisImeDialogParam* param = nullptr,
|
||||
const OrbisImeParamExtended* extended = nullptr);
|
||||
ImeDialogState(const ImeDialogState& other) = delete;
|
||||
ImeDialogState(ImeDialogState&& other) noexcept;
|
||||
ImeDialogState& operator=(ImeDialogState&& other);
|
||||
// Optional custom keyboard style (from extended params)
|
||||
bool has_custom_kb_style = false;
|
||||
KeyboardStyle custom_kb_style{};
|
||||
|
||||
public:
|
||||
/*──────────────── constructors / rule‑of‑five ────────────────*/
|
||||
ImeDialogState(const OrbisImeDialogParam* param = nullptr,
|
||||
const OrbisImeParamExtended* ext = nullptr);
|
||||
ImeDialogState(const ImeDialogState&) = delete;
|
||||
ImeDialogState(ImeDialogState&&) noexcept;
|
||||
ImeDialogState& operator=(ImeDialogState&&);
|
||||
|
||||
/*──────────────────── public read helpers ───────────────────*/
|
||||
bool IsMultiLine() const {
|
||||
return is_multi_line;
|
||||
}
|
||||
bool IsNumeric() const {
|
||||
return is_numeric;
|
||||
}
|
||||
u32 MaxTextLength() const {
|
||||
return max_text_length;
|
||||
}
|
||||
|
||||
const char* TitleUtf8() const {
|
||||
return title.empty() ? nullptr : title.data();
|
||||
}
|
||||
const char* PlaceholderUtf8() const {
|
||||
return placeholder.empty() ? nullptr : placeholder.data();
|
||||
}
|
||||
const char* CurrentTextUtf8() const {
|
||||
return current_text.begin();
|
||||
}
|
||||
|
||||
/*─────────────────── public write helpers ───────────────────*/
|
||||
// Replace the whole text buffer
|
||||
void SetTextUtf8(const char* utf8) {
|
||||
if (!utf8)
|
||||
return;
|
||||
std::strncpy(current_text.begin(), utf8, current_text.capacity() - 1);
|
||||
current_text[current_text.capacity() - 1] = '\0';
|
||||
input_changed = true;
|
||||
}
|
||||
|
||||
// Append raw UTF‑8 sequence of length 'len'
|
||||
void AppendUtf8(const char* utf8, std::size_t len) {
|
||||
if (!utf8 || len == 0)
|
||||
return;
|
||||
std::size_t old = std::strlen(current_text.begin());
|
||||
if (old + len >= current_text.capacity())
|
||||
return; // full: silently ignore
|
||||
std::memcpy(current_text.begin() + old, utf8, len);
|
||||
current_text[old + len] = '\0';
|
||||
input_changed = true;
|
||||
}
|
||||
|
||||
// Remove one UTF‑8 code‑point from the end (safe backspace)
|
||||
void BackspaceUtf8() {
|
||||
Utf8SafeBackspace(current_text.begin());
|
||||
input_changed = true;
|
||||
}
|
||||
|
||||
/*──────────────────────── IME support ───────────────────────*/
|
||||
bool CopyTextToOrbisBuffer();
|
||||
bool CallTextFilter();
|
||||
|
||||
|
@ -49,12 +111,16 @@ private:
|
|||
bool CallKeyboardFilter(const OrbisImeKeycode* src_keycode, u16* out_keycode, u32* out_status);
|
||||
|
||||
bool ConvertOrbisToUTF8(const char16_t* orbis_text, std::size_t orbis_text_len, char* utf8_text,
|
||||
std::size_t native_text_len);
|
||||
bool ConvertUTF8ToOrbis(const char* native_text, std::size_t utf8_text_len,
|
||||
char16_t* orbis_text, std::size_t orbis_text_len);
|
||||
std::size_t utf8_text_len);
|
||||
bool ConvertUTF8ToOrbis(const char* utf8_text, std::size_t utf8_text_len, char16_t* orbis_text,
|
||||
std::size_t orbis_text_len);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// ImeDialogUi — draws the IME dialog & on‑screen keyboard
|
||||
//---------------------------------------------------------------------
|
||||
class ImeDialogUi final : public ImGui::Layer {
|
||||
/*────────── private data ─────────*/
|
||||
ImeDialogState* state{};
|
||||
OrbisImeDialogStatus* status{};
|
||||
OrbisImeDialogResult* result{};
|
||||
|
@ -63,22 +129,38 @@ class ImeDialogUi final : public ImGui::Layer {
|
|||
std::mutex draw_mutex;
|
||||
|
||||
public:
|
||||
// Global pointer to the active dialog‑UI (used by the callback bridge)
|
||||
static ImeDialogUi* g_activeImeDialogUi;
|
||||
|
||||
/*───────── ctors / dtor ─────────*/
|
||||
explicit ImeDialogUi(ImeDialogState* state = nullptr, OrbisImeDialogStatus* status = nullptr,
|
||||
OrbisImeDialogResult* result = nullptr);
|
||||
~ImeDialogUi() override;
|
||||
ImeDialogUi(const ImeDialogUi& other) = delete;
|
||||
ImeDialogUi(ImeDialogUi&& other) noexcept;
|
||||
ImeDialogUi& operator=(ImeDialogUi&& other);
|
||||
ImeDialogUi(const ImeDialogUi&) = delete;
|
||||
ImeDialogUi(ImeDialogUi&&) noexcept;
|
||||
ImeDialogUi& operator=(ImeDialogUi&&);
|
||||
|
||||
/*────────── main draw ───────────*/
|
||||
void Draw() override;
|
||||
|
||||
private:
|
||||
void Free();
|
||||
/*────────── keyboard events ─────*/
|
||||
void OnVirtualKeyEvent(const VirtualKeyEvent* evt);
|
||||
|
||||
private:
|
||||
/*── helpers ─*/
|
||||
void Free();
|
||||
void DrawInputText();
|
||||
void DrawMultiLineInputText();
|
||||
|
||||
static int InputTextCallback(ImGuiInputTextCallbackData* data);
|
||||
|
||||
/*── keyboard section ─*/
|
||||
KeyboardMode kb_mode = KeyboardMode::Letters;
|
||||
ShiftState shift_state = ShiftState::None;
|
||||
u64 kb_language = 0;
|
||||
KeyboardStyle kb_style;
|
||||
|
||||
void DrawVirtualKeyboardSection();
|
||||
void DrawPredictionBarAnCancelButton();
|
||||
};
|
||||
|
||||
} // namespace Libraries::ImeDialog
|
||||
|
|
467
src/core/libraries/ime/ime_keyboard_layouts.cpp
Normal file
467
src/core/libraries/ime/ime_keyboard_layouts.cpp
Normal file
|
@ -0,0 +1,467 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include "ime_keyboard_layouts.h"
|
||||
|
||||
int c16rtomb(char* out, char16_t ch) {
|
||||
if (ch <= 0x7F) {
|
||||
out[0] = static_cast<char>(ch);
|
||||
out[1] = '\0';
|
||||
return 1;
|
||||
} else if (ch <= 0x7FF) {
|
||||
out[0] = 0xC0 | ((ch >> 6) & 0x1F);
|
||||
out[1] = 0x80 | (ch & 0x3F);
|
||||
out[2] = '\0';
|
||||
return 2;
|
||||
} else {
|
||||
out[0] = 0xE0 | ((ch >> 12) & 0x0F);
|
||||
out[1] = 0x80 | ((ch >> 6) & 0x3F);
|
||||
out[2] = 0x80 | (ch & 0x3F);
|
||||
out[3] = '\0';
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<KeyEntry> kLayoutEnLettersUppercase = {
|
||||
// Row 0
|
||||
{0x31, u'1', KeyType::Character, 0, 0, 1, 1, "1", "", {None, None}},
|
||||
{0x32, u'2', KeyType::Character, 0, 1, 1, 1, "2", "", {None, None}},
|
||||
{0x33, u'3', KeyType::Character, 0, 2, 1, 1, "3", "", {None, None}},
|
||||
{0x34, u'4', KeyType::Character, 0, 3, 1, 1, "4", "", {None, None}},
|
||||
{0x35, u'5', KeyType::Character, 0, 4, 1, 1, "5", "", {None, None}},
|
||||
{0x36, u'6', KeyType::Character, 0, 5, 1, 1, "6", "", {None, None}},
|
||||
{0x37, u'7', KeyType::Character, 0, 6, 1, 1, "7", "", {None, None}},
|
||||
{0x38, u'8', KeyType::Character, 0, 7, 1, 1, "8", "", {None, None}},
|
||||
{0x39, u'9', KeyType::Character, 0, 8, 1, 1, "9", "", {None, None}},
|
||||
{0x30, u'0', KeyType::Character, 0, 9, 1, 1, "0", "", {None, None}},
|
||||
|
||||
// Row 1
|
||||
{0x51, u'Q', KeyType::Character, 1, 0, 1, 1, "Q", "", {None, None}},
|
||||
{0x57, u'W', KeyType::Character, 1, 1, 1, 1, "W", "", {None, None}},
|
||||
{0x45, u'E', KeyType::Character, 1, 2, 1, 1, "E", "", {None, None}},
|
||||
{0x52, u'R', KeyType::Character, 1, 3, 1, 1, "R", "", {None, None}},
|
||||
{0x54, u'T', KeyType::Character, 1, 4, 1, 1, "T", "", {None, None}},
|
||||
{0x59, u'Y', KeyType::Character, 1, 5, 1, 1, "Y", "", {None, None}},
|
||||
{0x55, u'U', KeyType::Character, 1, 6, 1, 1, "U", "", {None, None}},
|
||||
{0x49, u'I', KeyType::Character, 1, 7, 1, 1, "I", "", {None, None}},
|
||||
{0x4F, u'O', KeyType::Character, 1, 8, 1, 1, "O", "", {None, None}},
|
||||
{0x50, u'P', KeyType::Character, 1, 9, 1, 1, "P", "", {None, None}},
|
||||
|
||||
// Row 2
|
||||
{0x41, u'A', KeyType::Character, 2, 0, 1, 1, "A", "", {None, None}},
|
||||
{0x53, u'S', KeyType::Character, 2, 1, 1, 1, "S", "", {None, None}},
|
||||
{0x44, u'D', KeyType::Character, 2, 2, 1, 1, "D", "", {None, None}},
|
||||
{0x46, u'F', KeyType::Character, 2, 3, 1, 1, "F", "", {None, None}},
|
||||
{0x47, u'G', KeyType::Character, 2, 4, 1, 1, "G", "", {None, None}},
|
||||
{0x48, u'H', KeyType::Character, 2, 5, 1, 1, "H", "", {None, None}},
|
||||
{0x4A, u'J', KeyType::Character, 2, 6, 1, 1, "J", "", {None, None}},
|
||||
{0x4B, u'K', KeyType::Character, 2, 7, 1, 1, "K", "", {None, None}},
|
||||
{0x4C, u'L', KeyType::Character, 2, 8, 1, 1, "L", "", {None, None}},
|
||||
{0x22, u'"', KeyType::Character, 2, 9, 1, 1, "\"", "", {None, None}},
|
||||
|
||||
// Row 3
|
||||
{0x5A, u'Z', KeyType::Character, 3, 0, 1, 1, "Z", "", {None, None}},
|
||||
{0x58, u'X', KeyType::Character, 3, 1, 1, 1, "X", "", {None, None}},
|
||||
{0x43, u'C', KeyType::Character, 3, 2, 1, 1, "C", "", {None, None}},
|
||||
{0x56, u'V', KeyType::Character, 3, 3, 1, 1, "V", "", {None, None}},
|
||||
{0x42, u'B', KeyType::Character, 3, 4, 1, 1, "B", "", {None, None}},
|
||||
{0x4E, u'N', KeyType::Character, 3, 5, 1, 1, "N", "", {None, None}},
|
||||
{0x4D, u'M', KeyType::Character, 3, 6, 1, 1, "M", "", {None, None}},
|
||||
{0x2D, u'-', KeyType::Character, 3, 7, 1, 1, "-", "", {None, None}},
|
||||
{0x5F, u'_', KeyType::Character, 3, 8, 1, 1, "_", "", {None, None}},
|
||||
{0x2F, u'/', KeyType::Character, 3, 9, 1, 1, "/", "", {None, None}},
|
||||
|
||||
// Row 4
|
||||
{0x10, u'\0', KeyType::Function, 4, 0, 1, 1, "⬆", "L2", {L2, None}},
|
||||
{KC_SYM1, u'\0', KeyType::Function, 4, 1, 1, 1, "@#:", "△", {Triangle, None}}, // TODO:
|
||||
{KC_ACCENTS, u'\0', KeyType::Function, 4, 2, 1, 1, "à", "", {None, None}}, // TODO:
|
||||
{0x20, u' ', KeyType::Character, 4, 3, 4, 1, "Space", "△", {Triangle, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 7, 1, 1, "", "", {None, None}},
|
||||
{0x08, u'\0', KeyType::Function, 4, 8, 2, 1, "⇦", "□", {Square, None}, true},
|
||||
|
||||
// Row 5
|
||||
{0xF020, u'\0', KeyType::Function, 5, 0, 1, 1, "▲", "", {Up, None}},
|
||||
{0xF021, u'\0', KeyType::Function, 5, 1, 1, 1, "▼", "", {Down, None}},
|
||||
{0xF022, u'\0', KeyType::Function, 5, 2, 1, 1, "◀", "L1", {L1, None}},
|
||||
{0xF023, u'\0', KeyType::Function, 5, 3, 1, 1, "▶", "R1", {R1, None}},
|
||||
{KC_KB, u'\0', KeyType::Function, 5, 4, 1, 1, "KB", "", {None, None}}, // TODO:
|
||||
{KC_OPT, u'\0', KeyType::Function, 5, 5, 1, 1, "...", "", {None, None}},
|
||||
{KC_GYRO, u'\0', KeyType::Function, 5, 6, 1, 1, "+/⊗", "R3", {R3, None}}, // TODO:
|
||||
{0x0000, u'\0', KeyType::Disabled, 5, 7, 1, 1, "", "", {None, None}},
|
||||
{0x0D, u'\r', KeyType::Function, 5, 8, 2, 1, "Done", "R2", {R2, None}},
|
||||
|
||||
};
|
||||
|
||||
const std::vector<KeyEntry> kLayoutEnLettersLowercase = {
|
||||
// Row 0
|
||||
{0x31, u'1', KeyType::Character, 0, 0, 1, 1, "1", "", {None, None}},
|
||||
{0x32, u'2', KeyType::Character, 0, 1, 1, 1, "2", "", {None, None}},
|
||||
{0x33, u'3', KeyType::Character, 0, 2, 1, 1, "3", "", {None, None}},
|
||||
{0x34, u'4', KeyType::Character, 0, 3, 1, 1, "4", "", {None, None}},
|
||||
{0x35, u'5', KeyType::Character, 0, 4, 1, 1, "5", "", {None, None}},
|
||||
{0x36, u'6', KeyType::Character, 0, 5, 1, 1, "6", "", {None, None}},
|
||||
{0x37, u'7', KeyType::Character, 0, 6, 1, 1, "7", "", {None, None}},
|
||||
{0x38, u'8', KeyType::Character, 0, 7, 1, 1, "8", "", {None, None}},
|
||||
{0x39, u'9', KeyType::Character, 0, 8, 1, 1, "9", "", {None, None}},
|
||||
{0x30, u'0', KeyType::Character, 0, 9, 1, 1, "0", "", {None, None}},
|
||||
|
||||
// Row 1
|
||||
{0x71, u'q', KeyType::Character, 1, 0, 1, 1, "q", "", {None, None}},
|
||||
{0x77, u'w', KeyType::Character, 1, 1, 1, 1, "w", "", {None, None}},
|
||||
{0x65, u'e', KeyType::Character, 1, 2, 1, 1, "e", "", {None, None}},
|
||||
{0x72, u'r', KeyType::Character, 1, 3, 1, 1, "r", "", {None, None}},
|
||||
{0x74, u't', KeyType::Character, 1, 4, 1, 1, "t", "", {None, None}},
|
||||
{0x79, u'y', KeyType::Character, 1, 5, 1, 1, "y", "", {None, None}},
|
||||
{0x75, u'u', KeyType::Character, 1, 6, 1, 1, "u", "", {None, None}},
|
||||
{0x69, u'i', KeyType::Character, 1, 7, 1, 1, "i", "", {None, None}},
|
||||
{0x6F, u'o', KeyType::Character, 1, 8, 1, 1, "o", "", {None, None}},
|
||||
{0x70, u'p', KeyType::Character, 1, 9, 1, 1, "p", "", {None, None}},
|
||||
|
||||
// Row 2
|
||||
{0x61, u'a', KeyType::Character, 2, 0, 1, 1, "a", "", {None, None}},
|
||||
{0x73, u's', KeyType::Character, 2, 1, 1, 1, "s", "", {None, None}},
|
||||
{0x64, u'd', KeyType::Character, 2, 2, 1, 1, "d", "", {None, None}},
|
||||
{0x66, u'f', KeyType::Character, 2, 3, 1, 1, "f", "", {None, None}},
|
||||
{0x67, u'g', KeyType::Character, 2, 4, 1, 1, "g", "", {None, None}},
|
||||
{0x68, u'h', KeyType::Character, 2, 5, 1, 1, "h", "", {None, None}},
|
||||
{0x6A, u'j', KeyType::Character, 2, 6, 1, 1, "j", "", {None, None}},
|
||||
{0x6B, u'k', KeyType::Character, 2, 7, 1, 1, "k", "", {None, None}},
|
||||
{0x6C, u'l', KeyType::Character, 2, 8, 1, 1, "l", "", {None, None}},
|
||||
{0x22, u'"', KeyType::Character, 2, 9, 1, 1, "\"", "", {None, None}},
|
||||
|
||||
// Row 3
|
||||
{0x7A, u'z', KeyType::Character, 3, 0, 1, 1, "z", "", {None, None}},
|
||||
{0x78, u'x', KeyType::Character, 3, 1, 1, 1, "x", "", {None, None}},
|
||||
{0x63, u'c', KeyType::Character, 3, 2, 1, 1, "c", "", {None, None}},
|
||||
{0x76, u'v', KeyType::Character, 3, 3, 1, 1, "v", "", {None, None}},
|
||||
{0x62, u'b', KeyType::Character, 3, 4, 1, 1, "b", "", {None, None}},
|
||||
{0x6E, u'n', KeyType::Character, 3, 5, 1, 1, "n", "", {None, None}},
|
||||
{0x6D, u'm', KeyType::Character, 3, 6, 1, 1, "m", "", {None, None}},
|
||||
{0x2D, u'-', KeyType::Character, 3, 7, 1, 1, "-", "", {None, None}},
|
||||
{0x5F, u'_', KeyType::Character, 3, 8, 1, 1, "_", "", {None, None}},
|
||||
{0x2F, u'/', KeyType::Character, 3, 9, 1, 1, "/", "", {None, None}},
|
||||
|
||||
// Row 4
|
||||
{0x105, u'\0', KeyType::Function, 4, 0, 1, 1, "⬆", "L2", {L2, None}},
|
||||
{KC_SYM1, u'\0', KeyType::Function, 4, 1, 1, 1, "@#:", "△", {Triangle, None}}, // TODO
|
||||
{KC_ACCENTS, u'\0', KeyType::Function, 4, 2, 1, 1, "à", "", {None, None}}, // TODO
|
||||
{0x20, u' ', KeyType::Character, 4, 3, 4, 1, "Space", "△", {Triangle, None}},
|
||||
{0x00, u'\0', KeyType::Disabled, 4, 7, 1, 1, "", "", {None, None}},
|
||||
{0x08, u'\0', KeyType::Function, 4, 8, 2, 1, "⇦", "□", {Square, None}, true},
|
||||
|
||||
// Row 5
|
||||
{0xF020, u'\0', KeyType::Function, 5, 0, 1, 1, "▲", "", {Up, None}},
|
||||
{0xF021, u'\0', KeyType::Function, 5, 1, 1, 1, "▼", "", {Down, None}},
|
||||
{0xF022, u'\0', KeyType::Function, 5, 2, 1, 1, "◀", "L1", {L1, None}},
|
||||
{0xF023, u'\0', KeyType::Function, 5, 3, 1, 1, "▶", "R1", {R1, None}},
|
||||
{KC_KB, u'\0', KeyType::Function, 5, 4, 1, 1, "KB", "", {None, None}}, // TODO
|
||||
{KC_OPT, u'\0', KeyType::Function, 5, 5, 1, 1, "...", "", {None, None}}, // TODO
|
||||
{KC_GYRO, u'\0', KeyType::Function, 5, 6, 1, 1, "+/⊗", "R3", {R3, None}}, // TODO
|
||||
{0x0000, u'\0', KeyType::Disabled, 5, 7, 1, 1, "", "", {None, None}},
|
||||
{0x0D, u'\r', KeyType::Function, 5, 8, 2, 1, "Done", "R2", {R2, None}},
|
||||
|
||||
};
|
||||
|
||||
// From PS5
|
||||
const std::vector<KeyEntry> kLayoutEnSymbols1 = {
|
||||
// Row 1
|
||||
{0x21, u'!', KeyType::Character, 0, 0, 1, 1, "!", "", {None, None}},
|
||||
{0x3F, u'?', KeyType::Character, 0, 1, 1, 1, "?", "", {None, None}},
|
||||
{0x22, u'"', KeyType::Character, 0, 2, 1, 1, "\"", "", {None, None}},
|
||||
{0x27, u'\'', KeyType::Character, 0, 3, 1, 1, "'", "", {None, None}},
|
||||
{0x23, u'#', KeyType::Character, 0, 4, 1, 1, "#", "", {None, None}},
|
||||
{0x25, u'%', KeyType::Character, 0, 5, 1, 1, "%", "", {None, None}},
|
||||
{0x28, u'(', KeyType::Character, 0, 6, 1, 1, "(", "", {None, None}},
|
||||
{0x29, u')', KeyType::Character, 0, 7, 1, 1, ")", "", {None, None}},
|
||||
{0xF001, u'\0', KeyType::Function, 0, 8, 1, 1, "()", "", {None, None}},
|
||||
{0x2F, u'/', KeyType::Character, 0, 9, 1, 1, "/", "", {None, None}},
|
||||
|
||||
// Row 2
|
||||
{0x2D, u'-', KeyType::Character, 1, 0, 1, 1, "-", "", {None, None}},
|
||||
{0x5F, u'_', KeyType::Character, 1, 1, 1, 1, "_", "", {None, None}},
|
||||
{0x2C, u',', KeyType::Character, 1, 2, 1, 1, ",", "", {None, None}},
|
||||
{0x2E, u'.', KeyType::Character, 1, 3, 1, 1, ".", "", {None, None}},
|
||||
{0x3A, u':', KeyType::Character, 1, 4, 1, 1, ":", "", {None, None}},
|
||||
{0x3B, u';', KeyType::Character, 1, 5, 1, 1, ";", "", {None, None}},
|
||||
{0x2A, u'*', KeyType::Character, 1, 6, 1, 1, "*", "", {None, None}},
|
||||
{0x26, u'&', KeyType::Character, 1, 7, 1, 1, "&", "", {None, None}},
|
||||
{0x2B, u'+', KeyType::Character, 1, 8, 1, 1, "+", "", {None, None}},
|
||||
{0x3D, u'=', KeyType::Character, 1, 9, 1, 1, "=", "", {None, None}},
|
||||
|
||||
// Row 3
|
||||
{0x3C, u'<', KeyType::Character, 2, 0, 1, 1, "<", "", {None, None}},
|
||||
{0x3E, u'>', KeyType::Character, 2, 1, 1, 1, ">", "", {None, None}},
|
||||
{0x40, u'@', KeyType::Character, 2, 2, 1, 1, "@", "", {None, None}},
|
||||
{0x5B, u'[', KeyType::Character, 2, 3, 1, 1, "[", "", {None, None}},
|
||||
{0x5D, u']', KeyType::Character, 2, 4, 1, 1, "]", "", {None, None}},
|
||||
{0xF002, u'\0', KeyType::Function, 2, 5, 1, 1, "[]", "", {None, None}},
|
||||
{0x7B, u'{', KeyType::Character, 2, 6, 1, 1, "{", "", {None, None}},
|
||||
{0x7D, u'}', KeyType::Character, 2, 7, 1, 1, "}", "", {None, None}},
|
||||
{0xF004, u'\0', KeyType::Function, 2, 8, 1, 1, "{}", "", {None, None}},
|
||||
{KC_SYM2, u'\0', KeyType::Function, 2, 9, 1, 2, "→", "", {None, None}},
|
||||
|
||||
// Row 4
|
||||
{0x5C, u'\\', KeyType::Character, 3, 0, 1, 1, "\\", "", {None, None}},
|
||||
{0x7C, u'|', KeyType::Character, 3, 1, 1, 1, "|", "", {None, None}},
|
||||
{0x5E, u'^', KeyType::Character, 3, 2, 1, 1, "^", "", {None, None}},
|
||||
{0x60, u'`', KeyType::Character, 3, 3, 1, 1, "`", "", {None, None}},
|
||||
{0x24, u'$', KeyType::Character, 3, 4, 1, 1, "$", "", {None, None}},
|
||||
{0x20AC, u'\u20AC', KeyType::Character, 3, 5, 1, 1, "€", "", {None, None}},
|
||||
{0x00A3, u'\u00A3', KeyType::Character, 3, 6, 1, 1, "£", "", {None, None}},
|
||||
{0x00A5, u'\u00A5', KeyType::Character, 3, 7, 1, 1, "¥", "", {None, None}},
|
||||
{0x20A9, u'\u20A9', KeyType::Character, 3, 8, 1, 1, "₩", "", {None, None}},
|
||||
|
||||
// Row 5
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 0, 1, 1, "", "", {None, None}},
|
||||
{KC_LETTERS, u'\0', KeyType::Function, 4, 1, 1, 1, "ABC", "L2+△", {L2, Triangle}}, // TODO:
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 2, 1, 1, "", "", {None, None}},
|
||||
{0x0020, u' ', KeyType::Character, 4, 3, 4, 1, "Space", "△", {Triangle, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 7, 1, 1, "", "", {None, None}},
|
||||
{0x0008, u'\0', KeyType::Function, 4, 8, 2, 1, "⇦", "□", {Square, None}, true},
|
||||
|
||||
// Row 6
|
||||
{0xF020, u'\0', KeyType::Function, 5, 0, 1, 1, "▲", "", {Up, None}},
|
||||
{0xF021, u'\0', KeyType::Function, 5, 1, 1, 1, "▼", "", {Down, None}},
|
||||
{0xF022, u'\0', KeyType::Function, 5, 2, 1, 1, "◀", "L1", {L1, None}},
|
||||
{0xF023, u'\0', KeyType::Function, 5, 3, 1, 1, "▶", "R1", {R1, None}},
|
||||
{KC_KB, u'\0', KeyType::Function, 5, 4, 1, 1, "KB", "", {None, None}}, // TODO:
|
||||
{KC_OPT, u'\0', KeyType::Function, 5, 5, 1, 1, "...", "", {None, None}}, // TODO:
|
||||
{KC_GYRO, u'\0', KeyType::Function, 5, 6, 1, 1, "+/⊗", "R3", {R3, None}}, // TODO:
|
||||
{0x0000, u'\0', KeyType::Disabled, 5, 7, 1, 1, "", "", {None, None}},
|
||||
{0x000D, u'\r', KeyType::Function, 5, 8, 2, 1, "Done", "R2", {R2, None}},
|
||||
|
||||
};
|
||||
|
||||
// From PS5
|
||||
const std::vector<KeyEntry> kLayoutEnSymbols2 = {
|
||||
// Row 1
|
||||
{0x201C, u'“', KeyType::Character, 0, 0, 1, 1, "“", "", {None, None}},
|
||||
{0x201D, u'”', KeyType::Character, 0, 1, 1, 1, "”", "", {None, None}},
|
||||
{0x201E, u'„', KeyType::Character, 0, 2, 1, 1, "„", "", {None, None}},
|
||||
{0x00A1, u'¡', KeyType::Character, 0, 3, 1, 1, "¡", "", {None, None}},
|
||||
{0xF013, u'\0', KeyType::Function, 0, 4, 1, 1, "¡!", "", {None, None}},
|
||||
{0x00BF, u'¿', KeyType::Character, 0, 5, 1, 1, "¿", "", {None, None}},
|
||||
{0xF014, u'\0', KeyType::Function, 0, 6, 1, 1, "¿?", "", {None, None}},
|
||||
{0x007E, u'~', KeyType::Character, 0, 7, 1, 1, "~", "", {None, None}},
|
||||
{0x00B7, u'·', KeyType::Character, 0, 8, 1, 1, "·", "", {None, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 0, 9, 1, 1, "", "", {None, None}},
|
||||
|
||||
// Row 2
|
||||
{0x00D7, u'×', KeyType::Character, 1, 0, 1, 1, "×", "", {None, None}},
|
||||
{0x00F7, u'÷', KeyType::Character, 1, 1, 1, 1, "÷", "", {None, None}},
|
||||
{0x2039, u'‹', KeyType::Character, 1, 2, 1, 1, "‹", "", {None, None}},
|
||||
{0x203A, u'›', KeyType::Character, 1, 3, 1, 1, "›", "", {None, None}},
|
||||
{0x00AB, u'«', KeyType::Character, 1, 4, 1, 1, "«", "", {None, None}},
|
||||
{0x00BB, u'»', KeyType::Character, 1, 5, 1, 1, "»", "", {None, None}},
|
||||
{0x00BA, u'º', KeyType::Character, 1, 6, 1, 1, "º", "", {None, None}},
|
||||
{0x00AA, u'ª', KeyType::Character, 1, 7, 1, 1, "ª", "", {None, None}},
|
||||
{0x00B0, u'°', KeyType::Character, 1, 8, 1, 1, "°", "", {None, None}},
|
||||
{0x00A7, u'§', KeyType::Character, 1, 9, 1, 1, "§", "", {None, None}},
|
||||
|
||||
// Row 3
|
||||
{KC_SYM1, u'\0', KeyType::Function, 2, 0, 1, 2, "←", "", {None, None}},
|
||||
{0x00A6, u'¦', KeyType::Character, 2, 1, 1, 1, "¦", "", {None, None}},
|
||||
{0x00B5, u'µ', KeyType::Character, 2, 2, 1, 1, "µ", "", {None, None}},
|
||||
{0x00AC, u'¬', KeyType::Character, 2, 3, 1, 1, "¬", "", {None, None}},
|
||||
{0x00B9, u'¹', KeyType::Character, 2, 4, 1, 1, "¹", "", {None, None}},
|
||||
{0x00B2, u'²', KeyType::Character, 2, 5, 1, 1, "²", "", {None, None}},
|
||||
{0x00B3, u'³', KeyType::Character, 2, 6, 1, 1, "³", "", {None, None}},
|
||||
{0x00BC, u'¼', KeyType::Character, 2, 7, 1, 1, "¼", "", {None, None}},
|
||||
{0x00BD, u'½', KeyType::Character, 2, 8, 1, 1, "½", "", {None, None}},
|
||||
{0x00BE, u'¾', KeyType::Character, 2, 9, 1, 1, "¾", "", {None, None}},
|
||||
|
||||
// Row 4
|
||||
{0x00A2, u'¢', KeyType::Character, 3, 1, 1, 1, "¢", "", {None, None}},
|
||||
{0x00A4, u'¤', KeyType::Character, 3, 2, 1, 1, "¤", "", {None, None}},
|
||||
{0x2019, u'’', KeyType::Character, 3, 3, 1, 1, "’", "", {None, None}},
|
||||
{0x2018, u'‘', KeyType::Character, 3, 4, 1, 1, "‘", "", {None, None}},
|
||||
{0x201B, u'‛', KeyType::Character, 3, 5, 1, 1, "‛", "", {None, None}},
|
||||
{0x201A, u'‚', KeyType::Character, 3, 6, 1, 1, "‚", "", {None, None}},
|
||||
{0x2116, u'№', KeyType::Character, 3, 7, 1, 1, "№", "", {None, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 3, 8, 1, 1, "", "", {None, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 3, 9, 1, 1, "", "", {None, None}},
|
||||
|
||||
// Row 5
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 0, 1, 1, "", "", {None, None}},
|
||||
{KC_LETTERS, u'\0', KeyType::Function, 4, 1, 1, 1, "ABC", "L2+△", {L2, Triangle}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 2, 1, 1, "", "", {None, None}},
|
||||
{0x20, u' ', KeyType::Character, 4, 3, 4, 1, "Space", "△", {Triangle, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 7, 1, 1, "", "", {None, None}},
|
||||
{0x08, u'\0', KeyType::Function, 4, 8, 2, 1, "⇦", "□", {Square, None}, true},
|
||||
|
||||
// Row 6
|
||||
{0xF020, u'\0', KeyType::Function, 5, 0, 1, 1, "▲", "", {Up, None}},
|
||||
{0xF021, u'\0', KeyType::Function, 5, 1, 1, 1, "▼", "", {Down, None}},
|
||||
{0xF022, u'\0', KeyType::Function, 5, 2, 1, 1, "◀", "L1", {L1, None}},
|
||||
{0xF023, u'\0', KeyType::Function, 5, 3, 1, 1, "▶", "R1", {R1, None}},
|
||||
{KC_KB, u'\0', KeyType::Function, 5, 4, 1, 1, "KB", "", {None, None}}, // TODO
|
||||
{KC_OPT, u'\0', KeyType::Function, 5, 5, 1, 1, "...", "", {None, None}}, // TODO
|
||||
{KC_GYRO, u'\0', KeyType::Function, 5, 6, 1, 1, "+/⊗", "R3", {R3, None}}, // TODO
|
||||
{0x0000, u'\0', KeyType::Disabled, 5, 7, 1, 1, "", "", {None, None}},
|
||||
{0x0D, u'\r', KeyType::Function, 5, 8, 2, 1, "Done", "R2", {R2, None}},
|
||||
|
||||
};
|
||||
|
||||
const std::vector<KeyEntry> kLayoutEnAccentLettersUppercase = {
|
||||
// Row 0
|
||||
{0x00C0, u'À', KeyType::Character, 0, 0, 1, 1, "À", "", {None, None}},
|
||||
{0x00C1, u'Á', KeyType::Character, 0, 1, 1, 1, "Á", "", {None, None}},
|
||||
{0x00C2, u'Â', KeyType::Character, 0, 2, 1, 1, "Â", "", {None, None}},
|
||||
{0x00C3, u'Ã', KeyType::Character, 0, 3, 1, 1, "Ã", "", {None, None}},
|
||||
{0x00C4, u'Ä', KeyType::Character, 0, 4, 1, 1, "Ä", "", {None, None}},
|
||||
{0x00C5, u'Å', KeyType::Character, 0, 5, 1, 1, "Å", "", {None, None}},
|
||||
{0x0104, u'Ą', KeyType::Character, 0, 6, 1, 1, "Ą", "", {None, None}},
|
||||
{0x00C6, u'Æ', KeyType::Character, 0, 7, 1, 1, "Æ", "", {None, None}},
|
||||
{0x00C7, u'Ç', KeyType::Character, 0, 8, 1, 1, "Ç", "", {None, None}},
|
||||
{0x0106, u'Ć', KeyType::Character, 0, 9, 1, 1, "Ć", "", {None, None}},
|
||||
|
||||
// Row 1
|
||||
{0x00C8, u'È', KeyType::Character, 1, 0, 1, 1, "È", "", {None, None}},
|
||||
{0x00C9, u'É', KeyType::Character, 1, 1, 1, 1, "É", "", {None, None}},
|
||||
{0x00CA, u'Ê', KeyType::Character, 1, 2, 1, 1, "Ê", "", {None, None}},
|
||||
{0x00CB, u'Ë', KeyType::Character, 1, 3, 1, 1, "Ë", "", {None, None}},
|
||||
{0x0118, u'Ę', KeyType::Character, 1, 4, 1, 1, "Ę", "", {None, None}},
|
||||
{0x011E, u'Ğ', KeyType::Character, 1, 5, 1, 1, "Ğ", "", {None, None}},
|
||||
{0x00CC, u'Ì', KeyType::Character, 1, 6, 1, 1, "Ì", "", {None, None}},
|
||||
{0x00CD, u'Í', KeyType::Character, 1, 7, 1, 1, "Í", "", {None, None}},
|
||||
{0x00CE, u'Î', KeyType::Character, 1, 8, 1, 1, "Î", "", {None, None}},
|
||||
{0x00CF, u'Ï', KeyType::Character, 1, 9, 1, 1, "Ï", "", {None, None}},
|
||||
|
||||
// Row 2
|
||||
{0x0130, u'İ', KeyType::Character, 2, 0, 1, 1, "İ", "", {None, None}},
|
||||
{0x0141, u'Ł', KeyType::Character, 2, 1, 1, 1, "Ł", "", {None, None}},
|
||||
{0x00D1, u'Ñ', KeyType::Character, 2, 2, 1, 1, "Ñ", "", {None, None}},
|
||||
{0x0143, u'Ń', KeyType::Character, 2, 3, 1, 1, "Ń", "", {None, None}},
|
||||
{0x00D2, u'Ò', KeyType::Character, 2, 4, 1, 1, "Ò", "", {None, None}},
|
||||
{0x00D3, u'Ó', KeyType::Character, 2, 5, 1, 1, "Ó", "", {None, None}},
|
||||
{0x00D4, u'Ô', KeyType::Character, 2, 6, 1, 1, "Ô", "", {None, None}},
|
||||
{0x00D5, u'Õ', KeyType::Character, 2, 7, 1, 1, "Õ", "", {None, None}},
|
||||
{0x00D6, u'Ö', KeyType::Character, 2, 8, 1, 1, "Ö", "", {None, None}},
|
||||
{0x00D8, u'Ø', KeyType::Character, 2, 9, 1, 1, "Ø", "", {None, None}},
|
||||
|
||||
// Row 3
|
||||
{0x0152, u'Œ', KeyType::Character, 3, 0, 1, 1, "Œ", "", {None, None}},
|
||||
{0x015A, u'Ś', KeyType::Character, 3, 1, 1, 1, "Ś", "", {None, None}},
|
||||
{0x015E, u'Ş', KeyType::Character, 3, 2, 1, 1, "Ş", "", {None, None}},
|
||||
{0x0160, u'Š', KeyType::Character, 3, 3, 1, 1, "Š", "", {None, None}},
|
||||
{0x00DF, u'ß', KeyType::Character, 3, 4, 1, 1, "ß", "", {None, None}},
|
||||
{0x00D9, u'Ù', KeyType::Character, 3, 5, 1, 1, "Ù", "", {None, None}},
|
||||
{0x00DA, u'Ú', KeyType::Character, 3, 6, 1, 1, "Ú", "", {None, None}},
|
||||
{0x00DB, u'Û', KeyType::Character, 3, 7, 1, 1, "Û", "", {None, None}},
|
||||
{0x00DC, u'Ü', KeyType::Character, 3, 8, 1, 1, "Ü", "", {None, None}},
|
||||
{0x00DD, u'Ý', KeyType::Character, 3, 9, 1, 1, "Ý", "", {None, None}},
|
||||
|
||||
// Row 4
|
||||
{0x0178, u'Ÿ', KeyType::Character, 4, 0, 1, 1, "Ÿ", "", {None, None}},
|
||||
{0x0179, u'Ź', KeyType::Character, 4, 1, 1, 1, "Ź", "", {None, None}},
|
||||
{0x017B, u'Ż', KeyType::Character, 4, 2, 1, 1, "Ż", "", {None, None}},
|
||||
{0x017D, u'Ž', KeyType::Character, 4, 3, 1, 1, "Ž", "", {None, None}},
|
||||
{0x00D0, u'Ð', KeyType::Character, 4, 4, 1, 1, "Ð", "", {None, None}},
|
||||
{0x00DE, u'Þ', KeyType::Character, 4, 5, 1, 1, "Þ", "", {None, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 6, 1, 1, "", "", {None, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 7, 1, 1, "", "", {None, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 8, 1, 1, "", "", {None, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 9, 1, 1, "", "", {None, None}},
|
||||
|
||||
// Row 5
|
||||
{0x0010, u'\0', KeyType::Function, 5, 0, 1, 1, "⬆", "L2", {L2, None}},
|
||||
{KC_LETTERS, u'\0', KeyType::Function, 5, 1, 1, 1, "ABC", "L2+△", {L3, Triangle}}, // TODO:
|
||||
{0x0000, u'\0', KeyType::Disabled, 5, 2, 1, 1, "", "", {None, None}}, // TODO:
|
||||
{0x0020, u' ', KeyType::Character, 5, 3, 4, 1, "Space", "△", {Triangle, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 5, 7, 1, 1, "", "", {None, None}},
|
||||
{0x0008, u'\0', KeyType::Function, 5, 8, 2, 1, "⇦", "□", {Square, None}, true},
|
||||
|
||||
// Row 6
|
||||
{0xF020, u'\0', KeyType::Function, 6, 0, 1, 1, "▲", "", {Up, None}},
|
||||
{0xF021, u'\0', KeyType::Function, 6, 1, 1, 1, "▼", "", {Down, None}},
|
||||
{0xF022, u'\0', KeyType::Function, 6, 2, 1, 1, "◀", "L1", {L1, None}},
|
||||
{0xF023, u'\0', KeyType::Function, 6, 3, 1, 1, "▶", "R1", {R1, None}},
|
||||
{KC_KB, u'\0', KeyType::Function, 6, 4, 1, 1, "KB", "", {None, None}}, // TODO
|
||||
{KC_OPT, u'\0', KeyType::Function, 6, 5, 1, 1, "...", "", {None, None}}, // TODO
|
||||
{KC_GYRO, u'\0', KeyType::Function, 6, 6, 1, 1, "+/⊗", "R3", {R3, None}}, // TODO
|
||||
{0x0000, u'\0', KeyType::Disabled, 6, 7, 1, 1, "", "", {None, None}},
|
||||
{0x000D, u'\r', KeyType::Function, 6, 8, 2, 1, "Done", "R2", {R2, None}},
|
||||
};
|
||||
|
||||
const std::vector<KeyEntry> kLayoutEnAccentLettersLowercase = {
|
||||
// Row 0
|
||||
{0x00E0, u'à', KeyType::Character, 0, 0, 1, 1, "à", "", {None, None}},
|
||||
{0x00E1, u'á', KeyType::Character, 0, 1, 1, 1, "á", "", {None, None}},
|
||||
{0x00E2, u'â', KeyType::Character, 0, 2, 1, 1, "â", "", {None, None}},
|
||||
{0x00E3, u'ã', KeyType::Character, 0, 3, 1, 1, "ã", "", {None, None}},
|
||||
{0x00E4, u'ä', KeyType::Character, 0, 4, 1, 1, "ä", "", {None, None}},
|
||||
{0x00E5, u'å', KeyType::Character, 0, 5, 1, 1, "å", "", {None, None}},
|
||||
{0x0105, u'ą', KeyType::Character, 0, 6, 1, 1, "ą", "", {None, None}},
|
||||
{0x00E6, u'æ', KeyType::Character, 0, 7, 1, 1, "æ", "", {None, None}},
|
||||
{0x00E7, u'ç', KeyType::Character, 0, 8, 1, 1, "ç", "", {None, None}},
|
||||
{0x0107, u'ć', KeyType::Character, 0, 9, 1, 1, "ć", "", {None, None}},
|
||||
|
||||
// Row 1
|
||||
{0x00E8, u'è', KeyType::Character, 1, 0, 1, 1, "è", "", {None, None}},
|
||||
{0x00E9, u'é', KeyType::Character, 1, 1, 1, 1, "é", "", {None, None}},
|
||||
{0x00EA, u'ê', KeyType::Character, 1, 2, 1, 1, "ê", "", {None, None}},
|
||||
{0x00EB, u'ë', KeyType::Character, 1, 3, 1, 1, "ë", "", {None, None}},
|
||||
{0x0119, u'ę', KeyType::Character, 1, 4, 1, 1, "ę", "", {None, None}},
|
||||
{0x011F, u'ğ', KeyType::Character, 1, 5, 1, 1, "ğ", "", {None, None}},
|
||||
{0x00EC, u'ì', KeyType::Character, 1, 6, 1, 1, "ì", "", {None, None}},
|
||||
{0x00ED, u'í', KeyType::Character, 1, 7, 1, 1, "í", "", {None, None}},
|
||||
{0x00EE, u'î', KeyType::Character, 1, 8, 1, 1, "î", "", {None, None}},
|
||||
{0x00EF, u'ï', KeyType::Character, 1, 9, 1, 1, "ï", "", {None, None}},
|
||||
|
||||
// Row 2
|
||||
{0x0131, u'ı', KeyType::Character, 2, 0, 1, 1, "ı", "", {None, None}},
|
||||
{0x0142, u'ł', KeyType::Character, 2, 1, 1, 1, "ł", "", {None, None}},
|
||||
{0x00F1, u'ñ', KeyType::Character, 2, 2, 1, 1, "ñ", "", {None, None}},
|
||||
{0x0144, u'ń', KeyType::Character, 2, 3, 1, 1, "ń", "", {None, None}},
|
||||
{0x00F2, u'ò', KeyType::Character, 2, 4, 1, 1, "ò", "", {None, None}},
|
||||
{0x00F3, u'ó', KeyType::Character, 2, 5, 1, 1, "ó", "", {None, None}},
|
||||
{0x00F4, u'ô', KeyType::Character, 2, 6, 1, 1, "ô", "", {None, None}},
|
||||
{0x00F5, u'õ', KeyType::Character, 2, 7, 1, 1, "õ", "", {None, None}},
|
||||
{0x00F6, u'ö', KeyType::Character, 2, 8, 1, 1, "ö", "", {None, None}},
|
||||
{0x00F8, u'ø', KeyType::Character, 2, 9, 1, 1, "ø", "", {None, None}},
|
||||
|
||||
// Row 3
|
||||
{0x0153, u'œ', KeyType::Character, 3, 0, 1, 1, "œ", "", {None, None}},
|
||||
{0x015B, u'ś', KeyType::Character, 3, 1, 1, 1, "ś", "", {None, None}},
|
||||
{0x015F, u'ş', KeyType::Character, 3, 2, 1, 1, "ş", "", {None, None}},
|
||||
{0x0161, u'š', KeyType::Character, 3, 3, 1, 1, "š", "", {None, None}},
|
||||
{0x00DF, u'ß', KeyType::Character, 3, 4, 1, 1, "ß", "", {None, None}},
|
||||
{0x00F9, u'ù', KeyType::Character, 3, 5, 1, 1, "ù", "", {None, None}},
|
||||
{0x00FA, u'ú', KeyType::Character, 3, 6, 1, 1, "ú", "", {None, None}},
|
||||
{0x00FB, u'û', KeyType::Character, 3, 7, 1, 1, "û", "", {None, None}},
|
||||
{0x00FC, u'ü', KeyType::Character, 3, 8, 1, 1, "ü", "", {None, None}},
|
||||
{0x00FD, u'ý', KeyType::Character, 3, 9, 1, 1, "ý", "", {None, None}},
|
||||
|
||||
// Row 4
|
||||
{0x00FF, u'ÿ', KeyType::Character, 4, 0, 1, 1, "ÿ", "", {None, None}},
|
||||
{0x017A, u'ź', KeyType::Character, 4, 1, 1, 1, "ź", "", {None, None}},
|
||||
{0x017C, u'ż', KeyType::Character, 4, 2, 1, 1, "ż", "", {None, None}},
|
||||
{0x017E, u'ž', KeyType::Character, 4, 3, 1, 1, "ž", "", {None, None}},
|
||||
{0x00F0, u'ð', KeyType::Character, 4, 4, 1, 1, "ð", "", {None, None}},
|
||||
{0x00FE, u'þ', KeyType::Character, 4, 5, 1, 1, "þ", "", {None, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 6, 1, 1, "", "", {None, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 7, 1, 1, "", "", {None, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 8, 1, 1, "", "", {None, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 4, 9, 1, 1, "", "", {None, None}},
|
||||
|
||||
// Row 5
|
||||
{0x0010, u'\0', KeyType::Function, 5, 0, 1, 1, "⬆", "L2", {L2, None}},
|
||||
{KC_LETTERS, u'\0', KeyType::Function, 5, 1, 1, 1, "ABC", "L2+△", {L3, Triangle}}, // TODO
|
||||
{0x0000, u'\0', KeyType::Disabled, 5, 2, 1, 1, "", "", {None, None}}, // TODO
|
||||
{0x0020, u' ', KeyType::Character, 5, 3, 4, 1, "Space", "△", {Triangle, None}},
|
||||
{0x0000, u'\0', KeyType::Disabled, 5, 7, 1, 1, "", "", {None, None}},
|
||||
{0x0008, u'\0', KeyType::Function, 5, 8, 2, 1, "⇦", "□", {Square, None}, true},
|
||||
|
||||
// Row 6
|
||||
{0xF020, u'\0', KeyType::Function, 6, 0, 1, 1, "▲", "", {Up, None}},
|
||||
{0xF021, u'\0', KeyType::Function, 6, 1, 1, 1, "▼", "", {Down, None}},
|
||||
{0xF022, u'\0', KeyType::Function, 6, 2, 1, 1, "◀", "L1", {L1, None}},
|
||||
{0xF023, u'\0', KeyType::Function, 6, 3, 1, 1, "▶", "R1", {R1, None}},
|
||||
{KC_KB, u'\0', KeyType::Function, 6, 4, 1, 1, "KB", "", {None, None}}, // TODO
|
||||
{KC_OPT, u'\0', KeyType::Function, 6, 5, 1, 1, "...", "", {None, None}}, // TODO
|
||||
{KC_GYRO, u'\0', KeyType::Function, 6, 6, 1, 1, "+/⊗", "R3", {R3, None}}, // TODO
|
||||
{0x0000, u'\0', KeyType::Disabled, 6, 7, 1, 1, "", "", {None, None}},
|
||||
{0x000D, u'\r', KeyType::Function, 6, 8, 2, 1, "Done", "R2", {R2, None}},
|
||||
};
|
60
src/core/libraries/ime/ime_keyboard_layouts.h
Normal file
60
src/core/libraries/ime/ime_keyboard_layouts.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <imgui.h>
|
||||
#include "common/types.h"
|
||||
|
||||
enum class KeyType : u8 { Character = 0, Function = 1, Disabled = 2 };
|
||||
|
||||
struct KeyEntry {
|
||||
u16 keycode; // 0xF100+ unused, so can be used as temporary defined keys for unknown
|
||||
char16_t character;
|
||||
KeyType type;
|
||||
u8 row;
|
||||
u8 col;
|
||||
u8 colspan;
|
||||
u8 rowspan;
|
||||
const char* label;
|
||||
const char* controller_hint;
|
||||
ImGuiNavInput bound_buttons[2];
|
||||
bool allow_repeat{false};
|
||||
};
|
||||
|
||||
int c16rtomb(char* out, char16_t ch);
|
||||
|
||||
extern const std::vector<KeyEntry> kLayoutEnLettersUppercase;
|
||||
extern const std::vector<KeyEntry> kLayoutEnLettersLowercase;
|
||||
extern const std::vector<KeyEntry> kLayoutEnAccentLettersUppercase;
|
||||
extern const std::vector<KeyEntry> kLayoutEnAccentLettersLowercase;
|
||||
extern const std::vector<KeyEntry> kLayoutEnSymbols1;
|
||||
extern const std::vector<KeyEntry> kLayoutEnSymbols2;
|
||||
|
||||
constexpr ImGuiNavInput None = ImGuiNavInput_COUNT;
|
||||
constexpr auto L1 = ImGuiNavInput_FocusPrev;
|
||||
constexpr auto R1 = ImGuiNavInput_FocusNext;
|
||||
constexpr auto L2 = ImGuiNavInput_TweakSlow;
|
||||
constexpr auto R2 = ImGuiNavInput_TweakFast;
|
||||
constexpr auto L3 = ImGuiNavInput_DpadLeft; // adjust if needed
|
||||
constexpr auto R3 = ImGuiNavInput_DpadRight; // adjust if needed
|
||||
constexpr auto Up = ImGuiNavInput_DpadUp;
|
||||
constexpr auto Down = ImGuiNavInput_DpadDown;
|
||||
constexpr auto Left = ImGuiNavInput_DpadLeft;
|
||||
constexpr auto Right = ImGuiNavInput_DpadRight;
|
||||
constexpr auto Cross = ImGuiNavInput_Activate;
|
||||
constexpr auto Circle = ImGuiNavInput_Menu;
|
||||
constexpr auto Square = ImGuiNavInput_Cancel;
|
||||
constexpr auto Triangle = ImGuiNavInput_Input;
|
||||
constexpr auto TouchPad = ImGuiNavInput_Menu; // reuse if needed
|
||||
|
||||
// Fake function keycodes
|
||||
constexpr u16 KC_SYM1 = 0xF100;
|
||||
constexpr u16 KC_SYM2 = 0xF101;
|
||||
constexpr u16 KC_ACCENTS = 0xF102;
|
||||
constexpr u16 KC_LETTERS = 0xF103;
|
||||
constexpr u16 KC_KB = 0xF104;
|
||||
constexpr u16 KC_GYRO = 0xF105;
|
||||
constexpr u16 KC_OPT = 0xF106;
|
213
src/core/libraries/ime/ime_keyboard_ui.cpp
Normal file
213
src/core/libraries/ime/ime_keyboard_ui.cpp
Normal file
|
@ -0,0 +1,213 @@
|
|||
#include <cstring>
|
||||
#include <unordered_set>
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
|
||||
#include "ime_common.h"
|
||||
#include "ime_dialog.h"
|
||||
#include "ime_keyboard_layouts.h"
|
||||
#include "ime_keyboard_ui.h"
|
||||
using namespace ImGui;
|
||||
|
||||
/**
|
||||
* Removes one UTF-8 codepoint from the end of 'buffer', if present.
|
||||
*/
|
||||
void Utf8SafeBackspace(char* buffer) {
|
||||
size_t len = std::strlen(buffer);
|
||||
if (len == 0)
|
||||
return;
|
||||
|
||||
// Move backward over any continuation bytes.
|
||||
while (len > 0 && (static_cast<unsigned char>(buffer[len]) & 0b11000000) == 0b10000000) {
|
||||
--len;
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
// Remove one codepoint.
|
||||
buffer[len - 1] = '\0';
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Picks which layout vector we want for OrbisImeType, kb_mode, shift_state, etc.
|
||||
*/
|
||||
const std::vector<KeyEntry>* GetKeyboardLayout(OrbisImeType type, KeyboardMode mode,
|
||||
ShiftState shift, u64 language) {
|
||||
switch (type) {
|
||||
case OrbisImeType::Number:
|
||||
// For numeric input, you might have a dedicated numeric layout,
|
||||
// but here we reuse kLayoutEnSymbols1.
|
||||
return &kLayoutEnSymbols1;
|
||||
|
||||
case OrbisImeType::Url:
|
||||
case OrbisImeType::Mail:
|
||||
// Use letters; uppercase if SHIFT is on.
|
||||
if (shift == ShiftState::CapsLock || shift == ShiftState::Shift) {
|
||||
return &kLayoutEnLettersUppercase;
|
||||
} else {
|
||||
return &kLayoutEnLettersLowercase;
|
||||
}
|
||||
|
||||
case OrbisImeType::BasicLatin:
|
||||
case OrbisImeType::Default:
|
||||
default:
|
||||
switch (mode) {
|
||||
case KeyboardMode::Symbols1:
|
||||
return &kLayoutEnSymbols1;
|
||||
case KeyboardMode::Symbols2:
|
||||
return &kLayoutEnSymbols2;
|
||||
case KeyboardMode::AccentLetters:
|
||||
if (shift == ShiftState::CapsLock || shift == ShiftState::Shift) {
|
||||
return &kLayoutEnAccentLettersUppercase;
|
||||
} else {
|
||||
return &kLayoutEnAccentLettersLowercase;
|
||||
}
|
||||
case KeyboardMode::Letters:
|
||||
default:
|
||||
if (shift == ShiftState::CapsLock || shift == ShiftState::Shift) {
|
||||
return &kLayoutEnLettersUppercase;
|
||||
} else {
|
||||
return &kLayoutEnLettersLowercase;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the given layout using the style logic:
|
||||
* - For symbols layout and if style.use_button_symbol_color is true,
|
||||
* character keys get style.color_button_symbol.
|
||||
* - Function keys get style.color_button_function.
|
||||
* - The "Done"/"Enter" key (keycode 0x0D) gets style.color_special.
|
||||
* - Otherwise, keys use style.color_button_default.
|
||||
*
|
||||
* This version retains all GUI layout details (positions, colors, sizes, etc.) exactly as in your
|
||||
* base files. The only change is in key event detection: after drawing each key with Button(), we
|
||||
* use IsItemActive() to determine the pressed state so that the backend key processing works
|
||||
* correctly.
|
||||
*/
|
||||
void RenderKeyboardLayout(const std::vector<KeyEntry>& layout, KeyboardMode mode,
|
||||
void (*on_key_event)(const VirtualKeyEvent*),
|
||||
const KeyboardStyle& style) {
|
||||
ImGui::BeginGroup();
|
||||
|
||||
/* ─────────────── 1. grid size & cell metrics ─────────────── */
|
||||
int max_col = 0, max_row = 0;
|
||||
for (const KeyEntry& k : layout) {
|
||||
max_col = std::max(max_col, k.col + (int)k.colspan);
|
||||
max_row = std::max(max_row, k.row + (int)k.rowspan);
|
||||
}
|
||||
if (max_col == 0 || max_row == 0) {
|
||||
ImGui::EndGroup();
|
||||
return;
|
||||
}
|
||||
|
||||
const float pad = 20.0f;
|
||||
const float spacing_w = (max_col - 1) * style.key_spacing;
|
||||
const float spacing_h = (max_row - 1) * style.key_spacing;
|
||||
const float cell_w = std::floor((style.layout_width - spacing_w - 2 * pad) / max_col + 0.5f);
|
||||
const float cell_h = std::floor((style.layout_height - spacing_h - 85.0f) / max_row + 0.5f);
|
||||
|
||||
ImVec2 origin = ImGui::GetCursorScreenPos();
|
||||
origin.x += pad;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_NavHighlight, style.color_line);
|
||||
ImGui::SetWindowFontScale(1.50f);
|
||||
|
||||
const int function_rows_start = std::max(0, max_row - 2);
|
||||
|
||||
/* ─────────────── 2. draw every key ───────────────────────── */
|
||||
for (const KeyEntry& key : layout) {
|
||||
/* position & size */
|
||||
float x = origin.x + key.col * (cell_w + style.key_spacing);
|
||||
float y = origin.y + key.row * (cell_h + style.key_spacing);
|
||||
float w = key.colspan * cell_w + (key.colspan - 1) * style.key_spacing;
|
||||
float h = key.rowspan * cell_h + (key.rowspan - 1) * style.key_spacing;
|
||||
ImVec2 pos(x, y), size(w, h);
|
||||
|
||||
/* ------------ background colour decision --------------- */
|
||||
const bool in_function_rows = (key.row >= function_rows_start);
|
||||
const bool is_done_enter = (key.keycode == 0x0D);
|
||||
|
||||
ImU32 bg_color;
|
||||
if (is_done_enter) {
|
||||
bg_color = style.color_special; // always wins
|
||||
} else if (in_function_rows) {
|
||||
bg_color = style.color_button_function; // bottom two rows
|
||||
} else if ((mode == KeyboardMode::Symbols1 || mode == KeyboardMode::Symbols2) &&
|
||||
style.use_button_symbol_color) {
|
||||
bg_color = style.color_button_symbol; // symbol tint
|
||||
} else {
|
||||
bg_color = style.color_button_default; // normal default
|
||||
}
|
||||
|
||||
/* label */
|
||||
std::string label = (key.label && key.label[0]) ? key.label : " ";
|
||||
|
||||
/* ---------- ImGui button ---------- */
|
||||
ImGui::PushID(&key);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, style.color_text);
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, bg_color);
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered,
|
||||
IM_COL32((bg_color >> IM_COL32_R_SHIFT & 0xFF) * 220 / 255,
|
||||
(bg_color >> IM_COL32_G_SHIFT & 0xFF) * 220 / 255,
|
||||
(bg_color >> IM_COL32_B_SHIFT & 0xFF) * 220 / 255,
|
||||
(bg_color >> IM_COL32_A_SHIFT & 0xFF)));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive,
|
||||
IM_COL32((bg_color >> IM_COL32_R_SHIFT & 0xFF) * 180 / 255,
|
||||
(bg_color >> IM_COL32_G_SHIFT & 0xFF) * 180 / 255,
|
||||
(bg_color >> IM_COL32_B_SHIFT & 0xFF) * 180 / 255,
|
||||
(bg_color >> IM_COL32_A_SHIFT & 0xFF)));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
|
||||
|
||||
if (key.allow_repeat)
|
||||
ImGui::PushButtonRepeat(true);
|
||||
|
||||
ImGui::SetCursorScreenPos(pos);
|
||||
bool pressed = ImGui::Button(label.c_str(), size); // Down + repeats
|
||||
|
||||
if (key.allow_repeat)
|
||||
ImGui::PopButtonRepeat();
|
||||
|
||||
/* ---------- event generation ---------- */
|
||||
if (on_key_event) {
|
||||
if (ImGui::IsItemActivated()) {
|
||||
VirtualKeyEvent ev{VirtualKeyEventType::Down, &key};
|
||||
on_key_event(&ev);
|
||||
} else if (pressed && key.allow_repeat) {
|
||||
VirtualKeyEvent ev{VirtualKeyEventType::Repeat, &key};
|
||||
on_key_event(&ev);
|
||||
}
|
||||
|
||||
if (ImGui::IsItemDeactivated()) {
|
||||
VirtualKeyEvent ev{VirtualKeyEventType::Up, &key};
|
||||
on_key_event(&ev);
|
||||
}
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::PopStyleColor(4);
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::PopStyleColor(); // NavHighlight
|
||||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the correct layout via GetKeyboardLayout() then calls RenderKeyboardLayout().
|
||||
*/
|
||||
void DrawVirtualKeyboard(KeyboardMode kb_mode, OrbisImeType ime_type, ShiftState shift_state,
|
||||
u64 language, void (*on_key_event)(const VirtualKeyEvent*),
|
||||
const KeyboardStyle& style) {
|
||||
const std::vector<KeyEntry>* layout =
|
||||
GetKeyboardLayout(ime_type, kb_mode, shift_state, language);
|
||||
if (!layout)
|
||||
return;
|
||||
|
||||
RenderKeyboardLayout(*layout, kb_mode, on_key_event, style);
|
||||
}
|
88
src/core/libraries/ime/ime_keyboard_ui.h
Normal file
88
src/core/libraries/ime/ime_keyboard_ui.h
Normal file
|
@ -0,0 +1,88 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "core/libraries/ime/ime_keyboard_layouts.h"
|
||||
|
||||
/**
|
||||
* KeyboardMode: which layout we show (letters, accents, symbols, etc.)
|
||||
*/
|
||||
enum class KeyboardMode { Letters, AccentLetters, Symbols1, Symbols2 };
|
||||
|
||||
/**
|
||||
* We handle raw key "Down" or "Up" events from an on-screen keyboard.
|
||||
*/
|
||||
enum class VirtualKeyEventType { Down, Up, Repeat };
|
||||
|
||||
struct VirtualKeyEvent {
|
||||
VirtualKeyEventType type;
|
||||
const KeyEntry* key;
|
||||
};
|
||||
|
||||
enum class ShiftState : u8 {
|
||||
None = 0, // lowercase
|
||||
Shift = 1, // temporary uppercase
|
||||
CapsLock = 2 // full uppercase
|
||||
};
|
||||
|
||||
/**
|
||||
* This struct holds all visual parameters for the on-screen keyboard,
|
||||
* including layout size, spacing, and button colors.
|
||||
*
|
||||
* If extended parameters are present, it override these defaults
|
||||
* in IME code. Then pass the result to DrawVirtualKeyboard(...).
|
||||
*/
|
||||
struct KeyboardStyle {
|
||||
float layout_width = 500.0f;
|
||||
float layout_height = 300.0f;
|
||||
float key_spacing = 5.0f;
|
||||
|
||||
// For text, lines, etc.
|
||||
ImU32 color_text = IM_COL32(225, 225, 225, 255);
|
||||
ImU32 color_line = IM_COL32(88, 88, 88, 255);
|
||||
|
||||
// Button colors
|
||||
ImU32 color_button_default = IM_COL32(35, 35, 35, 255);
|
||||
ImU32 color_button_function = IM_COL32(50, 50, 50, 255);
|
||||
ImU32 color_special = IM_COL32(0, 140, 200, 255);
|
||||
|
||||
// If you're on a symbols layout, you may want to color them differently.
|
||||
bool use_button_symbol_color = false;
|
||||
ImU32 color_button_symbol = IM_COL32(60, 60, 60, 255);
|
||||
};
|
||||
|
||||
/**
|
||||
* Safely remove one UTF-8 glyph from the end of 'buffer'.
|
||||
*/
|
||||
void Utf8SafeBackspace(char* buffer);
|
||||
|
||||
/**
|
||||
* Returns the appropriate layout (vector of KeyEntry) for the given
|
||||
* OrbisImeType, KeyboardMode, ShiftState, and language bitmask.
|
||||
*/
|
||||
const std::vector<KeyEntry>* GetKeyboardLayout(OrbisImeType type, KeyboardMode mode,
|
||||
ShiftState shift, u64 language);
|
||||
|
||||
/**
|
||||
* Renders a given layout using the style logic:
|
||||
* - If 'mode' is a symbols layout (Symbols1 or Symbols2) AND style.use_button_symbol_color == true,
|
||||
* then normal character keys are drawn with style.color_button_symbol
|
||||
* - Function keys => style.color_button_function
|
||||
* - The "Done" or "Enter" key (keycode 0x0D) => style.color_special
|
||||
* - Otherwise => style.color_button_default
|
||||
*
|
||||
* We call on_key_event(...) with VirtualKeyEventType::Down/Up when the user clicks or releases a
|
||||
* key.
|
||||
*/
|
||||
void RenderKeyboardLayout(const std::vector<KeyEntry>& layout, KeyboardMode mode,
|
||||
void (*on_key_event)(const VirtualKeyEvent*), const KeyboardStyle& style);
|
||||
|
||||
/**
|
||||
* Picks the correct layout from GetKeyboardLayout() for the given
|
||||
* kb_mode, shift_state, etc., then calls RenderKeyboardLayout().
|
||||
*/
|
||||
void DrawVirtualKeyboard(KeyboardMode kb_mode, OrbisImeType ime_type, ShiftState shift_state,
|
||||
u64 language, void (*on_key_event)(const VirtualKeyEvent*),
|
||||
const KeyboardStyle& style);
|
|
@ -249,5 +249,4 @@ int ImeUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
|
|||
void ImeUi::Free() {
|
||||
RemoveLayer(this);
|
||||
}
|
||||
|
||||
}; // namespace Libraries::Ime
|
||||
}; // namespace Libraries::Ime
|
|
@ -72,5 +72,4 @@ private:
|
|||
|
||||
static int InputTextCallback(ImGuiInputTextCallbackData* data);
|
||||
};
|
||||
|
||||
}; // namespace Libraries::Ime
|
|
@ -69,14 +69,51 @@ void Initialize(const ::Vulkan::Instance& instance, const Frontend::WindowSDL& w
|
|||
rb.AddRanges(io.Fonts->GetGlyphRangesKorean());
|
||||
rb.AddRanges(io.Fonts->GetGlyphRangesJapanese());
|
||||
rb.AddRanges(io.Fonts->GetGlyphRangesCyrillic());
|
||||
// For keyboard
|
||||
rb.AddChar(U'×');
|
||||
rb.AddChar(U'○');
|
||||
rb.AddChar(U'△');
|
||||
rb.AddChar(U'□');
|
||||
rb.AddChar(U'↑');
|
||||
rb.AddChar(U'↓');
|
||||
rb.AddChar(U'←');
|
||||
rb.AddChar(U'→');
|
||||
rb.AddChar(U'⊗');
|
||||
rb.AddChar(U'⮾');
|
||||
rb.AddChar(U'╳');
|
||||
rb.AddChar(U'◀');
|
||||
rb.AddChar(U'▲');
|
||||
rb.AddChar(U'▶');
|
||||
rb.AddChar(U'▼');
|
||||
rb.AddChar(U'⇧');
|
||||
rb.AddChar(U'⬆');
|
||||
rb.AddChar(U'⇦');
|
||||
rb.AddChar(U'€');
|
||||
rb.AddChar(U'₩');
|
||||
rb.AddChar(U'“');
|
||||
rb.AddChar(U'”');
|
||||
rb.AddChar(U'„');
|
||||
rb.AddChar(U'‼');
|
||||
rb.AddChar(U'¿');
|
||||
rb.AddChar(U'⁇');
|
||||
rb.AddChar(U'‹');
|
||||
rb.AddChar(U'›');
|
||||
rb.AddChar(U'’');
|
||||
rb.AddChar(U'‘');
|
||||
rb.AddChar(U'‛');
|
||||
rb.AddChar(U'‚');
|
||||
rb.AddChar(U'№');
|
||||
|
||||
ImVector<ImWchar> ranges{};
|
||||
rb.BuildRanges(&ranges);
|
||||
ImFontConfig font_cfg{};
|
||||
font_cfg.OversampleH = 2;
|
||||
font_cfg.OversampleV = 1;
|
||||
font_cfg.MergeMode = false;
|
||||
io.FontDefault = io.Fonts->AddFontFromMemoryCompressedTTF(
|
||||
imgui_font_notosansjp_regular_compressed_data,
|
||||
imgui_font_notosansjp_regular_compressed_size, 16.0f, &font_cfg, ranges.Data);
|
||||
font_cfg.MergeMode = true;
|
||||
io.Fonts->AddFontFromMemoryCompressedTTF(imgui_font_proggyvector_regular_compressed_data,
|
||||
imgui_font_proggyvector_regular_compressed_size,
|
||||
16.0f);
|
||||
|
|
Loading…
Add table
Reference in a new issue