compile and commit this hard stuff
This commit is contained in:
parent
62edb120c1
commit
520150c78a
|
@ -12,7 +12,7 @@
|
|||
#include "core/hle/service/am/applets/applet_cabinet.h"
|
||||
#include "core/hle/service/mii/mii_manager.h"
|
||||
#include "core/hle/service/nfc/common/device.h"
|
||||
#include "core/hle/service/hid/hid_server/hid_types.h"
|
||||
#include "core/hle/service/hid/hid_types.h"
|
||||
|
||||
namespace Service::AM::Applets {
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "core/core.h"
|
||||
#include "core/frontend/applets/controller.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/service/hid/hid_server/hid_types.h"
|
||||
#include "core/hle/service/hid/hid_types.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/am/am.h"
|
||||
#include "core/hle/service/am/applets/applet_controller.h"
|
||||
|
|
|
@ -20,6 +20,7 @@ constexpr Result ResultInvalidNpadId{ErrorModule::HID, 709};
|
|||
constexpr Result ResultNpadNotConnected{ErrorModule::HID, 710};
|
||||
constexpr Result ResultInvalidArraySize{ErrorModule::HID, 715};
|
||||
constexpr Result ResultUndefinedStyleSet{ErrorModule::HID, 716};
|
||||
constexpr Result ResultInvalidStyleSet{ErrorModule::HID, 717};
|
||||
|
||||
constexpr Result ResultUnknown108{ErrorModule::HID, 108};
|
||||
|
||||
|
|
|
@ -338,6 +338,10 @@ struct NpadStyleTag {
|
|||
BitField<30, 1, u32> system;
|
||||
};
|
||||
|
||||
NpadStyleTag() {
|
||||
raw = NpadStyleSet::None;
|
||||
}
|
||||
|
||||
NpadStyleTag(NpadStyleSet style_set) {
|
||||
raw = style_set;
|
||||
}
|
||||
|
|
|
@ -81,4 +81,23 @@ constexpr NpadIdType IndexToNpadIdType(size_t index) {
|
|||
}
|
||||
}
|
||||
|
||||
constexpr NpadStyleSet GetStylesetByIndex(std::size_t index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return NpadStyleSet::Fullkey;
|
||||
case 1:
|
||||
return NpadStyleSet::Handheld;
|
||||
case 2:
|
||||
return NpadStyleSet::JoyDual;
|
||||
case 3:
|
||||
return NpadStyleSet::JoyLeft;
|
||||
case 4:
|
||||
return NpadStyleSet::JoyRight;
|
||||
case 5:
|
||||
return NpadStyleSet::Palma;
|
||||
default:
|
||||
return NpadStyleSet::None;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace Service::HID {
|
|||
return player_memory;
|
||||
}*/
|
||||
|
||||
ResourceManager::ResourceManager(Core::System& system_) {}
|
||||
ResourceManager::ResourceManager(Core::System& system_) : service_context{system_, "hid"} {}
|
||||
|
||||
ResourceManager::~ResourceManager() = default;
|
||||
|
||||
|
@ -76,7 +76,7 @@ void ResourceManager::Initialize() {
|
|||
gesture = std::make_shared<Gesture>();
|
||||
keyboard = std::make_shared<Keyboard>();
|
||||
mouse = std::make_shared<Mouse>();
|
||||
npad = std::make_shared<Npad>();
|
||||
npad = std::make_shared<Npad>(service_context);
|
||||
palma = std::make_shared<Palma>();
|
||||
sixaxis = std::make_shared<SixAxis>();
|
||||
touch_screen = std::make_shared<TouchScreen>();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "core/hle/service/service.h"
|
||||
#include "core/hle/service/kernel_helpers.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
|
@ -38,7 +39,6 @@ public:
|
|||
std::shared_ptr<SixAxis> GetSixAxis();
|
||||
std::shared_ptr<TouchScreen> GetTouchScreen();
|
||||
|
||||
|
||||
std::shared_ptr<DebugPad> debug_pad = nullptr;
|
||||
std::shared_ptr<Gesture> gesture = nullptr;
|
||||
std::shared_ptr<Keyboard> keyboard = nullptr;
|
||||
|
@ -47,6 +47,8 @@ public:
|
|||
std::shared_ptr<Palma> palma = nullptr;
|
||||
std::shared_ptr<SixAxis> sixaxis = nullptr;
|
||||
std::shared_ptr<TouchScreen> touch_screen = nullptr;
|
||||
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
};
|
||||
|
||||
} // namespace Service::HID
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "core/hle/service/hid/hid_types.h"
|
||||
#include "core/hle/service/hid/hid_util.h"
|
||||
#include "core/hle/service/hid/resource_manager/npad.h"
|
||||
#include "core/hle/service/kernel_helpers.h"
|
||||
|
||||
#pragma optimize("", off)
|
||||
namespace Service::HID {
|
||||
|
@ -97,11 +96,12 @@ NpadJoyHoldType NpadState::GetNpadJoyHoldType() const {
|
|||
}
|
||||
|
||||
Result NpadState::SetSupportedNpadIdType(std::span<const NpadIdType> list) {
|
||||
if (list.size() >= SUPPORTED_NPAD_TYPES_MAX) {
|
||||
// Note: Real limit is 11. But array size is 10. N's bug?
|
||||
if (list.size() >= PLAYERS_MAX) {
|
||||
return ResultInvalidArraySize;
|
||||
}
|
||||
|
||||
data.supported_npad_id_types_count = list.size();
|
||||
data.supported_npad_id_types_count = static_cast<u32>(list.size());
|
||||
memcpy(data.supported_npad_id_types.data(), list.data(), list.size_bytes());
|
||||
|
||||
return ResultSuccess;
|
||||
|
@ -141,6 +141,10 @@ void NpadState::SetNpadAnalogStickUseCenterClampImpl(const bool is_enabled) {
|
|||
data.status.use_center_clamp.Assign(is_enabled);
|
||||
}
|
||||
|
||||
void NpadState::SetCaptureButtonAssignment(std::size_t index, NpadButton npad_button_set) {
|
||||
data.npad_button_assignment[index] = npad_button_set;
|
||||
}
|
||||
|
||||
Npad::Npad(KernelHelpers::ServiceContext& context) : service_context{context} {
|
||||
for (auto& npad : npad_state) {
|
||||
npad = std::make_shared<NpadState>();
|
||||
|
@ -566,7 +570,19 @@ Result Npad::EnableUnintendedHomeButtonInputProtection(const u64 aruid, const Np
|
|||
}
|
||||
|
||||
void Npad::SetNpadAnalogStickUseCenterClamp(const u64 aruid, const bool use_center_clamp) {
|
||||
std::scoped_lock lock{mutex};
|
||||
SetNpadAnalogStickUseCenterClampImpl(aruid, use_center_clamp);
|
||||
// update abstract handles
|
||||
// UpdateAbstractCenterClamp(GetAbstractHandle(param_1->abstract_active_player));
|
||||
// UpdateAbstractCenterClamp(GetAbstractHandle(param_1->abstract_active_player+1));
|
||||
// UpdateAbstractCenterClamp(GetAbstractHandle(param_1->abstract_active_player+2));
|
||||
// UpdateAbstractCenterClamp(GetAbstractHandle(param_1->abstract_active_player+3));
|
||||
// UpdateAbstractCenterClamp(GetAbstractHandle(param_1->abstract_active_player+4));
|
||||
// UpdateAbstractCenterClamp(GetAbstractHandle(param_1->abstract_active_player+5));
|
||||
// UpdateAbstractCenterClamp(GetAbstractHandle(param_1->abstract_active_player+6));
|
||||
// UpdateAbstractCenterClamp(GetAbstractHandle(param_1->abstract_active_player+7));
|
||||
// UpdateAbstractCenterClamp(GetAbstractHandle(param_1->abstract_active_player+8));
|
||||
// UpdateAbstractCenterClamp(GetAbstractHandle(param_1->abstract_active_player+9));
|
||||
}
|
||||
|
||||
Result Npad::SetNpadAnalogStickUseCenterClampImpl(const u64 aruid, const bool use_center_clamp) {
|
||||
|
@ -585,13 +601,55 @@ Result Npad::SetNpadAnalogStickUseCenterClampImpl(const u64 aruid, const bool us
|
|||
}
|
||||
|
||||
Result Npad::SetNpadCaptureButtonAssignment(const u64 aruid, const NpadStyleSet npad_styleset,
|
||||
const NpadButton buttons) {
|
||||
// tooo complicated
|
||||
const NpadButton npad_button_set) {
|
||||
std::scoped_lock lock{mutex};
|
||||
const auto index = GetIndexFromAruid(aruid);
|
||||
|
||||
if (index >= ARUID_MAX) {
|
||||
return ResultNpadNotConnected;
|
||||
}
|
||||
|
||||
// Must be a power of two
|
||||
const auto raw_styleset = static_cast<u32>(npad_styleset);
|
||||
if (raw_styleset == 0 && (raw_styleset & (raw_styleset - 1)) != 0) {
|
||||
return ResultInvalidStyleSet;
|
||||
}
|
||||
|
||||
int style_index{};
|
||||
NpadStyleSet style_selected{};
|
||||
for (style_index = 0; style_index < 7; ++style_index) {
|
||||
style_selected = GetStylesetByIndex(style_index);
|
||||
if (npad_styleset == style_selected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (style_selected == NpadStyleSet::None) {
|
||||
return ResultInvalidStyleSet;
|
||||
}
|
||||
|
||||
npad_state[index]->SetCaptureButtonAssignment(style_index, npad_button_set);
|
||||
if (active_aruid == aruid) {
|
||||
active_npad_state->SetCaptureButtonAssignment(style_index, npad_button_set);
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result Npad::ClearNpadCaptureButtonAssignment(const u64 aruid) {
|
||||
std::scoped_lock lock{mutex};
|
||||
const auto index = GetIndexFromAruid(aruid);
|
||||
|
||||
if (index >= ARUID_MAX) {
|
||||
return ResultNpadNotConnected;
|
||||
}
|
||||
|
||||
for (std::size_t style_index = 0; style_index < 7; ++style_index) {
|
||||
npad_state[index]->SetCaptureButtonAssignment(style_index, NpadButton::None);
|
||||
if (active_aruid == aruid) {
|
||||
active_npad_state->SetCaptureButtonAssignment(style_index, NpadButton::None);
|
||||
}
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
|
||||
#include "core/hle/service/hid/resource_manager/base_resource.h"
|
||||
#include "core/hle/service/kernel_helpers.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
|
@ -15,10 +18,6 @@ namespace Kernel {
|
|||
class KReadableEvent;
|
||||
}
|
||||
|
||||
namespace KernelHelpers {
|
||||
class ServiceContext;
|
||||
}
|
||||
|
||||
namespace Service::HID {
|
||||
enum class NpadIdType : u32;
|
||||
enum class NpadJoyAssignmentMode : u32;
|
||||
|
@ -97,14 +96,17 @@ public:
|
|||
bool IsUnintendedHomeButtonInputProtectionEnabled(const NpadIdType npad_id) const;
|
||||
void SetNpadAnalogStickUseCenterClampImpl(const bool is_enabled);
|
||||
|
||||
void SetCaptureButtonAssignment(std::size_t index, NpadButton npad_button_set);
|
||||
|
||||
private:
|
||||
struct DataStructure {
|
||||
NpadStatus status{};
|
||||
NpadStyleSet supported_npad_style_set{};
|
||||
u32 npad_hold_type{};
|
||||
u32 handheld_activation_mode{};
|
||||
std::array<NpadIdType, SUPPORTED_NPAD_TYPES_MAX> supported_npad_id_types{};
|
||||
INSERT_PADDING_BYTES(0x64);
|
||||
std::array<NpadIdType, PLAYERS_MAX> supported_npad_id_types{};
|
||||
std::array<NpadButton, 7> npad_button_assignment;
|
||||
INSERT_PADDING_BYTES(0x30);
|
||||
u32 supported_npad_id_types_count{};
|
||||
std::array<bool, PLAYERS_MAX> is_unintended_home_button_input_proptection{};
|
||||
INSERT_PADDING_BYTES(0x2);
|
||||
|
@ -164,7 +166,7 @@ public:
|
|||
const bool is_enabled);
|
||||
void SetNpadAnalogStickUseCenterClamp(const u64 aruid, const bool use_center_clamp);
|
||||
Result SetNpadCaptureButtonAssignment(const u64 aruid, const NpadStyleSet npad_styleset,
|
||||
const NpadButton buttons);
|
||||
const NpadButton npad_button_set);
|
||||
Result ClearNpadCaptureButtonAssignment(const u64 aruid);
|
||||
|
||||
// Events
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/hid/hid_server/hid_types.h"
|
||||
#include "core/hle/service/hid/hid_types.h"
|
||||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/nfc/common/device.h"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/service/hid/hid_server/hid_types.h"
|
||||
#include "core/hle/service/hid/hid_types.h"
|
||||
#include "core/hle/service/hid/hid.h"
|
||||
#include "core/hle/service/sm/sm.h"
|
||||
#include "ui_qt_controller.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/service/hid/hid_server/hid_types.h"
|
||||
#include "core/hle/service/hid/hid_types.h"
|
||||
//#include "core/hid/input_interpreter.h"
|
||||
#include "ui_qt_software_keyboard.h"
|
||||
#include "yuzu/applets/qt_software_keyboard.h"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "common/assert.h"
|
||||
#include "common/param_package.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/service/hid/hid_server/hid_types.h"
|
||||
#include "core/hle/service/hid/hid_types.h"
|
||||
#include "input_common/drivers/keyboard.h"
|
||||
#include "input_common/drivers/mouse.h"
|
||||
#include "input_common/main.h"
|
||||
|
|
Loading…
Reference in New Issue