diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2020-08-21 13:39:24 +0200 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2020-09-04 18:23:25 +0200 |
commit | 5219615418920be8502aa24507572cf0930d65ea (patch) | |
tree | d15e05d0bf328d5e289409977cf07b30ca84fe7e /src/core/frontend | |
parent | Merge pull request #4596 from FearlessTobi/port-5495 (diff) | |
download | yuzu-5219615418920be8502aa24507572cf0930d65ea.tar yuzu-5219615418920be8502aa24507572cf0930d65ea.tar.gz yuzu-5219615418920be8502aa24507572cf0930d65ea.tar.bz2 yuzu-5219615418920be8502aa24507572cf0930d65ea.tar.lz yuzu-5219615418920be8502aa24507572cf0930d65ea.tar.xz yuzu-5219615418920be8502aa24507572cf0930d65ea.tar.zst yuzu-5219615418920be8502aa24507572cf0930d65ea.zip |
Diffstat (limited to 'src/core/frontend')
-rw-r--r-- | src/core/frontend/applets/controller.cpp | 40 | ||||
-rw-r--r-- | src/core/frontend/applets/controller.h | 45 |
2 files changed, 85 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 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/core.h" +#include "core/frontend/applets/controller.h" +#include "core/hle/service/hid/controllers/npad.h" +#include "core/hle/service/hid/hid.h" +#include "core/hle/service/sm/sm.h" + +namespace Core::Frontend { + +ControllerApplet::~ControllerApplet() = default; + +DefaultControllerApplet::~DefaultControllerApplet() = default; + +void DefaultControllerApplet::ReconfigureControllers(std::function<void()> callback, + ControllerParameters parameters) const { + LOG_INFO(Service_HID, "called, deducing the best configuration based on the given parameters!"); + + auto& npad = + Core::System::GetInstance() + .ServiceManager() + .GetService<Service::HID::Hid>("hid") + ->GetAppletResource() + ->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad); + + auto& players = Settings::values.players; + + // Deduce the best configuration based on the input parameters. + for (std::size_t index = 0; index < players.size(); ++index) { + // First, disconnect all controllers regardless of the value of keep_controllers_connected. + // This makes it easy to connect the desired controllers. + npad.DisconnectNPadAtIndex(index); + } + + callback(); +} + +} // namespace Core::Frontend diff --git a/src/core/frontend/applets/controller.h b/src/core/frontend/applets/controller.h new file mode 100644 index 000000000..0908f2b69 --- /dev/null +++ b/src/core/frontend/applets/controller.h @@ -0,0 +1,45 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <functional> + +#include "common/common_types.h" + +namespace Core::Frontend { + +using BorderColor = std::array<u8, 4>; + +struct ControllerParameters { + s8 min_players{}; + s8 max_players{}; + bool keep_controllers_connected{}; + bool enable_single_mode{}; + bool enable_border_color{}; + std::vector<BorderColor> border_colors{}; + bool allow_pro_controller{}; + bool allow_handheld{}; + bool allow_dual_joycons{}; + bool allow_left_joycon{}; + bool allow_right_joycon{}; +}; + +class ControllerApplet { +public: + virtual ~ControllerApplet(); + + virtual void ReconfigureControllers(std::function<void()> callback, + ControllerParameters parameters) const = 0; +}; + +class DefaultControllerApplet final : public ControllerApplet { +public: + ~DefaultControllerApplet() override; + + void ReconfigureControllers(std::function<void()> callback, + ControllerParameters parameters) const override; +}; + +} // namespace Core::Frontend |