From 3b662681cbee0448455bc290c4c18fd88e84e7d2 Mon Sep 17 00:00:00 2001 From: w1naenator Date: Wed, 2 Apr 2025 17:56:35 +0300 Subject: [PATCH] Build: Recovered CMakeSettings.json configuration file Input Handling: Temporarily removed custom keyboard shortcut code; navigation is now handled via ImGui's native navigation system Virtual Keyboard: Modified first symbols layout (based on PS5 layout) Added second symbols layout (based on PS5 layout) Fonts: Added required symbols to ImGui font atlas for correct rendering in keyboard layouts --- CMakeSettings.json | 2 +- src/core/libraries/ime/ime_dialog_ui.cpp | 2 +- .../libraries/ime/ime_keyboard_layouts.cpp | 201 +++++++++++++++--- src/core/libraries/ime/ime_keyboard_layouts.h | 11 +- src/core/libraries/ime/ime_keyboard_ui.cpp | 131 ++++-------- src/core/libraries/ime/ime_keyboard_ui.h | 11 +- src/core/libraries/ime/ime_ui.cpp | 28 ++- src/imgui/renderer/imgui_core.cpp | 63 +++--- 8 files changed, 293 insertions(+), 156 deletions(-) diff --git a/CMakeSettings.json b/CMakeSettings.json index 1e9e3594c..bb522fcfc 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -6,7 +6,7 @@ "configurationType": "Release", "buildRoot": "${projectDir}\\Build\\${name}", "installRoot": "${projectDir}\\Install\\${name}", - "cmakeCommandArgs": "-DENABLE_QT_GUI=ON -DCMAKE_PREFIX_PATH=C:\\Qt\\6.8.2\\msvc2022_64", + "cmakeCommandArgs": "", "buildCommandArgs": "", "ctestCommandArgs": "", "inheritEnvironments": [ "clang_cl_x64_x64" ], diff --git a/src/core/libraries/ime/ime_dialog_ui.cpp b/src/core/libraries/ime/ime_dialog_ui.cpp index 3c576059d..e34fd064e 100644 --- a/src/core/libraries/ime/ime_dialog_ui.cpp +++ b/src/core/libraries/ime/ime_dialog_ui.cpp @@ -342,7 +342,7 @@ void ImeDialogUi::DrawMultiLineInputText() { } void ImeDialogUi::DrawKeyboard() { - static KeyboardMode kb_mode = KeyboardMode::Letters; + static KeyboardMode kb_mode = KeyboardMode::Letters1; static bool shift_enabled = false; static bool has_logged = false; diff --git a/src/core/libraries/ime/ime_keyboard_layouts.cpp b/src/core/libraries/ime/ime_keyboard_layouts.cpp index e81bfb209..87ea2931a 100644 --- a/src/core/libraries/ime/ime_keyboard_layouts.cpp +++ b/src/core/libraries/ime/ime_keyboard_layouts.cpp @@ -1,25 +1,24 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/libraries/pad/pad.h" +#include #include "ime_keyboard_layouts.h" -using B = Libraries::Pad::OrbisPadButtonDataOffset; -constexpr auto L1 = B::L1; -constexpr auto R1 = B::R1; -constexpr auto L2 = B::L2; -constexpr auto R2 = B::R2; -constexpr auto L3 = B::L3; -constexpr auto R3 = B::R3; -constexpr auto Up = B::Up; -constexpr auto Down = B::Down; -constexpr auto Left = B::Left; -constexpr auto Right = B::Right; -constexpr auto Cross = B::Cross; -constexpr auto Circle = B::Circle; -constexpr auto Square = B::Square; -constexpr auto Triangle = B::Triangle; -constexpr auto TouchPad = B::TouchPad; +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 const std::vector kUppercaseLayout = { // Row 1 @@ -73,15 +72,15 @@ const std::vector kUppercaseLayout = { // Row 5 {4, 0, 1, 1, "⬆", "L2", KeyType::Shift, {L2}}, - {4, 1, 1, 1, "@#:", "L2+△", KeyType::SymbolsLayout, {L3, Triangle}}, + {4, 1, 1, 1, "@#:", "L2+△", KeyType::Symbols1Layout, {L3, Triangle}}, {4, 2, 1, 1, "à", "L3", KeyType::UnknownFunction, {L3}}, {4, 3, 4, 1, "Space", "△", KeyType::Space, {Triangle}}, - //{4, 4, 4, 1, "Space", "△", KeyType::Space,{}}, - //{4, 5, 4, 1, "Space", "△", KeyType::Space,{}}, - //{4, 6, 4, 1, "Space", "△", KeyType::Space,{}}, + //{4, 4, 4, 1, "Space", "△", KeyType::Space,{Triangle}}, + //{4, 5, 4, 1, "Space", "△", KeyType::Space,{Triangle}}, + //{4, 6, 4, 1, "Space", "△", KeyType::Space,{Triangle}}, {4, 7, 1, 1, "", "", KeyType::Disabled, {}}, {4, 8, 2, 1, "⇦", "□", KeyType::Backspace, {Square}}, - //{4, 9, 2, 1, "⇦", "□", KeyType::Backspace,{}}, + //{4, 9, 2, 1, "⇦", "□", KeyType::Backspace,{Square}}, // Row 6 {5, 0, 1, 1, "▲", "", KeyType::CursorUp, {Up}}, @@ -95,7 +94,7 @@ const std::vector kUppercaseLayout = { {5, 6, 1, 1, "+/⊗", "R3", KeyType::ControllerAction, {R3}}, {5, 7, 1, 1, "", "", KeyType::Disabled, {}}, {5, 8, 2, 1, "Done", "R2", KeyType::Done, {R2}}, - //{5, 9, 2, 1, "Done", "R2", KeyType::Done,{}}, + //{5, 9, 2, 1, "Done", "R2", KeyType::Done,{R2}}, }; const std::vector kLowercaseLayout = { @@ -149,7 +148,7 @@ const std::vector kLowercaseLayout = { // Row 5 {4, 0, 1, 1, "⇧", "L2", KeyType::Shift, {L2}}, - {4, 1, 1, 1, "@#:", "L2+△", KeyType::SymbolsLayout, {L2, Triangle}}, + {4, 1, 1, 1, "@#:", "L2+△", KeyType::Symbols1Layout, {L2, Triangle}}, {4, 2, 1, 1, "à", "L3", KeyType::UnknownFunction, {L3}}, {4, 3, 4, 1, "Space", "△", KeyType::Space, {Triangle}}, //{4, 4, 4, 1, "Space", "△", KeyType::Space, {Triangle}}, @@ -171,7 +170,7 @@ const std::vector kLowercaseLayout = { {5, 8, 2, 1, "Done", "R2", KeyType::Done, {R2}}, //{5, 9, 2, 1, "Done", "R2", KeyType::Done, {R2}}, }; - +/* const std::vector kSymbols1Layout = { // Row 1 {0, 0, 1, 1, "!", "", KeyType::Text, {}}, @@ -246,3 +245,155 @@ const std::vector kSymbols1Layout = { //{5, 9, 2, 1, "Done", "R2", KeyType::Done, {R2}}, }; +*/ +// From PS5 +const std::vector kSymbols1Layout = { + // Row 1 + {0, 0, 1, 1, "!", "", KeyType::Text, {}}, + {0, 1, 1, 1, "?", "", KeyType::Text, {}}, + {0, 2, 1, 1, "\"", "", KeyType::Text, {}}, + {0, 3, 1, 1, "'", "", KeyType::Text, {}}, + {0, 4, 1, 1, "#", "", KeyType::Text, {}}, + {0, 5, 1, 1, "%", "", KeyType::Text, {}}, + {0, 6, 1, 1, "(", "", KeyType::Text, {}}, + {0, 7, 1, 1, ")", "", KeyType::Text, {}}, + {0, 8, 1, 1, "()", "", KeyType::Text, {}}, + {0, 9, 1, 1, "/", "", KeyType::Text, {}}, + + // Row 2 + {1, 0, 1, 1, "-", "", KeyType::Text, {}}, + {1, 1, 1, 1, "_", "", KeyType::Text, {}}, + {1, 2, 1, 1, ",", "", KeyType::Text, {}}, + {1, 3, 1, 1, ".", "", KeyType::Text, {}}, + {1, 4, 1, 1, ":", "", KeyType::Text, {}}, + {1, 5, 1, 1, ";", "", KeyType::Text, {}}, + {1, 6, 1, 1, "*", "", KeyType::Text, {}}, + {1, 7, 1, 1, "&", "", KeyType::Text, {}}, + {1, 8, 1, 1, "+", "", KeyType::Text, {}}, + {1, 9, 1, 1, "=", "", KeyType::Text, {}}, + + // Row 3 + {2, 0, 1, 1, "<", "", KeyType::Text, {}}, + {2, 1, 1, 1, ">", "", KeyType::Text, {}}, + {2, 2, 1, 1, "@", "", KeyType::Text, {}}, + {2, 3, 1, 1, "[", "", KeyType::Text, {}}, + {2, 4, 1, 1, "]", "", KeyType::Text, {}}, + {2, 5, 1, 1, "[]", "", KeyType::Text, {}}, + {2, 6, 1, 1, "{", "", KeyType::Text, {}}, + {2, 7, 1, 1, "}", "", KeyType::Text, {}}, + {2, 8, 1, 1, "{}", "", KeyType::Text, {}}, + {2, 9, 1, 2, "→", "", KeyType::Symbols2Layout, {}}, + + // Row 4 + {3, 0, 1, 1, "\\", "", KeyType::Text, {}}, + {3, 1, 1, 1, "|", "", KeyType::Text, {}}, + {3, 2, 1, 1, "^", "", KeyType::Text, {}}, + {3, 3, 1, 1, "`", "", KeyType::Text, {}}, + {3, 4, 1, 1, "$", "", KeyType::Text, {}}, + {3, 5, 1, 1, "€", "", KeyType::Text, {}}, + {3, 6, 1, 1, "£", "", KeyType::Text, {}}, + {3, 7, 1, 1, "¥", "", KeyType::Text, {}}, + {3, 8, 1, 1, "₩", "", KeyType::Text, {}}, + //{3, 9, 1, 2, "→", "", KeyType::Symbols2Layout,{}}, + + // Row 5 + {4, 0, 1, 1, "", "", KeyType::Disabled, {}}, + {4, 1, 1, 1, "ABC", "L2+△", KeyType::TextLayout, {L2, Triangle}}, + {4, 2, 1, 1, "", "", KeyType::Disabled, {}}, + {4, 3, 4, 1, "Space", "△", KeyType::Space, {Triangle}}, + //{4, 4, 4, 1, "Space", "△", KeyType::Space, {Triangle}}, + //{4, 5, 4, 1, "Space", "△", KeyType::Space, {Triangle}}, + //{4, 6, 4, 1, "Space", "△", KeyType::Space, {Triangle}}, + {4, 7, 1, 1, "", "", KeyType::Disabled, {}}, + {4, 8, 2, 1, "⇦", "□", KeyType::Backspace, {Square}}, + //{4, 9, 2, 1, "⇦", "□", KeyType::Backspace, {Square}}, + + // Row 6 + {5, 0, 1, 1, "▲", "", KeyType::CursorUp, {Up}}, + {5, 1, 1, 1, "▼", "", KeyType::CursorDown, {Down}}, + {5, 2, 1, 1, "◀", "L1", KeyType::CursorLeft, {L1}}, + {5, 3, 1, 1, "▶", "R1", KeyType::CursorRight, {R1}}, + {5, 4, 1, 1, "KB", "", KeyType::ToggleKeyboard, {}}, + {5, 5, 1, 1, "...", "", KeyType::MoreOptions, {}}, + {5, 6, 1, 1, "+/⊗", "R3", KeyType::ControllerAction, {R3}}, + {5, 7, 1, 1, "", "", KeyType::Disabled, {}}, + {5, 8, 2, 1, "Done", "R2", KeyType::Done, {R2}}, + //{5, 9, 2, 1, "Done", "R2", KeyType::Done, {R2}}, + +}; + +// From PS5 +const std::vector kSymbols2Layout = { + // Row 1 + {0, 0, 1, 1, "“", "", KeyType::Text, {}}, + {0, 1, 1, 1, "”", "", KeyType::Text, {}}, + {0, 2, 1, 1, "„", "", KeyType::Text, {}}, + {0, 3, 1, 1, "¡", "", KeyType::Text, {}}, + {0, 4, 1, 1, "‼", "", KeyType::Text, {}}, + {0, 5, 1, 1, "¿", "", KeyType::Text, {}}, + {0, 6, 1, 1, "⁇", "", KeyType::Text, {}}, + {0, 7, 1, 1, "~", "", KeyType::Text, {}}, + {0, 8, 1, 1, "·", "", KeyType::Text, {}}, + {0, 9, 1, 1, "", "", KeyType::Disabled, {}}, + + // Row 2 + {1, 0, 1, 1, "×", "", KeyType::Text, {}}, + {1, 1, 1, 1, "÷", "", KeyType::Text, {}}, + {1, 2, 1, 1, "‹", "", KeyType::Text, {}}, + {1, 3, 1, 1, "›", "", KeyType::Text, {}}, + {1, 4, 1, 1, "«", "", KeyType::Text, {}}, + {1, 5, 1, 1, "»", "", KeyType::Text, {}}, + {1, 6, 1, 1, "º", "", KeyType::Text, {}}, + {1, 7, 1, 1, "ª", "", KeyType::Text, {}}, + {1, 8, 1, 1, "°", "", KeyType::Text, {}}, + {1, 9, 1, 1, "§", "", KeyType::Text, {}}, + + // Row 3 + {2, 0, 1, 2, "←", "", KeyType::Symbols1Layout, {}}, + {2, 1, 1, 1, "¦", "", KeyType::Text, {}}, + {2, 2, 1, 1, "µ", "", KeyType::Text, {}}, + {2, 3, 1, 1, "¬", "", KeyType::Text, {}}, + {2, 4, 1, 1, "¹", "", KeyType::Text, {}}, + {2, 5, 1, 1, "²", "", KeyType::Text, {}}, + {2, 6, 1, 1, "³", "", KeyType::Text, {}}, + {2, 7, 1, 1, "¼", "", KeyType::Text, {}}, + {2, 8, 1, 1, "½", "", KeyType::Text, {}}, + {2, 9, 1, 1, "¾", "", KeyType::Text, {}}, + + // Row 4 + //{3, 0, 1, 1, "←", "", KeyType::Symbols1Layout, {}}, + {3, 1, 1, 1, "¢", "", KeyType::Text, {}}, + {3, 2, 1, 1, "¤", "", KeyType::Text, {}}, + {3, 3, 1, 1, "’", "", KeyType::Text, {}},//not sure + {3, 4, 1, 1, "‘", "", KeyType::Text, {}},//not sure + {3, 5, 1, 1, "‛", "", KeyType::Text, {}},//not sure + {3, 6, 1, 1, "‚", "", KeyType::Text, {}},//not sure + {3, 7, 1, 1, "№", "", KeyType::Text, {}}, + {3, 8, 1, 1, "", "", KeyType::Disabled, {}}, + {3, 9, 1, 1, "", "", KeyType::Disabled,{}}, + + // Row 5 + {4, 0, 1, 1, "", "", KeyType::Disabled, {}}, + {4, 1, 1, 1, "ABC", "L2+△", KeyType::TextLayout, {L2, Triangle}}, + {4, 2, 1, 1, "", "", KeyType::Disabled, {}}, + {4, 3, 4, 1, "Space", "△", KeyType::Space, {Triangle}}, + //{4, 4, 4, 1, "Space", "△", KeyType::Space, {Triangle}}, + //{4, 5, 4, 1, "Space", "△", KeyType::Space, {Triangle}}, + //{4, 6, 4, 1, "Space", "△", KeyType::Space, {Triangle}}, + {4, 7, 1, 1, "", "", KeyType::Disabled, {}}, + {4, 8, 2, 1, "⇦", "□", KeyType::Backspace, {Square}}, + //{4, 9, 2, 1, "⇦", "□", KeyType::Backspace, {Square}}, + + // Row 6 + {5, 0, 1, 1, "▲", "", KeyType::CursorUp, {Up}}, + {5, 1, 1, 1, "▼", "", KeyType::CursorDown, {Down}}, + {5, 2, 1, 1, "◀", "L1", KeyType::CursorLeft, {L1}}, + {5, 3, 1, 1, "▶", "R1", KeyType::CursorRight, {R1}}, + {5, 4, 1, 1, "KB", "", KeyType::ToggleKeyboard, {}}, + {5, 5, 1, 1, "...", "", KeyType::MoreOptions, {}}, + {5, 6, 1, 1, "+/⊗", "R3", KeyType::ControllerAction, {R3}}, + {5, 7, 1, 1, "", "", KeyType::Disabled, {}}, + {5, 8, 2, 1, "Done", "R2", KeyType::Done, {R2}}, + //{5, 9, 2, 1, "Done", "R2", KeyType::Done, {R2}}, + +}; \ No newline at end of file diff --git a/src/core/libraries/ime/ime_keyboard_layouts.h b/src/core/libraries/ime/ime_keyboard_layouts.h index 2a0f4819b..3da681219 100644 --- a/src/core/libraries/ime/ime_keyboard_layouts.h +++ b/src/core/libraries/ime/ime_keyboard_layouts.h @@ -5,8 +5,7 @@ #include #include -#include "core/libraries/pad/pad.h" -// using B = Libraries::Pad::OrbisPadButtonDataOffset; +#include enum class KeyType { Text, // Inserts character(s) into input buffer @@ -14,7 +13,8 @@ enum class KeyType { Space, // Adds space Enter, // Submits input Shift, // Toggle uppercase/lowercase - SymbolsLayout, // Switch to symbols layout + Symbols1Layout, // Switch to symbols layout + Symbols2Layout, // Switch to symbols layout TextLayout, // Switch to text layout Done, // Finish and close keyboard CursorLeft, @@ -35,10 +35,11 @@ struct Key { int rowspan = 1; std::string label; std::string controller_hint; - KeyType type = KeyType::Text; // default to Text input - std::vector bound_buttons = {}; // new field + KeyType type = KeyType::Text; + std::vector bound_buttons = {}; // Now using ImGui navigation inputs }; extern const std::vector kUppercaseLayout; extern const std::vector kLowercaseLayout; extern const std::vector kSymbols1Layout; +extern const std::vector kSymbols2Layout; diff --git a/src/core/libraries/ime/ime_keyboard_ui.cpp b/src/core/libraries/ime/ime_keyboard_ui.cpp index 7fe56d39a..08185c6ed 100644 --- a/src/core/libraries/ime/ime_keyboard_ui.cpp +++ b/src/core/libraries/ime/ime_keyboard_ui.cpp @@ -5,40 +5,55 @@ #include #include "ime_keyboard_layouts.h" #include "ime_keyboard_ui.h" -#include "input/controller.h" - -#include "common/singleton.h" +#include "ime_ui.h" // for ImeState +#include "ime_common.h" using namespace ImGui; +// --- UTF-8 safe backspace helper --- +void Utf8SafeBackspace(char* buffer) { + size_t len = std::strlen(buffer); + if (len == 0) + return; + + while (len > 0 && (static_cast(buffer[len]) & 0b11000000) == 0b10000000) { + --len; + } + + if (len > 0) { + buffer[len - 1] = '\0'; + buffer[len] = '\0'; + } +} + void DrawVirtualKeyboard(char* buffer, std::size_t buffer_capacity, bool* input_changed, KeyboardMode& kb_mode, bool& shift_enabled, bool* done_pressed) { const std::vector* layout = nullptr; - if (kb_mode == KeyboardMode::Symbols) { + switch (kb_mode) { + case KeyboardMode::Symbols1: layout = &kSymbols1Layout; - } else { + break; + case KeyboardMode::Symbols2: + layout = &kSymbols2Layout; + break; + default: layout = shift_enabled ? &kUppercaseLayout : &kLowercaseLayout; + break; } - auto current_pad_button = - Common::Singleton::Instance()->GetLastState().buttonsState; - RenderKeyboardLayout(*layout, buffer, buffer_capacity, input_changed, kb_mode, shift_enabled, - done_pressed, current_pad_button); + done_pressed); } void RenderKeyboardLayout(const std::vector& layout, char* buffer, std::size_t buffer_capacity, bool* input_changed, KeyboardMode& kb_mode, bool& shift_enabled, - bool* done_pressed, - Libraries::Pad::OrbisPadButtonDataOffset current_pad_button) { - // Define desired total layout size (in pixels) + bool* done_pressed) { const float layout_width = 485.0f; const float layout_height = 200.0f; const float cell_spacing = 4.0f; const float hint_padding = 2.0f; - // Find max rows and columns int max_col = 0; int max_row = 0; for (const Key& key : layout) { @@ -46,7 +61,6 @@ void RenderKeyboardLayout(const std::vector& layout, char* buffer, std::siz max_row = std::max(max_row, key.row + static_cast(key.rowspan)); } - // Calculate cell size dynamically const float cell_width = (layout_width - (max_col - 1) * cell_spacing) / max_col; const float cell_height = (layout_height - (max_row - 1) * cell_spacing) / max_row; @@ -66,8 +80,9 @@ void RenderKeyboardLayout(const std::vector& layout, char* buffer, std::siz : key.label; ImGui::SetCursorScreenPos(pos); + bool key_activated = ImGui::Button(button_id.c_str(), size); - if (ImGui::Button(button_id.c_str(), size)) { + if (key_activated) { switch (key.type) { case KeyType::Text: if (!key.label.empty()) { @@ -77,78 +92,11 @@ void RenderKeyboardLayout(const std::vector& layout, char* buffer, std::siz if (input_changed) *input_changed = true; } - // Controller debug injection - for (Libraries::Pad::OrbisPadButtonDataOffset button : key.bound_buttons) { - if (current_pad_button == button) { - // DEBUG: always insert "ok" when a key is triggered via gamepad - size_t len = std::strlen(buffer); - if (len + 2 < buffer_capacity) { - std::strcat(buffer, "ok"); - if (input_changed) - *input_changed = true; - } - } - } - - // Controller press simulation - for (Libraries::Pad::OrbisPadButtonDataOffset button : key.bound_buttons) { - if (current_pad_button == button) { - switch (key.type) { - case KeyType::Text: - if (!key.label.empty()) { - size_t len = std::strlen(buffer); - if (len + key.label.size() < buffer_capacity) { - std::strcat(buffer, key.label.c_str()); - if (input_changed) - *input_changed = true; - } - } - break; - case KeyType::Backspace: - if (buffer[0] != '\0') { - size_t len = std::strlen(buffer); - buffer[len - 1] = '\0'; - if (input_changed) - *input_changed = true; - } - break; - case KeyType::Space: - if (std::strlen(buffer) + 1 < buffer_capacity) { - std::strcat(buffer, " "); - if (input_changed) - *input_changed = true; - } - break; - case KeyType::Enter: - case KeyType::Done: - if (done_pressed) - *done_pressed = true; - break; - case KeyType::Shift: - shift_enabled = !shift_enabled; - break; - case KeyType::SymbolsLayout: - kb_mode = KeyboardMode::Symbols; - break; - case KeyType::TextLayout: - kb_mode = KeyboardMode::Letters; - break; - case KeyType::ToggleKeyboard: - kb_mode = (kb_mode == KeyboardMode::Letters) - ? KeyboardMode::Symbols - : KeyboardMode::Letters; - break; - default: - break; - } - } - } } break; case KeyType::Backspace: if (buffer[0] != '\0') { - size_t len = std::strlen(buffer); - buffer[len - 1] = '\0'; + Utf8SafeBackspace(buffer); if (input_changed) *input_changed = true; } @@ -168,22 +116,25 @@ void RenderKeyboardLayout(const std::vector& layout, char* buffer, std::siz case KeyType::Shift: shift_enabled = !shift_enabled; break; - case KeyType::SymbolsLayout: - kb_mode = KeyboardMode::Symbols; + case KeyType::Symbols1Layout: + kb_mode = KeyboardMode::Symbols1; + break; + case KeyType::Symbols2Layout: + kb_mode = KeyboardMode::Symbols2; break; case KeyType::TextLayout: - kb_mode = KeyboardMode::Letters; + kb_mode = KeyboardMode::Letters1; break; case KeyType::ToggleKeyboard: - kb_mode = (kb_mode == KeyboardMode::Letters) ? KeyboardMode::Symbols - : KeyboardMode::Letters; + kb_mode = (kb_mode == KeyboardMode::Letters1) ? KeyboardMode::Symbols1 + : KeyboardMode::Letters1; break; default: break; } } - // Controller hint + // Draw controller hint label if (!key.controller_hint.empty()) { float original_font_size = ImGui::GetFontSize(); float small_font_size = original_font_size * 0.5f; @@ -204,4 +155,4 @@ void RenderKeyboardLayout(const std::vector& layout, char* buffer, std::siz key.controller_hint.c_str()); } } -} \ No newline at end of file +} diff --git a/src/core/libraries/ime/ime_keyboard_ui.h b/src/core/libraries/ime/ime_keyboard_ui.h index 73220646e..bbe6f7852 100644 --- a/src/core/libraries/ime/ime_keyboard_ui.h +++ b/src/core/libraries/ime/ime_keyboard_ui.h @@ -6,14 +6,19 @@ #include #include #include +#include "core/libraries/pad/pad.h" #include "ime_keyboard_layouts.h" +#include "core/libraries/ime/ime.h" +#include "core/libraries/ime/ime_error.h" +#include "core/libraries/ime/ime_ui.h" +#include "core/libraries/ime/ime_common.h" -enum class KeyboardMode { Letters, Symbols }; +enum class KeyboardMode { Letters1, Letters2, Symbols1, Symbols2 }; void DrawVirtualKeyboard(char* buffer, std::size_t buffer_capacity, bool* input_changed, KeyboardMode& kb_mode, bool& shift_enabled, bool* done_pressed); + void RenderKeyboardLayout(const std::vector& layout, char* buffer, std::size_t buffer_capacity, bool* input_changed, KeyboardMode& kb_mode, bool& shift_enabled, - bool* done_pressed, - Libraries::Pad::OrbisPadButtonDataOffset current_pad_button); + bool* done_pressed); \ No newline at end of file diff --git a/src/core/libraries/ime/ime_ui.cpp b/src/core/libraries/ime/ime_ui.cpp index 0ba2dc433..a3b1e2e92 100644 --- a/src/core/libraries/ime/ime_ui.cpp +++ b/src/core/libraries/ime/ime_ui.cpp @@ -190,7 +190,7 @@ void ImeUi::DrawInputText() { } void ImeUi::DrawKeyboard() { - static KeyboardMode kb_mode = KeyboardMode::Letters; + static KeyboardMode kb_mode = KeyboardMode::Letters1; static bool shift_enabled = false; static bool has_logged = false; @@ -205,11 +205,35 @@ void ImeUi::DrawKeyboard() { DrawVirtualKeyboard(state->current_text.begin(), state->current_text.capacity(), &input_changed, kb_mode, shift_enabled, &done_pressed); + if (input_changed) { + OrbisImeEditText eventParam{}; + eventParam.str = reinterpret_cast(ime_param->work); + eventParam.caret_index = std::strlen(state->current_text.begin()); + eventParam.area_num = 1; + eventParam.text_area[0].mode = 1; + eventParam.text_area[0].index = 0; + eventParam.text_area[0].length = eventParam.caret_index; + + state->ConvertUTF8ToOrbis(state->current_text.begin(), eventParam.caret_index, + eventParam.str, ime_param->maxTextLength); + state->ConvertUTF8ToOrbis(state->current_text.begin(), eventParam.caret_index, + ime_param->inputTextBuffer, ime_param->maxTextLength); + + OrbisImeEvent event{}; + event.id = OrbisImeEventId::UpdateText; + event.param.text = eventParam; + state->SendEvent(&event); + } + if (done_pressed) { - state->SendEnterEvent(); // Submit action + state->SendEnterEvent(); } } + + + + int ImeUi::InputTextCallback(ImGuiInputTextCallbackData* data) { ImeUi* ui = static_cast(data->UserData); ASSERT(ui); diff --git a/src/imgui/renderer/imgui_core.cpp b/src/imgui/renderer/imgui_core.cpp index 5ce2686a7..9f2c961cc 100644 --- a/src/imgui/renderer/imgui_core.cpp +++ b/src/imgui/renderer/imgui_core.cpp @@ -69,37 +69,42 @@ 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()); - rb.AddChar(0x00D7); // × Cross - rb.AddChar(0x25CB); // ○ Circle - rb.AddChar(0x25B3); // △ Triangle - rb.AddChar(0x25A1); // □ Square - rb.AddChar(0x2191); // ↑ Up Arrow - rb.AddChar(0x2193); // ↓ Down Arrow - rb.AddChar(0x2190); // ← Left Arrow - rb.AddChar(0x2192); // → Right Arrow - - rb.AddChar(0x2297); // ⊗ Circled Times (often used as cross) - rb.AddChar(0x2BBE); // ⮾ Circled X (if supported by font) - rb.AddChar(0x1F5D9); // 🗙 Cancellation X (heavy) - - rb.AddChar(0x25C0); // ◀ Black Left-Pointing Triangle - rb.AddChar(0x25B2); // ▲ Black Up-Pointing Triangle - rb.AddChar(0x25B6); // ▶ Black Right-Pointing Triangle - rb.AddChar(0x25BC); // ▼ Black Down-Pointing Triangle - - rb.AddChar(0x232B); // ⌫ Backspace - - rb.AddChar(0x21E7); // ⇧ UPWARDS WHITE ARROW - rb.AddChar(0x2B06); // ⬆ UPWARDS BLACK ARROW - - rb.AddChar(0x21E6); // ⇦ Leftwards White Arrow + //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'№'); - //rb.AddRanges(io.Fonts->GetGlyphRangesDefault()); - // Manually add full BMP range - //for (ImWchar c = 0x0020; c <= 0xFFFF; ++c) { - // rb.AddChar(c); - //} ImVector ranges{}; rb.BuildRanges(&ranges); ImFontConfig font_cfg{};