summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/set/set.cpp72
-rw-r--r--src/core/hle/service/set/set.h2
2 files changed, 72 insertions, 2 deletions
diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp
index f3b4b286c..e5cfd2101 100644
--- a/src/core/hle/service/set/set.cpp
+++ b/src/core/hle/service/set/set.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <array>
6#include <chrono> 7#include <chrono>
7#include "common/logging/log.h" 8#include "common/logging/log.h"
8#include "core/hle/ipc_helpers.h" 9#include "core/hle/ipc_helpers.h"
@@ -31,6 +32,44 @@ constexpr std::array<LanguageCode, 17> available_language_codes = {{
31 LanguageCode::ZH_HANT, 32 LanguageCode::ZH_HANT,
32}}; 33}};
33 34
35enum class KeyboardLayout : u64 {
36 Japanese = 0,
37 EnglishUs = 1,
38 EnglishUsInternational = 2,
39 EnglishUk = 3,
40 French = 4,
41 FrenchCa = 5,
42 Spanish = 6,
43 SpanishLatin = 7,
44 German = 8,
45 Italian = 9,
46 Portuguese = 10,
47 Russian = 11,
48 Korean = 12,
49 ChineseSimplified = 13,
50 ChineseTraditional = 14,
51};
52
53constexpr std::array<std::pair<LanguageCode, KeyboardLayout>, 17> language_to_layout{{
54 {LanguageCode::JA, KeyboardLayout::Japanese},
55 {LanguageCode::EN_US, KeyboardLayout::EnglishUs},
56 {LanguageCode::FR, KeyboardLayout::French},
57 {LanguageCode::DE, KeyboardLayout::German},
58 {LanguageCode::IT, KeyboardLayout::Italian},
59 {LanguageCode::ES, KeyboardLayout::Spanish},
60 {LanguageCode::ZH_CN, KeyboardLayout::ChineseSimplified},
61 {LanguageCode::KO, KeyboardLayout::Korean},
62 {LanguageCode::NL, KeyboardLayout::EnglishUsInternational},
63 {LanguageCode::PT, KeyboardLayout::Portuguese},
64 {LanguageCode::RU, KeyboardLayout::Russian},
65 {LanguageCode::ZH_TW, KeyboardLayout::ChineseTraditional},
66 {LanguageCode::EN_GB, KeyboardLayout::EnglishUk},
67 {LanguageCode::FR_CA, KeyboardLayout::FrenchCa},
68 {LanguageCode::ES_419, KeyboardLayout::SpanishLatin},
69 {LanguageCode::ZH_HANS, KeyboardLayout::ChineseSimplified},
70 {LanguageCode::ZH_HANT, KeyboardLayout::ChineseTraditional},
71}};
72
34constexpr std::size_t pre4_0_0_max_entries = 15; 73constexpr std::size_t pre4_0_0_max_entries = 15;
35constexpr std::size_t post4_0_0_max_entries = 17; 74constexpr std::size_t post4_0_0_max_entries = 17;
36 75
@@ -50,6 +89,25 @@ void GetAvailableLanguageCodesImpl(Kernel::HLERequestContext& ctx, std::size_t m
50 ctx.WriteBuffer(available_language_codes.data(), copy_size); 89 ctx.WriteBuffer(available_language_codes.data(), copy_size);
51 PushResponseLanguageCode(ctx, copy_amount); 90 PushResponseLanguageCode(ctx, copy_amount);
52} 91}
92
93void GetKeyCodeMapImpl(Kernel::HLERequestContext& ctx) {
94 const auto language_code = available_language_codes[Settings::values.language_index];
95 const auto key_code =
96 std::find_if(language_to_layout.cbegin(), language_to_layout.cend(),
97 [=](const auto& element) { return element.first == language_code; });
98 KeyboardLayout layout = KeyboardLayout::EnglishUs;
99 if (key_code == language_to_layout.cend()) {
100 LOG_ERROR(Service_SET,
101 "Could not find keyboard layout for language index {}, defaulting to English us",
102 Settings::values.language_index);
103 } else {
104 layout = key_code->second;
105 }
106
107 IPC::ResponseBuilder rb{ctx, 2};
108 rb.Push(RESULT_SUCCESS);
109 ctx.WriteBuffer(&layout, sizeof(KeyboardLayout));
110}
53} // Anonymous namespace 111} // Anonymous namespace
54 112
55LanguageCode GetLanguageCodeFromIndex(std::size_t index) { 113LanguageCode GetLanguageCodeFromIndex(std::size_t index) {
@@ -120,6 +178,16 @@ void SET::GetRegionCode(Kernel::HLERequestContext& ctx) {
120 rb.Push(Settings::values.region_index); 178 rb.Push(Settings::values.region_index);
121} 179}
122 180
181void SET::GetKeyCodeMap(Kernel::HLERequestContext& ctx) {
182 LOG_DEBUG(Service_SET, "Called {}", ctx.Description());
183 GetKeyCodeMapImpl(ctx);
184}
185
186void SET::GetKeyCodeMap2(Kernel::HLERequestContext& ctx) {
187 LOG_DEBUG(Service_SET, "Called {}", ctx.Description());
188 GetKeyCodeMapImpl(ctx);
189}
190
123SET::SET() : ServiceFramework("set") { 191SET::SET() : ServiceFramework("set") {
124 // clang-format off 192 // clang-format off
125 static const FunctionInfo functions[] = { 193 static const FunctionInfo functions[] = {
@@ -130,9 +198,9 @@ SET::SET() : ServiceFramework("set") {
130 {4, &SET::GetRegionCode, "GetRegionCode"}, 198 {4, &SET::GetRegionCode, "GetRegionCode"},
131 {5, &SET::GetAvailableLanguageCodes2, "GetAvailableLanguageCodes2"}, 199 {5, &SET::GetAvailableLanguageCodes2, "GetAvailableLanguageCodes2"},
132 {6, &SET::GetAvailableLanguageCodeCount2, "GetAvailableLanguageCodeCount2"}, 200 {6, &SET::GetAvailableLanguageCodeCount2, "GetAvailableLanguageCodeCount2"},
133 {7, nullptr, "GetKeyCodeMap"}, 201 {7, &SET::GetKeyCodeMap, "GetKeyCodeMap"},
134 {8, &SET::GetQuestFlag, "GetQuestFlag"}, 202 {8, &SET::GetQuestFlag, "GetQuestFlag"},
135 {9, nullptr, "GetKeyCodeMap2"}, 203 {9, &SET::GetKeyCodeMap2, "GetKeyCodeMap2"},
136 {10, nullptr, "GetFirmwareVersionForDebug"}, 204 {10, nullptr, "GetFirmwareVersionForDebug"},
137 }; 205 };
138 // clang-format on 206 // clang-format on
diff --git a/src/core/hle/service/set/set.h b/src/core/hle/service/set/set.h
index 6084b345d..8ac9c169d 100644
--- a/src/core/hle/service/set/set.h
+++ b/src/core/hle/service/set/set.h
@@ -44,6 +44,8 @@ private:
44 void GetAvailableLanguageCodeCount2(Kernel::HLERequestContext& ctx); 44 void GetAvailableLanguageCodeCount2(Kernel::HLERequestContext& ctx);
45 void GetQuestFlag(Kernel::HLERequestContext& ctx); 45 void GetQuestFlag(Kernel::HLERequestContext& ctx);
46 void GetRegionCode(Kernel::HLERequestContext& ctx); 46 void GetRegionCode(Kernel::HLERequestContext& ctx);
47 void GetKeyCodeMap(Kernel::HLERequestContext& ctx);
48 void GetKeyCodeMap2(Kernel::HLERequestContext& ctx);
47}; 49};
48 50
49} // namespace Service::Set 51} // namespace Service::Set