mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-21 16:12:47 -05:00
The signature is inferred from PPSA12361: a 16-bit keycode, a second argument the title passes as 0, the type from sceConvertKeycodeGetImeKeyboardType and a UTF-16 output. The keycode is a USB HID keyboard usage and the unshifted US character is returned; a keycode without a character returns 0. A second argument or keyboard type other than 0 throws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
2.2 KiB
C++
53 lines
2.2 KiB
C++
#include <cstdint>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include "SceTypes.hpp"
|
|
#include "HitLog.hpp"
|
|
#include "prx/libc/include/General.hpp"
|
|
|
|
namespace {
|
|
constexpr int kErrInvalidAddress = static_cast<int>(0x80BC0031u);
|
|
constexpr int kErrInvalidUserId = static_cast<int>(0x80BC0010u);
|
|
|
|
char16_t UsCharacter(std::uint16_t keycode) {
|
|
static constexpr char16_t kPunctuation[] = u"-=[]\\\0;'`,./";
|
|
static constexpr char16_t kKeypad[] = u"/*-+\0" u"1234567890.";
|
|
if (keycode >= 0x04 && keycode <= 0x1D) return static_cast<char16_t>(u'a' + (keycode - 0x04));
|
|
if (keycode >= 0x1E && keycode <= 0x26) return static_cast<char16_t>(u'1' + (keycode - 0x1E));
|
|
if (keycode == 0x27) return u'0';
|
|
if (keycode == 0x2C) return u' ';
|
|
if (keycode >= 0x2D && keycode <= 0x38) return kPunctuation[keycode - 0x2D];
|
|
if (keycode >= 0x54 && keycode <= 0x63) return kKeypad[keycode - 0x54];
|
|
return 0;
|
|
}
|
|
} // namespace
|
|
|
|
extern "C" {
|
|
|
|
int APS5_VABI sceConvertKeycodeGetImeKeyboardType(int32_t userId, uint32_t* type) {
|
|
if (type == nullptr) return kErrInvalidAddress;
|
|
if (userId < 0) return kErrInvalidUserId;
|
|
*type = 0;
|
|
return 0;
|
|
}
|
|
int APS5_VABI sceConvertKeycodeGetVirtualKeycode(std::uint64_t a0, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3) {
|
|
APS5_HIT("CONVERTKEYCODE", "sceConvertKeycodeGetVirtualKeycode args 0x%llx 0x%llx 0x%llx 0x%llx -> error (signature unknown)",
|
|
static_cast<unsigned long long>(a0), static_cast<unsigned long long>(a1), static_cast<unsigned long long>(a2), static_cast<unsigned long long>(a3));
|
|
return kErrInvalidAddress;
|
|
}
|
|
|
|
int APS5_VABI sceConvertKeycodeGetCharacterFromKeyboardData(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceConvertKeycodeGetCharacter(std::uint16_t keycode, std::uint32_t state, std::uint32_t type, char16_t* character) {
|
|
if (character == nullptr) return kErrInvalidAddress;
|
|
if (state != 0) throw std::runtime_error("sceConvertKeycodeGetCharacter: unsupported state " + std::to_string(state));
|
|
if (type != 0) throw std::runtime_error("sceConvertKeycodeGetCharacter: unsupported keyboard type " + std::to_string(type));
|
|
*character = UsCharacter(keycode);
|
|
return 0;
|
|
}
|
|
|
|
}
|