summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/string_util.h12
-rw-r--r--src/common/virtual_buffer.cpp2
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.cpp61
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.h1
-rw-r--r--src/core/hle/service/hid/controllers/debug_pad.cpp53
-rw-r--r--src/core/hle/service/hid/controllers/keyboard.cpp17
-rw-r--r--src/input_common/gcadapter/gc_adapter.cpp2
-rw-r--r--src/input_common/gcadapter/gc_poller.cpp6
-rw-r--r--src/yuzu/configuration/configure_debug.ui22
9 files changed, 91 insertions, 85 deletions
diff --git a/src/common/string_util.h b/src/common/string_util.h
index 583fd05e6..023dff5dc 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -74,16 +74,4 @@ std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t
74std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer, 74std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer,
75 std::size_t max_len); 75 std::size_t max_len);
76 76
77/**
78 * Attempts to trim an arbitrary prefix from `path`, leaving only the part starting at `root`. It's
79 * intended to be used to strip a system-specific build directory from the `__FILE__` macro,
80 * leaving only the path relative to the sources root.
81 *
82 * @param path The input file path as a null-terminated string
83 * @param root The name of the root source directory as a null-terminated string. Path up to and
84 * including the last occurrence of this name will be stripped
85 * @return A pointer to the same string passed as `path`, but starting at the trimmed portion
86 */
87const char* TrimSourcePath(const char* path, const char* root = "src");
88
89} // namespace Common 77} // namespace Common
diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp
index b426f4747..be5b67752 100644
--- a/src/common/virtual_buffer.cpp
+++ b/src/common/virtual_buffer.cpp
@@ -38,7 +38,7 @@ void* AllocateMemoryPages(std::size_t size) {
38 return base; 38 return base;
39} 39}
40 40
41void FreeMemoryPages(void* base, std::size_t size) { 41void FreeMemoryPages(void* base, [[maybe_unused]] std::size_t size) {
42 if (!base) { 42 if (!base) {
43 return; 43 return;
44 } 44 }
diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp
index fbe3686ae..289da2619 100644
--- a/src/core/hle/service/am/applets/software_keyboard.cpp
+++ b/src/core/hle/service/am/applets/software_keyboard.cpp
@@ -13,11 +13,23 @@
13 13
14namespace Service::AM::Applets { 14namespace Service::AM::Applets {
15 15
16namespace {
17enum class Request : u32 {
18 Finalize = 0x4,
19 SetUserWordInfo = 0x6,
20 SetCustomizeDic = 0x7,
21 Calc = 0xa,
22 SetCustomizedDictionaries = 0xb,
23 UnsetCustomizedDictionaries = 0xc,
24 UnknownD = 0xd,
25 UnknownE = 0xe,
26};
27constexpr std::size_t SWKBD_INLINE_INIT_SIZE = 0x8;
16constexpr std::size_t SWKBD_OUTPUT_BUFFER_SIZE = 0x7D8; 28constexpr std::size_t SWKBD_OUTPUT_BUFFER_SIZE = 0x7D8;
17constexpr std::size_t SWKBD_OUTPUT_INTERACTIVE_BUFFER_SIZE = 0x7D4; 29constexpr std::size_t SWKBD_OUTPUT_INTERACTIVE_BUFFER_SIZE = 0x7D4;
18constexpr std::size_t DEFAULT_MAX_LENGTH = 500; 30constexpr std::size_t DEFAULT_MAX_LENGTH = 500;
19constexpr bool INTERACTIVE_STATUS_OK = false; 31constexpr bool INTERACTIVE_STATUS_OK = false;
20 32} // Anonymous namespace
21static Core::Frontend::SoftwareKeyboardParameters ConvertToFrontendParameters( 33static Core::Frontend::SoftwareKeyboardParameters ConvertToFrontendParameters(
22 KeyboardConfig config, std::u16string initial_text) { 34 KeyboardConfig config, std::u16string initial_text) {
23 Core::Frontend::SoftwareKeyboardParameters params{}; 35 Core::Frontend::SoftwareKeyboardParameters params{};
@@ -47,6 +59,7 @@ SoftwareKeyboard::~SoftwareKeyboard() = default;
47 59
48void SoftwareKeyboard::Initialize() { 60void SoftwareKeyboard::Initialize() {
49 complete = false; 61 complete = false;
62 is_inline = false;
50 initial_text.clear(); 63 initial_text.clear();
51 final_data.clear(); 64 final_data.clear();
52 65
@@ -56,6 +69,11 @@ void SoftwareKeyboard::Initialize() {
56 ASSERT(keyboard_config_storage != nullptr); 69 ASSERT(keyboard_config_storage != nullptr);
57 const auto& keyboard_config = keyboard_config_storage->GetData(); 70 const auto& keyboard_config = keyboard_config_storage->GetData();
58 71
72 if (keyboard_config.size() == SWKBD_INLINE_INIT_SIZE) {
73 is_inline = true;
74 return;
75 }
76
59 ASSERT(keyboard_config.size() >= sizeof(KeyboardConfig)); 77 ASSERT(keyboard_config.size() >= sizeof(KeyboardConfig));
60 std::memcpy(&config, keyboard_config.data(), sizeof(KeyboardConfig)); 78 std::memcpy(&config, keyboard_config.data(), sizeof(KeyboardConfig));
61 79
@@ -87,16 +105,32 @@ void SoftwareKeyboard::ExecuteInteractive() {
87 const auto storage = broker.PopInteractiveDataToApplet(); 105 const auto storage = broker.PopInteractiveDataToApplet();
88 ASSERT(storage != nullptr); 106 ASSERT(storage != nullptr);
89 const auto data = storage->GetData(); 107 const auto data = storage->GetData();
90 const auto status = static_cast<bool>(data[0]); 108 if (!is_inline) {
91 109 const auto status = static_cast<bool>(data[0]);
92 if (status == INTERACTIVE_STATUS_OK) { 110 if (status == INTERACTIVE_STATUS_OK) {
93 complete = true; 111 complete = true;
112 } else {
113 std::array<char16_t, SWKBD_OUTPUT_INTERACTIVE_BUFFER_SIZE / 2 - 2> string;
114 std::memcpy(string.data(), data.data() + 4, string.size() * 2);
115 frontend.SendTextCheckDialog(
116 Common::UTF16StringFromFixedZeroTerminatedBuffer(string.data(), string.size()),
117 [this] { broker.SignalStateChanged(); });
118 }
94 } else { 119 } else {
95 std::array<char16_t, SWKBD_OUTPUT_INTERACTIVE_BUFFER_SIZE / 2 - 2> string; 120 Request request{};
96 std::memcpy(string.data(), data.data() + 4, string.size() * 2); 121 std::memcpy(&request, data.data(), sizeof(Request));
97 frontend.SendTextCheckDialog( 122
98 Common::UTF16StringFromFixedZeroTerminatedBuffer(string.data(), string.size()), 123 switch (request) {
99 [this] { broker.SignalStateChanged(); }); 124 case Request::Calc: {
125 broker.PushNormalDataFromApplet(
126 std::make_shared<IStorage>(std::move(std::vector<u8>{1})));
127 broker.SignalStateChanged();
128 break;
129 }
130 default:
131 UNIMPLEMENTED_MSG("Request {:X} is not implemented", request);
132 break;
133 }
100 } 134 }
101} 135}
102 136
@@ -108,9 +142,10 @@ void SoftwareKeyboard::Execute() {
108 } 142 }
109 143
110 const auto parameters = ConvertToFrontendParameters(config, initial_text); 144 const auto parameters = ConvertToFrontendParameters(config, initial_text);
111 145 if (!is_inline) {
112 frontend.RequestText([this](std::optional<std::u16string> text) { WriteText(std::move(text)); }, 146 frontend.RequestText(
113 parameters); 147 [this](std::optional<std::u16string> text) { WriteText(std::move(text)); }, parameters);
148 }
114} 149}
115 150
116void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) { 151void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) {
diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h
index ef4801fc6..5a3824b5a 100644
--- a/src/core/hle/service/am/applets/software_keyboard.h
+++ b/src/core/hle/service/am/applets/software_keyboard.h
@@ -78,6 +78,7 @@ private:
78 KeyboardConfig config; 78 KeyboardConfig config;
79 std::u16string initial_text; 79 std::u16string initial_text;
80 bool complete = false; 80 bool complete = false;
81 bool is_inline = false;
81 std::vector<u8> final_data; 82 std::vector<u8> final_data;
82}; 83};
83 84
diff --git a/src/core/hle/service/hid/controllers/debug_pad.cpp b/src/core/hle/service/hid/controllers/debug_pad.cpp
index cb35919e9..ad251ed4a 100644
--- a/src/core/hle/service/hid/controllers/debug_pad.cpp
+++ b/src/core/hle/service/hid/controllers/debug_pad.cpp
@@ -39,33 +39,36 @@ void Controller_DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing,
39 39
40 cur_entry.sampling_number = last_entry.sampling_number + 1; 40 cur_entry.sampling_number = last_entry.sampling_number + 1;
41 cur_entry.sampling_number2 = cur_entry.sampling_number; 41 cur_entry.sampling_number2 = cur_entry.sampling_number;
42 cur_entry.attribute.connected.Assign(1);
43 auto& pad = cur_entry.pad_state;
44 42
45 using namespace Settings::NativeButton; 43 if (Settings::values.debug_pad_enabled) {
46 pad.a.Assign(buttons[A - BUTTON_HID_BEGIN]->GetStatus()); 44 cur_entry.attribute.connected.Assign(1);
47 pad.b.Assign(buttons[B - BUTTON_HID_BEGIN]->GetStatus()); 45 auto& pad = cur_entry.pad_state;
48 pad.x.Assign(buttons[X - BUTTON_HID_BEGIN]->GetStatus());
49 pad.y.Assign(buttons[Y - BUTTON_HID_BEGIN]->GetStatus());
50 pad.l.Assign(buttons[L - BUTTON_HID_BEGIN]->GetStatus());
51 pad.r.Assign(buttons[R - BUTTON_HID_BEGIN]->GetStatus());
52 pad.zl.Assign(buttons[ZL - BUTTON_HID_BEGIN]->GetStatus());
53 pad.zr.Assign(buttons[ZR - BUTTON_HID_BEGIN]->GetStatus());
54 pad.plus.Assign(buttons[Plus - BUTTON_HID_BEGIN]->GetStatus());
55 pad.minus.Assign(buttons[Minus - BUTTON_HID_BEGIN]->GetStatus());
56 pad.d_left.Assign(buttons[DLeft - BUTTON_HID_BEGIN]->GetStatus());
57 pad.d_up.Assign(buttons[DUp - BUTTON_HID_BEGIN]->GetStatus());
58 pad.d_right.Assign(buttons[DRight - BUTTON_HID_BEGIN]->GetStatus());
59 pad.d_down.Assign(buttons[DDown - BUTTON_HID_BEGIN]->GetStatus());
60 46
61 const auto [stick_l_x_f, stick_l_y_f] = 47 using namespace Settings::NativeButton;
62 analogs[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetStatus(); 48 pad.a.Assign(buttons[A - BUTTON_HID_BEGIN]->GetStatus());
63 const auto [stick_r_x_f, stick_r_y_f] = 49 pad.b.Assign(buttons[B - BUTTON_HID_BEGIN]->GetStatus());
64 analogs[static_cast<std::size_t>(JoystickId::Joystick_Right)]->GetStatus(); 50 pad.x.Assign(buttons[X - BUTTON_HID_BEGIN]->GetStatus());
65 cur_entry.l_stick.x = static_cast<s32>(stick_l_x_f * HID_JOYSTICK_MAX); 51 pad.y.Assign(buttons[Y - BUTTON_HID_BEGIN]->GetStatus());
66 cur_entry.l_stick.y = static_cast<s32>(stick_l_y_f * HID_JOYSTICK_MAX); 52 pad.l.Assign(buttons[L - BUTTON_HID_BEGIN]->GetStatus());
67 cur_entry.r_stick.x = static_cast<s32>(stick_r_x_f * HID_JOYSTICK_MAX); 53 pad.r.Assign(buttons[R - BUTTON_HID_BEGIN]->GetStatus());
68 cur_entry.r_stick.y = static_cast<s32>(stick_r_y_f * HID_JOYSTICK_MAX); 54 pad.zl.Assign(buttons[ZL - BUTTON_HID_BEGIN]->GetStatus());
55 pad.zr.Assign(buttons[ZR - BUTTON_HID_BEGIN]->GetStatus());
56 pad.plus.Assign(buttons[Plus - BUTTON_HID_BEGIN]->GetStatus());
57 pad.minus.Assign(buttons[Minus - BUTTON_HID_BEGIN]->GetStatus());
58 pad.d_left.Assign(buttons[DLeft - BUTTON_HID_BEGIN]->GetStatus());
59 pad.d_up.Assign(buttons[DUp - BUTTON_HID_BEGIN]->GetStatus());
60 pad.d_right.Assign(buttons[DRight - BUTTON_HID_BEGIN]->GetStatus());
61 pad.d_down.Assign(buttons[DDown - BUTTON_HID_BEGIN]->GetStatus());
62
63 const auto [stick_l_x_f, stick_l_y_f] =
64 analogs[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetStatus();
65 const auto [stick_r_x_f, stick_r_y_f] =
66 analogs[static_cast<std::size_t>(JoystickId::Joystick_Right)]->GetStatus();
67 cur_entry.l_stick.x = static_cast<s32>(stick_l_x_f * HID_JOYSTICK_MAX);
68 cur_entry.l_stick.y = static_cast<s32>(stick_l_y_f * HID_JOYSTICK_MAX);
69 cur_entry.r_stick.x = static_cast<s32>(stick_r_x_f * HID_JOYSTICK_MAX);
70 cur_entry.r_stick.y = static_cast<s32>(stick_r_y_f * HID_JOYSTICK_MAX);
71 }
69 72
70 std::memcpy(data, &shared_memory, sizeof(SharedMemory)); 73 std::memcpy(data, &shared_memory, sizeof(SharedMemory));
71} 74}
diff --git a/src/core/hle/service/hid/controllers/keyboard.cpp b/src/core/hle/service/hid/controllers/keyboard.cpp
index feae89525..0b896d5ad 100644
--- a/src/core/hle/service/hid/controllers/keyboard.cpp
+++ b/src/core/hle/service/hid/controllers/keyboard.cpp
@@ -40,15 +40,16 @@ void Controller_Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing,
40 40
41 cur_entry.key.fill(0); 41 cur_entry.key.fill(0);
42 cur_entry.modifier = 0; 42 cur_entry.modifier = 0;
43 43 if (Settings::values.keyboard_enabled) {
44 for (std::size_t i = 0; i < keyboard_keys.size(); ++i) { 44 for (std::size_t i = 0; i < keyboard_keys.size(); ++i) {
45 cur_entry.key[i / KEYS_PER_BYTE] |= (keyboard_keys[i]->GetStatus() << (i % KEYS_PER_BYTE)); 45 cur_entry.key[i / KEYS_PER_BYTE] |=
46 } 46 (keyboard_keys[i]->GetStatus() << (i % KEYS_PER_BYTE));
47 47 }
48 for (std::size_t i = 0; i < keyboard_mods.size(); ++i) { 48
49 cur_entry.modifier |= (keyboard_mods[i]->GetStatus() << i); 49 for (std::size_t i = 0; i < keyboard_mods.size(); ++i) {
50 cur_entry.modifier |= (keyboard_mods[i]->GetStatus() << i);
51 }
50 } 52 }
51
52 std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory)); 53 std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
53} 54}
54 55
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp
index 02d06876f..29ea1f2c7 100644
--- a/src/input_common/gcadapter/gc_adapter.cpp
+++ b/src/input_common/gcadapter/gc_adapter.cpp
@@ -254,7 +254,7 @@ void Adapter::GetGCEndpoint(libusb_device* device) {
254 sizeof(clear_payload), nullptr, 16); 254 sizeof(clear_payload), nullptr, 16);
255 255
256 adapter_thread_running = true; 256 adapter_thread_running = true;
257 adapter_input_thread = std::thread([=] { Read(); }); // Read input 257 adapter_input_thread = std::thread(&Adapter::Read, this);
258} 258}
259 259
260Adapter::~Adapter() { 260Adapter::~Adapter() {
diff --git a/src/input_common/gcadapter/gc_poller.cpp b/src/input_common/gcadapter/gc_poller.cpp
index 96e22d3ad..f45983f3f 100644
--- a/src/input_common/gcadapter/gc_poller.cpp
+++ b/src/input_common/gcadapter/gc_poller.cpp
@@ -76,8 +76,7 @@ std::unique_ptr<Input::ButtonDevice> GCButtonFactory::Create(const Common::Param
76 76
77 // button is not an axis/stick button 77 // button is not an axis/stick button
78 if (button_id != PAD_STICK_ID) { 78 if (button_id != PAD_STICK_ID) {
79 auto button = std::make_unique<GCButton>(port, button_id, adapter.get()); 79 return std::make_unique<GCButton>(port, button_id, adapter.get());
80 return std::move(button);
81 } 80 }
82 81
83 // For Axis buttons, used by the binary sticks. 82 // For Axis buttons, used by the binary sticks.
@@ -264,7 +263,8 @@ Common::ParamPackage GCAnalogFactory::GetNextInput() {
264 if (analog_x_axis == -1) { 263 if (analog_x_axis == -1) {
265 analog_x_axis = axis; 264 analog_x_axis = axis;
266 controller_number = static_cast<int>(port); 265 controller_number = static_cast<int>(port);
267 } else if (analog_y_axis == -1 && analog_x_axis != axis && controller_number == port) { 266 } else if (analog_y_axis == -1 && analog_x_axis != axis &&
267 controller_number == static_cast<int>(port)) {
268 analog_y_axis = axis; 268 analog_y_axis = axis;
269 } 269 }
270 } 270 }
diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui
index 272bdd6b8..9d6feb9f7 100644
--- a/src/yuzu/configuration/configure_debug.ui
+++ b/src/yuzu/configuration/configure_debug.ui
@@ -171,26 +171,6 @@
171 </property> 171 </property>
172 <layout class="QVBoxLayout" name="verticalLayout_6"> 172 <layout class="QVBoxLayout" name="verticalLayout_6">
173 <item> 173 <item>
174 <widget class="QCheckBox" name="dump_decompressed_nso">
175 <property name="whatsThis">
176 <string>When checked, any NSO yuzu tries to load or patch will be copied decompressed to the yuzu/dump directory.</string>
177 </property>
178 <property name="text">
179 <string>Dump Decompressed NSOs</string>
180 </property>
181 </widget>
182 </item>
183 <item>
184 <widget class="QCheckBox" name="dump_exefs">
185 <property name="whatsThis">
186 <string>When checked, any game that yuzu loads will have its ExeFS dumped to the yuzu/dump directory.</string>
187 </property>
188 <property name="text">
189 <string>Dump ExeFS</string>
190 </property>
191 </widget>
192 </item>
193 <item>
194 <widget class="QCheckBox" name="reporting_services"> 174 <widget class="QCheckBox" name="reporting_services">
195 <property name="text"> 175 <property name="text">
196 <string>Enable Verbose Reporting Services</string> 176 <string>Enable Verbose Reporting Services</string>
@@ -257,8 +237,6 @@
257 <tabstop>open_log_button</tabstop> 237 <tabstop>open_log_button</tabstop>
258 <tabstop>homebrew_args_edit</tabstop> 238 <tabstop>homebrew_args_edit</tabstop>
259 <tabstop>enable_graphics_debugging</tabstop> 239 <tabstop>enable_graphics_debugging</tabstop>
260 <tabstop>dump_decompressed_nso</tabstop>
261 <tabstop>dump_exefs</tabstop>
262 <tabstop>reporting_services</tabstop> 240 <tabstop>reporting_services</tabstop>
263 <tabstop>quest_flag</tabstop> 241 <tabstop>quest_flag</tabstop>
264 </tabstops> 242 </tabstops>