summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/cache_management.cpp5
-rw-r--r--src/common/cache_management.h2
-rw-r--r--src/common/input.h40
-rw-r--r--src/core/hid/emulated_console.cpp4
-rw-r--r--src/core/hid/emulated_controller.cpp38
-rw-r--r--src/core/hid/emulated_devices.cpp14
-rw-r--r--src/core/hle/service/nvdrv/core/syncpoint_manager.cpp46
-rw-r--r--src/core/hle/service/nvdrv/core/syncpoint_manager.h2
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.cpp44
-rw-r--r--src/core/hle/service/nvflinger/buffer_item_consumer.cpp2
-rw-r--r--src/core/hle/service/nvflinger/buffer_item_consumer.h2
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue_consumer.cpp2
-rw-r--r--src/core/hle/service/nvflinger/consumer_base.cpp6
-rw-r--r--src/core/hle/service/nvflinger/consumer_base.h16
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp3
-rw-r--r--src/core/hle/service/nvflinger/producer_listener.h1
-rw-r--r--src/input_common/helpers/stick_from_buttons.cpp25
-rw-r--r--src/input_common/helpers/touch_from_buttons.cpp13
-rw-r--r--src/input_common/main.cpp102
-rw-r--r--src/video_core/host1x/syncpoint_manager.cpp6
-rw-r--r--src/video_core/host1x/syncpoint_manager.h12
-rw-r--r--src/video_core/surface.cpp15
-rw-r--r--src/yuzu/main.cpp3
23 files changed, 211 insertions, 192 deletions
diff --git a/src/common/cache_management.cpp b/src/common/cache_management.cpp
index 57810b76a..ed353828a 100644
--- a/src/common/cache_management.cpp
+++ b/src/common/cache_management.cpp
@@ -1,11 +1,10 @@
1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include <cstdint>
4#include <cstring> 5#include <cstring>
5 6
6#include "alignment.h" 7#include "common/cache_management.h"
7#include "cache_management.h"
8#include "common_types.h"
9 8
10namespace Common { 9namespace Common {
11 10
diff --git a/src/common/cache_management.h b/src/common/cache_management.h
index e467b87e4..038323e95 100644
--- a/src/common/cache_management.h
+++ b/src/common/cache_management.h
@@ -3,7 +3,7 @@
3 3
4#pragma once 4#pragma once
5 5
6#include "stdlib.h" 6#include <cstddef>
7 7
8namespace Common { 8namespace Common {
9 9
diff --git a/src/common/input.h b/src/common/input.h
index cb30b7254..449e0193f 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -383,6 +383,16 @@ void RegisterFactory(const std::string& name, std::shared_ptr<Factory<InputDevic
383 } 383 }
384} 384}
385 385
386inline void RegisterInputFactory(const std::string& name,
387 std::shared_ptr<Factory<InputDevice>> factory) {
388 RegisterFactory<InputDevice>(name, std::move(factory));
389}
390
391inline void RegisterOutputFactory(const std::string& name,
392 std::shared_ptr<Factory<OutputDevice>> factory) {
393 RegisterFactory<OutputDevice>(name, std::move(factory));
394}
395
386/** 396/**
387 * Unregisters an input device factory. 397 * Unregisters an input device factory.
388 * @tparam InputDeviceType the type of input devices the factory can create 398 * @tparam InputDeviceType the type of input devices the factory can create
@@ -395,6 +405,14 @@ void UnregisterFactory(const std::string& name) {
395 } 405 }
396} 406}
397 407
408inline void UnregisterInputFactory(const std::string& name) {
409 UnregisterFactory<InputDevice>(name);
410}
411
412inline void UnregisterOutputFactory(const std::string& name) {
413 UnregisterFactory<OutputDevice>(name);
414}
415
398/** 416/**
399 * Create an input device from given paramters. 417 * Create an input device from given paramters.
400 * @tparam InputDeviceType the type of input devices to create 418 * @tparam InputDeviceType the type of input devices to create
@@ -416,13 +434,21 @@ std::unique_ptr<InputDeviceType> CreateDeviceFromString(const std::string& param
416 return pair->second->Create(package); 434 return pair->second->Create(package);
417} 435}
418 436
437inline std::unique_ptr<InputDevice> CreateInputDeviceFromString(const std::string& params) {
438 return CreateDeviceFromString<InputDevice>(params);
439}
440
441inline std::unique_ptr<OutputDevice> CreateOutputDeviceFromString(const std::string& params) {
442 return CreateDeviceFromString<OutputDevice>(params);
443}
444
419/** 445/**
420 * Create an input device from given paramters. 446 * Create an input device from given parameters.
421 * @tparam InputDeviceType the type of input devices to create 447 * @tparam InputDeviceType the type of input devices to create
422 * @param A ParamPackage that contains all parameters for creating the device 448 * @param package A ParamPackage that contains all parameters for creating the device
423 */ 449 */
424template <typename InputDeviceType> 450template <typename InputDeviceType>
425std::unique_ptr<InputDeviceType> CreateDevice(const Common::ParamPackage package) { 451std::unique_ptr<InputDeviceType> CreateDevice(const ParamPackage& package) {
426 const std::string engine = package.Get("engine", "null"); 452 const std::string engine = package.Get("engine", "null");
427 const auto& factory_list = Impl::FactoryList<InputDeviceType>::list; 453 const auto& factory_list = Impl::FactoryList<InputDeviceType>::list;
428 const auto pair = factory_list.find(engine); 454 const auto pair = factory_list.find(engine);
@@ -435,4 +461,12 @@ std::unique_ptr<InputDeviceType> CreateDevice(const Common::ParamPackage package
435 return pair->second->Create(package); 461 return pair->second->Create(package);
436} 462}
437 463
464inline std::unique_ptr<InputDevice> CreateInputDevice(const ParamPackage& package) {
465 return CreateDevice<InputDevice>(package);
466}
467
468inline std::unique_ptr<OutputDevice> CreateOutputDevice(const ParamPackage& package) {
469 return CreateDevice<OutputDevice>(package);
470}
471
438} // namespace Common::Input 472} // namespace Common::Input
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp
index fb7e5802a..b6c8cc58d 100644
--- a/src/core/hid/emulated_console.cpp
+++ b/src/core/hid/emulated_console.cpp
@@ -68,7 +68,7 @@ void EmulatedConsole::ReloadInput() {
68 // If you load any device here add the equivalent to the UnloadInput() function 68 // If you load any device here add the equivalent to the UnloadInput() function
69 SetTouchParams(); 69 SetTouchParams();
70 70
71 motion_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(motion_params); 71 motion_devices = Common::Input::CreateInputDevice(motion_params);
72 if (motion_devices) { 72 if (motion_devices) {
73 motion_devices->SetCallback({ 73 motion_devices->SetCallback({
74 .on_change = 74 .on_change =
@@ -79,7 +79,7 @@ void EmulatedConsole::ReloadInput() {
79 // Unique index for identifying touch device source 79 // Unique index for identifying touch device source
80 std::size_t index = 0; 80 std::size_t index = 0;
81 for (auto& touch_device : touch_devices) { 81 for (auto& touch_device : touch_devices) {
82 touch_device = Common::Input::CreateDevice<Common::Input::InputDevice>(touch_params[index]); 82 touch_device = Common::Input::CreateInputDevice(touch_params[index]);
83 if (!touch_device) { 83 if (!touch_device) {
84 continue; 84 continue;
85 } 85 }
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index ec1364452..c96d9eef3 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -1,6 +1,8 @@
1// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include <algorithm>
5
4#include "common/thread.h" 6#include "common/thread.h"
5#include "core/hid/emulated_controller.h" 7#include "core/hid/emulated_controller.h"
6#include "core/hid/input_converter.h" 8#include "core/hid/input_converter.h"
@@ -144,29 +146,23 @@ void EmulatedController::LoadDevices() {
144 146
145 LoadTASParams(); 147 LoadTASParams();
146 148
147 std::transform(button_params.begin() + Settings::NativeButton::BUTTON_HID_BEGIN, 149 std::ranges::transform(button_params, button_devices.begin(), Common::Input::CreateInputDevice);
148 button_params.begin() + Settings::NativeButton::BUTTON_NS_END, 150 std::ranges::transform(stick_params, stick_devices.begin(), Common::Input::CreateInputDevice);
149 button_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>); 151 std::ranges::transform(motion_params, motion_devices.begin(), Common::Input::CreateInputDevice);
150 std::transform(stick_params.begin() + Settings::NativeAnalog::STICK_HID_BEGIN, 152 std::ranges::transform(trigger_params, trigger_devices.begin(),
151 stick_params.begin() + Settings::NativeAnalog::STICK_HID_END, 153 Common::Input::CreateInputDevice);
152 stick_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>); 154 std::ranges::transform(battery_params, battery_devices.begin(),
153 std::transform(motion_params.begin() + Settings::NativeMotion::MOTION_HID_BEGIN, 155 Common::Input::CreateInputDevice);
154 motion_params.begin() + Settings::NativeMotion::MOTION_HID_END, 156 camera_devices = Common::Input::CreateInputDevice(camera_params);
155 motion_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>); 157 nfc_devices = Common::Input::CreateInputDevice(nfc_params);
156 std::transform(trigger_params.begin(), trigger_params.end(), trigger_devices.begin(), 158 std::ranges::transform(output_params, output_devices.begin(),
157 Common::Input::CreateDevice<Common::Input::InputDevice>); 159 Common::Input::CreateOutputDevice);
158 std::transform(battery_params.begin(), battery_params.end(), battery_devices.begin(),
159 Common::Input::CreateDevice<Common::Input::InputDevice>);
160 camera_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(camera_params);
161 nfc_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(nfc_params);
162 std::transform(output_params.begin(), output_params.end(), output_devices.begin(),
163 Common::Input::CreateDevice<Common::Input::OutputDevice>);
164 160
165 // Initialize TAS devices 161 // Initialize TAS devices
166 std::transform(tas_button_params.begin(), tas_button_params.end(), tas_button_devices.begin(), 162 std::ranges::transform(tas_button_params, tas_button_devices.begin(),
167 Common::Input::CreateDevice<Common::Input::InputDevice>); 163 Common::Input::CreateInputDevice);
168 std::transform(tas_stick_params.begin(), tas_stick_params.end(), tas_stick_devices.begin(), 164 std::ranges::transform(tas_stick_params, tas_stick_devices.begin(),
169 Common::Input::CreateDevice<Common::Input::InputDevice>); 165 Common::Input::CreateInputDevice);
170} 166}
171 167
172void EmulatedController::LoadTASParams() { 168void EmulatedController::LoadTASParams() {
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp
index 658dbd318..e421828d2 100644
--- a/src/core/hid/emulated_devices.cpp
+++ b/src/core/hid/emulated_devices.cpp
@@ -25,12 +25,12 @@ void EmulatedDevices::ReloadInput() {
25 Common::ParamPackage mouse_params; 25 Common::ParamPackage mouse_params;
26 mouse_params.Set("engine", "mouse"); 26 mouse_params.Set("engine", "mouse");
27 mouse_params.Set("button", static_cast<int>(key_index)); 27 mouse_params.Set("button", static_cast<int>(key_index));
28 mouse_device = Common::Input::CreateDevice<Common::Input::InputDevice>(mouse_params); 28 mouse_device = Common::Input::CreateInputDevice(mouse_params);
29 key_index++; 29 key_index++;
30 } 30 }
31 31
32 mouse_stick_device = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( 32 mouse_stick_device =
33 "engine:mouse,axis_x:0,axis_y:1"); 33 Common::Input::CreateInputDeviceFromString("engine:mouse,axis_x:0,axis_y:1");
34 34
35 // First two axis are reserved for mouse position 35 // First two axis are reserved for mouse position
36 key_index = 2; 36 key_index = 2;
@@ -38,7 +38,7 @@ void EmulatedDevices::ReloadInput() {
38 Common::ParamPackage mouse_params; 38 Common::ParamPackage mouse_params;
39 mouse_params.Set("engine", "mouse"); 39 mouse_params.Set("engine", "mouse");
40 mouse_params.Set("axis", static_cast<int>(key_index)); 40 mouse_params.Set("axis", static_cast<int>(key_index));
41 mouse_device = Common::Input::CreateDevice<Common::Input::InputDevice>(mouse_params); 41 mouse_device = Common::Input::CreateInputDevice(mouse_params);
42 key_index++; 42 key_index++;
43 } 43 }
44 44
@@ -50,7 +50,7 @@ void EmulatedDevices::ReloadInput() {
50 keyboard_params.Set("button", static_cast<int>(key_index)); 50 keyboard_params.Set("button", static_cast<int>(key_index));
51 keyboard_params.Set("port", 1); 51 keyboard_params.Set("port", 1);
52 keyboard_params.Set("pad", 0); 52 keyboard_params.Set("pad", 0);
53 keyboard_device = Common::Input::CreateDevice<Common::Input::InputDevice>(keyboard_params); 53 keyboard_device = Common::Input::CreateInputDevice(keyboard_params);
54 key_index++; 54 key_index++;
55 } 55 }
56 56
@@ -62,11 +62,11 @@ void EmulatedDevices::ReloadInput() {
62 keyboard_params.Set("button", static_cast<int>(key_index)); 62 keyboard_params.Set("button", static_cast<int>(key_index));
63 keyboard_params.Set("port", 1); 63 keyboard_params.Set("port", 1);
64 keyboard_params.Set("pad", 1); 64 keyboard_params.Set("pad", 1);
65 keyboard_device = Common::Input::CreateDevice<Common::Input::InputDevice>(keyboard_params); 65 keyboard_device = Common::Input::CreateInputDevice(keyboard_params);
66 key_index++; 66 key_index++;
67 } 67 }
68 68
69 ring_analog_device = Common::Input::CreateDevice<Common::Input::InputDevice>(ring_params); 69 ring_analog_device = Common::Input::CreateInputDevice(ring_params);
70 70
71 for (std::size_t index = 0; index < mouse_button_devices.size(); ++index) { 71 for (std::size_t index = 0; index < mouse_button_devices.size(); ++index) {
72 if (!mouse_button_devices[index]) { 72 if (!mouse_button_devices[index]) {
diff --git a/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp b/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp
index eda2041a0..aba51d280 100644
--- a/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp
+++ b/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp
@@ -28,13 +28,15 @@ SyncpointManager::SyncpointManager(Tegra::Host1x::Host1x& host1x_) : host1x{host
28SyncpointManager::~SyncpointManager() = default; 28SyncpointManager::~SyncpointManager() = default;
29 29
30u32 SyncpointManager::ReserveSyncpoint(u32 id, bool client_managed) { 30u32 SyncpointManager::ReserveSyncpoint(u32 id, bool client_managed) {
31 if (syncpoints.at(id).reserved) { 31 auto& syncpoint = syncpoints.at(id);
32
33 if (syncpoint.reserved) {
32 ASSERT_MSG(false, "Requested syncpoint is in use"); 34 ASSERT_MSG(false, "Requested syncpoint is in use");
33 return 0; 35 return 0;
34 } 36 }
35 37
36 syncpoints.at(id).reserved = true; 38 syncpoint.reserved = true;
37 syncpoints.at(id).interface_managed = client_managed; 39 syncpoint.interface_managed = client_managed;
38 40
39 return id; 41 return id;
40} 42}
@@ -56,11 +58,12 @@ u32 SyncpointManager::AllocateSyncpoint(bool client_managed) {
56 58
57void SyncpointManager::FreeSyncpoint(u32 id) { 59void SyncpointManager::FreeSyncpoint(u32 id) {
58 std::lock_guard lock(reservation_lock); 60 std::lock_guard lock(reservation_lock);
59 ASSERT(syncpoints.at(id).reserved); 61 auto& syncpoint = syncpoints.at(id);
60 syncpoints.at(id).reserved = false; 62 ASSERT(syncpoint.reserved);
63 syncpoint.reserved = false;
61} 64}
62 65
63bool SyncpointManager::IsSyncpointAllocated(u32 id) { 66bool SyncpointManager::IsSyncpointAllocated(u32 id) const {
64 return (id <= SyncpointCount) && syncpoints[id].reserved; 67 return (id <= SyncpointCount) && syncpoints[id].reserved;
65} 68}
66 69
@@ -69,7 +72,7 @@ bool SyncpointManager::HasSyncpointExpired(u32 id, u32 threshold) const {
69 72
70 if (!syncpoint.reserved) { 73 if (!syncpoint.reserved) {
71 ASSERT(false); 74 ASSERT(false);
72 return 0; 75 return false;
73 } 76 }
74 77
75 // If the interface manages counters then we don't keep track of the maximum value as it handles 78 // If the interface manages counters then we don't keep track of the maximum value as it handles
@@ -82,40 +85,51 @@ bool SyncpointManager::HasSyncpointExpired(u32 id, u32 threshold) const {
82} 85}
83 86
84u32 SyncpointManager::IncrementSyncpointMaxExt(u32 id, u32 amount) { 87u32 SyncpointManager::IncrementSyncpointMaxExt(u32 id, u32 amount) {
85 if (!syncpoints.at(id).reserved) { 88 auto& syncpoint = syncpoints.at(id);
89
90 if (!syncpoint.reserved) {
86 ASSERT(false); 91 ASSERT(false);
87 return 0; 92 return 0;
88 } 93 }
89 94
90 return syncpoints.at(id).counter_max += amount; 95 return syncpoint.counter_max += amount;
91} 96}
92 97
93u32 SyncpointManager::ReadSyncpointMinValue(u32 id) { 98u32 SyncpointManager::ReadSyncpointMinValue(u32 id) {
94 if (!syncpoints.at(id).reserved) { 99 auto& syncpoint = syncpoints.at(id);
100
101 if (!syncpoint.reserved) {
95 ASSERT(false); 102 ASSERT(false);
96 return 0; 103 return 0;
97 } 104 }
98 105
99 return syncpoints.at(id).counter_min; 106 return syncpoint.counter_min;
100} 107}
101 108
102u32 SyncpointManager::UpdateMin(u32 id) { 109u32 SyncpointManager::UpdateMin(u32 id) {
103 if (!syncpoints.at(id).reserved) { 110 auto& syncpoint = syncpoints.at(id);
111
112 if (!syncpoint.reserved) {
104 ASSERT(false); 113 ASSERT(false);
105 return 0; 114 return 0;
106 } 115 }
107 116
108 syncpoints.at(id).counter_min = host1x.GetSyncpointManager().GetHostSyncpointValue(id); 117 syncpoint.counter_min = host1x.GetSyncpointManager().GetHostSyncpointValue(id);
109 return syncpoints.at(id).counter_min; 118 return syncpoint.counter_min;
110} 119}
111 120
112NvFence SyncpointManager::GetSyncpointFence(u32 id) { 121NvFence SyncpointManager::GetSyncpointFence(u32 id) {
113 if (!syncpoints.at(id).reserved) { 122 auto& syncpoint = syncpoints.at(id);
123
124 if (!syncpoint.reserved) {
114 ASSERT(false); 125 ASSERT(false);
115 return NvFence{}; 126 return NvFence{};
116 } 127 }
117 128
118 return {.id = static_cast<s32>(id), .value = syncpoints.at(id).counter_max}; 129 return {
130 .id = static_cast<s32>(id),
131 .value = syncpoint.counter_max,
132 };
119} 133}
120 134
121} // namespace Service::Nvidia::NvCore 135} // namespace Service::Nvidia::NvCore
diff --git a/src/core/hle/service/nvdrv/core/syncpoint_manager.h b/src/core/hle/service/nvdrv/core/syncpoint_manager.h
index b76ef9032..4f2cefae5 100644
--- a/src/core/hle/service/nvdrv/core/syncpoint_manager.h
+++ b/src/core/hle/service/nvdrv/core/syncpoint_manager.h
@@ -44,7 +44,7 @@ public:
44 /** 44 /**
45 * @brief Checks if the given syncpoint is both allocated and below the number of HW syncpoints 45 * @brief Checks if the given syncpoint is both allocated and below the number of HW syncpoints
46 */ 46 */
47 bool IsSyncpointAllocated(u32 id); 47 bool IsSyncpointAllocated(u32 id) const;
48 48
49 /** 49 /**
50 * @brief Finds a free syncpoint and reserves it 50 * @brief Finds a free syncpoint and reserves it
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp
index 9f4c7c99a..6fc8565c0 100644
--- a/src/core/hle/service/nvdrv/nvdrv.cpp
+++ b/src/core/hle/service/nvdrv/nvdrv.cpp
@@ -55,48 +55,40 @@ void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger
55Module::Module(Core::System& system) 55Module::Module(Core::System& system)
56 : container{system.Host1x()}, service_context{system, "nvdrv"}, events_interface{*this} { 56 : container{system.Host1x()}, service_context{system, "nvdrv"}, events_interface{*this} {
57 builders["/dev/nvhost-as-gpu"] = [this, &system](DeviceFD fd) { 57 builders["/dev/nvhost-as-gpu"] = [this, &system](DeviceFD fd) {
58 std::shared_ptr<Devices::nvdevice> device = 58 auto device = std::make_shared<Devices::nvhost_as_gpu>(system, *this, container);
59 std::make_shared<Devices::nvhost_as_gpu>(system, *this, container); 59 return open_files.emplace(fd, std::move(device)).first;
60 return open_files.emplace(fd, device).first;
61 }; 60 };
62 builders["/dev/nvhost-gpu"] = [this, &system](DeviceFD fd) { 61 builders["/dev/nvhost-gpu"] = [this, &system](DeviceFD fd) {
63 std::shared_ptr<Devices::nvdevice> device = 62 auto device = std::make_shared<Devices::nvhost_gpu>(system, events_interface, container);
64 std::make_shared<Devices::nvhost_gpu>(system, events_interface, container); 63 return open_files.emplace(fd, std::move(device)).first;
65 return open_files.emplace(fd, device).first;
66 }; 64 };
67 builders["/dev/nvhost-ctrl-gpu"] = [this, &system](DeviceFD fd) { 65 builders["/dev/nvhost-ctrl-gpu"] = [this, &system](DeviceFD fd) {
68 std::shared_ptr<Devices::nvdevice> device = 66 auto device = std::make_shared<Devices::nvhost_ctrl_gpu>(system, events_interface);
69 std::make_shared<Devices::nvhost_ctrl_gpu>(system, events_interface); 67 return open_files.emplace(fd, std::move(device)).first;
70 return open_files.emplace(fd, device).first;
71 }; 68 };
72 builders["/dev/nvmap"] = [this, &system](DeviceFD fd) { 69 builders["/dev/nvmap"] = [this, &system](DeviceFD fd) {
73 std::shared_ptr<Devices::nvdevice> device = 70 auto device = std::make_shared<Devices::nvmap>(system, container);
74 std::make_shared<Devices::nvmap>(system, container); 71 return open_files.emplace(fd, std::move(device)).first;
75 return open_files.emplace(fd, device).first;
76 }; 72 };
77 builders["/dev/nvdisp_disp0"] = [this, &system](DeviceFD fd) { 73 builders["/dev/nvdisp_disp0"] = [this, &system](DeviceFD fd) {
78 std::shared_ptr<Devices::nvdevice> device = 74 auto device = std::make_shared<Devices::nvdisp_disp0>(system, container);
79 std::make_shared<Devices::nvdisp_disp0>(system, container); 75 return open_files.emplace(fd, std::move(device)).first;
80 return open_files.emplace(fd, device).first;
81 }; 76 };
82 builders["/dev/nvhost-ctrl"] = [this, &system](DeviceFD fd) { 77 builders["/dev/nvhost-ctrl"] = [this, &system](DeviceFD fd) {
83 std::shared_ptr<Devices::nvdevice> device = 78 auto device = std::make_shared<Devices::nvhost_ctrl>(system, events_interface, container);
84 std::make_shared<Devices::nvhost_ctrl>(system, events_interface, container); 79 return open_files.emplace(fd, std::move(device)).first;
85 return open_files.emplace(fd, device).first;
86 }; 80 };
87 builders["/dev/nvhost-nvdec"] = [this, &system](DeviceFD fd) { 81 builders["/dev/nvhost-nvdec"] = [this, &system](DeviceFD fd) {
88 std::shared_ptr<Devices::nvdevice> device = 82 auto device = std::make_shared<Devices::nvhost_nvdec>(system, container);
89 std::make_shared<Devices::nvhost_nvdec>(system, container); 83 return open_files.emplace(fd, std::move(device)).first;
90 return open_files.emplace(fd, device).first;
91 }; 84 };
92 builders["/dev/nvhost-nvjpg"] = [this, &system](DeviceFD fd) { 85 builders["/dev/nvhost-nvjpg"] = [this, &system](DeviceFD fd) {
93 std::shared_ptr<Devices::nvdevice> device = std::make_shared<Devices::nvhost_nvjpg>(system); 86 auto device = std::make_shared<Devices::nvhost_nvjpg>(system);
94 return open_files.emplace(fd, device).first; 87 return open_files.emplace(fd, std::move(device)).first;
95 }; 88 };
96 builders["/dev/nvhost-vic"] = [this, &system](DeviceFD fd) { 89 builders["/dev/nvhost-vic"] = [this, &system](DeviceFD fd) {
97 std::shared_ptr<Devices::nvdevice> device = 90 auto device = std::make_shared<Devices::nvhost_vic>(system, container);
98 std::make_shared<Devices::nvhost_vic>(system, container); 91 return open_files.emplace(fd, std::move(device)).first;
99 return open_files.emplace(fd, device).first;
100 }; 92 };
101} 93}
102 94
diff --git a/src/core/hle/service/nvflinger/buffer_item_consumer.cpp b/src/core/hle/service/nvflinger/buffer_item_consumer.cpp
index 6d2c92a2c..152bb5bdf 100644
--- a/src/core/hle/service/nvflinger/buffer_item_consumer.cpp
+++ b/src/core/hle/service/nvflinger/buffer_item_consumer.cpp
@@ -39,7 +39,7 @@ Status BufferItemConsumer::AcquireBuffer(BufferItem* item, std::chrono::nanoseco
39 return Status::NoError; 39 return Status::NoError;
40} 40}
41 41
42Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, Fence& release_fence) { 42Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, const Fence& release_fence) {
43 std::scoped_lock lock{mutex}; 43 std::scoped_lock lock{mutex};
44 44
45 if (const auto status = AddReleaseFenceLocked(item.buf, item.graphic_buffer, release_fence); 45 if (const auto status = AddReleaseFenceLocked(item.buf, item.graphic_buffer, release_fence);
diff --git a/src/core/hle/service/nvflinger/buffer_item_consumer.h b/src/core/hle/service/nvflinger/buffer_item_consumer.h
index 69046233d..a5c655d9e 100644
--- a/src/core/hle/service/nvflinger/buffer_item_consumer.h
+++ b/src/core/hle/service/nvflinger/buffer_item_consumer.h
@@ -22,7 +22,7 @@ public:
22 explicit BufferItemConsumer(std::unique_ptr<BufferQueueConsumer> consumer); 22 explicit BufferItemConsumer(std::unique_ptr<BufferQueueConsumer> consumer);
23 Status AcquireBuffer(BufferItem* item, std::chrono::nanoseconds present_when, 23 Status AcquireBuffer(BufferItem* item, std::chrono::nanoseconds present_when,
24 bool wait_for_fence = true); 24 bool wait_for_fence = true);
25 Status ReleaseBuffer(const BufferItem& item, Fence& release_fence); 25 Status ReleaseBuffer(const BufferItem& item, const Fence& release_fence);
26}; 26};
27 27
28} // namespace Service::android 28} // namespace Service::android
diff --git a/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp b/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp
index 1ce67c771..0767e548d 100644
--- a/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp
@@ -169,7 +169,7 @@ Status BufferQueueConsumer::Connect(std::shared_ptr<IConsumerListener> consumer_
169 return Status::NoInit; 169 return Status::NoInit;
170 } 170 }
171 171
172 core->consumer_listener = consumer_listener; 172 core->consumer_listener = std::move(consumer_listener);
173 core->consumer_controlled_by_app = controlled_by_app; 173 core->consumer_controlled_by_app = controlled_by_app;
174 174
175 return Status::NoError; 175 return Status::NoError;
diff --git a/src/core/hle/service/nvflinger/consumer_base.cpp b/src/core/hle/service/nvflinger/consumer_base.cpp
index 5b9995854..982531e2d 100644
--- a/src/core/hle/service/nvflinger/consumer_base.cpp
+++ b/src/core/hle/service/nvflinger/consumer_base.cpp
@@ -83,7 +83,7 @@ Status ConsumerBase::AcquireBufferLocked(BufferItem* item, std::chrono::nanoseco
83} 83}
84 84
85Status ConsumerBase::AddReleaseFenceLocked(s32 slot, 85Status ConsumerBase::AddReleaseFenceLocked(s32 slot,
86 const std::shared_ptr<GraphicBuffer> graphic_buffer, 86 const std::shared_ptr<GraphicBuffer>& graphic_buffer,
87 const Fence& fence) { 87 const Fence& fence) {
88 LOG_DEBUG(Service_NVFlinger, "slot={}", slot); 88 LOG_DEBUG(Service_NVFlinger, "slot={}", slot);
89 89
@@ -100,7 +100,7 @@ Status ConsumerBase::AddReleaseFenceLocked(s32 slot,
100} 100}
101 101
102Status ConsumerBase::ReleaseBufferLocked(s32 slot, 102Status ConsumerBase::ReleaseBufferLocked(s32 slot,
103 const std::shared_ptr<GraphicBuffer> graphic_buffer) { 103 const std::shared_ptr<GraphicBuffer>& graphic_buffer) {
104 // If consumer no longer tracks this graphic_buffer (we received a new 104 // If consumer no longer tracks this graphic_buffer (we received a new
105 // buffer on the same slot), the buffer producer is definitely no longer 105 // buffer on the same slot), the buffer producer is definitely no longer
106 // tracking it. 106 // tracking it.
@@ -121,7 +121,7 @@ Status ConsumerBase::ReleaseBufferLocked(s32 slot,
121} 121}
122 122
123bool ConsumerBase::StillTracking(s32 slot, 123bool ConsumerBase::StillTracking(s32 slot,
124 const std::shared_ptr<GraphicBuffer> graphic_buffer) const { 124 const std::shared_ptr<GraphicBuffer>& graphic_buffer) const {
125 if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) { 125 if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
126 return false; 126 return false;
127 } 127 }
diff --git a/src/core/hle/service/nvflinger/consumer_base.h b/src/core/hle/service/nvflinger/consumer_base.h
index 90ba07f45..9a8a5f6bb 100644
--- a/src/core/hle/service/nvflinger/consumer_base.h
+++ b/src/core/hle/service/nvflinger/consumer_base.h
@@ -27,18 +27,18 @@ public:
27 27
28protected: 28protected:
29 explicit ConsumerBase(std::unique_ptr<BufferQueueConsumer> consumer_); 29 explicit ConsumerBase(std::unique_ptr<BufferQueueConsumer> consumer_);
30 virtual ~ConsumerBase(); 30 ~ConsumerBase() override;
31 31
32 virtual void OnFrameAvailable(const BufferItem& item) override; 32 void OnFrameAvailable(const BufferItem& item) override;
33 virtual void OnFrameReplaced(const BufferItem& item) override; 33 void OnFrameReplaced(const BufferItem& item) override;
34 virtual void OnBuffersReleased() override; 34 void OnBuffersReleased() override;
35 virtual void OnSidebandStreamChanged() override; 35 void OnSidebandStreamChanged() override;
36 36
37 void FreeBufferLocked(s32 slot_index); 37 void FreeBufferLocked(s32 slot_index);
38 Status AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when); 38 Status AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when);
39 Status ReleaseBufferLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer); 39 Status ReleaseBufferLocked(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer);
40 bool StillTracking(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer) const; 40 bool StillTracking(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer) const;
41 Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer, 41 Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer,
42 const Fence& fence); 42 const Fence& fence);
43 43
44 struct Slot final { 44 struct Slot final {
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index c3af12c90..d1cbadde4 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -307,8 +307,7 @@ void NVFlinger::Compose() {
307 307
308 swap_interval = buffer.swap_interval; 308 swap_interval = buffer.swap_interval;
309 309
310 auto fence = android::Fence::NoFence(); 310 layer.GetConsumer().ReleaseBuffer(buffer, android::Fence::NoFence());
311 layer.GetConsumer().ReleaseBuffer(buffer, fence);
312 } 311 }
313} 312}
314 313
diff --git a/src/core/hle/service/nvflinger/producer_listener.h b/src/core/hle/service/nvflinger/producer_listener.h
index 1c4d5db0e..6bf8aaf1e 100644
--- a/src/core/hle/service/nvflinger/producer_listener.h
+++ b/src/core/hle/service/nvflinger/producer_listener.h
@@ -10,6 +10,7 @@ namespace Service::android {
10 10
11class IProducerListener { 11class IProducerListener {
12public: 12public:
13 virtual ~IProducerListener() = default;
13 virtual void OnBufferReleased() = 0; 14 virtual void OnBufferReleased() = 0;
14}; 15};
15 16
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp
index 536d413a5..82aa6ac2f 100644
--- a/src/input_common/helpers/stick_from_buttons.cpp
+++ b/src/input_common/helpers/stick_from_buttons.cpp
@@ -294,6 +294,15 @@ public:
294 } 294 }
295 295
296private: 296private:
297 static constexpr Common::Input::AnalogProperties properties{
298 .deadzone = 0.0f,
299 .range = 1.0f,
300 .threshold = 0.5f,
301 .offset = 0.0f,
302 .inverted = false,
303 .toggle = false,
304 };
305
297 Button up; 306 Button up;
298 Button down; 307 Button down;
299 Button left; 308 Button left;
@@ -311,23 +320,17 @@ private:
311 float last_x_axis_value{}; 320 float last_x_axis_value{};
312 float last_y_axis_value{}; 321 float last_y_axis_value{};
313 Common::Input::ButtonStatus modifier_status{}; 322 Common::Input::ButtonStatus modifier_status{};
314 const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};
315 std::chrono::time_point<std::chrono::steady_clock> last_update; 323 std::chrono::time_point<std::chrono::steady_clock> last_update;
316}; 324};
317 325
318std::unique_ptr<Common::Input::InputDevice> StickFromButton::Create( 326std::unique_ptr<Common::Input::InputDevice> StickFromButton::Create(
319 const Common::ParamPackage& params) { 327 const Common::ParamPackage& params) {
320 const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); 328 const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize();
321 auto up = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( 329 auto up = Common::Input::CreateInputDeviceFromString(params.Get("up", null_engine));
322 params.Get("up", null_engine)); 330 auto down = Common::Input::CreateInputDeviceFromString(params.Get("down", null_engine));
323 auto down = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( 331 auto left = Common::Input::CreateInputDeviceFromString(params.Get("left", null_engine));
324 params.Get("down", null_engine)); 332 auto right = Common::Input::CreateInputDeviceFromString(params.Get("right", null_engine));
325 auto left = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( 333 auto modifier = Common::Input::CreateInputDeviceFromString(params.Get("modifier", null_engine));
326 params.Get("left", null_engine));
327 auto right = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
328 params.Get("right", null_engine));
329 auto modifier = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
330 params.Get("modifier", null_engine));
331 auto modifier_scale = params.Get("modifier_scale", 0.5f); 334 auto modifier_scale = params.Get("modifier_scale", 0.5f);
332 auto modifier_angle = params.Get("modifier_angle", 5.5f); 335 auto modifier_angle = params.Get("modifier_angle", 5.5f);
333 return std::make_unique<Stick>(std::move(up), std::move(down), std::move(left), 336 return std::make_unique<Stick>(std::move(up), std::move(down), std::move(left),
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp
index 003a38da5..e064b13d9 100644
--- a/src/input_common/helpers/touch_from_buttons.cpp
+++ b/src/input_common/helpers/touch_from_buttons.cpp
@@ -59,18 +59,25 @@ public:
59 } 59 }
60 60
61private: 61private:
62 static constexpr Common::Input::AnalogProperties properties{
63 .deadzone = 0.0f,
64 .range = 1.0f,
65 .threshold = 0.5f,
66 .offset = 0.0f,
67 .inverted = false,
68 .toggle = false,
69 };
70
62 Button button; 71 Button button;
63 bool last_button_value; 72 bool last_button_value;
64 const float x; 73 const float x;
65 const float y; 74 const float y;
66 const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};
67}; 75};
68 76
69std::unique_ptr<Common::Input::InputDevice> TouchFromButton::Create( 77std::unique_ptr<Common::Input::InputDevice> TouchFromButton::Create(
70 const Common::ParamPackage& params) { 78 const Common::ParamPackage& params) {
71 const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); 79 const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize();
72 auto button = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( 80 auto button = Common::Input::CreateInputDeviceFromString(params.Get("button", null_engine));
73 params.Get("button", null_engine));
74 const float x = params.Get("x", 0.0f) / 1280.0f; 81 const float x = params.Get("x", 0.0f) / 1280.0f;
75 const float y = params.Get("y", 0.0f) / 720.0f; 82 const float y = params.Get("y", 0.0f) / 720.0f;
76 return std::make_unique<TouchFromButtonDevice>(std::move(button), x, y); 83 return std::make_unique<TouchFromButtonDevice>(std::move(button), x, y);
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index 76df133f3..baeed2e02 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -33,129 +33,113 @@ struct InputSubsystem::Impl {
33 keyboard->SetMappingCallback(mapping_callback); 33 keyboard->SetMappingCallback(mapping_callback);
34 keyboard_factory = std::make_shared<InputFactory>(keyboard); 34 keyboard_factory = std::make_shared<InputFactory>(keyboard);
35 keyboard_output_factory = std::make_shared<OutputFactory>(keyboard); 35 keyboard_output_factory = std::make_shared<OutputFactory>(keyboard);
36 Common::Input::RegisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName(), 36 Common::Input::RegisterInputFactory(keyboard->GetEngineName(), keyboard_factory);
37 keyboard_factory); 37 Common::Input::RegisterOutputFactory(keyboard->GetEngineName(), keyboard_output_factory);
38 Common::Input::RegisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName(),
39 keyboard_output_factory);
40 38
41 mouse = std::make_shared<Mouse>("mouse"); 39 mouse = std::make_shared<Mouse>("mouse");
42 mouse->SetMappingCallback(mapping_callback); 40 mouse->SetMappingCallback(mapping_callback);
43 mouse_factory = std::make_shared<InputFactory>(mouse); 41 mouse_factory = std::make_shared<InputFactory>(mouse);
44 mouse_output_factory = std::make_shared<OutputFactory>(mouse); 42 mouse_output_factory = std::make_shared<OutputFactory>(mouse);
45 Common::Input::RegisterFactory<Common::Input::InputDevice>(mouse->GetEngineName(), 43 Common::Input::RegisterInputFactory(mouse->GetEngineName(), mouse_factory);
46 mouse_factory); 44 Common::Input::RegisterOutputFactory(mouse->GetEngineName(), mouse_output_factory);
47 Common::Input::RegisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName(),
48 mouse_output_factory);
49 45
50 touch_screen = std::make_shared<TouchScreen>("touch"); 46 touch_screen = std::make_shared<TouchScreen>("touch");
51 touch_screen_factory = std::make_shared<InputFactory>(touch_screen); 47 touch_screen_factory = std::make_shared<InputFactory>(touch_screen);
52 Common::Input::RegisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName(), 48 Common::Input::RegisterInputFactory(touch_screen->GetEngineName(), touch_screen_factory);
53 touch_screen_factory);
54 49
55 gcadapter = std::make_shared<GCAdapter>("gcpad"); 50 gcadapter = std::make_shared<GCAdapter>("gcpad");
56 gcadapter->SetMappingCallback(mapping_callback); 51 gcadapter->SetMappingCallback(mapping_callback);
57 gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter); 52 gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter);
58 gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter); 53 gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter);
59 Common::Input::RegisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName(), 54 Common::Input::RegisterInputFactory(gcadapter->GetEngineName(), gcadapter_input_factory);
60 gcadapter_input_factory); 55 Common::Input::RegisterOutputFactory(gcadapter->GetEngineName(), gcadapter_output_factory);
61 Common::Input::RegisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName(),
62 gcadapter_output_factory);
63 56
64 udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp"); 57 udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp");
65 udp_client->SetMappingCallback(mapping_callback); 58 udp_client->SetMappingCallback(mapping_callback);
66 udp_client_input_factory = std::make_shared<InputFactory>(udp_client); 59 udp_client_input_factory = std::make_shared<InputFactory>(udp_client);
67 udp_client_output_factory = std::make_shared<OutputFactory>(udp_client); 60 udp_client_output_factory = std::make_shared<OutputFactory>(udp_client);
68 Common::Input::RegisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName(), 61 Common::Input::RegisterInputFactory(udp_client->GetEngineName(), udp_client_input_factory);
69 udp_client_input_factory); 62 Common::Input::RegisterOutputFactory(udp_client->GetEngineName(),
70 Common::Input::RegisterFactory<Common::Input::OutputDevice>(udp_client->GetEngineName(), 63 udp_client_output_factory);
71 udp_client_output_factory);
72 64
73 tas_input = std::make_shared<TasInput::Tas>("tas"); 65 tas_input = std::make_shared<TasInput::Tas>("tas");
74 tas_input->SetMappingCallback(mapping_callback); 66 tas_input->SetMappingCallback(mapping_callback);
75 tas_input_factory = std::make_shared<InputFactory>(tas_input); 67 tas_input_factory = std::make_shared<InputFactory>(tas_input);
76 tas_output_factory = std::make_shared<OutputFactory>(tas_input); 68 tas_output_factory = std::make_shared<OutputFactory>(tas_input);
77 Common::Input::RegisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName(), 69 Common::Input::RegisterInputFactory(tas_input->GetEngineName(), tas_input_factory);
78 tas_input_factory); 70 Common::Input::RegisterOutputFactory(tas_input->GetEngineName(), tas_output_factory);
79 Common::Input::RegisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName(),
80 tas_output_factory);
81 71
82 camera = std::make_shared<Camera>("camera"); 72 camera = std::make_shared<Camera>("camera");
83 camera->SetMappingCallback(mapping_callback); 73 camera->SetMappingCallback(mapping_callback);
84 camera_input_factory = std::make_shared<InputFactory>(camera); 74 camera_input_factory = std::make_shared<InputFactory>(camera);
85 camera_output_factory = std::make_shared<OutputFactory>(camera); 75 camera_output_factory = std::make_shared<OutputFactory>(camera);
86 Common::Input::RegisterFactory<Common::Input::InputDevice>(camera->GetEngineName(), 76 Common::Input::RegisterInputFactory(camera->GetEngineName(), camera_input_factory);
87 camera_input_factory); 77 Common::Input::RegisterOutputFactory(camera->GetEngineName(), camera_output_factory);
88 Common::Input::RegisterFactory<Common::Input::OutputDevice>(camera->GetEngineName(),
89 camera_output_factory);
90 78
91 virtual_amiibo = std::make_shared<VirtualAmiibo>("virtual_amiibo"); 79 virtual_amiibo = std::make_shared<VirtualAmiibo>("virtual_amiibo");
92 virtual_amiibo->SetMappingCallback(mapping_callback); 80 virtual_amiibo->SetMappingCallback(mapping_callback);
93 virtual_amiibo_input_factory = std::make_shared<InputFactory>(virtual_amiibo); 81 virtual_amiibo_input_factory = std::make_shared<InputFactory>(virtual_amiibo);
94 virtual_amiibo_output_factory = std::make_shared<OutputFactory>(virtual_amiibo); 82 virtual_amiibo_output_factory = std::make_shared<OutputFactory>(virtual_amiibo);
95 Common::Input::RegisterFactory<Common::Input::InputDevice>(virtual_amiibo->GetEngineName(), 83 Common::Input::RegisterInputFactory(virtual_amiibo->GetEngineName(),
96 virtual_amiibo_input_factory); 84 virtual_amiibo_input_factory);
97 Common::Input::RegisterFactory<Common::Input::OutputDevice>(virtual_amiibo->GetEngineName(), 85 Common::Input::RegisterOutputFactory(virtual_amiibo->GetEngineName(),
98 virtual_amiibo_output_factory); 86 virtual_amiibo_output_factory);
99 87
100#ifdef HAVE_SDL2 88#ifdef HAVE_SDL2
101 sdl = std::make_shared<SDLDriver>("sdl"); 89 sdl = std::make_shared<SDLDriver>("sdl");
102 sdl->SetMappingCallback(mapping_callback); 90 sdl->SetMappingCallback(mapping_callback);
103 sdl_input_factory = std::make_shared<InputFactory>(sdl); 91 sdl_input_factory = std::make_shared<InputFactory>(sdl);
104 sdl_output_factory = std::make_shared<OutputFactory>(sdl); 92 sdl_output_factory = std::make_shared<OutputFactory>(sdl);
105 Common::Input::RegisterFactory<Common::Input::InputDevice>(sdl->GetEngineName(), 93 Common::Input::RegisterInputFactory(sdl->GetEngineName(), sdl_input_factory);
106 sdl_input_factory); 94 Common::Input::RegisterOutputFactory(sdl->GetEngineName(), sdl_output_factory);
107 Common::Input::RegisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName(),
108 sdl_output_factory);
109#endif 95#endif
110 96
111 Common::Input::RegisterFactory<Common::Input::InputDevice>( 97 Common::Input::RegisterInputFactory("touch_from_button",
112 "touch_from_button", std::make_shared<TouchFromButton>()); 98 std::make_shared<TouchFromButton>());
113 Common::Input::RegisterFactory<Common::Input::InputDevice>( 99 Common::Input::RegisterInputFactory("analog_from_button",
114 "analog_from_button", std::make_shared<StickFromButton>()); 100 std::make_shared<StickFromButton>());
115 } 101 }
116 102
117 void Shutdown() { 103 void Shutdown() {
118 Common::Input::UnregisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName()); 104 Common::Input::UnregisterInputFactory(keyboard->GetEngineName());
119 Common::Input::UnregisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName()); 105 Common::Input::UnregisterOutputFactory(keyboard->GetEngineName());
120 keyboard.reset(); 106 keyboard.reset();
121 107
122 Common::Input::UnregisterFactory<Common::Input::InputDevice>(mouse->GetEngineName()); 108 Common::Input::UnregisterInputFactory(mouse->GetEngineName());
123 Common::Input::UnregisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName()); 109 Common::Input::UnregisterOutputFactory(mouse->GetEngineName());
124 mouse.reset(); 110 mouse.reset();
125 111
126 Common::Input::UnregisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName()); 112 Common::Input::UnregisterInputFactory(touch_screen->GetEngineName());
127 touch_screen.reset(); 113 touch_screen.reset();
128 114
129 Common::Input::UnregisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName()); 115 Common::Input::UnregisterInputFactory(gcadapter->GetEngineName());
130 Common::Input::UnregisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName()); 116 Common::Input::UnregisterOutputFactory(gcadapter->GetEngineName());
131 gcadapter.reset(); 117 gcadapter.reset();
132 118
133 Common::Input::UnregisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName()); 119 Common::Input::UnregisterInputFactory(udp_client->GetEngineName());
134 Common::Input::UnregisterFactory<Common::Input::OutputDevice>(udp_client->GetEngineName()); 120 Common::Input::UnregisterOutputFactory(udp_client->GetEngineName());
135 udp_client.reset(); 121 udp_client.reset();
136 122
137 Common::Input::UnregisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName()); 123 Common::Input::UnregisterInputFactory(tas_input->GetEngineName());
138 Common::Input::UnregisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName()); 124 Common::Input::UnregisterOutputFactory(tas_input->GetEngineName());
139 tas_input.reset(); 125 tas_input.reset();
140 126
141 Common::Input::UnregisterFactory<Common::Input::InputDevice>(camera->GetEngineName()); 127 Common::Input::UnregisterInputFactory(camera->GetEngineName());
142 Common::Input::UnregisterFactory<Common::Input::OutputDevice>(camera->GetEngineName()); 128 Common::Input::UnregisterOutputFactory(camera->GetEngineName());
143 camera.reset(); 129 camera.reset();
144 130
145 Common::Input::UnregisterFactory<Common::Input::InputDevice>( 131 Common::Input::UnregisterInputFactory(virtual_amiibo->GetEngineName());
146 virtual_amiibo->GetEngineName()); 132 Common::Input::UnregisterOutputFactory(virtual_amiibo->GetEngineName());
147 Common::Input::UnregisterFactory<Common::Input::OutputDevice>(
148 virtual_amiibo->GetEngineName());
149 virtual_amiibo.reset(); 133 virtual_amiibo.reset();
150 134
151#ifdef HAVE_SDL2 135#ifdef HAVE_SDL2
152 Common::Input::UnregisterFactory<Common::Input::InputDevice>(sdl->GetEngineName()); 136 Common::Input::UnregisterInputFactory(sdl->GetEngineName());
153 Common::Input::UnregisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName()); 137 Common::Input::UnregisterOutputFactory(sdl->GetEngineName());
154 sdl.reset(); 138 sdl.reset();
155#endif 139#endif
156 140
157 Common::Input::UnregisterFactory<Common::Input::InputDevice>("touch_from_button"); 141 Common::Input::UnregisterInputFactory("touch_from_button");
158 Common::Input::UnregisterFactory<Common::Input::InputDevice>("analog_from_button"); 142 Common::Input::UnregisterInputFactory("analog_from_button");
159 } 143 }
160 144
161 [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const { 145 [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const {
diff --git a/src/video_core/host1x/syncpoint_manager.cpp b/src/video_core/host1x/syncpoint_manager.cpp
index a44fc83d3..8f23ce527 100644
--- a/src/video_core/host1x/syncpoint_manager.cpp
+++ b/src/video_core/host1x/syncpoint_manager.cpp
@@ -34,7 +34,7 @@ SyncpointManager::ActionHandle SyncpointManager::RegisterAction(
34} 34}
35 35
36void SyncpointManager::DeregisterAction(std::list<RegisteredAction>& action_storage, 36void SyncpointManager::DeregisterAction(std::list<RegisteredAction>& action_storage,
37 ActionHandle& handle) { 37 const ActionHandle& handle) {
38 std::unique_lock lk(guard); 38 std::unique_lock lk(guard);
39 39
40 // We want to ensure the iterator still exists prior to erasing it 40 // We want to ensure the iterator still exists prior to erasing it
@@ -49,11 +49,11 @@ void SyncpointManager::DeregisterAction(std::list<RegisteredAction>& action_stor
49 } 49 }
50} 50}
51 51
52void SyncpointManager::DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle) { 52void SyncpointManager::DeregisterGuestAction(u32 syncpoint_id, const ActionHandle& handle) {
53 DeregisterAction(guest_action_storage[syncpoint_id], handle); 53 DeregisterAction(guest_action_storage[syncpoint_id], handle);
54} 54}
55 55
56void SyncpointManager::DeregisterHostAction(u32 syncpoint_id, ActionHandle& handle) { 56void SyncpointManager::DeregisterHostAction(u32 syncpoint_id, const ActionHandle& handle) {
57 DeregisterAction(host_action_storage[syncpoint_id], handle); 57 DeregisterAction(host_action_storage[syncpoint_id], handle);
58} 58}
59 59
diff --git a/src/video_core/host1x/syncpoint_manager.h b/src/video_core/host1x/syncpoint_manager.h
index 50a264e23..847ed20c8 100644
--- a/src/video_core/host1x/syncpoint_manager.h
+++ b/src/video_core/host1x/syncpoint_manager.h
@@ -36,21 +36,19 @@ public:
36 36
37 template <typename Func> 37 template <typename Func>
38 ActionHandle RegisterGuestAction(u32 syncpoint_id, u32 expected_value, Func&& action) { 38 ActionHandle RegisterGuestAction(u32 syncpoint_id, u32 expected_value, Func&& action) {
39 std::function<void()> func(action);
40 return RegisterAction(syncpoints_guest[syncpoint_id], guest_action_storage[syncpoint_id], 39 return RegisterAction(syncpoints_guest[syncpoint_id], guest_action_storage[syncpoint_id],
41 expected_value, std::move(func)); 40 expected_value, std::move(action));
42 } 41 }
43 42
44 template <typename Func> 43 template <typename Func>
45 ActionHandle RegisterHostAction(u32 syncpoint_id, u32 expected_value, Func&& action) { 44 ActionHandle RegisterHostAction(u32 syncpoint_id, u32 expected_value, Func&& action) {
46 std::function<void()> func(action);
47 return RegisterAction(syncpoints_host[syncpoint_id], host_action_storage[syncpoint_id], 45 return RegisterAction(syncpoints_host[syncpoint_id], host_action_storage[syncpoint_id],
48 expected_value, std::move(func)); 46 expected_value, std::move(action));
49 } 47 }
50 48
51 void DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle); 49 void DeregisterGuestAction(u32 syncpoint_id, const ActionHandle& handle);
52 50
53 void DeregisterHostAction(u32 syncpoint_id, ActionHandle& handle); 51 void DeregisterHostAction(u32 syncpoint_id, const ActionHandle& handle);
54 52
55 void IncrementGuest(u32 syncpoint_id); 53 void IncrementGuest(u32 syncpoint_id);
56 54
@@ -76,7 +74,7 @@ private:
76 std::list<RegisteredAction>& action_storage, u32 expected_value, 74 std::list<RegisteredAction>& action_storage, u32 expected_value,
77 std::function<void()>&& action); 75 std::function<void()>&& action);
78 76
79 void DeregisterAction(std::list<RegisteredAction>& action_storage, ActionHandle& handle); 77 void DeregisterAction(std::list<RegisteredAction>& action_storage, const ActionHandle& handle);
80 78
81 void Wait(std::atomic<u32>& syncpoint, std::condition_variable& wait_cv, u32 expected_value); 79 void Wait(std::atomic<u32>& syncpoint, std::condition_variable& wait_cv, u32 expected_value);
82 80
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp
index b618e1a25..1a76d4178 100644
--- a/src/video_core/surface.cpp
+++ b/src/video_core/surface.cpp
@@ -214,23 +214,16 @@ PixelFormat PixelFormatFromGPUPixelFormat(Service::android::PixelFormat format)
214} 214}
215 215
216SurfaceType GetFormatType(PixelFormat pixel_format) { 216SurfaceType GetFormatType(PixelFormat pixel_format) {
217 if (static_cast<std::size_t>(pixel_format) < 217 if (pixel_format < PixelFormat::MaxColorFormat) {
218 static_cast<std::size_t>(PixelFormat::MaxColorFormat)) {
219 return SurfaceType::ColorTexture; 218 return SurfaceType::ColorTexture;
220 } 219 }
221 220 if (pixel_format < PixelFormat::MaxDepthFormat) {
222 if (static_cast<std::size_t>(pixel_format) <
223 static_cast<std::size_t>(PixelFormat::MaxDepthFormat)) {
224 return SurfaceType::Depth; 221 return SurfaceType::Depth;
225 } 222 }
226 223 if (pixel_format < PixelFormat::MaxStencilFormat) {
227 if (static_cast<std::size_t>(pixel_format) <
228 static_cast<std::size_t>(PixelFormat::MaxStencilFormat)) {
229 return SurfaceType::Stencil; 224 return SurfaceType::Stencil;
230 } 225 }
231 226 if (pixel_format < PixelFormat::MaxDepthStencilFormat) {
232 if (static_cast<std::size_t>(pixel_format) <
233 static_cast<std::size_t>(PixelFormat::MaxDepthStencilFormat)) {
234 return SurfaceType::DepthStencil; 227 return SurfaceType::DepthStencil;
235 } 228 }
236 229
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 2aae746f0..346d14252 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -4037,7 +4037,6 @@ void GMainWindow::UpdateUITheme() {
4037 const QString default_theme = 4037 const QString default_theme =
4038 QString::fromUtf8(UISettings::themes[static_cast<size_t>(Config::default_theme)].second); 4038 QString::fromUtf8(UISettings::themes[static_cast<size_t>(Config::default_theme)].second);
4039 QString current_theme = UISettings::values.theme; 4039 QString current_theme = UISettings::values.theme;
4040 QStringList theme_paths(default_theme_paths);
4041 4040
4042 if (current_theme.isEmpty()) { 4041 if (current_theme.isEmpty()) {
4043 current_theme = default_theme; 4042 current_theme = default_theme;
@@ -4050,7 +4049,7 @@ void GMainWindow::UpdateUITheme() {
4050 if (current_theme == QStringLiteral("default") || current_theme == QStringLiteral("colorful")) { 4049 if (current_theme == QStringLiteral("default") || current_theme == QStringLiteral("colorful")) {
4051 QIcon::setThemeName(current_theme == QStringLiteral("colorful") ? current_theme 4050 QIcon::setThemeName(current_theme == QStringLiteral("colorful") ? current_theme
4052 : startup_icon_theme); 4051 : startup_icon_theme);
4053 QIcon::setThemeSearchPaths(theme_paths); 4052 QIcon::setThemeSearchPaths(QStringList(default_theme_paths));
4054 if (CheckDarkMode()) { 4053 if (CheckDarkMode()) {
4055 current_theme = QStringLiteral("default_dark"); 4054 current_theme = QStringLiteral("default_dark");
4056 } 4055 }