summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hid/emulated_controller.cpp6
-rw-r--r--src/core/hle/service/hid/hid.cpp1
-rw-r--r--src/input_common/drivers/gc_adapter.cpp3
-rw-r--r--src/input_common/drivers/gc_adapter.h2
-rw-r--r--src/input_common/drivers/sdl_driver.h2
-rw-r--r--src/input_common/helpers/stick_from_buttons.cpp3
-rw-r--r--src/input_common/helpers/stick_from_buttons.h3
-rw-r--r--src/input_common/helpers/touch_from_buttons.cpp4
-rw-r--r--src/input_common/input_engine.h10
-rw-r--r--src/input_common/input_poller.cpp8
-rw-r--r--src/input_common/input_poller.h10
-rw-r--r--src/input_common/main.cpp6
-rw-r--r--src/yuzu/applets/qt_controller.h1
-rw-r--r--src/yuzu/configuration/configure_dialog.cpp2
-rw-r--r--src/yuzu/configuration/configure_input.cpp9
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.cpp25
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.h16
-rw-r--r--src/yuzu/debugger/controller.cpp9
-rw-r--r--src/yuzu/debugger/controller.h9
-rw-r--r--src/yuzu/main.cpp7
20 files changed, 83 insertions, 53 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index b9d16657a..b04ab4cd8 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -91,6 +91,7 @@ void EmulatedController::ReloadFromSettings() {
91} 91}
92 92
93void EmulatedController::ReloadInput() { 93void EmulatedController::ReloadInput() {
94 // If you load any device here add the equivalent to the UnloadInput() function
94 const auto player_index = NpadIdTypeToIndex(npad_id_type); 95 const auto player_index = NpadIdTypeToIndex(npad_id_type);
95 const auto left_side = button_params[Settings::NativeButton::ZL]; 96 const auto left_side = button_params[Settings::NativeButton::ZL];
96 const auto right_side = button_params[Settings::NativeButton::ZR]; 97 const auto right_side = button_params[Settings::NativeButton::ZR];
@@ -113,7 +114,7 @@ void EmulatedController::ReloadInput() {
113 battery_devices[0] = Input::CreateDevice<Input::InputDevice>(left_side); 114 battery_devices[0] = Input::CreateDevice<Input::InputDevice>(left_side);
114 battery_devices[1] = Input::CreateDevice<Input::InputDevice>(right_side); 115 battery_devices[1] = Input::CreateDevice<Input::InputDevice>(right_side);
115 116
116 button_params[Settings::NativeButton::ZL].Set("output",true); 117 button_params[Settings::NativeButton::ZL].Set("output", true);
117 output_devices[0] = 118 output_devices[0] =
118 Input::CreateDevice<Input::OutputDevice>(button_params[Settings::NativeButton::ZL]); 119 Input::CreateDevice<Input::OutputDevice>(button_params[Settings::NativeButton::ZL]);
119 120
@@ -179,6 +180,9 @@ void EmulatedController::UnloadInput() {
179 for (auto& battery : battery_devices) { 180 for (auto& battery : battery_devices) {
180 battery.reset(); 181 battery.reset();
181 } 182 }
183 for (auto& output : output_devices) {
184 output.reset();
185 }
182} 186}
183 187
184void EmulatedController::EnableConfiguration() { 188void EmulatedController::EnableConfiguration() {
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 18f29bb78..5391334f4 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -8,7 +8,6 @@
8#include "common/settings.h" 8#include "common/settings.h"
9#include "core/core.h" 9#include "core/core.h"
10#include "core/core_timing.h" 10#include "core/core_timing.h"
11#include "core/frontend/input.h"
12#include "core/hardware_properties.h" 11#include "core/hardware_properties.h"
13#include "core/hle/ipc_helpers.h" 12#include "core/hle/ipc_helpers.h"
14#include "core/hle/kernel/k_readable_event.h" 13#include "core/hle/kernel/k_readable_event.h"
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp
index 2aa5a16a6..4a56abb99 100644
--- a/src/input_common/drivers/gc_adapter.cpp
+++ b/src/input_common/drivers/gc_adapter.cpp
@@ -322,7 +322,8 @@ bool GCAdapter::GetGCEndpoint(libusb_device* device) {
322 return true; 322 return true;
323} 323}
324 324
325Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier, const Input::VibrationStatus vibration) { 325Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier,
326 const Input::VibrationStatus vibration) {
326 const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; 327 const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f;
327 const auto processed_amplitude = 328 const auto processed_amplitude =
328 static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8); 329 static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8);
diff --git a/src/input_common/drivers/gc_adapter.h b/src/input_common/drivers/gc_adapter.h
index dd23dd9f3..dd0e4aa1d 100644
--- a/src/input_common/drivers/gc_adapter.h
+++ b/src/input_common/drivers/gc_adapter.h
@@ -25,7 +25,7 @@ public:
25 ~GCAdapter(); 25 ~GCAdapter();
26 26
27 Input::VibrationError SetRumble(const PadIdentifier& identifier, 27 Input::VibrationError SetRumble(const PadIdentifier& identifier,
28 const Input::VibrationStatus vibration) override; 28 const Input::VibrationStatus vibration) override;
29 29
30 /// Used for automapping features 30 /// Used for automapping features
31 std::vector<Common::ParamPackage> GetInputDevices() const override; 31 std::vector<Common::ParamPackage> GetInputDevices() const override;
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h
index f66b33c77..1ff85f48d 100644
--- a/src/input_common/drivers/sdl_driver.h
+++ b/src/input_common/drivers/sdl_driver.h
@@ -59,7 +59,7 @@ public:
59 u8 GetHatButtonId(const std::string direction_name) const override; 59 u8 GetHatButtonId(const std::string direction_name) const override;
60 60
61 Input::VibrationError SetRumble(const PadIdentifier& identifier, 61 Input::VibrationError SetRumble(const PadIdentifier& identifier,
62 const Input::VibrationStatus vibration) override; 62 const Input::VibrationStatus vibration) override;
63 63
64private: 64private:
65 void InitJoystick(int joystick_index); 65 void InitJoystick(int joystick_index);
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp
index 89ba4aeb1..38f150746 100644
--- a/src/input_common/helpers/stick_from_buttons.cpp
+++ b/src/input_common/helpers/stick_from_buttons.cpp
@@ -251,8 +251,7 @@ private:
251 std::chrono::time_point<std::chrono::steady_clock> last_update; 251 std::chrono::time_point<std::chrono::steady_clock> last_update;
252}; 252};
253 253
254std::unique_ptr<Input::InputDevice> StickFromButton::Create( 254std::unique_ptr<Input::InputDevice> StickFromButton::Create(const Common::ParamPackage& params) {
255 const Common::ParamPackage& params) {
256 const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); 255 const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize();
257 auto up = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("up", null_engine)); 256 auto up = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("up", null_engine));
258 auto down = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("down", null_engine)); 257 auto down = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("down", null_engine));
diff --git a/src/input_common/helpers/stick_from_buttons.h b/src/input_common/helpers/stick_from_buttons.h
index 87165e022..1d6e24c98 100644
--- a/src/input_common/helpers/stick_from_buttons.h
+++ b/src/input_common/helpers/stick_from_buttons.h
@@ -25,8 +25,7 @@ public:
25 * - "modifier": a serialized ParamPackage for creating a button device as the modifier 25 * - "modifier": a serialized ParamPackage for creating a button device as the modifier
26 * - "modifier_scale": a float for the multiplier the modifier gives to the position 26 * - "modifier_scale": a float for the multiplier the modifier gives to the position
27 */ 27 */
28 std::unique_ptr<Input::InputDevice> Create( 28 std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override;
29 const Common::ParamPackage& params) override;
30}; 29};
31 30
32} // namespace InputCommon 31} // namespace InputCommon
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp
index 6c9046ffb..2abfaf841 100644
--- a/src/input_common/helpers/touch_from_buttons.cpp
+++ b/src/input_common/helpers/touch_from_buttons.cpp
@@ -57,9 +57,7 @@ private:
57 const Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; 57 const Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};
58}; 58};
59 59
60 60std::unique_ptr<Input::InputDevice> TouchFromButton::Create(const Common::ParamPackage& params) {
61std::unique_ptr<Input::InputDevice> TouchFromButton::Create(
62 const Common::ParamPackage& params) {
63 const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); 61 const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize();
64 auto button = 62 auto button =
65 Input::CreateDeviceFromString<Input::InputDevice>(params.Get("button", null_engine)); 63 Input::CreateDeviceFromString<Input::InputDevice>(params.Get("button", null_engine));
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h
index 8a953c382..31ce900d7 100644
--- a/src/input_common/input_engine.h
+++ b/src/input_common/input_engine.h
@@ -121,14 +121,16 @@ public:
121 } 121 }
122 122
123 // Sets rumble to a controller 123 // Sets rumble to a controller
124 virtual Input::VibrationError SetRumble([[maybe_unused]] const PadIdentifier& identifier, 124 virtual Input::VibrationError SetRumble(
125 [[maybe_unused]] const Input::VibrationStatus vibration) { 125 [[maybe_unused]] const PadIdentifier& identifier,
126 [[maybe_unused]] const Input::VibrationStatus vibration) {
126 return Input::VibrationError::NotSupported; 127 return Input::VibrationError::NotSupported;
127 } 128 }
128 129
129 // Sets polling mode to a controller 130 // Sets polling mode to a controller
130 virtual Input::PollingError SetPollingMode([[maybe_unused]] const PadIdentifier& identifier, 131 virtual Input::PollingError SetPollingMode(
131 [[maybe_unused]] const Input::PollingMode vibration) { 132 [[maybe_unused]] const PadIdentifier& identifier,
133 [[maybe_unused]] const Input::PollingMode vibration) {
132 return Input::PollingError::NotSupported; 134 return Input::PollingError::NotSupported;
133 } 135 }
134 136
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp
index 781012886..62ade951c 100644
--- a/src/input_common/input_poller.cpp
+++ b/src/input_common/input_poller.cpp
@@ -597,7 +597,7 @@ public:
597 explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) 597 explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_)
598 : identifier(identifier_), input_engine(input_engine_) {} 598 : identifier(identifier_), input_engine(input_engine_) {}
599 599
600 virtual void SetLED( Input::LedStatus led_status) { 600 virtual void SetLED(Input::LedStatus led_status) {
601 input_engine->SetLeds(identifier, led_status); 601 input_engine->SetLeds(identifier, led_status);
602 } 602 }
603 603
@@ -847,8 +847,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par
847InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_) 847InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_)
848 : input_engine(std::move(input_engine_)) {} 848 : input_engine(std::move(input_engine_)) {}
849 849
850std::unique_ptr<Input::InputDevice> InputFactory::Create( 850std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPackage& params) {
851 const Common::ParamPackage& params) {
852 if (params.Has("button") && params.Has("axis")) { 851 if (params.Has("button") && params.Has("axis")) {
853 return CreateTriggerDevice(params); 852 return CreateTriggerDevice(params);
854 } 853 }
@@ -883,8 +882,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::Create(
883OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_) 882OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_)
884 : input_engine(std::move(input_engine_)) {} 883 : input_engine(std::move(input_engine_)) {}
885 884
886std::unique_ptr<Input::OutputDevice> OutputFactory::Create( 885std::unique_ptr<Input::OutputDevice> OutputFactory::Create(const Common::ParamPackage& params) {
887 const Common::ParamPackage& params) {
888 const PadIdentifier identifier = { 886 const PadIdentifier identifier = {
889 .guid = Common::UUID{params.Get("guid", "")}, 887 .guid = Common::UUID{params.Get("guid", "")},
890 .port = static_cast<std::size_t>(params.Get("port", 0)), 888 .port = static_cast<std::size_t>(params.Get("port", 0)),
diff --git a/src/input_common/input_poller.h b/src/input_common/input_poller.h
index 16cade5fa..1357e104b 100644
--- a/src/input_common/input_poller.h
+++ b/src/input_common/input_poller.h
@@ -29,8 +29,7 @@ public:
29 * @param - "pad": slot of the connected controller 29 * @param - "pad": slot of the connected controller
30 * @return an unique ouput device with the parameters specified 30 * @return an unique ouput device with the parameters specified
31 */ 31 */
32 std::unique_ptr<Input::OutputDevice> Create( 32 std::unique_ptr<Input::OutputDevice> Create(const Common::ParamPackage& params) override;
33 const Common::ParamPackage& params) override;
34 33
35private: 34private:
36 std::shared_ptr<InputEngine> input_engine; 35 std::shared_ptr<InputEngine> input_engine;
@@ -41,8 +40,8 @@ public:
41 explicit InputFactory(std::shared_ptr<InputEngine> input_engine_); 40 explicit InputFactory(std::shared_ptr<InputEngine> input_engine_);
42 41
43 /** 42 /**
44 * Creates an input device from the parameters given. Identifies the type of input to be returned 43 * Creates an input device from the parameters given. Identifies the type of input to be
45 * if it contains the following parameters: 44 * returned if it contains the following parameters:
46 * - button: Contains "button" or "code" 45 * - button: Contains "button" or "code"
47 * - hat_button: Contains "hat" 46 * - hat_button: Contains "hat"
48 * - analog: Contains "axis" 47 * - analog: Contains "axis"
@@ -65,8 +64,7 @@ public:
65 * @param - "battery": Only used as a placeholder to set the input type 64 * @param - "battery": Only used as a placeholder to set the input type
66 * @return an unique input device with the parameters specified 65 * @return an unique input device with the parameters specified
67 */ 66 */
68 std::unique_ptr<Input::InputDevice> Create( 67 std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override;
69 const Common::ParamPackage& params) override;
70 68
71private: 69private:
72 /** 70 /**
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index b7fe9cb37..7807dd38f 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -48,8 +48,10 @@ struct InputSubsystem::Impl {
48 gcadapter->SetMappingCallback(mapping_callback); 48 gcadapter->SetMappingCallback(mapping_callback);
49 gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter); 49 gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter);
50 gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter); 50 gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter);
51 Input::RegisterFactory<Input::InputDevice>(gcadapter->GetEngineName(), gcadapter_input_factory); 51 Input::RegisterFactory<Input::InputDevice>(gcadapter->GetEngineName(),
52 Input::RegisterFactory<Input::OutputDevice>(gcadapter->GetEngineName(), gcadapter_output_factory); 52 gcadapter_input_factory);
53 Input::RegisterFactory<Input::OutputDevice>(gcadapter->GetEngineName(),
54 gcadapter_output_factory);
53 55
54 udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp"); 56 udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp");
55 udp_client->SetMappingCallback(mapping_callback); 57 udp_client->SetMappingCallback(mapping_callback);
diff --git a/src/yuzu/applets/qt_controller.h b/src/yuzu/applets/qt_controller.h
index 98060e6f8..ca09fde04 100644
--- a/src/yuzu/applets/qt_controller.h
+++ b/src/yuzu/applets/qt_controller.h
@@ -106,7 +106,6 @@ private:
106 Core::Frontend::ControllerParameters parameters; 106 Core::Frontend::ControllerParameters parameters;
107 107
108 InputCommon::InputSubsystem* input_subsystem; 108 InputCommon::InputSubsystem* input_subsystem;
109 Core::System& system;
110 109
111 std::unique_ptr<InputProfiles> input_profiles; 110 std::unique_ptr<InputProfiles> input_profiles;
112 111
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp
index 642a5f966..1eb9d70e5 100644
--- a/src/yuzu/configuration/configure_dialog.cpp
+++ b/src/yuzu/configuration/configure_dialog.cpp
@@ -74,7 +74,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
74 hotkeys_tab->Populate(registry); 74 hotkeys_tab->Populate(registry);
75 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); 75 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
76 76
77 input_tab->Initialize(input_subsystem); 77 input_tab->Initialize(input_subsystem, system_);
78 78
79 general_tab->SetResetCallback([&] { this->close(); }); 79 general_tab->SetResetCallback([&] { this->close(); });
80 80
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp
index 61513865f..a8611f77f 100644
--- a/src/yuzu/configuration/configure_input.cpp
+++ b/src/yuzu/configuration/configure_input.cpp
@@ -146,10 +146,11 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, Co
146 advanced = new ConfigureInputAdvanced(this); 146 advanced = new ConfigureInputAdvanced(this);
147 ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced)); 147 ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced));
148 ui->tabAdvanced->layout()->addWidget(advanced); 148 ui->tabAdvanced->layout()->addWidget(advanced);
149 connect(advanced, &ConfigureInputAdvanced::CallDebugControllerDialog, [this, input_subsystem] { 149 connect(advanced, &ConfigureInputAdvanced::CallDebugControllerDialog,
150 CallConfigureDialog<ConfigureDebugController>(*this, input_subsystem, profiles.get(), 150 [this, input_subsystem, &system] {
151 system); 151 CallConfigureDialog<ConfigureDebugController>(*this, input_subsystem,
152 }); 152 profiles.get(), system);
153 });
153 connect(advanced, &ConfigureInputAdvanced::CallMouseConfigDialog, [this, input_subsystem] { 154 connect(advanced, &ConfigureInputAdvanced::CallMouseConfigDialog, [this, input_subsystem] {
154 CallConfigureDialog<ConfigureMouseAdvanced>(*this, input_subsystem); 155 CallConfigureDialog<ConfigureMouseAdvanced>(*this, input_subsystem);
155 }); 156 });
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 2ba9d7290..446b72e55 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -19,15 +19,11 @@ PlayerControlPreview::PlayerControlPreview(QWidget* parent) : QFrame(parent) {
19} 19}
20 20
21PlayerControlPreview::~PlayerControlPreview() { 21PlayerControlPreview::~PlayerControlPreview() {
22 if (is_controller_set) { 22 UnloadController();
23 controller->DeleteCallback(callback_key);
24 }
25}; 23};
26 24
27void PlayerControlPreview::SetController(Core::HID::EmulatedController* controller_) { 25void PlayerControlPreview::SetController(Core::HID::EmulatedController* controller_) {
28 if (is_controller_set) { 26 UnloadController();
29 controller->DeleteCallback(callback_key);
30 }
31 is_controller_set = true; 27 is_controller_set = true;
32 controller = controller_; 28 controller = controller_;
33 Core::HID::ControllerUpdateCallback engine_callback{ 29 Core::HID::ControllerUpdateCallback engine_callback{
@@ -36,14 +32,21 @@ void PlayerControlPreview::SetController(Core::HID::EmulatedController* controll
36 ControllerUpdate(Core::HID::ControllerTriggerType::All); 32 ControllerUpdate(Core::HID::ControllerTriggerType::All);
37} 33}
38 34
39void PlayerControlPreview::BeginMappingButton(std::size_t index) { 35void PlayerControlPreview::UnloadController() {
40 button_mapping_index = index; 36 if (is_controller_set) {
37 controller->DeleteCallback(callback_key);
38 is_controller_set = false;
39 }
40}
41
42void PlayerControlPreview::BeginMappingButton(std::size_t button_id) {
43 button_mapping_index = button_id;
41 mapping_active = true; 44 mapping_active = true;
42} 45}
43 46
44void PlayerControlPreview::BeginMappingAnalog(std::size_t index) { 47void PlayerControlPreview::BeginMappingAnalog(std::size_t stick_id) {
45 button_mapping_index = Settings::NativeButton::LStick + index; 48 button_mapping_index = Settings::NativeButton::LStick + stick_id;
46 analog_mapping_index = index; 49 analog_mapping_index = stick_id;
47 mapping_active = true; 50 mapping_active = true;
48} 51}
49 52
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index 16f9748f5..333c3fc56 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -25,11 +25,25 @@ public:
25 explicit PlayerControlPreview(QWidget* parent); 25 explicit PlayerControlPreview(QWidget* parent);
26 ~PlayerControlPreview() override; 26 ~PlayerControlPreview() override;
27 27
28 // Sets the emulated controller to be displayed
28 void SetController(Core::HID::EmulatedController* controller); 29 void SetController(Core::HID::EmulatedController* controller);
30
31 // Disables events from the emulated controller
32 void UnloadController();
33
34 // Starts blinking animation at the button specified
29 void BeginMappingButton(std::size_t button_id); 35 void BeginMappingButton(std::size_t button_id);
30 void BeginMappingAnalog(std::size_t button_id); 36
37 // Starts moving animation at the stick specified
38 void BeginMappingAnalog(std::size_t stick_id);
39
40 // Stops any ongoing animation
31 void EndMapping(); 41 void EndMapping();
42
43 // Handles emulated controller events
32 void ControllerUpdate(Core::HID::ControllerTriggerType type); 44 void ControllerUpdate(Core::HID::ControllerTriggerType type);
45
46 // Updates input on sheduled interval
33 void UpdateInput(); 47 void UpdateInput();
34 48
35protected: 49protected:
diff --git a/src/yuzu/debugger/controller.cpp b/src/yuzu/debugger/controller.cpp
index d8e41f8b6..3619aed26 100644
--- a/src/yuzu/debugger/controller.cpp
+++ b/src/yuzu/debugger/controller.cpp
@@ -10,7 +10,8 @@
10#include "yuzu/configuration/configure_input_player_widget.h" 10#include "yuzu/configuration/configure_input_player_widget.h"
11#include "yuzu/debugger/controller.h" 11#include "yuzu/debugger/controller.h"
12 12
13ControllerDialog::ControllerDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) { 13ControllerDialog::ControllerDialog(Core::System& system, QWidget* parent)
14 : QWidget(parent, Qt::Dialog) {
14 setObjectName(QStringLiteral("Controller")); 15 setObjectName(QStringLiteral("Controller"));
15 setWindowTitle(tr("Controller P1")); 16 setWindowTitle(tr("Controller P1"));
16 resize(500, 350); 17 resize(500, 350);
@@ -20,7 +21,7 @@ ControllerDialog::ControllerDialog(QWidget* parent) : QWidget(parent, Qt::Dialog
20 Qt::WindowMaximizeButtonHint); 21 Qt::WindowMaximizeButtonHint);
21 22
22 widget = new PlayerControlPreview(this); 23 widget = new PlayerControlPreview(this);
23 widget->SetController(Core::System::GetInstance().HIDCore().GetEmulatedController( 24 widget->SetController(system.HIDCore().GetEmulatedController(
24 Core::HID::NpadIdType::Player1)); 25 Core::HID::NpadIdType::Player1));
25 QLayout* layout = new QVBoxLayout(this); 26 QLayout* layout = new QVBoxLayout(this);
26 layout->setContentsMargins(0, 0, 0, 0); 27 layout->setContentsMargins(0, 0, 0, 0);
@@ -45,6 +46,10 @@ QAction* ControllerDialog::toggleViewAction() {
45 return toggle_view_action; 46 return toggle_view_action;
46} 47}
47 48
49void ControllerDialog::UnloadController() {
50 widget->UnloadController();
51}
52
48void ControllerDialog::showEvent(QShowEvent* ev) { 53void ControllerDialog::showEvent(QShowEvent* ev) {
49 if (toggle_view_action) { 54 if (toggle_view_action) {
50 toggle_view_action->setChecked(isVisible()); 55 toggle_view_action->setChecked(isVisible());
diff --git a/src/yuzu/debugger/controller.h b/src/yuzu/debugger/controller.h
index 697489cbb..33f617b9b 100644
--- a/src/yuzu/debugger/controller.h
+++ b/src/yuzu/debugger/controller.h
@@ -11,6 +11,10 @@ class QHideEvent;
11class QShowEvent; 11class QShowEvent;
12class PlayerControlPreview; 12class PlayerControlPreview;
13 13
14namespace Core {
15class System;
16}
17
14namespace InputCommon { 18namespace InputCommon {
15class InputSubsystem; 19class InputSubsystem;
16} 20}
@@ -19,11 +23,14 @@ class ControllerDialog : public QWidget {
19 Q_OBJECT 23 Q_OBJECT
20 24
21public: 25public:
22 explicit ControllerDialog(QWidget* parent = nullptr); 26 explicit ControllerDialog(Core::System& system, QWidget* parent = nullptr);
23 27
24 /// Returns a QAction that can be used to toggle visibility of this dialog. 28 /// Returns a QAction that can be used to toggle visibility of this dialog.
25 QAction* toggleViewAction(); 29 QAction* toggleViewAction();
26 30
31 // Disables events from the emulated controller
32 void UnloadController();
33
27protected: 34protected:
28 void showEvent(QShowEvent* ev) override; 35 void showEvent(QShowEvent* ev) override;
29 void hideEvent(QHideEvent* ev) override; 36 void hideEvent(QHideEvent* ev) override;
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 19cb5313f..ae997ccfa 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -228,7 +228,7 @@ GMainWindow::GMainWindow()
228 ConnectMenuEvents(); 228 ConnectMenuEvents();
229 ConnectWidgetEvents(); 229 ConnectWidgetEvents();
230 230
231 Core::System::GetInstance().HIDCore().ReloadInputDevices(); 231 system->HIDCore().ReloadInputDevices();
232 232
233 const auto branch_name = std::string(Common::g_scm_branch); 233 const auto branch_name = std::string(Common::g_scm_branch);
234 const auto description = std::string(Common::g_scm_desc); 234 const auto description = std::string(Common::g_scm_desc);
@@ -924,7 +924,7 @@ void GMainWindow::InitializeDebugWidgets() {
924 waitTreeWidget->hide(); 924 waitTreeWidget->hide();
925 debug_menu->addAction(waitTreeWidget->toggleViewAction()); 925 debug_menu->addAction(waitTreeWidget->toggleViewAction());
926 926
927 controller_dialog = new ControllerDialog(this); 927 controller_dialog = new ControllerDialog(*system, this);
928 controller_dialog->hide(); 928 controller_dialog->hide();
929 debug_menu->addAction(controller_dialog->toggleViewAction()); 929 debug_menu->addAction(controller_dialog->toggleViewAction());
930 930
@@ -3372,7 +3372,8 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
3372 UpdateUISettings(); 3372 UpdateUISettings();
3373 game_list->SaveInterfaceLayout(); 3373 game_list->SaveInterfaceLayout();
3374 hotkey_registry.SaveHotkeys(); 3374 hotkey_registry.SaveHotkeys();
3375 Core::System::GetInstance().HIDCore().UnloadInputDevices(); 3375 controller_dialog->UnloadController();
3376 system->HIDCore().UnloadInputDevices();
3376 3377
3377 // Shutdown session if the emu thread is active... 3378 // Shutdown session if the emu thread is active...
3378 if (emu_thread != nullptr) { 3379 if (emu_thread != nullptr) {