mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-23 04:16:57 +02:00
ime: implement libIme and shared host overlay
This commit is contained in:
+1020
File diff suppressed because it is too large
Load Diff
+245
@@ -0,0 +1,245 @@
|
||||
#ifndef EMULATOR_INCLUDE_EMULATOR_LIBS_IME_H_
|
||||
#define EMULATOR_INCLUDE_EMULATOR_LIBS_IME_H_
|
||||
|
||||
#include "common/abi.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace Libs::Ime {
|
||||
|
||||
constexpr uint32_t WORK_BUFFER_SIZE = 20 * 1024;
|
||||
constexpr uint32_t MAX_TEXT_LENGTH = 2048;
|
||||
|
||||
enum class Type : uint32_t { Default = 0, BasicLatin = 1, Url = 2, Mail = 3, Number = 4 };
|
||||
enum class EnterLabel : uint32_t { Default = 0, Send = 1, Search = 2, Go = 3 };
|
||||
enum class Alignment : uint32_t { Start = 0, Center = 1, End = 2 };
|
||||
|
||||
struct Event;
|
||||
struct Keycode;
|
||||
|
||||
using TextFilter = int32_t(KYTY_SYSV_ABI*)(char16_t* out_text, uint32_t* out_text_length,
|
||||
const char16_t* source_text,
|
||||
uint32_t source_text_length);
|
||||
using EventHandler = void(KYTY_SYSV_ABI*)(void* arg, const Event* event);
|
||||
using ExtKeyboardFilter = int(KYTY_SYSV_ABI*)(const Keycode* source_keycode, uint16_t* out_keycode,
|
||||
uint32_t* out_status, void* reserved);
|
||||
|
||||
struct Color {
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
uint8_t a;
|
||||
};
|
||||
|
||||
struct Caret {
|
||||
float x;
|
||||
float y;
|
||||
uint32_t height;
|
||||
uint32_t index;
|
||||
};
|
||||
|
||||
struct TextGeometry {
|
||||
float x;
|
||||
float y;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
|
||||
struct Rect {
|
||||
float x;
|
||||
float y;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
|
||||
enum class TextAreaMode : uint32_t { Disable = 0, Edit = 1, Preedit = 2, Select = 3 };
|
||||
|
||||
struct TextAreaProperty {
|
||||
TextAreaMode mode;
|
||||
uint32_t index;
|
||||
int32_t length;
|
||||
};
|
||||
|
||||
struct EditText {
|
||||
char16_t* str;
|
||||
uint32_t caret_index;
|
||||
uint32_t area_num;
|
||||
TextAreaProperty text_area[4];
|
||||
};
|
||||
|
||||
struct KeyboardResourceIdArray {
|
||||
int32_t user_id;
|
||||
uint32_t resource_id[5];
|
||||
};
|
||||
|
||||
struct Keycode {
|
||||
uint16_t keycode;
|
||||
char16_t character;
|
||||
uint32_t status;
|
||||
uint32_t type;
|
||||
int32_t user_id;
|
||||
uint32_t resource_id;
|
||||
uint64_t timestamp;
|
||||
};
|
||||
|
||||
union EventParam {
|
||||
Rect rect;
|
||||
EditText text;
|
||||
uint32_t caret_move;
|
||||
Keycode keycode;
|
||||
KeyboardResourceIdArray resource_id_array;
|
||||
uint64_t reserved[8];
|
||||
};
|
||||
|
||||
struct Event {
|
||||
uint32_t id;
|
||||
EventParam param;
|
||||
};
|
||||
|
||||
struct Param {
|
||||
int32_t user_id;
|
||||
Type type;
|
||||
uint64_t supported_languages;
|
||||
EnterLabel enter_label;
|
||||
uint32_t input_method;
|
||||
TextFilter filter;
|
||||
uint32_t option;
|
||||
uint32_t max_text_length;
|
||||
char16_t* input_text_buffer;
|
||||
float posx;
|
||||
float posy;
|
||||
Alignment horizontal_alignment;
|
||||
Alignment vertical_alignment;
|
||||
void* work;
|
||||
void* arg;
|
||||
EventHandler handler;
|
||||
int8_t reserved[8];
|
||||
};
|
||||
|
||||
struct ExtendedParam {
|
||||
uint32_t option;
|
||||
Color color_base;
|
||||
Color color_line;
|
||||
Color color_text_field;
|
||||
Color color_preedit;
|
||||
Color color_button_default;
|
||||
Color color_button_function;
|
||||
Color color_button_symbol;
|
||||
Color color_text;
|
||||
Color color_special;
|
||||
uint32_t priority;
|
||||
const char* additional_dictionary_path;
|
||||
ExtKeyboardFilter ext_keyboard_filter;
|
||||
uint32_t disable_device;
|
||||
uint32_t ext_keyboard_mode;
|
||||
int8_t reserved[60];
|
||||
};
|
||||
|
||||
struct KeyboardParam {
|
||||
uint32_t option;
|
||||
int8_t reserved1[4];
|
||||
void* arg;
|
||||
EventHandler handler;
|
||||
int8_t reserved2[8];
|
||||
};
|
||||
|
||||
struct KeyboardInfo {
|
||||
int32_t user_id;
|
||||
uint32_t device;
|
||||
uint32_t type;
|
||||
uint32_t repeat_delay;
|
||||
uint32_t repeat_rate;
|
||||
uint32_t status;
|
||||
int8_t reserved[12];
|
||||
};
|
||||
|
||||
enum class ExternalAction : uint8_t {
|
||||
None,
|
||||
Text,
|
||||
Backspace,
|
||||
MoveLeft,
|
||||
MoveRight,
|
||||
Cancel,
|
||||
Accept,
|
||||
Newline,
|
||||
};
|
||||
|
||||
struct ExternalInput {
|
||||
Keycode key;
|
||||
ExternalAction action;
|
||||
std::u16string text;
|
||||
};
|
||||
|
||||
static_assert(sizeof(Caret) == 0x10);
|
||||
static_assert(sizeof(TextGeometry) == 0x10);
|
||||
static_assert(sizeof(TextAreaProperty) == 0x0c);
|
||||
static_assert(sizeof(EditText) == 0x40);
|
||||
static_assert(sizeof(EventParam) == 0x40);
|
||||
static_assert(alignof(EventParam) == 0x08);
|
||||
static_assert(sizeof(Event) == 0x48);
|
||||
static_assert(offsetof(Event, param) == 0x08);
|
||||
static_assert(sizeof(Param) == 0x60);
|
||||
static_assert(offsetof(Param, input_text_buffer) == 0x28);
|
||||
static_assert(offsetof(Param, work) == 0x40);
|
||||
static_assert(offsetof(Param, handler) == 0x50);
|
||||
static_assert(sizeof(ExtendedParam) == 0x88);
|
||||
static_assert(offsetof(ExtendedParam, additional_dictionary_path) == 0x30);
|
||||
static_assert(sizeof(KeyboardParam) == 0x20);
|
||||
static_assert(sizeof(KeyboardResourceIdArray) == 0x18);
|
||||
static_assert(sizeof(KeyboardInfo) == 0x24);
|
||||
static_assert(sizeof(Keycode) == 0x20);
|
||||
|
||||
struct VisualState {
|
||||
bool active;
|
||||
uint64_t revision;
|
||||
};
|
||||
|
||||
struct HostSnapshot {
|
||||
uint64_t generation;
|
||||
Type type;
|
||||
EnterLabel enter_label;
|
||||
uint32_t option;
|
||||
uint32_t max_text_length;
|
||||
uint32_t cursor;
|
||||
uint32_t disable_device;
|
||||
bool key_panel_visible;
|
||||
float posx;
|
||||
float posy;
|
||||
Alignment horizontal_alignment;
|
||||
Alignment vertical_alignment;
|
||||
uint32_t panel_width;
|
||||
uint32_t panel_height;
|
||||
std::u16string text;
|
||||
};
|
||||
|
||||
using VisibilityCallback = void (*)(bool visible, uint64_t generation);
|
||||
|
||||
void KYTY_SYSV_ABI ImeParamInit(Param* param);
|
||||
int KYTY_SYSV_ABI ImeGetPanelSize(const Param* param, uint32_t* width, uint32_t* height);
|
||||
int KYTY_SYSV_ABI ImeOpen(const Param* param, const ExtendedParam* extended);
|
||||
int KYTY_SYSV_ABI ImeUpdate(EventHandler handler);
|
||||
int KYTY_SYSV_ABI ImeClose();
|
||||
int KYTY_SYSV_ABI ImeSetText(const char16_t* text, uint32_t length);
|
||||
int KYTY_SYSV_ABI ImeSetCaret(const Caret* caret);
|
||||
int KYTY_SYSV_ABI ImeSetTextGeometry(TextAreaMode mode, const TextGeometry* geometry);
|
||||
int KYTY_SYSV_ABI ImeKeyboardOpen(int32_t user_id, const KeyboardParam* param);
|
||||
int KYTY_SYSV_ABI ImeKeyboardClose(int32_t user_id);
|
||||
int KYTY_SYSV_ABI ImeKeyboardGetResourceId(int32_t user_id, KeyboardResourceIdArray* resource_ids);
|
||||
int KYTY_SYSV_ABI ImeKeyboardGetInfo(uint32_t resource_id, KeyboardInfo* info);
|
||||
int KYTY_SYSV_ABI ImeKeyboardSetMode(int32_t user_id, uint32_t mode);
|
||||
|
||||
VisualState GetVisualState() noexcept;
|
||||
void SetVisibilityCallback(VisibilityCallback callback) noexcept;
|
||||
bool GetHostSnapshot(HostSnapshot* snapshot);
|
||||
bool HostInsertText(uint64_t generation, std::u16string_view text);
|
||||
bool HostBackspace(uint64_t generation);
|
||||
bool HostAccept(uint64_t generation);
|
||||
bool HostCancel(uint64_t generation);
|
||||
bool HostQueueExternalInput(uint64_t generation, ExternalInput input);
|
||||
|
||||
} // namespace Libs::Ime
|
||||
|
||||
#endif // EMULATOR_INCLUDE_EMULATOR_LIBS_IME_H_
|
||||
@@ -3804,77 +3804,6 @@ LIB_DEFINE(InitPlatform_1_Random) {
|
||||
|
||||
} // namespace LibRandom
|
||||
|
||||
namespace LibIme {
|
||||
|
||||
LIB_VERSION("Ime", 1, "Ime", 1, 1);
|
||||
|
||||
static int KYTY_SYSV_ABI ImeKeyboardOpen(int user_id, const void* param) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t user_id = %d\n"
|
||||
"\t param = 0x%016" PRIx64 "\n",
|
||||
user_id, reinterpret_cast<uint64_t>(param));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int KYTY_SYSV_ABI ImeKeyboardClose(int user_id) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t user_id = %d\n", user_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int KYTY_SYSV_ABI ImeKeyboardGetResourceId(int user_id, void* resource_id_array) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t user_id = %d\n"
|
||||
"\t resource_id_array = 0x%016" PRIx64 "\n",
|
||||
user_id, reinterpret_cast<uint64_t>(resource_id_array));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int KYTY_SYSV_ABI ImeKeyboardGetInfo(uint32_t resource_id, void* info) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t resource_id = 0x%08" PRIx32 "\n"
|
||||
"\t info = 0x%016" PRIx64 "\n",
|
||||
resource_id, reinterpret_cast<uint64_t>(info));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int KYTY_SYSV_ABI ImeKeyboardSetMode(int user_id, uint32_t mode) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t user_id = %d\n"
|
||||
"\t mode = 0x%08" PRIx32 "\n",
|
||||
user_id, mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int KYTY_SYSV_ABI ImeUpdate(void* handler) {
|
||||
PRINT_NAME();
|
||||
|
||||
// LOGF("\t handler = 0x%016" PRIx64 "\n", reinterpret_cast<uint64_t>(handler));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LIB_DEFINE(InitPlatform_1_Ime) {
|
||||
LIB_FUNC("eaFXjfJv3xs", LibIme::ImeKeyboardOpen);
|
||||
LIB_FUNC("PMVehSlfZ94", LibIme::ImeKeyboardClose);
|
||||
LIB_FUNC("dKadqZFgKKQ", LibIme::ImeKeyboardGetResourceId);
|
||||
LIB_FUNC("VkqLPArfFdc", LibIme::ImeKeyboardGetInfo);
|
||||
LIB_FUNC("ua+13Hk9kKs", LibIme::ImeKeyboardSetMode);
|
||||
LIB_FUNC("-4GCfYdNF1s", LibIme::ImeUpdate);
|
||||
}
|
||||
|
||||
} // namespace LibIme
|
||||
|
||||
namespace LibRemoteplay {
|
||||
|
||||
LIB_VERSION("Remoteplay", 1, "Remoteplay", 1, 1);
|
||||
@@ -3994,7 +3923,6 @@ LIB_DEFINE(InitPlatform_1_SharePlay) {
|
||||
|
||||
LIB_DEFINE(InitPlatform_1) {
|
||||
LibRandom::InitPlatform_1_Random(s);
|
||||
LibIme::InitPlatform_1_Ime(s);
|
||||
LibRemoteplay::InitPlatform_1_Remoteplay(s);
|
||||
LibWebBrowserDialog::InitPlatform_1_WebBrowserDialog(s);
|
||||
LibGameLiveStreaming::InitPlatform_1_GameLiveStreaming(s);
|
||||
|
||||
@@ -34,6 +34,10 @@ namespace LibKeyboard {
|
||||
LIB_DEFINE(InitKeyboard_1);
|
||||
} // namespace LibKeyboard
|
||||
|
||||
namespace Ime {
|
||||
LIB_DEFINE(InitPlatform_1_Ime);
|
||||
} // namespace Ime
|
||||
|
||||
namespace LibUlt {
|
||||
LIB_DEFINE(InitUlt_1);
|
||||
} // namespace LibUlt
|
||||
@@ -89,6 +93,7 @@ void InitAll(Loader::SymbolDatabase* s) {
|
||||
LIB_LOAD(InitLibKernel_1);
|
||||
LIB_LOAD(LibMouse::InitMouse_1);
|
||||
LIB_LOAD(LibKeyboard::InitKeyboard_1);
|
||||
LIB_LOAD(Ime::InitPlatform_1_Ime);
|
||||
LIB_LOAD(InitNet_1);
|
||||
LIB_LOAD(InitPad_1);
|
||||
LIB_LOAD(InitPlayGo_1);
|
||||
|
||||
Reference in New Issue
Block a user