summaryrefslogtreecommitdiff
path: root/src/core/frontend/applets/controller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/frontend/applets/controller.cpp')
-rw-r--r--src/core/frontend/applets/controller.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/core/frontend/applets/controller.cpp b/src/core/frontend/applets/controller.cpp
new file mode 100644
index 000000000..0fbc7932c
--- /dev/null
+++ b/src/core/frontend/applets/controller.cpp
@@ -0,0 +1,40 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "core/core.h"
6#include "core/frontend/applets/controller.h"
7#include "core/hle/service/hid/controllers/npad.h"
8#include "core/hle/service/hid/hid.h"
9#include "core/hle/service/sm/sm.h"
10
11namespace Core::Frontend {
12
13ControllerApplet::~ControllerApplet() = default;
14
15DefaultControllerApplet::~DefaultControllerApplet() = default;
16
17void DefaultControllerApplet::ReconfigureControllers(std::function<void()> callback,
18 ControllerParameters parameters) const {
19 LOG_INFO(Service_HID, "called, deducing the best configuration based on the given parameters!");
20
21 auto& npad =
22 Core::System::GetInstance()
23 .ServiceManager()
24 .GetService<Service::HID::Hid>("hid")
25 ->GetAppletResource()
26 ->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad);
27
28 auto& players = Settings::values.players;
29
30 // Deduce the best configuration based on the input parameters.
31 for (std::size_t index = 0; index < players.size(); ++index) {
32 // First, disconnect all controllers regardless of the value of keep_controllers_connected.
33 // This makes it easy to connect the desired controllers.
34 npad.DisconnectNPadAtIndex(index);
35 }
36
37 callback();
38}
39
40} // namespace Core::Frontend