frontend: Add frontend responder for controller applet
This commit is contained in:
@@ -84,6 +84,8 @@ add_library(core STATIC
|
||||
file_sys/vfs_vector.h
|
||||
file_sys/xts_archive.cpp
|
||||
file_sys/xts_archive.h
|
||||
frontend/applets/controller.cpp
|
||||
frontend/applets/controller.h
|
||||
frontend/applets/profile_select.cpp
|
||||
frontend/applets/profile_select.h
|
||||
frontend/applets/software_keyboard.cpp
|
||||
@@ -169,6 +171,8 @@ add_library(core STATIC
|
||||
hle/service/am/applet_oe.h
|
||||
hle/service/am/applets/applets.cpp
|
||||
hle/service/am/applets/applets.h
|
||||
hle/service/am/applets/controller.cpp
|
||||
hle/service/am/applets/controller.h
|
||||
hle/service/am/applets/profile_select.cpp
|
||||
hle/service/am/applets/profile_select.h
|
||||
hle/service/am/applets/software_keyboard.cpp
|
||||
|
||||
38
src/core/frontend/applets/controller.cpp
Normal file
38
src/core/frontend/applets/controller.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// 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(bool)> completed,
|
||||
ControllerParameters parameters) const {
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called, automatically setting controller types to best fit "
|
||||
"in configuration, may be incorrect!");
|
||||
|
||||
const auto& npad =
|
||||
Core::System::GetInstance()
|
||||
.ServiceManager()
|
||||
.GetService<Service::HID::Hid>("hid")
|
||||
->GetAppletResource()
|
||||
->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad);
|
||||
|
||||
for (auto& player : Settings::values.players) {
|
||||
const auto prio = Service::HID::Controller_NPad::MapSettingsTypeToNPad(player.type);
|
||||
player.type =
|
||||
Service::HID::Controller_NPad::MapNPadTypeToSettings(npad.DecideBestController(prio));
|
||||
}
|
||||
|
||||
completed(true);
|
||||
}
|
||||
|
||||
} // namespace Core::Frontend
|
||||
47
src/core/frontend/applets/controller.h
Normal file
47
src/core/frontend/applets/controller.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Core::Frontend {
|
||||
|
||||
struct ControllerParameters {
|
||||
u8 min_players;
|
||||
u8 max_players;
|
||||
bool keep_current_connected;
|
||||
bool merge_dual_joycons;
|
||||
bool allowed_single_layout;
|
||||
|
||||
bool allowed_pro_controller;
|
||||
bool allowed_handheld;
|
||||
bool allowed_joycon_dual;
|
||||
bool allowed_joycon_left;
|
||||
bool allowed_joycon_right;
|
||||
|
||||
bool horizontal_single_joycons;
|
||||
};
|
||||
|
||||
class ControllerApplet {
|
||||
public:
|
||||
virtual ~ControllerApplet();
|
||||
|
||||
virtual void ReconfigureControllers(std::function<void(bool)> completed,
|
||||
ControllerParameters parameters) const = 0;
|
||||
};
|
||||
|
||||
class DefaultControllerApplet final : public ControllerApplet {
|
||||
public:
|
||||
~DefaultControllerApplet() override;
|
||||
|
||||
void ReconfigureControllers(std::function<void(bool)> completed,
|
||||
ControllerParameters parameters) const override;
|
||||
};
|
||||
|
||||
} // namespace Core::Frontend
|
||||
Reference in New Issue
Block a user