Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ set(HLE_LIBC_INTERNAL_LIB src/core/libraries/libc_internal/libc_internal.cpp
set(IME_LIB src/core/libraries/ime/error_dialog.cpp
src/core/libraries/ime/error_dialog.h
src/core/libraries/ime/ime_common.h
src/core/libraries/ime/ime_kb_layout.cpp
src/core/libraries/ime/ime_kb_layout.h
src/core/libraries/ime/ime_dialog_ui.cpp
src/core/libraries/ime/ime_dialog_ui.h
src/core/libraries/ime/ime_dialog.cpp
Expand Down
23 changes: 23 additions & 0 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ static ConfigEntry<bool> isMotionControlsEnabled(true);
static ConfigEntry<bool> useUnifiedInputConfig(true);
static ConfigEntry<string> defaultControllerID("");
static ConfigEntry<bool> backgroundControllerInput(false);
static ConfigEntry<bool> imeAccessibilityEnabled(false);
static ConfigEntry<bool> imeUrlMailShortPanel(false);

// Audio
static ConfigEntry<string> micDevice("Default Device");
Expand Down Expand Up @@ -832,6 +834,22 @@ void setBackgroundControllerInput(bool enable, bool is_game_specific) {
backgroundControllerInput.set(enable, is_game_specific);
}

bool getImeAccessibilityEnabled() {
return imeAccessibilityEnabled.get();
}

void setImeAccessibilityEnabled(bool enable, bool is_game_specific) {
imeAccessibilityEnabled.set(enable, is_game_specific);
}

bool getImeUrlMailShortPanel() {
return imeUrlMailShortPanel.get();
}

void setImeUrlMailShortPanel(bool enable, bool is_game_specific) {
imeUrlMailShortPanel.set(enable, is_game_specific);
}

bool getFsrEnabled() {
return fsrEnabled.get();
}
Expand Down Expand Up @@ -923,6 +941,8 @@ void load(const std::filesystem::path& path, bool is_game_specific) {
isMotionControlsEnabled.setFromToml(input, "isMotionControlsEnabled", is_game_specific);
useUnifiedInputConfig.setFromToml(input, "useUnifiedInputConfig", is_game_specific);
backgroundControllerInput.setFromToml(input, "backgroundControllerInput", is_game_specific);
imeAccessibilityEnabled.setFromToml(input, "imeAccessibilityEnabled", is_game_specific);
imeUrlMailShortPanel.setFromToml(input, "imeUrlMailShortPanel", is_game_specific);
usbDeviceBackend.setFromToml(input, "usbDeviceBackend", is_game_specific);
}

Expand Down Expand Up @@ -1109,6 +1129,9 @@ void save(const std::filesystem::path& path, bool is_game_specific) {
is_game_specific);
backgroundControllerInput.setTomlValue(data, "Input", "backgroundControllerInput",
is_game_specific);
imeAccessibilityEnabled.setTomlValue(data, "Input", "imeAccessibilityEnabled",
is_game_specific);
imeUrlMailShortPanel.setTomlValue(data, "Input", "imeUrlMailShortPanel", is_game_specific);
usbDeviceBackend.setTomlValue(data, "Input", "usbDeviceBackend", is_game_specific);

micDevice.setTomlValue(data, "Audio", "micDevice", is_game_specific);
Expand Down
4 changes: 4 additions & 0 deletions src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ std::string getDefaultControllerID();
void setDefaultControllerID(std::string id);
bool getBackgroundControllerInput();
void setBackgroundControllerInput(bool enable, bool is_game_specific = false);
bool getImeAccessibilityEnabled();
void setImeAccessibilityEnabled(bool enable, bool is_game_specific = false);
bool getImeUrlMailShortPanel();
void setImeUrlMailShortPanel(bool enable, bool is_game_specific = false);
bool getLoggingEnabled();
void setLoggingEnabled(bool enable, bool is_game_specific = false);
bool getFsrEnabled();
Expand Down
85 changes: 41 additions & 44 deletions src/core/libraries/ime/ime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <queue>
#include "common/logging/log.h"
#include "core/libraries/ime/ime.h"
#include "core/libraries/ime/ime_dialog.h"
#include "core/libraries/ime/ime_error.h"
#include "core/libraries/ime/ime_ui.h"
#include "core/libraries/libs.h"
Expand Down Expand Up @@ -202,7 +203,8 @@ int PS4_SYSV_ABI sceImeConfigSet() {
return ORBIS_OK;
}

int PS4_SYSV_ABI sceImeConfirmCandidate() {
int PS4_SYSV_ABI sceImeConfirmCandidate(s32 index) {
(void)index;
LOG_ERROR(Lib_Ime, "(STUBBED) called");
return ORBIS_OK;
}
Expand Down Expand Up @@ -252,7 +254,10 @@ int PS4_SYSV_ABI sceImeForTestFunction() {
return ORBIS_OK;
}

int PS4_SYSV_ABI sceImeGetPanelPositionAndForm() {
int PS4_SYSV_ABI sceImeGetPanelPositionAndForm(OrbisImePositionAndForm* posForm) {
if (!posForm) {
return ORBIS_OK;
}
LOG_ERROR(Lib_Ime, "(STUBBED) called");
return ORBIS_OK;
}
Expand All @@ -274,45 +279,26 @@ Error PS4_SYSV_ABI sceImeGetPanelSize(const OrbisImeParam* param, u32* width, u3
return Error::INVALID_ADDRESS;
}

if (static_cast<u32>(param->option) & ~0x7BFF) { // Basic check for invalid options
LOG_ERROR(Lib_Ime, "Invalid option: {:032b}", static_cast<u32>(param->option));
return Error::INVALID_OPTION;
}

switch (param->type) {
case OrbisImeType::Default:
*width = 500; // dummy value
*height = 100; // dummy value
LOG_DEBUG(Lib_Ime, "param->type: Default ({})", static_cast<u32>(param->type));
break;
case OrbisImeType::BasicLatin:
*width = 500; // dummy value
*height = 100; // dummy value
LOG_DEBUG(Lib_Ime, "param->type: BasicLatin ({})", static_cast<u32>(param->type));
break;
case OrbisImeType::Url:
*width = 500; // dummy value
*height = 100; // dummy value
LOG_DEBUG(Lib_Ime, "param->type: Url ({})", static_cast<u32>(param->type));
break;
case OrbisImeType::Mail:
// We set our custom sizes, commented sizes are the original ones
*width = 500; // 793
*height = 100; // 408
LOG_DEBUG(Lib_Ime, "param->type: Mail ({})", static_cast<u32>(param->type));
break;
case OrbisImeType::Number:
*width = 370;
*height = 402;
LOG_DEBUG(Lib_Ime, "param->type: Number ({})", static_cast<u32>(param->type));
break;
default:
LOG_ERROR(Lib_Ime, "Invalid param->type: ({})", static_cast<u32>(param->type));
return Error::INVALID_TYPE;
}

OrbisImeDialogParam dialog_param{};
dialog_param.user_id = param->user_id;
dialog_param.type = param->type;
dialog_param.supported_languages = param->supported_languages;
dialog_param.enter_label = param->enter_label;
dialog_param.input_method = param->input_method;
dialog_param.filter = param->filter;
dialog_param.option = param->option;
dialog_param.max_text_length = param->maxTextLength;
dialog_param.input_text_buffer = param->inputTextBuffer;
dialog_param.posx = param->posx;
dialog_param.posy = param->posy;
dialog_param.horizontal_alignment = param->horizontal_alignment;
dialog_param.vertical_alignment = param->vertical_alignment;
dialog_param.placeholder = nullptr;
dialog_param.title = nullptr;

const Error ret = Libraries::ImeDialog::sceImeDialogGetPanelSize(&dialog_param, width, height);
LOG_DEBUG(Lib_Ime, "IME panel size: width={}, height={}", *width, *height);
return Error::OK;
return ret;
}

Error PS4_SYSV_ABI sceImeKeyboardClose(Libraries::UserService::OrbisUserServiceUserId userId) {
Expand All @@ -339,7 +325,11 @@ Error PS4_SYSV_ABI sceImeKeyboardClose(Libraries::UserService::OrbisUserServiceU
return Error::OK;
}

int PS4_SYSV_ABI sceImeKeyboardGetInfo() {
int PS4_SYSV_ABI sceImeKeyboardGetInfo(u32 resourceId, OrbisImeKeyboardInfo* info) {
(void)resourceId;
if (info) {
*info = {};
}
LOG_ERROR(Lib_Ime, "(STUBBED) called");
return ORBIS_OK;
}
Expand Down Expand Up @@ -463,7 +453,10 @@ int PS4_SYSV_ABI sceImeKeyboardOpenInternal() {
return ORBIS_OK;
}

int PS4_SYSV_ABI sceImeKeyboardSetMode() {
int PS4_SYSV_ABI sceImeKeyboardSetMode(Libraries::UserService::OrbisUserServiceUserId userId,
u32 mode) {
(void)userId;
(void)mode;
LOG_ERROR(Lib_Ime, "(STUBBED) called");
return ORBIS_OK;
}
Expand Down Expand Up @@ -681,7 +674,8 @@ void PS4_SYSV_ABI sceImeParamInit(OrbisImeParam* param) {
param->user_id = Libraries::UserService::ORBIS_USER_SERVICE_USER_ID_INVALID;
}

int PS4_SYSV_ABI sceImeSetCandidateIndex() {
int PS4_SYSV_ABI sceImeSetCandidateIndex(s32 index) {
(void)index;
LOG_ERROR(Lib_Ime, "(STUBBED) called");
return ORBIS_OK;
}
Expand Down Expand Up @@ -714,7 +708,10 @@ Error PS4_SYSV_ABI sceImeSetText(const char16_t* text, u32 length) {
return g_ime_handler->SetText(text, length);
}

int PS4_SYSV_ABI sceImeSetTextGeometry() {
int PS4_SYSV_ABI sceImeSetTextGeometry(OrbisImeTextAreaMode mode,
const OrbisImeTextGeometry* geometry) {
(void)mode;
(void)geometry;
LOG_ERROR(Lib_Ime, "(STUBBED) called");
return ORBIS_OK;
}
Expand Down
14 changes: 8 additions & 6 deletions src/core/libraries/ime/ime.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int PS4_SYSV_ABI sceImeCheckUpdateTextInfo();
Error PS4_SYSV_ABI sceImeClose();
int PS4_SYSV_ABI sceImeConfigGet();
int PS4_SYSV_ABI sceImeConfigSet();
int PS4_SYSV_ABI sceImeConfirmCandidate();
int PS4_SYSV_ABI sceImeConfirmCandidate(s32 index);
int PS4_SYSV_ABI sceImeDicAddWord();
int PS4_SYSV_ABI sceImeDicDeleteLearnDics();
int PS4_SYSV_ABI sceImeDicDeleteUserDics();
Expand All @@ -31,25 +31,27 @@ int PS4_SYSV_ABI sceImeDicReplaceWord();
int PS4_SYSV_ABI sceImeDisableController();
int PS4_SYSV_ABI sceImeFilterText();
int PS4_SYSV_ABI sceImeForTestFunction();
int PS4_SYSV_ABI sceImeGetPanelPositionAndForm();
int PS4_SYSV_ABI sceImeGetPanelPositionAndForm(OrbisImePositionAndForm* posForm);
Error PS4_SYSV_ABI sceImeGetPanelSize(const OrbisImeParam* param, u32* width, u32* height);
Error PS4_SYSV_ABI sceImeKeyboardClose(Libraries::UserService::OrbisUserServiceUserId userId);
int PS4_SYSV_ABI sceImeKeyboardGetInfo();
int PS4_SYSV_ABI sceImeKeyboardGetInfo(u32 resourceId, OrbisImeKeyboardInfo* info);
Error PS4_SYSV_ABI
sceImeKeyboardGetResourceId(Libraries::UserService::OrbisUserServiceUserId userId,
OrbisImeKeyboardResourceIdArray* resourceIdArray);
Error PS4_SYSV_ABI sceImeKeyboardOpen(Libraries::UserService::OrbisUserServiceUserId userId,
const OrbisImeKeyboardParam* param);
int PS4_SYSV_ABI sceImeKeyboardOpenInternal();
int PS4_SYSV_ABI sceImeKeyboardSetMode();
int PS4_SYSV_ABI sceImeKeyboardSetMode(Libraries::UserService::OrbisUserServiceUserId userId,
u32 mode);
int PS4_SYSV_ABI sceImeKeyboardUpdate();
Error PS4_SYSV_ABI sceImeOpen(const OrbisImeParam* param, const OrbisImeParamExtended* extended);
int PS4_SYSV_ABI sceImeOpenInternal();
void PS4_SYSV_ABI sceImeParamInit(OrbisImeParam* param);
int PS4_SYSV_ABI sceImeSetCandidateIndex();
int PS4_SYSV_ABI sceImeSetCandidateIndex(s32 index);
Error PS4_SYSV_ABI sceImeSetCaret(const OrbisImeCaret* caret);
Error PS4_SYSV_ABI sceImeSetText(const char16_t* text, u32 length);
int PS4_SYSV_ABI sceImeSetTextGeometry();
int PS4_SYSV_ABI sceImeSetTextGeometry(OrbisImeTextAreaMode mode,
const OrbisImeTextGeometry* geometry);
Error PS4_SYSV_ABI sceImeUpdate(OrbisImeEventHandler handler);
int PS4_SYSV_ABI sceImeVshClearPreedit();
int PS4_SYSV_ABI sceImeVshClose();
Expand Down
37 changes: 37 additions & 0 deletions src/core/libraries/ime/ime_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,16 @@ enum class OrbisImeKeyboardType : u32 {
HUNGARIAN = 37,
};

enum class OrbisImeKeyboardDeviceType : u32 {
Keyboard = 0,
Osk = 1,
};

enum class OrbisImeKeyboardStatus : u32 {
Disconnected = 0,
Connected = 1,
};

enum class OrbisImeDeviceType : u32 {
None = 0,
Controller = 1,
Expand Down Expand Up @@ -438,6 +448,16 @@ struct OrbisImeKeyboardResourceIdArray {
u32 resource_id[5];
};

struct OrbisImeKeyboardInfo {
Libraries::UserService::OrbisUserServiceUserId user_id;
OrbisImeKeyboardDeviceType device;
OrbisImeKeyboardType type;
u32 repeat_delay;
u32 repeat_rate;
OrbisImeKeyboardStatus status;
s8 reserved[12];
};

enum class OrbisImeCaretMovementDirection : u32 {
Still = 0,
Left = 1,
Expand All @@ -462,6 +482,23 @@ enum class OrbisImePanelType : u32 {
Accessibility = 6,
};

struct OrbisImePositionAndForm {
OrbisImePanelType type;
f32 posx;
f32 posy;
OrbisImeHorizontalAlignment horizontal_alignment;
OrbisImeVerticalAlignment vertical_alignment;
u32 width;
u32 height;
};

struct OrbisImeTextGeometry {
f32 x;
f32 y;
u32 width;
u32 height;
};

union OrbisImeEventParam {
OrbisImeRect rect;
OrbisImeEditText text;
Expand Down
Loading