mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-12 13:43:15 +00:00
core: Library cleanup (#1631)
* core: Split error codes into separate files * Reduces build times and is cleaner * core: Bring structs and enums to codebase style * core: More style changes
This commit is contained in:
parent
3d0aacd43d
commit
5b6e0ab238
114 changed files with 2158 additions and 2509 deletions
|
@ -2,14 +2,12 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <queue>
|
||||
#include "ime.h"
|
||||
#include "ime_ui.h"
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "common/singleton.h"
|
||||
#include "core/libraries/error_codes.h"
|
||||
#include "core/libraries/ime/ime.h"
|
||||
#include "core/libraries/ime/ime_error.h"
|
||||
#include "core/libraries/ime/ime_ui.h"
|
||||
#include "core/libraries/libs.h"
|
||||
#include "core/linker.h"
|
||||
#include "core/tls.h"
|
||||
|
||||
namespace Libraries::Ime {
|
||||
|
||||
|
@ -37,7 +35,7 @@ public:
|
|||
|
||||
// Open an event to let the game know the IME has started
|
||||
OrbisImeEvent openEvent{};
|
||||
openEvent.id = (ime_mode ? OrbisImeEventId::OPEN : OrbisImeEventId::KEYBOARD_OPEN);
|
||||
openEvent.id = (ime_mode ? OrbisImeEventId::Open : OrbisImeEventId::KeyboardOpen);
|
||||
|
||||
if (ime_mode) {
|
||||
sceImeGetPanelSize(&m_param.ime, &openEvent.param.rect.width,
|
||||
|
@ -45,8 +43,8 @@ public:
|
|||
openEvent.param.rect.x = m_param.ime.posx;
|
||||
openEvent.param.rect.y = m_param.ime.posy;
|
||||
} else {
|
||||
openEvent.param.resourceIdArray.userId = 1;
|
||||
openEvent.param.resourceIdArray.resourceId[0] = 1;
|
||||
openEvent.param.resource_id_array.userId = 1;
|
||||
openEvent.param.resource_id_array.resource_id[0] = 1;
|
||||
}
|
||||
|
||||
Execute(nullptr, &openEvent, true);
|
||||
|
@ -215,15 +213,15 @@ s32 PS4_SYSV_ABI sceImeGetPanelSize(const OrbisImeParam* param, u32* width, u32*
|
|||
}
|
||||
|
||||
switch (param->type) {
|
||||
case OrbisImeType::DEFAULT:
|
||||
case OrbisImeType::BASIC_LATIN:
|
||||
case OrbisImeType::URL:
|
||||
case OrbisImeType::MAIL:
|
||||
case OrbisImeType::Default:
|
||||
case OrbisImeType::BasicLatin:
|
||||
case OrbisImeType::Url:
|
||||
case OrbisImeType::Mail:
|
||||
// We set our custom sizes, commented sizes are the original ones
|
||||
*width = 500; // 793
|
||||
*height = 100; // 408
|
||||
break;
|
||||
case OrbisImeType::NUMBER:
|
||||
case OrbisImeType::Number:
|
||||
*width = 370;
|
||||
*height = 402;
|
||||
break;
|
||||
|
@ -315,7 +313,7 @@ void PS4_SYSV_ABI sceImeParamInit(OrbisImeParam* param) {
|
|||
}
|
||||
|
||||
memset(param, 0, sizeof(OrbisImeParam));
|
||||
param->userId = -1;
|
||||
param->user_id = -1;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceImeSetCandidateIndex() {
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/enum.h"
|
||||
#include "common/types.h"
|
||||
|
||||
#include "ime_common.h"
|
||||
#include "core/libraries/ime/ime_common.h"
|
||||
|
||||
namespace Core::Loader {
|
||||
class SymbolsResolver;
|
||||
|
@ -16,13 +16,13 @@ namespace Libraries::Ime {
|
|||
constexpr u32 ORBIS_IME_MAX_TEXT_LENGTH = 2048;
|
||||
|
||||
enum class OrbisImeKeyboardOption : u32 {
|
||||
DEFAULT = 0,
|
||||
REPEAT = 1,
|
||||
REPEAT_EACH_KEY = 2,
|
||||
ADD_OSK = 4,
|
||||
EFFECTIVE_WITH_TIME = 8,
|
||||
DISABLE_RESUME = 16,
|
||||
DISABLE_CAPSLOCK_WITHOUT_SHIFT = 32,
|
||||
Default = 0,
|
||||
Repeat = 1,
|
||||
RepeatEachKey = 2,
|
||||
AddOsk = 4,
|
||||
EffectiveWithTime = 8,
|
||||
DisableResume = 16,
|
||||
DisableCapslockWithoutShift = 32,
|
||||
};
|
||||
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeKeyboardOption)
|
||||
|
||||
|
@ -35,19 +35,19 @@ struct OrbisImeKeyboardParam {
|
|||
};
|
||||
|
||||
struct OrbisImeParam {
|
||||
s32 userId;
|
||||
s32 user_id;
|
||||
OrbisImeType type;
|
||||
u64 supportedLanguages;
|
||||
OrbisImeEnterLabel enterLabel;
|
||||
OrbisImeInputMethod inputMethod;
|
||||
u64 supported_languages;
|
||||
OrbisImeEnterLabel enter_label;
|
||||
OrbisImeInputMethod input_method;
|
||||
OrbisImeTextFilter filter;
|
||||
u32 option;
|
||||
u32 maxTextLength;
|
||||
char16_t* inputTextBuffer;
|
||||
u32 max_text_length;
|
||||
char16_t* input_text_buffer;
|
||||
float posx;
|
||||
float posy;
|
||||
OrbisImeHorizontalAlignment horizontalAlignment;
|
||||
OrbisImeVerticalAlignment verticalAlignment;
|
||||
OrbisImeHorizontalAlignment horizontal_alignment;
|
||||
OrbisImeVerticalAlignment vertical_alignment;
|
||||
void* work;
|
||||
void* arg;
|
||||
OrbisImeEventHandler handler;
|
||||
|
@ -117,4 +117,5 @@ int PS4_SYSV_ABI sceImeVshUpdateContext();
|
|||
int PS4_SYSV_ABI sceImeVshUpdateContext2();
|
||||
|
||||
void RegisterlibSceIme(Core::Loader::SymbolsResolver* sym);
|
||||
} // namespace Libraries::Ime
|
||||
|
||||
} // namespace Libraries::Ime
|
||||
|
|
|
@ -2,65 +2,64 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
#include <sys/types.h>
|
||||
#include "common/enum.h"
|
||||
|
||||
#include "common/types.h"
|
||||
#include "core/libraries/rtc/rtc.h"
|
||||
|
||||
enum class OrbisImeType : u32 {
|
||||
DEFAULT = 0,
|
||||
BASIC_LATIN = 1,
|
||||
URL = 2,
|
||||
MAIL = 3,
|
||||
NUMBER = 4,
|
||||
Default = 0,
|
||||
BasicLatin = 1,
|
||||
Url = 2,
|
||||
Mail = 3,
|
||||
Number = 4,
|
||||
};
|
||||
|
||||
enum class OrbisImeHorizontalAlignment : u32 {
|
||||
LEFT = 0,
|
||||
CENTER = 1,
|
||||
RIGHT = 2,
|
||||
Left = 0,
|
||||
Center = 1,
|
||||
Right = 2,
|
||||
};
|
||||
|
||||
enum class OrbisImeVerticalAlignment : u32 {
|
||||
TOP = 0,
|
||||
CENTER = 1,
|
||||
BOTTOM = 2,
|
||||
Top = 0,
|
||||
Center = 1,
|
||||
Bottom = 2,
|
||||
};
|
||||
|
||||
enum class OrbisImeEnterLabel : u32 {
|
||||
DEFAULT = 0,
|
||||
SEND = 1,
|
||||
SEARCH = 2,
|
||||
GO = 3,
|
||||
Default = 0,
|
||||
Send = 1,
|
||||
Search = 2,
|
||||
Go = 3,
|
||||
};
|
||||
|
||||
enum class OrbisImeInputMethod : u32 {
|
||||
DEFAULT = 0,
|
||||
Default = 0,
|
||||
};
|
||||
|
||||
enum class OrbisImeEventId : u32 {
|
||||
OPEN = 0,
|
||||
UPDATE_TEXT = 1,
|
||||
UPDATE_CARET = 2,
|
||||
PRESS_CLOSE = 4,
|
||||
PRESS_ENTER = 5,
|
||||
ABORT = 6,
|
||||
CANDIDATE_LIST_START = 7,
|
||||
CANDIDATE_LIST_END = 8,
|
||||
CANDIDATE_WORD = 9,
|
||||
CANDIDATE_INDEX = 10,
|
||||
CANDIDATE_DONE = 11,
|
||||
CANDIDATE_CANCEL = 12,
|
||||
CHANGE_DEVICE = 14,
|
||||
CHANGE_INPUT_METHOD_STATE = 18,
|
||||
Open = 0,
|
||||
UpdateText = 1,
|
||||
UpdateCaret = 2,
|
||||
PressClose = 4,
|
||||
PressEnter = 5,
|
||||
Abort = 6,
|
||||
CandidateListStart = 7,
|
||||
CandidateListEnd = 8,
|
||||
CandidateWord = 9,
|
||||
CandidateIndex = 10,
|
||||
CandidateDone = 11,
|
||||
CandidateCancel = 12,
|
||||
ChangeDevice = 14,
|
||||
ChangeInputMethodState = 18,
|
||||
|
||||
KEYBOARD_OPEN = 256,
|
||||
KEYBOARD_KEYCODE_DOWN = 257,
|
||||
KEYBOARD_KEYCODE_UP = 258,
|
||||
KEYBOARD_KEYCODE_REPEAT = 259,
|
||||
KEYBOARD_CONNECTION = 260,
|
||||
KEYBOARD_DISCONNECTION = 261,
|
||||
KEYBOARD_ABORT = 262,
|
||||
KeyboardOpen = 256,
|
||||
KeyboardKeycodeDoen = 257,
|
||||
KeyboardKeycodeUp = 258,
|
||||
KeyboardKeycodeRepeat = 259,
|
||||
KeyboardConnection = 260,
|
||||
KeyboardDisconnection = 261,
|
||||
KeyboardAbort = 262,
|
||||
};
|
||||
|
||||
enum class OrbisImeKeyboardType : u32 {
|
||||
|
@ -105,10 +104,10 @@ enum class OrbisImeKeyboardType : u32 {
|
|||
};
|
||||
|
||||
enum class OrbisImeDeviceType : u32 {
|
||||
NONE = 0,
|
||||
CONTROLLER = 1,
|
||||
EXT_KEYBOARD = 2,
|
||||
REMOTE_OSK = 3,
|
||||
None = 0,
|
||||
Controller = 1,
|
||||
ExtKeyboard = 2,
|
||||
RemoteOsk = 3,
|
||||
};
|
||||
|
||||
struct OrbisImeRect {
|
||||
|
@ -126,9 +125,9 @@ struct OrbisImeTextAreaProperty {
|
|||
|
||||
struct OrbisImeEditText {
|
||||
char16_t* str;
|
||||
u32 caretIndex;
|
||||
u32 areaNum;
|
||||
OrbisImeTextAreaProperty textArea[4];
|
||||
u32 caret_index;
|
||||
u32 area_num;
|
||||
OrbisImeTextAreaProperty text_area[4];
|
||||
};
|
||||
|
||||
struct OrbisImeKeycode {
|
||||
|
@ -136,40 +135,40 @@ struct OrbisImeKeycode {
|
|||
char16_t character;
|
||||
u32 status;
|
||||
OrbisImeKeyboardType type;
|
||||
s32 userId;
|
||||
u32 resourceId;
|
||||
s32 user_id;
|
||||
u32 resource_id;
|
||||
Libraries::Rtc::OrbisRtcTick timestamp;
|
||||
};
|
||||
|
||||
struct OrbisImeKeyboardResourceIdArray {
|
||||
s32 userId;
|
||||
u32 resourceId[6];
|
||||
u32 resource_id[6];
|
||||
};
|
||||
|
||||
enum class OrbisImeCaretMovementDirection : u32 {
|
||||
STILL = 0,
|
||||
LEFT = 1,
|
||||
RIGHT = 2,
|
||||
UP = 3,
|
||||
DOWN = 4,
|
||||
HOME = 5,
|
||||
END = 6,
|
||||
PAGE_UP = 7,
|
||||
PAGE_DOWN = 8,
|
||||
TOP = 9,
|
||||
BOTTOM = 10,
|
||||
Still = 0,
|
||||
Left = 1,
|
||||
Right = 2,
|
||||
Up = 3,
|
||||
Down = 4,
|
||||
Home = 5,
|
||||
End = 6,
|
||||
PageUp = 7,
|
||||
PageDown = 8,
|
||||
Top = 9,
|
||||
Bottom = 10,
|
||||
};
|
||||
|
||||
union OrbisImeEventParam {
|
||||
OrbisImeRect rect;
|
||||
OrbisImeEditText text;
|
||||
OrbisImeCaretMovementDirection caretMove;
|
||||
OrbisImeCaretMovementDirection caret_move;
|
||||
OrbisImeKeycode keycode;
|
||||
OrbisImeKeyboardResourceIdArray resourceIdArray;
|
||||
char16_t* candidateWord;
|
||||
s32 candidateIndex;
|
||||
OrbisImeDeviceType deviceType;
|
||||
u32 inputMethodState;
|
||||
OrbisImeKeyboardResourceIdArray resource_id_array;
|
||||
char16_t* candidate_word;
|
||||
s32 candidate_index;
|
||||
OrbisImeDeviceType device_type;
|
||||
u32 input_method_state;
|
||||
s8 reserved[64];
|
||||
};
|
||||
|
||||
|
@ -178,7 +177,7 @@ struct OrbisImeEvent {
|
|||
OrbisImeEventParam param;
|
||||
};
|
||||
|
||||
typedef PS4_SYSV_ABI int (*OrbisImeTextFilter)(char16_t* outText, u32* outTextLength,
|
||||
const char16_t* srcText, u32 srcTextLength);
|
||||
using OrbisImeTextFilter = PS4_SYSV_ABI int (*)(char16_t* outText, u32* outTextLength,
|
||||
const char16_t* srcText, u32 srcTextLength);
|
||||
|
||||
typedef PS4_SYSV_ABI void (*OrbisImeEventHandler)(void* arg, const OrbisImeEvent* e);
|
||||
using OrbisImeEventHandler = PS4_SYSV_ABI void (*)(void* arg, const OrbisImeEvent* e);
|
||||
|
|
|
@ -14,24 +14,24 @@ static constexpr std::array<float, 2> MAX_Y_POSITIONS = {2160.0f, 1080.0f};
|
|||
|
||||
namespace Libraries::ImeDialog {
|
||||
|
||||
static OrbisImeDialogStatus g_ime_dlg_status = OrbisImeDialogStatus::NONE;
|
||||
static OrbisImeDialogStatus g_ime_dlg_status = OrbisImeDialogStatus::None;
|
||||
static OrbisImeDialogResult g_ime_dlg_result{};
|
||||
static ImeDialogState g_ime_dlg_state{};
|
||||
static ImeDialogUi g_ime_dlg_ui;
|
||||
|
||||
static bool IsValidOption(OrbisImeDialogOption option, OrbisImeType type) {
|
||||
if (False(~option &
|
||||
(OrbisImeDialogOption::MULTILINE | OrbisImeDialogOption::NO_AUTO_COMPLETION))) {
|
||||
(OrbisImeDialogOption::Multiline | OrbisImeDialogOption::NoAutoCompletion))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (True(option & OrbisImeDialogOption::MULTILINE) && type != OrbisImeType::DEFAULT &&
|
||||
type != OrbisImeType::BASIC_LATIN) {
|
||||
if (True(option & OrbisImeDialogOption::Multiline) && type != OrbisImeType::Default &&
|
||||
type != OrbisImeType::BasicLatin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (True(option & OrbisImeDialogOption::NO_AUTO_COMPLETION) && type != OrbisImeType::NUMBER &&
|
||||
type != OrbisImeType::BASIC_LATIN) {
|
||||
if (True(option & OrbisImeDialogOption::NoAutoCompletion) && type != OrbisImeType::Number &&
|
||||
type != OrbisImeType::BasicLatin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -39,29 +39,29 @@ static bool IsValidOption(OrbisImeDialogOption option, OrbisImeType type) {
|
|||
}
|
||||
|
||||
Error PS4_SYSV_ABI sceImeDialogAbort() {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::None) {
|
||||
LOG_INFO(Lib_ImeDialog, "IME dialog not in use");
|
||||
return Error::DIALOG_NOT_IN_USE;
|
||||
}
|
||||
|
||||
if (g_ime_dlg_status != OrbisImeDialogStatus::RUNNING) {
|
||||
if (g_ime_dlg_status != OrbisImeDialogStatus::Running) {
|
||||
LOG_INFO(Lib_ImeDialog, "IME dialog not running");
|
||||
return Error::DIALOG_NOT_RUNNING;
|
||||
}
|
||||
|
||||
g_ime_dlg_status = OrbisImeDialogStatus::FINISHED;
|
||||
g_ime_dlg_result.endstatus = OrbisImeDialogEndStatus::ABORTED;
|
||||
g_ime_dlg_status = OrbisImeDialogStatus::Finished;
|
||||
g_ime_dlg_result.endstatus = OrbisImeDialogEndStatus::Aborted;
|
||||
|
||||
return Error::OK;
|
||||
}
|
||||
|
||||
Error PS4_SYSV_ABI sceImeDialogForceClose() {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::None) {
|
||||
LOG_INFO(Lib_ImeDialog, "IME dialog not in use");
|
||||
return Error::DIALOG_NOT_IN_USE;
|
||||
}
|
||||
|
||||
g_ime_dlg_status = OrbisImeDialogStatus::NONE;
|
||||
g_ime_dlg_status = OrbisImeDialogStatus::None;
|
||||
g_ime_dlg_ui = ImeDialogUi();
|
||||
g_ime_dlg_state = ImeDialogState();
|
||||
|
||||
|
@ -93,7 +93,7 @@ int PS4_SYSV_ABI sceImeDialogGetPanelSizeExtended() {
|
|||
}
|
||||
|
||||
Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::None) {
|
||||
LOG_INFO(Lib_ImeDialog, "IME dialog is not running");
|
||||
return Error::DIALOG_NOT_IN_USE;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) {
|
|||
|
||||
result->endstatus = g_ime_dlg_result.endstatus;
|
||||
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::RUNNING) {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::Running) {
|
||||
return Error::DIALOG_NOT_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) {
|
|||
}
|
||||
|
||||
OrbisImeDialogStatus PS4_SYSV_ABI sceImeDialogGetStatus() {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::RUNNING) {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::Running) {
|
||||
g_ime_dlg_state.CallTextFilter();
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ OrbisImeDialogStatus PS4_SYSV_ABI sceImeDialogGetStatus() {
|
|||
}
|
||||
|
||||
Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExtended* extended) {
|
||||
if (g_ime_dlg_status != OrbisImeDialogStatus::NONE) {
|
||||
if (g_ime_dlg_status != OrbisImeDialogStatus::None) {
|
||||
LOG_INFO(Lib_ImeDialog, "IME dialog is already running");
|
||||
return Error::BUSY;
|
||||
}
|
||||
|
@ -142,24 +142,24 @@ Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExt
|
|||
|
||||
if (param->posx < 0.0f ||
|
||||
param->posx >=
|
||||
MAX_X_POSITIONS[False(param->option & OrbisImeDialogOption::LARGE_RESOLUTION)]) {
|
||||
MAX_X_POSITIONS[False(param->option & OrbisImeDialogOption::LargeResolution)]) {
|
||||
LOG_INFO(Lib_ImeDialog, "Invalid param->posx");
|
||||
return Error::INVALID_POSX;
|
||||
}
|
||||
|
||||
if (param->posy < 0.0f ||
|
||||
param->posy >=
|
||||
MAX_Y_POSITIONS[False(param->option & OrbisImeDialogOption::LARGE_RESOLUTION)]) {
|
||||
MAX_Y_POSITIONS[False(param->option & OrbisImeDialogOption::LargeResolution)]) {
|
||||
LOG_INFO(Lib_ImeDialog, "Invalid param->posy");
|
||||
return Error::INVALID_POSY;
|
||||
}
|
||||
|
||||
if (!magic_enum::enum_contains(param->horizontalAlignment)) {
|
||||
if (!magic_enum::enum_contains(param->horizontal_alignment)) {
|
||||
LOG_INFO(Lib_ImeDialog, "Invalid param->horizontalAlignment");
|
||||
return Error::INVALID_HORIZONTALIGNMENT;
|
||||
}
|
||||
|
||||
if (!magic_enum::enum_contains(param->verticalAlignment)) {
|
||||
if (!magic_enum::enum_contains(param->vertical_alignment)) {
|
||||
LOG_INFO(Lib_ImeDialog, "Invalid param->verticalAlignment");
|
||||
return Error::INVALID_VERTICALALIGNMENT;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExt
|
|||
return Error::INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (param->inputTextBuffer == nullptr) {
|
||||
if (param->input_text_buffer == nullptr) {
|
||||
LOG_INFO(Lib_ImeDialog, "Invalid param->inputTextBuffer");
|
||||
return Error::INVALID_INPUT_TEXT_BUFFER;
|
||||
}
|
||||
|
@ -182,25 +182,25 @@ Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExt
|
|||
|
||||
// TODO: do correct extended->option validation
|
||||
|
||||
if ((extended->extKeyboardMode & 0xe3fffffc) != 0) {
|
||||
if ((extended->ext_keyboard_mode & 0xe3fffffc) != 0) {
|
||||
LOG_INFO(Lib_ImeDialog, "Invalid extended->extKeyboardMode");
|
||||
return Error::INVALID_EXTENDED;
|
||||
}
|
||||
|
||||
if (extended->disableDevice > 7) {
|
||||
if (extended->disable_device > 7) {
|
||||
LOG_INFO(Lib_ImeDialog, "Invalid extended->disableDevice");
|
||||
return Error::INVALID_EXTENDED;
|
||||
}
|
||||
}
|
||||
|
||||
if (param->maxTextLength > ORBIS_IME_DIALOG_MAX_TEXT_LENGTH) {
|
||||
if (param->max_text_length > ORBIS_IME_DIALOG_MAX_TEXT_LENGTH) {
|
||||
LOG_INFO(Lib_ImeDialog, "Invalid param->maxTextLength");
|
||||
return Error::INVALID_MAX_TEXT_LENGTH;
|
||||
}
|
||||
|
||||
g_ime_dlg_result = {};
|
||||
g_ime_dlg_state = ImeDialogState(param, extended);
|
||||
g_ime_dlg_status = OrbisImeDialogStatus::RUNNING;
|
||||
g_ime_dlg_status = OrbisImeDialogStatus::Running;
|
||||
g_ime_dlg_ui = ImeDialogUi(&g_ime_dlg_state, &g_ime_dlg_status, &g_ime_dlg_result);
|
||||
|
||||
return Error::OK;
|
||||
|
@ -227,17 +227,17 @@ int PS4_SYSV_ABI sceImeDialogSetPanelPosition() {
|
|||
}
|
||||
|
||||
Error PS4_SYSV_ABI sceImeDialogTerm() {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::NONE) {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::None) {
|
||||
LOG_INFO(Lib_ImeDialog, "IME dialog not in use");
|
||||
return Error::DIALOG_NOT_IN_USE;
|
||||
}
|
||||
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::RUNNING) {
|
||||
if (g_ime_dlg_status == OrbisImeDialogStatus::Running) {
|
||||
LOG_INFO(Lib_ImeDialog, "IME dialog is still running");
|
||||
return Error::DIALOG_NOT_FINISHED;
|
||||
}
|
||||
|
||||
g_ime_dlg_status = OrbisImeDialogStatus::NONE;
|
||||
g_ime_dlg_status = OrbisImeDialogStatus::None;
|
||||
g_ime_dlg_ui = ImeDialogUi();
|
||||
g_ime_dlg_state = ImeDialogState();
|
||||
|
||||
|
@ -274,4 +274,4 @@ void RegisterlibSceImeDialog(Core::Loader::SymbolsResolver* sym) {
|
|||
LIB_FUNCTION("gyTyVn+bXMw", "libSceImeDialog", 1, "libSceImeDialog", 1, 1, sceImeDialogTerm);
|
||||
};
|
||||
|
||||
} // namespace Libraries::ImeDialog
|
||||
} // namespace Libraries::ImeDialog
|
||||
|
|
|
@ -58,32 +58,32 @@ enum class Error : u32 {
|
|||
};
|
||||
|
||||
enum class OrbisImeDialogStatus : u32 {
|
||||
NONE = 0,
|
||||
RUNNING = 1,
|
||||
FINISHED = 2,
|
||||
None = 0,
|
||||
Running = 1,
|
||||
Finished = 2,
|
||||
};
|
||||
|
||||
enum class OrbisImeDialogEndStatus : u32 {
|
||||
OK = 0,
|
||||
USER_CANCELED = 1,
|
||||
ABORTED = 2,
|
||||
Ok = 0,
|
||||
UserCanceled = 1,
|
||||
Aborted = 2,
|
||||
};
|
||||
|
||||
enum class OrbisImeDialogOption : u32 {
|
||||
DEFAULT = 0,
|
||||
MULTILINE = 1,
|
||||
NO_AUTO_CORRECTION = 2,
|
||||
NO_AUTO_COMPLETION = 4,
|
||||
Default = 0,
|
||||
Multiline = 1,
|
||||
NoAutoCorrection = 2,
|
||||
NoAutoCompletion = 4,
|
||||
// TODO: Document missing options
|
||||
LARGE_RESOLUTION = 1024,
|
||||
LargeResolution = 1024,
|
||||
};
|
||||
DECLARE_ENUM_FLAG_OPERATORS(OrbisImeDialogOption)
|
||||
|
||||
enum class OrbisImePanelPriority : u32 {
|
||||
DEFAULT = 0,
|
||||
ALPHABET = 1,
|
||||
SYMBOL = 2,
|
||||
ACCENT = 3,
|
||||
Default = 0,
|
||||
Alphabet = 1,
|
||||
Symbol = 2,
|
||||
Accent = 3,
|
||||
};
|
||||
|
||||
struct OrbisImeColor {
|
||||
|
@ -103,29 +103,29 @@ struct OrbisImeKeycode {
|
|||
char16_t character;
|
||||
u32 status;
|
||||
OrbisImeKeyboardType type;
|
||||
s32 userId;
|
||||
u32 resourceId;
|
||||
s32 user_id;
|
||||
u32 resource_id;
|
||||
u64 timestamp;
|
||||
};
|
||||
|
||||
typedef PS4_SYSV_ABI int (*OrbisImeExtKeyboardFilter)(const OrbisImeKeycode* srcKeycode,
|
||||
u16* outKeycode, u32* outStatus,
|
||||
void* reserved);
|
||||
using OrbisImeExtKeyboardFilter = PS4_SYSV_ABI int (*)(const OrbisImeKeycode* srcKeycode,
|
||||
u16* outKeycode, u32* outStatus,
|
||||
void* reserved);
|
||||
|
||||
struct OrbisImeDialogParam {
|
||||
s32 userId;
|
||||
s32 user_id;
|
||||
OrbisImeType type;
|
||||
u64 supportedLanguages;
|
||||
OrbisImeEnterLabel enterLabel;
|
||||
OrbisImeInputMethod inputMethod;
|
||||
u64 supported_languages;
|
||||
OrbisImeEnterLabel enter_label;
|
||||
OrbisImeInputMethod input_method;
|
||||
OrbisImeTextFilter filter;
|
||||
OrbisImeDialogOption option;
|
||||
u32 maxTextLength;
|
||||
char16_t* inputTextBuffer;
|
||||
u32 max_text_length;
|
||||
char16_t* input_text_buffer;
|
||||
float posx;
|
||||
float posy;
|
||||
OrbisImeHorizontalAlignment horizontalAlignment;
|
||||
OrbisImeVerticalAlignment verticalAlignment;
|
||||
OrbisImeHorizontalAlignment horizontal_alignment;
|
||||
OrbisImeVerticalAlignment vertical_alignment;
|
||||
const char16_t* placeholder;
|
||||
const char16_t* title;
|
||||
s8 reserved[16];
|
||||
|
@ -133,20 +133,20 @@ struct OrbisImeDialogParam {
|
|||
|
||||
struct OrbisImeParamExtended {
|
||||
u32 option; // OrbisImeDialogOptionExtended
|
||||
OrbisImeColor colorBase;
|
||||
OrbisImeColor colorLine;
|
||||
OrbisImeColor colorTextField;
|
||||
OrbisImeColor colorPreedit;
|
||||
OrbisImeColor colorButtonDefault;
|
||||
OrbisImeColor colorButtonFunction;
|
||||
OrbisImeColor colorButtonSymbol;
|
||||
OrbisImeColor colorText;
|
||||
OrbisImeColor colorSpecial;
|
||||
OrbisImeColor color_base;
|
||||
OrbisImeColor color_line;
|
||||
OrbisImeColor color_text_field;
|
||||
OrbisImeColor color_preedit;
|
||||
OrbisImeColor color_button_default;
|
||||
OrbisImeColor color_button_function;
|
||||
OrbisImeColor color_button_symbol;
|
||||
OrbisImeColor color_text;
|
||||
OrbisImeColor color_special;
|
||||
OrbisImePanelPriority priority;
|
||||
char* additionalDictionaryPath;
|
||||
OrbisImeExtKeyboardFilter extKeyboardFilter;
|
||||
uint32_t disableDevice;
|
||||
uint32_t extKeyboardMode;
|
||||
char* additional_dictionary_path;
|
||||
OrbisImeExtKeyboardFilter ext_keyboard_filter;
|
||||
uint32_t disable_device;
|
||||
uint32_t ext_keyboard_mode;
|
||||
int8_t reserved[60];
|
||||
};
|
||||
|
||||
|
@ -167,4 +167,4 @@ int PS4_SYSV_ABI sceImeDialogSetPanelPosition();
|
|||
Error PS4_SYSV_ABI sceImeDialogTerm();
|
||||
|
||||
void RegisterlibSceImeDialog(Core::Loader::SymbolsResolver* sym);
|
||||
} // namespace Libraries::ImeDialog
|
||||
} // namespace Libraries::ImeDialog
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/singleton.h"
|
||||
#include "core/libraries/ime/ime_dialog.h"
|
||||
#include "core/libraries/ime/ime_dialog_ui.h"
|
||||
#include "core/tls.h"
|
||||
|
@ -26,15 +25,15 @@ ImeDialogState::ImeDialogState(const OrbisImeDialogParam* param,
|
|||
return;
|
||||
}
|
||||
|
||||
userId = param->userId;
|
||||
is_multiLine = True(param->option & OrbisImeDialogOption::MULTILINE);
|
||||
is_numeric = param->type == OrbisImeType::NUMBER;
|
||||
user_id = param->user_id;
|
||||
is_multi_line = True(param->option & OrbisImeDialogOption::Multiline);
|
||||
is_numeric = param->type == OrbisImeType::Number;
|
||||
type = param->type;
|
||||
enter_label = param->enterLabel;
|
||||
enter_label = param->enter_label;
|
||||
text_filter = param->filter;
|
||||
keyboard_filter = extended ? extended->extKeyboardFilter : nullptr;
|
||||
max_text_length = param->maxTextLength;
|
||||
text_buffer = param->inputTextBuffer;
|
||||
keyboard_filter = extended ? extended->ext_keyboard_filter : nullptr;
|
||||
max_text_length = param->max_text_length;
|
||||
text_buffer = param->input_text_buffer;
|
||||
|
||||
if (param->title) {
|
||||
std::size_t title_len = std::char_traits<char16_t>::length(param->title);
|
||||
|
@ -65,12 +64,12 @@ ImeDialogState::ImeDialogState(const OrbisImeDialogParam* param,
|
|||
}
|
||||
|
||||
ImeDialogState::ImeDialogState(ImeDialogState&& other) noexcept
|
||||
: input_changed(other.input_changed), userId(other.userId), is_multiLine(other.is_multiLine),
|
||||
is_numeric(other.is_numeric), type(other.type), enter_label(other.enter_label),
|
||||
text_filter(other.text_filter), keyboard_filter(other.keyboard_filter),
|
||||
max_text_length(other.max_text_length), text_buffer(other.text_buffer),
|
||||
title(std::move(other.title)), placeholder(std::move(other.placeholder)),
|
||||
current_text(other.current_text) {
|
||||
: input_changed(other.input_changed), user_id(other.user_id),
|
||||
is_multi_line(other.is_multi_line), is_numeric(other.is_numeric), type(other.type),
|
||||
enter_label(other.enter_label), text_filter(other.text_filter),
|
||||
keyboard_filter(other.keyboard_filter), max_text_length(other.max_text_length),
|
||||
text_buffer(other.text_buffer), title(std::move(other.title)),
|
||||
placeholder(std::move(other.placeholder)), current_text(other.current_text) {
|
||||
|
||||
other.text_buffer = nullptr;
|
||||
}
|
||||
|
@ -78,8 +77,8 @@ ImeDialogState::ImeDialogState(ImeDialogState&& other) noexcept
|
|||
ImeDialogState& ImeDialogState::operator=(ImeDialogState&& other) {
|
||||
if (this != &other) {
|
||||
input_changed = other.input_changed;
|
||||
userId = other.userId;
|
||||
is_multiLine = other.is_multiLine;
|
||||
user_id = other.user_id;
|
||||
is_multi_line = other.is_multi_line;
|
||||
is_numeric = other.is_numeric;
|
||||
type = other.type;
|
||||
enter_label = other.enter_label;
|
||||
|
@ -171,7 +170,7 @@ ImeDialogUi::ImeDialogUi(ImeDialogState* state, OrbisImeDialogStatus* status,
|
|||
OrbisImeDialogResult* result)
|
||||
: state(state), status(status), result(result) {
|
||||
|
||||
if (state && *status == OrbisImeDialogStatus::RUNNING) {
|
||||
if (state && *status == OrbisImeDialogStatus::Running) {
|
||||
AddLayer(this);
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +190,7 @@ ImeDialogUi::ImeDialogUi(ImeDialogUi&& other) noexcept
|
|||
other.status = nullptr;
|
||||
other.result = nullptr;
|
||||
|
||||
if (state && *status == OrbisImeDialogStatus::RUNNING) {
|
||||
if (state && *status == OrbisImeDialogStatus::Running) {
|
||||
AddLayer(this);
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +207,7 @@ ImeDialogUi& ImeDialogUi::operator=(ImeDialogUi&& other) {
|
|||
other.status = nullptr;
|
||||
other.result = nullptr;
|
||||
|
||||
if (state && *status == OrbisImeDialogStatus::RUNNING) {
|
||||
if (state && *status == OrbisImeDialogStatus::Running) {
|
||||
AddLayer(this);
|
||||
}
|
||||
|
||||
|
@ -226,7 +225,7 @@ void ImeDialogUi::Draw() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!status || *status != OrbisImeDialogStatus::RUNNING) {
|
||||
if (!status || *status != OrbisImeDialogStatus::Running) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -235,7 +234,7 @@ void ImeDialogUi::Draw() {
|
|||
|
||||
ImVec2 window_size;
|
||||
|
||||
if (state->is_multiLine) {
|
||||
if (state->is_multi_line) {
|
||||
window_size = {500.0f, 300.0f};
|
||||
} else {
|
||||
window_size = {500.0f, 150.0f};
|
||||
|
@ -259,7 +258,7 @@ void ImeDialogUi::Draw() {
|
|||
SetWindowFontScale(1.0f);
|
||||
}
|
||||
|
||||
if (state->is_multiLine) {
|
||||
if (state->is_multi_line) {
|
||||
DrawMultiLineInputText();
|
||||
} else {
|
||||
DrawInputText();
|
||||
|
@ -270,16 +269,16 @@ void ImeDialogUi::Draw() {
|
|||
const char* button_text;
|
||||
|
||||
switch (state->enter_label) {
|
||||
case OrbisImeEnterLabel::GO:
|
||||
case OrbisImeEnterLabel::Go:
|
||||
button_text = "Go##ImeDialogOK";
|
||||
break;
|
||||
case OrbisImeEnterLabel::SEARCH:
|
||||
case OrbisImeEnterLabel::Search:
|
||||
button_text = "Search##ImeDialogOK";
|
||||
break;
|
||||
case OrbisImeEnterLabel::SEND:
|
||||
case OrbisImeEnterLabel::Send:
|
||||
button_text = "Send##ImeDialogOK";
|
||||
break;
|
||||
case OrbisImeEnterLabel::DEFAULT:
|
||||
case OrbisImeEnterLabel::Default:
|
||||
default:
|
||||
button_text = "OK##ImeDialogOK";
|
||||
break;
|
||||
|
@ -292,16 +291,16 @@ void ImeDialogUi::Draw() {
|
|||
SetCursorPosX(button_start_pos);
|
||||
|
||||
if (Button(button_text, BUTTON_SIZE) ||
|
||||
(!state->is_multiLine && IsKeyPressed(ImGuiKey_Enter))) {
|
||||
*status = OrbisImeDialogStatus::FINISHED;
|
||||
result->endstatus = OrbisImeDialogEndStatus::OK;
|
||||
(!state->is_multi_line && IsKeyPressed(ImGuiKey_Enter))) {
|
||||
*status = OrbisImeDialogStatus::Finished;
|
||||
result->endstatus = OrbisImeDialogEndStatus::Ok;
|
||||
}
|
||||
|
||||
SameLine(0.0f, button_spacing);
|
||||
|
||||
if (Button("Cancel##ImeDialogCancel", BUTTON_SIZE)) {
|
||||
*status = OrbisImeDialogStatus::FINISHED;
|
||||
result->endstatus = OrbisImeDialogEndStatus::USER_CANCELED;
|
||||
*status = OrbisImeDialogStatus::Finished;
|
||||
result->endstatus = OrbisImeDialogEndStatus::UserCanceled;
|
||||
}
|
||||
}
|
||||
End();
|
||||
|
@ -362,9 +361,10 @@ int ImeDialogUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
|
|||
.status = 1, // ??? 1 = key pressed, 0 = key released
|
||||
.type = OrbisImeKeyboardType::ENGLISH_US, // TODO set this to the correct value (maybe use
|
||||
// the current language?)
|
||||
.userId = ui->state->userId,
|
||||
.resourceId = 0,
|
||||
.timestamp = 0};
|
||||
.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");
|
||||
|
|
|
@ -20,8 +20,8 @@ class ImeDialogState final {
|
|||
|
||||
bool input_changed = false;
|
||||
|
||||
s32 userId{};
|
||||
bool is_multiLine{};
|
||||
s32 user_id{};
|
||||
bool is_multi_line{};
|
||||
bool is_numeric{};
|
||||
OrbisImeType type{};
|
||||
OrbisImeEnterLabel enter_label{};
|
||||
|
|
51
src/core/libraries/ime/ime_error.h
Normal file
51
src/core/libraries/ime/ime_error.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/libraries/error_codes.h"
|
||||
|
||||
// ImeDialog library
|
||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_NOT_INITIALIZED = 0x80ED0001;
|
||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_ALREADY_INITIALIZED = 0x80ED0002;
|
||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_PARAM_INVALID = 0x80ED0003;
|
||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_UNEXPECTED_FATAL = 0x80ED0004;
|
||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_INVALID_STATE = 0x80ED0005;
|
||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_SERVICE_BUSY = 0x80ED0006;
|
||||
constexpr int ORBIS_ERROR_DIALOG_ERROR_INVALID_USER_ID = 0x80ED0007;
|
||||
|
||||
// Ime library
|
||||
constexpr int ORBIS_IME_ERROR_BUSY = 0x80BC0001;
|
||||
constexpr int ORBIS_IME_ERROR_NOT_OPENED = 0x80BC0002;
|
||||
constexpr int ORBIS_IME_ERROR_NO_MEMORY = 0x80BC0003;
|
||||
constexpr int ORBIS_IME_ERROR_CONNECTION_FAILED = 0x80BC0004;
|
||||
constexpr int ORBIS_IME_ERROR_TOO_MANY_REQUESTS = 0x80BC0005;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_TEXT = 0x80BC0006;
|
||||
constexpr int ORBIS_IME_ERROR_EVENT_OVERFLOW = 0x80BC0007;
|
||||
constexpr int ORBIS_IME_ERROR_NOT_ACTIVE = 0x80BC0008;
|
||||
constexpr int ORBIS_IME_ERROR_IME_SUSPENDING = 0x80BC0009;
|
||||
constexpr int ORBIS_IME_ERROR_DEVICE_IN_USE = 0x80BC000A;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_USER_ID = 0x80BC0010;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_TYPE = 0x80BC0011;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_SUPPORTED_LANGUAGES = 0x80BC0012;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_ENTER_LABEL = 0x80BC0013;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_INPUT_METHOD = 0x80BC0014;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_OPTION = 0x80BC0015;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_MAX_TEXT_LENGTH = 0x80BC0016;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_INPUT_TEXT_BUFFER = 0x80BC0017;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_POSX = 0x80BC0018;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_POSY = 0x80BC0019;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_HORIZONTAL_ALIGNMENT = 0x80BC001A;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_VERTICAL_ALIGNMENT = 0x80BC001B;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_EXTENDED = 0x80BC001C;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_KEYBOARD_TYPE = 0x80BC001D;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_WORK = 0x80BC0020;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_ARG = 0x80BC0021;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_HANDLER = 0x80BC0022;
|
||||
constexpr int ORBIS_IME_ERROR_NO_RESOURCE_ID = 0x80BC0023;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_MODE = 0x80BC0024;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_PARAM = 0x80BC0030;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_ADDRESS = 0x80BC0031;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_RESERVED = 0x80BC0032;
|
||||
constexpr int ORBIS_IME_ERROR_INVALID_TIMING = 0x80BC0033;
|
||||
constexpr int ORBIS_IME_ERROR_INTERNAL = 0x80BC00FF;
|
|
@ -16,7 +16,7 @@ ImeState::ImeState(const OrbisImeParam* param) {
|
|||
}
|
||||
|
||||
work_buffer = param->work;
|
||||
text_buffer = param->inputTextBuffer;
|
||||
text_buffer = param->input_text_buffer;
|
||||
|
||||
std::size_t text_len = std::char_traits<char16_t>::length(text_buffer);
|
||||
if (!ConvertOrbisToUTF8(text_buffer, text_len, current_text.begin(),
|
||||
|
@ -52,13 +52,13 @@ void ImeState::SendEvent(OrbisImeEvent* event) {
|
|||
|
||||
void ImeState::SendEnterEvent() {
|
||||
OrbisImeEvent enterEvent{};
|
||||
enterEvent.id = OrbisImeEventId::PRESS_ENTER;
|
||||
enterEvent.id = OrbisImeEventId::PressEnter;
|
||||
SendEvent(&enterEvent);
|
||||
}
|
||||
|
||||
void ImeState::SendCloseEvent() {
|
||||
OrbisImeEvent closeEvent{};
|
||||
closeEvent.id = OrbisImeEventId::PRESS_CLOSE;
|
||||
closeEvent.id = OrbisImeEventId::PressClose;
|
||||
closeEvent.param.text.str = reinterpret_cast<char16_t*>(work_buffer);
|
||||
SendEvent(&closeEvent);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ void ImeUi::DrawInputText() {
|
|||
if (first_render) {
|
||||
SetKeyboardFocusHere();
|
||||
}
|
||||
if (InputTextEx("##ImeInput", nullptr, state->current_text.begin(), ime_param->maxTextLength,
|
||||
if (InputTextEx("##ImeInput", nullptr, state->current_text.begin(), ime_param->max_text_length,
|
||||
input_size, ImGuiInputTextFlags_CallbackAlways, InputTextCallback, this)) {
|
||||
state->input_changed = true;
|
||||
}
|
||||
|
@ -194,16 +194,16 @@ int ImeUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
|
|||
if (lastCaretPos == -1) {
|
||||
lastCaretPos = data->CursorPos;
|
||||
} else if (data->CursorPos != lastCaretPos) {
|
||||
OrbisImeCaretMovementDirection caretDirection = OrbisImeCaretMovementDirection::STILL;
|
||||
OrbisImeCaretMovementDirection caretDirection = OrbisImeCaretMovementDirection::Still;
|
||||
if (data->CursorPos < lastCaretPos) {
|
||||
caretDirection = OrbisImeCaretMovementDirection::LEFT;
|
||||
caretDirection = OrbisImeCaretMovementDirection::Left;
|
||||
} else if (data->CursorPos > lastCaretPos) {
|
||||
caretDirection = OrbisImeCaretMovementDirection::RIGHT;
|
||||
caretDirection = OrbisImeCaretMovementDirection::Right;
|
||||
}
|
||||
|
||||
OrbisImeEvent event{};
|
||||
event.id = OrbisImeEventId::UPDATE_CARET;
|
||||
event.param.caretMove = caretDirection;
|
||||
event.id = OrbisImeEventId::UpdateCaret;
|
||||
event.param.caret_move = caretDirection;
|
||||
|
||||
lastCaretPos = data->CursorPos;
|
||||
ui->state->SendEvent(&event);
|
||||
|
@ -214,28 +214,28 @@ int ImeUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
|
|||
if (currentText != lastText) {
|
||||
OrbisImeEditText eventParam{};
|
||||
eventParam.str = reinterpret_cast<char16_t*>(ui->ime_param->work);
|
||||
eventParam.caretIndex = data->CursorPos;
|
||||
eventParam.areaNum = 1;
|
||||
eventParam.caret_index = data->CursorPos;
|
||||
eventParam.area_num = 1;
|
||||
|
||||
eventParam.textArea[0].mode = 1; // Edit mode
|
||||
eventParam.textArea[0].index = data->CursorPos;
|
||||
eventParam.textArea[0].length = data->BufTextLen;
|
||||
eventParam.text_area[0].mode = 1; // Edit mode
|
||||
eventParam.text_area[0].index = data->CursorPos;
|
||||
eventParam.text_area[0].length = data->BufTextLen;
|
||||
|
||||
if (!ui->state->ConvertUTF8ToOrbis(data->Buf, data->BufTextLen, eventParam.str,
|
||||
ui->ime_param->maxTextLength)) {
|
||||
ui->ime_param->max_text_length)) {
|
||||
LOG_ERROR(Lib_ImeDialog, "Failed to convert Orbis char to UTF-8");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!ui->state->ConvertUTF8ToOrbis(data->Buf, data->BufTextLen,
|
||||
ui->ime_param->inputTextBuffer,
|
||||
ui->ime_param->maxTextLength)) {
|
||||
ui->ime_param->input_text_buffer,
|
||||
ui->ime_param->max_text_length)) {
|
||||
LOG_ERROR(Lib_ImeDialog, "Failed to convert Orbis char to UTF-8");
|
||||
return 0;
|
||||
}
|
||||
|
||||
OrbisImeEvent event{};
|
||||
event.id = OrbisImeEventId::UPDATE_TEXT;
|
||||
event.id = OrbisImeEventId::UpdateText;
|
||||
event.param.text = eventParam;
|
||||
|
||||
lastText = currentText;
|
||||
|
@ -249,4 +249,4 @@ void ImeUi::Free() {
|
|||
RemoveLayer(this);
|
||||
}
|
||||
|
||||
}; // namespace Libraries::Ime
|
||||
}; // namespace Libraries::Ime
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue