summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-11-04 19:08:54 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-25 03:30:27 +0100
commit5d0f3540c4b085103afa27d6120ea29e0324a5a2 (patch)
tree9cdfe756391969476385d3f391d74a6e75aa5889 /src/core
parentconfig: Cleanup and documentation (diff)
downloadyuzu-5d0f3540c4b085103afa27d6120ea29e0324a5a2.tar
yuzu-5d0f3540c4b085103afa27d6120ea29e0324a5a2.tar.gz
yuzu-5d0f3540c4b085103afa27d6120ea29e0324a5a2.tar.bz2
yuzu-5d0f3540c4b085103afa27d6120ea29e0324a5a2.tar.lz
yuzu-5d0f3540c4b085103afa27d6120ea29e0324a5a2.tar.xz
yuzu-5d0f3540c4b085103afa27d6120ea29e0324a5a2.tar.zst
yuzu-5d0f3540c4b085103afa27d6120ea29e0324a5a2.zip
Diffstat (limited to '')
-rw-r--r--src/core/frontend/applets/controller.cpp10
-rw-r--r--src/core/hid/emulated_controller.cpp44
-rw-r--r--src/core/hid/emulated_controller.h18
-rw-r--r--src/core/hid/hid_types.h13
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp129
-rw-r--r--src/core/hle/service/hid/controllers/npad.h11
-rw-r--r--src/core/hle/service/hid/hid.cpp14
7 files changed, 125 insertions, 114 deletions
diff --git a/src/core/frontend/applets/controller.cpp b/src/core/frontend/applets/controller.cpp
index 212ace892..6dbd38ffa 100644
--- a/src/core/frontend/applets/controller.cpp
+++ b/src/core/frontend/applets/controller.cpp
@@ -44,26 +44,26 @@ void DefaultControllerApplet::ReconfigureControllers(std::function<void()> callb
// Connect controllers based on the following priority list from highest to lowest priority:
// Pro Controller -> Dual Joycons -> Left Joycon/Right Joycon -> Handheld
if (parameters.allow_pro_controller) {
- controller->SetNpadType(Core::HID::NpadType::ProController);
+ controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::ProController);
controller->Connect();
} else if (parameters.allow_dual_joycons) {
- controller->SetNpadType(Core::HID::NpadType::JoyconDual);
+ controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::JoyconDual);
controller->Connect();
} else if (parameters.allow_left_joycon && parameters.allow_right_joycon) {
// Assign left joycons to even player indices and right joycons to odd player indices.
// We do this since Captain Toad Treasure Tracker expects a left joycon for Player 1 and
// a right Joycon for Player 2 in 2 Player Assist mode.
if (index % 2 == 0) {
- controller->SetNpadType(Core::HID::NpadType::JoyconLeft);
+ controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::JoyconLeft);
controller->Connect();
} else {
- controller->SetNpadType(Core::HID::NpadType::JoyconRight);
+ controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::JoyconRight);
controller->Connect();
}
} else if (index == 0 && parameters.enable_single_mode && parameters.allow_handheld &&
!Settings::values.use_docked_mode.GetValue()) {
// We should *never* reach here under any normal circumstances.
- controller->SetNpadType(Core::HID::NpadType::Handheld);
+ controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::Handheld);
controller->Connect();
} else {
UNREACHABLE_MSG("Unable to add a new controller based on the given parameters!");
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 6fe3744fd..a200992f2 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -13,38 +13,38 @@ EmulatedController::EmulatedController(NpadIdType npad_id_type_) : npad_id_type(
EmulatedController::~EmulatedController() = default;
-NpadType EmulatedController::MapSettingsTypeToNPad(Settings::ControllerType type) {
+NpadStyleIndex EmulatedController::MapSettingsTypeToNPad(Settings::ControllerType type) {
switch (type) {
case Settings::ControllerType::ProController:
- return NpadType::ProController;
+ return NpadStyleIndex::ProController;
case Settings::ControllerType::DualJoyconDetached:
- return NpadType::JoyconDual;
+ return NpadStyleIndex::JoyconDual;
case Settings::ControllerType::LeftJoycon:
- return NpadType::JoyconLeft;
+ return NpadStyleIndex::JoyconLeft;
case Settings::ControllerType::RightJoycon:
- return NpadType::JoyconRight;
+ return NpadStyleIndex::JoyconRight;
case Settings::ControllerType::Handheld:
- return NpadType::Handheld;
+ return NpadStyleIndex::Handheld;
case Settings::ControllerType::GameCube:
- return NpadType::GameCube;
+ return NpadStyleIndex::GameCube;
default:
- return NpadType::ProController;
+ return NpadStyleIndex::ProController;
}
}
-Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadType type) {
+Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadStyleIndex type) {
switch (type) {
- case NpadType::ProController:
+ case NpadStyleIndex::ProController:
return Settings::ControllerType::ProController;
- case NpadType::JoyconDual:
+ case NpadStyleIndex::JoyconDual:
return Settings::ControllerType::DualJoyconDetached;
- case NpadType::JoyconLeft:
+ case NpadStyleIndex::JoyconLeft:
return Settings::ControllerType::LeftJoycon;
- case NpadType::JoyconRight:
+ case NpadStyleIndex::JoyconRight:
return Settings::ControllerType::RightJoycon;
- case NpadType::Handheld:
+ case NpadStyleIndex::Handheld:
return Settings::ControllerType::Handheld;
- case NpadType::GameCube:
+ case NpadStyleIndex::GameCube:
return Settings::ControllerType::GameCube;
default:
return Settings::ControllerType::ProController;
@@ -79,9 +79,9 @@ void EmulatedController::ReloadFromSettings() {
// Other or debug controller should always be a pro controller
if (npad_id_type != NpadIdType::Other) {
- SetNpadType(MapSettingsTypeToNPad(player.controller_type));
+ SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
} else {
- SetNpadType(NpadType::ProController);
+ SetNpadStyleIndex(NpadStyleIndex::ProController);
}
if (player.connected) {
@@ -306,7 +306,7 @@ void EmulatedController::DisableConfiguration() {
if (is_connected) {
Disconnect();
}
- SetNpadType(tmp_npad_type);
+ SetNpadStyleIndex(tmp_npad_type);
}
// Apply temporary connected status to the real controller
@@ -569,10 +569,10 @@ void EmulatedController::SetButton(Common::Input::CallbackStatus callback, std::
}
}
if (!is_connected) {
- if (npad_id_type == NpadIdType::Player1 && npad_type != NpadType::Handheld) {
+ if (npad_id_type == NpadIdType::Player1 && npad_type != NpadStyleIndex::Handheld) {
Connect();
}
- if (npad_id_type == NpadIdType::Handheld && npad_type == NpadType::Handheld) {
+ if (npad_id_type == NpadIdType::Handheld && npad_type == NpadStyleIndex::Handheld) {
Connect();
}
}
@@ -896,14 +896,14 @@ NpadIdType EmulatedController::GetNpadIdType() const {
return npad_id_type;
}
-NpadType EmulatedController::GetNpadType(bool get_temporary_value) const {
+NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) const {
if (get_temporary_value) {
return tmp_npad_type;
}
return npad_type;
}
-void EmulatedController::SetNpadType(NpadType npad_type_) {
+void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) {
{
std::lock_guard lock{mutex};
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h
index 9a8bdf14d..fa2e89c0b 100644
--- a/src/core/hid/emulated_controller.h
+++ b/src/core/hid/emulated_controller.h
@@ -142,23 +142,23 @@ public:
YUZU_NON_MOVEABLE(EmulatedController);
/// Converts the controller type from settings to npad type
- static NpadType MapSettingsTypeToNPad(Settings::ControllerType type);
+ static NpadStyleIndex MapSettingsTypeToNPad(Settings::ControllerType type);
/// Converts npad type to the equivalent of controller type from settings
- static Settings::ControllerType MapNPadToSettingsType(NpadType type);
+ static Settings::ControllerType MapNPadToSettingsType(NpadStyleIndex type);
/// Gets the NpadIdType for this controller
NpadIdType GetNpadIdType() const;
- /// Sets the NpadType for this controller
- void SetNpadType(NpadType npad_type_);
+ /// Sets the NpadStyleIndex for this controller
+ void SetNpadStyleIndex(NpadStyleIndex npad_type_);
/**
- * Gets the NpadType for this controller
+ * Gets the NpadStyleIndex for this controller
* @param If true tmp_npad_type will be returned
- * @return NpadType set on the controller
+ * @return NpadStyleIndex set on the controller
*/
- NpadType GetNpadType(bool get_temporary_value = false) const;
+ NpadStyleIndex GetNpadStyleIndex(bool get_temporary_value = false) const;
/// Sets the connected status to true
void Connect();
@@ -351,14 +351,14 @@ private:
void TriggerOnChange(ControllerTriggerType type, bool is_service_update);
NpadIdType npad_id_type;
- NpadType npad_type{NpadType::None};
+ NpadStyleIndex npad_type{NpadStyleIndex::None};
bool is_connected{false};
bool is_configuring{false};
f32 motion_sensitivity{0.01f};
bool force_update_motion{false};
// Temporary values to avoid doing changes while the controller is on configuration mode
- NpadType tmp_npad_type{NpadType::None};
+ NpadStyleIndex tmp_npad_type{NpadStyleIndex::None};
bool tmp_is_connected{false};
ButtonParams button_params;
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h
index f8a0d5edd..7e4f6a804 100644
--- a/src/core/hid/hid_types.h
+++ b/src/core/hid/hid_types.h
@@ -84,8 +84,8 @@ constexpr NpadIdType IndexToNpadIdType(size_t index) {
}
}
-// This is nn::hid::NpadType
-enum class NpadType : u8 {
+// This is nn::hid::NpadStyleIndex
+enum class NpadStyleIndex : u8 {
None = 0,
ProController = 3,
Handheld = 4,
@@ -94,7 +94,14 @@ enum class NpadType : u8 {
JoyconRight = 7,
GameCube = 8,
Pokeball = 9,
- MaxNpadType = 10,
+ NES = 10,
+ HandheldNES = 11,
+ SNES = 12,
+ N64 = 13,
+ SegaGenesis = 14,
+ SystemExt = 32,
+ System = 33,
+ MaxNpadType = 34,
};
// This is nn::hid::NpadStyleTag
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index 0b5a23696..e4a3d9163 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -93,7 +93,7 @@ bool Controller_NPad::IsNpadIdValid(u32 npad_id) {
bool Controller_NPad::IsDeviceHandleValid(const DeviceHandle& device_handle) {
return IsNpadIdValid(device_handle.npad_id) &&
- device_handle.npad_type < Core::HID::NpadType::MaxNpadType &&
+ device_handle.npad_type < Core::HID::NpadStyleIndex::MaxNpadType &&
device_handle.device_index < DeviceIndex::MaxDeviceIndex;
}
@@ -134,7 +134,7 @@ void Controller_NPad::ControllerUpdate(Core::HID::ControllerTriggerType type,
auto& controller = controller_data[controller_idx];
const auto is_connected = controller.device->IsConnected();
- const auto npad_type = controller.device->GetNpadType();
+ const auto npad_type = controller.device->GetNpadStyleIndex();
switch (type) {
case Core::HID::ControllerTriggerType::Connected:
case Core::HID::ControllerTriggerType::Disconnected:
@@ -161,9 +161,9 @@ void Controller_NPad::ControllerUpdate(Core::HID::ControllerTriggerType type,
void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
auto& controller = controller_data[controller_idx];
- const auto controller_type = controller.device->GetNpadType();
+ const auto controller_type = controller.device->GetNpadStyleIndex();
auto& shared_memory = controller.shared_memory_entry;
- if (controller_type == Core::HID::NpadType::None) {
+ if (controller_type == Core::HID::NpadStyleIndex::None) {
controller.styleset_changed_event->GetWritableEvent().Signal();
return;
}
@@ -171,10 +171,10 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
shared_memory.device_type.raw = 0;
shared_memory.system_properties.raw = 0;
switch (controller_type) {
- case Core::HID::NpadType::None:
+ case Core::HID::NpadStyleIndex::None:
UNREACHABLE();
break;
- case Core::HID::NpadType::ProController:
+ case Core::HID::NpadStyleIndex::ProController:
shared_memory.style_set.fullkey.Assign(1);
shared_memory.device_type.fullkey.Assign(1);
shared_memory.system_properties.is_vertical.Assign(1);
@@ -183,7 +183,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
shared_memory.assignment_mode = NpadJoyAssignmentMode::Single;
shared_memory.applet_footer.type = AppletFooterUiType::SwitchProController;
break;
- case Core::HID::NpadType::Handheld:
+ case Core::HID::NpadStyleIndex::Handheld:
shared_memory.style_set.handheld.Assign(1);
shared_memory.device_type.handheld_left.Assign(1);
shared_memory.device_type.handheld_right.Assign(1);
@@ -193,7 +193,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual;
shared_memory.applet_footer.type = AppletFooterUiType::HandheldJoyConLeftJoyConRight;
break;
- case Core::HID::NpadType::JoyconDual:
+ case Core::HID::NpadStyleIndex::JoyconDual:
shared_memory.style_set.joycon_dual.Assign(1);
shared_memory.device_type.joycon_left.Assign(1);
shared_memory.device_type.joycon_right.Assign(1);
@@ -203,7 +203,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual;
shared_memory.applet_footer.type = AppletFooterUiType::JoyDual;
break;
- case Core::HID::NpadType::JoyconLeft:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
shared_memory.style_set.joycon_left.Assign(1);
shared_memory.device_type.joycon_left.Assign(1);
shared_memory.system_properties.is_horizontal.Assign(1);
@@ -211,7 +211,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
shared_memory.assignment_mode = NpadJoyAssignmentMode::Single;
shared_memory.applet_footer.type = AppletFooterUiType::JoyLeftHorizontal;
break;
- case Core::HID::NpadType::JoyconRight:
+ case Core::HID::NpadStyleIndex::JoyconRight:
shared_memory.style_set.joycon_right.Assign(1);
shared_memory.device_type.joycon_right.Assign(1);
shared_memory.system_properties.is_horizontal.Assign(1);
@@ -219,14 +219,14 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
shared_memory.assignment_mode = NpadJoyAssignmentMode::Single;
shared_memory.applet_footer.type = AppletFooterUiType::JoyRightHorizontal;
break;
- case Core::HID::NpadType::GameCube:
+ case Core::HID::NpadStyleIndex::GameCube:
shared_memory.style_set.gamecube.Assign(1);
// The GC Controller behaves like a wired Pro Controller
shared_memory.device_type.fullkey.Assign(1);
shared_memory.system_properties.is_vertical.Assign(1);
shared_memory.system_properties.use_plus.Assign(1);
break;
- case Core::HID::NpadType::Pokeball:
+ case Core::HID::NpadStyleIndex::Pokeball:
shared_memory.style_set.palma.Assign(1);
shared_memory.device_type.palma.Assign(1);
shared_memory.assignment_mode = NpadJoyAssignmentMode::Single;
@@ -307,7 +307,7 @@ void Controller_NPad::OnInit() {
const auto& device = controller.device;
if (device->IsConnected()) {
const std::size_t index = Core::HID::NpadIdTypeToIndex(device->GetNpadIdType());
- AddNewControllerAt(device->GetNpadType(), index);
+ AddNewControllerAt(device->GetNpadStyleIndex(), index);
}
}
}
@@ -347,7 +347,7 @@ void Controller_NPad::RequestPadStateUpdate(u32 npad_id) {
std::lock_guard lock{mutex};
const auto controller_idx = NPadIdToIndex(npad_id);
auto& controller = controller_data[controller_idx];
- const auto controller_type = controller.device->GetNpadType();
+ const auto controller_type = controller.device->GetNpadStyleIndex();
if (!controller.device->IsConnected()) {
return;
}
@@ -359,7 +359,7 @@ void Controller_NPad::RequestPadStateUpdate(u32 npad_id) {
using btn = Core::HID::NpadButton;
pad_entry.npad_buttons.raw = btn::None;
- if (controller_type != Core::HID::NpadType::JoyconLeft) {
+ if (controller_type != Core::HID::NpadStyleIndex::JoyconLeft) {
constexpr btn right_button_mask = btn::A | btn::B | btn::X | btn::Y | btn::StickR | btn::R |
btn::ZR | btn::Plus | btn::StickRLeft | btn::StickRUp |
btn::StickRRight | btn::StickRDown;
@@ -367,7 +367,7 @@ void Controller_NPad::RequestPadStateUpdate(u32 npad_id) {
pad_entry.r_stick = stick_state.right;
}
- if (controller_type != Core::HID::NpadType::JoyconRight) {
+ if (controller_type != Core::HID::NpadStyleIndex::JoyconRight) {
constexpr btn left_button_mask =
btn::Left | btn::Up | btn::Right | btn::Down | btn::StickL | btn::L | btn::ZL |
btn::Minus | btn::StickLLeft | btn::StickLUp | btn::StickLRight | btn::StickLDown;
@@ -375,17 +375,17 @@ void Controller_NPad::RequestPadStateUpdate(u32 npad_id) {
pad_entry.l_stick = stick_state.left;
}
- if (controller_type == Core::HID::NpadType::JoyconLeft) {
+ if (controller_type == Core::HID::NpadStyleIndex::JoyconLeft) {
pad_entry.npad_buttons.left_sl.Assign(button_state.left_sl);
pad_entry.npad_buttons.left_sr.Assign(button_state.left_sr);
}
- if (controller_type == Core::HID::NpadType::JoyconRight) {
+ if (controller_type == Core::HID::NpadStyleIndex::JoyconRight) {
pad_entry.npad_buttons.right_sl.Assign(button_state.right_sl);
pad_entry.npad_buttons.right_sr.Assign(button_state.right_sr);
}
- if (controller_type == Core::HID::NpadType::GameCube) {
+ if (controller_type == Core::HID::NpadStyleIndex::GameCube) {
const auto& trigger_state = controller.device->GetTriggers();
trigger_entry.l_analog = trigger_state.left;
trigger_entry.r_analog = trigger_state.right;
@@ -406,9 +406,10 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
auto& controller = controller_data[i];
auto& npad = controller.shared_memory_entry;
- const auto& controller_type = controller.device->GetNpadType();
+ const auto& controller_type = controller.device->GetNpadStyleIndex();
- if (controller_type == Core::HID::NpadType::None || !controller.device->IsConnected()) {
+ if (controller_type == Core::HID::NpadStyleIndex::None ||
+ !controller.device->IsConnected()) {
// Refresh shared memory
std::memcpy(data + NPAD_OFFSET + (i * sizeof(NpadInternalState)),
&controller.shared_memory_entry, sizeof(NpadInternalState));
@@ -426,10 +427,10 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
libnx_state.connection_status.raw = 0;
libnx_state.connection_status.is_connected.Assign(1);
switch (controller_type) {
- case Core::HID::NpadType::None:
+ case Core::HID::NpadStyleIndex::None:
UNREACHABLE();
break;
- case Core::HID::NpadType::ProController:
+ case Core::HID::NpadStyleIndex::ProController:
pad_state.connection_status.raw = 0;
pad_state.connection_status.is_connected.Assign(1);
pad_state.connection_status.is_wired.Assign(1);
@@ -439,7 +440,7 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
npad.fullkey_lifo.ReadCurrentEntry().state.sampling_number + 1;
npad.fullkey_lifo.WriteNextEntry(pad_state);
break;
- case Core::HID::NpadType::Handheld:
+ case Core::HID::NpadStyleIndex::Handheld:
pad_state.connection_status.raw = 0;
pad_state.connection_status.is_connected.Assign(1);
pad_state.connection_status.is_wired.Assign(1);
@@ -457,7 +458,7 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
npad.handheld_lifo.ReadCurrentEntry().state.sampling_number + 1;
npad.handheld_lifo.WriteNextEntry(pad_state);
break;
- case Core::HID::NpadType::JoyconDual:
+ case Core::HID::NpadStyleIndex::JoyconDual:
pad_state.connection_status.raw = 0;
pad_state.connection_status.is_connected.Assign(1);
pad_state.connection_status.is_left_connected.Assign(1);
@@ -469,7 +470,7 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
npad.joy_dual_lifo.ReadCurrentEntry().state.sampling_number + 1;
npad.joy_dual_lifo.WriteNextEntry(pad_state);
break;
- case Core::HID::NpadType::JoyconLeft:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
pad_state.connection_status.raw = 0;
pad_state.connection_status.is_connected.Assign(1);
pad_state.connection_status.is_left_connected.Assign(1);
@@ -479,7 +480,7 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
npad.joy_left_lifo.ReadCurrentEntry().state.sampling_number + 1;
npad.joy_left_lifo.WriteNextEntry(pad_state);
break;
- case Core::HID::NpadType::JoyconRight:
+ case Core::HID::NpadStyleIndex::JoyconRight:
pad_state.connection_status.raw = 0;
pad_state.connection_status.is_connected.Assign(1);
pad_state.connection_status.is_right_connected.Assign(1);
@@ -489,7 +490,7 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
npad.joy_right_lifo.ReadCurrentEntry().state.sampling_number + 1;
npad.joy_right_lifo.WriteNextEntry(pad_state);
break;
- case Core::HID::NpadType::GameCube:
+ case Core::HID::NpadStyleIndex::GameCube:
pad_state.connection_status.raw = 0;
pad_state.connection_status.is_connected.Assign(1);
pad_state.connection_status.is_wired.Assign(1);
@@ -502,7 +503,7 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
npad.fullkey_lifo.WriteNextEntry(pad_state);
npad.gc_trigger_lifo.WriteNextEntry(trigger_state);
break;
- case Core::HID::NpadType::Pokeball:
+ case Core::HID::NpadStyleIndex::Pokeball:
pad_state.connection_status.raw = 0;
pad_state.connection_status.is_connected.Assign(1);
pad_state.sampling_number =
@@ -534,9 +535,10 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
for (std::size_t i = 0; i < controller_data.size(); ++i) {
auto& controller = controller_data[i];
- const auto& controller_type = controller.device->GetNpadType();
+ const auto& controller_type = controller.device->GetNpadStyleIndex();
- if (controller_type == Core::HID::NpadType::None || !controller.device->IsConnected()) {
+ if (controller_type == Core::HID::NpadStyleIndex::None ||
+ !controller.device->IsConnected()) {
continue;
}
@@ -557,10 +559,10 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
}
switch (controller_type) {
- case Core::HID::NpadType::None:
+ case Core::HID::NpadStyleIndex::None:
UNREACHABLE();
break;
- case Core::HID::NpadType::ProController:
+ case Core::HID::NpadStyleIndex::ProController:
sixaxis_fullkey_state.attribute.raw = 0;
if (sixaxis_sensors_enabled) {
sixaxis_fullkey_state.attribute.is_connected.Assign(1);
@@ -570,7 +572,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
sixaxis_fullkey_state.orientation = motion_state[0].orientation;
}
break;
- case Core::HID::NpadType::Handheld:
+ case Core::HID::NpadStyleIndex::Handheld:
sixaxis_handheld_state.attribute.raw = 0;
if (sixaxis_sensors_enabled) {
sixaxis_handheld_state.attribute.is_connected.Assign(1);
@@ -580,7 +582,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
sixaxis_handheld_state.orientation = motion_state[0].orientation;
}
break;
- case Core::HID::NpadType::JoyconDual:
+ case Core::HID::NpadStyleIndex::JoyconDual:
sixaxis_dual_left_state.attribute.raw = 0;
sixaxis_dual_right_state.attribute.raw = 0;
if (sixaxis_sensors_enabled) {
@@ -600,7 +602,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
sixaxis_dual_right_state.orientation = motion_state[1].orientation;
}
break;
- case Core::HID::NpadType::JoyconLeft:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
sixaxis_left_lifo_state.attribute.raw = 0;
if (sixaxis_sensors_enabled) {
sixaxis_left_lifo_state.attribute.is_connected.Assign(1);
@@ -610,7 +612,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing
sixaxis_left_lifo_state.orientation = motion_state[0].orientation;
}
break;
- case Core::HID::NpadType::JoyconRight:
+ case Core::HID::NpadStyleIndex::JoyconRight:
sixaxis_right_lifo_state.attribute.raw = 0;
if (sixaxis_sensors_enabled) {
sixaxis_right_lifo_state.attribute.is_connected.Assign(1);
@@ -779,11 +781,11 @@ void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_han
}
// Some games try to send mismatched parameters in the device handle, block these.
- if ((controller.device->GetNpadType() == Core::HID::NpadType::JoyconLeft &&
- (vibration_device_handle.npad_type == Core::HID::NpadType::JoyconRight ||
+ if ((controller.device->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconLeft &&
+ (vibration_device_handle.npad_type == Core::HID::NpadStyleIndex::JoyconRight ||
vibration_device_handle.device_index == DeviceIndex::Right)) ||
- (controller.device->GetNpadType() == Core::HID::NpadType::JoyconRight &&
- (vibration_device_handle.npad_type == Core::HID::NpadType::JoyconLeft ||
+ (controller.device->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight &&
+ (vibration_device_handle.npad_type == Core::HID::NpadStyleIndex::JoyconLeft ||
vibration_device_handle.device_index == DeviceIndex::Left))) {
return;
}
@@ -876,11 +878,12 @@ void Controller_NPad::SignalStyleSetChangedEvent(u32 npad_id) const {
controller.styleset_changed_event->GetWritableEvent().Signal();
}
-void Controller_NPad::AddNewControllerAt(Core::HID::NpadType controller, std::size_t npad_index) {
+void Controller_NPad::AddNewControllerAt(Core::HID::NpadStyleIndex controller,
+ std::size_t npad_index) {
UpdateControllerAt(controller, npad_index, true);
}
-void Controller_NPad::UpdateControllerAt(Core::HID::NpadType type, std::size_t npad_index,
+void Controller_NPad::UpdateControllerAt(Core::HID::NpadStyleIndex type, std::size_t npad_index,
bool connected) {
auto& controller = controller_data[npad_index];
if (!connected) {
@@ -888,7 +891,7 @@ void Controller_NPad::UpdateControllerAt(Core::HID::NpadType type, std::size_t n
return;
}
- controller.device->SetNpadType(type);
+ controller.device->SetNpadStyleIndex(type);
InitNewlyAddedController(npad_index);
}
@@ -971,13 +974,13 @@ void Controller_NPad::MergeSingleJoyAsDualJoy(u32 npad_id_1, u32 npad_id_2) {
// If the controllers at both npad indices form a pair of left and right joycons, merge them.
// Otherwise, do nothing.
- if ((controller_1->GetNpadType() == Core::HID::NpadType::JoyconLeft &&
- controller_2->GetNpadType() == Core::HID::NpadType::JoyconRight) ||
- (controller_2->GetNpadType() == Core::HID::NpadType::JoyconLeft &&
- controller_1->GetNpadType() == Core::HID::NpadType::JoyconRight)) {
+ if ((controller_1->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconLeft &&
+ controller_2->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight) ||
+ (controller_2->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconLeft &&
+ controller_1->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight)) {
// Disconnect the joycon at the second id and connect the dual joycon at the first index.
DisconnectNpad(npad_id_2);
- AddNewControllerAt(Core::HID::NpadType::JoyconDual, npad_index_1);
+ AddNewControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_index_1);
}
}
@@ -1000,8 +1003,8 @@ bool Controller_NPad::SwapNpadAssignment(u32 npad_id_1, u32 npad_id_2) {
const auto npad_index_2 = NPadIdToIndex(npad_id_2);
const auto& controller_1 = controller_data[npad_index_1].device;
const auto& controller_2 = controller_data[npad_index_2].device;
- const auto type_index_1 = controller_1->GetNpadType();
- const auto type_index_2 = controller_2->GetNpadType();
+ const auto type_index_1 = controller_1->GetNpadStyleIndex();
+ const auto type_index_2 = controller_2->GetNpadStyleIndex();
if (!IsControllerSupported(type_index_1) || !IsControllerSupported(type_index_2)) {
return false;
@@ -1039,9 +1042,9 @@ void Controller_NPad::SetAnalogStickUseCenterClamp(bool use_center_clamp) {
void Controller_NPad::ClearAllConnectedControllers() {
for (auto& controller : controller_data) {
if (controller.device->IsConnected() &&
- controller.device->GetNpadType() != Core::HID::NpadType::None) {
- controller.device->SetNpadType(Core::HID::NpadType::None);
+ controller.device->GetNpadStyleIndex() != Core::HID::NpadStyleIndex::None) {
controller.device->Disconnect();
+ controller.device->SetNpadStyleIndex(Core::HID::NpadStyleIndex::None);
}
}
}
@@ -1054,7 +1057,7 @@ void Controller_NPad::DisconnectAllConnectedControllers() {
void Controller_NPad::ConnectAllDisconnectedControllers() {
for (auto& controller : controller_data) {
- if (controller.device->GetNpadType() != Core::HID::NpadType::None &&
+ if (controller.device->GetNpadStyleIndex() != Core::HID::NpadStyleIndex::None &&
!controller.device->IsConnected()) {
controller.device->Connect();
}
@@ -1063,8 +1066,8 @@ void Controller_NPad::ConnectAllDisconnectedControllers() {
void Controller_NPad::ClearAllControllers() {
for (auto& controller : controller_data) {
- controller.device->SetNpadType(Core::HID::NpadType::None);
controller.device->Disconnect();
+ controller.device->SetNpadStyleIndex(Core::HID::NpadStyleIndex::None);
}
}
@@ -1072,8 +1075,8 @@ u32 Controller_NPad::GetAndResetPressState() {
return press_state.exchange(0);
}
-bool Controller_NPad::IsControllerSupported(Core::HID::NpadType controller) const {
- if (controller == Core::HID::NpadType::Handheld) {
+bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller) const {
+ if (controller == Core::HID::NpadStyleIndex::Handheld) {
const bool support_handheld =
std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(),
NPAD_HANDHELD) != supported_npad_id_types.end();
@@ -1093,17 +1096,17 @@ bool Controller_NPad::IsControllerSupported(Core::HID::NpadType controller) cons
[](u32 npad_id) { return npad_id <= MAX_NPAD_ID; })) {
Core::HID::NpadStyleTag style = GetSupportedStyleSet();
switch (controller) {
- case Core::HID::NpadType::ProController:
+ case Core::HID::NpadStyleIndex::ProController:
return style.fullkey;
- case Core::HID::NpadType::JoyconDual:
+ case Core::HID::NpadStyleIndex::JoyconDual:
return style.joycon_dual;
- case Core::HID::NpadType::JoyconLeft:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
return style.joycon_left;
- case Core::HID::NpadType::JoyconRight:
+ case Core::HID::NpadStyleIndex::JoyconRight:
return style.joycon_right;
- case Core::HID::NpadType::GameCube:
+ case Core::HID::NpadStyleIndex::GameCube:
return style.gamecube;
- case Core::HID::NpadType::Pokeball:
+ case Core::HID::NpadStyleIndex::Pokeball:
return style.palma;
default:
return false;
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index 871d245fd..512fb5afc 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -96,7 +96,7 @@ public:
};
struct DeviceHandle {
- Core::HID::NpadType npad_type;
+ Core::HID::NpadStyleIndex npad_type;
u8 npad_id;
DeviceIndex device_index;
INSERT_PADDING_BYTES_NOINIT(1);
@@ -160,9 +160,10 @@ public:
void SignalStyleSetChangedEvent(u32 npad_id) const;
// Adds a new controller at an index.
- void AddNewControllerAt(Core::HID::NpadType controller, std::size_t npad_index);
+ void AddNewControllerAt(Core::HID::NpadStyleIndex controller, std::size_t npad_index);
// Adds a new controller at an index with connection status.
- void UpdateControllerAt(Core::HID::NpadType controller, std::size_t npad_index, bool connected);
+ void UpdateControllerAt(Core::HID::NpadStyleIndex controller, std::size_t npad_index,
+ bool connected);
void DisconnectNpad(u32 npad_id);
void DisconnectNpadAtIndex(std::size_t index);
@@ -496,7 +497,7 @@ private:
std::array<VibrationData, 2> vibration{};
bool unintended_home_button_input_protection{};
bool is_connected{};
- Core::HID::NpadType npad_type{Core::HID::NpadType::None};
+ Core::HID::NpadStyleIndex npad_type{Core::HID::NpadStyleIndex::None};
// Current pad state
NPadGenericState npad_pad_state{};
@@ -513,7 +514,7 @@ private:
void ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t controller_idx);
void InitNewlyAddedController(std::size_t controller_idx);
- bool IsControllerSupported(Core::HID::NpadType controller) const;
+ bool IsControllerSupported(Core::HID::NpadStyleIndex controller) const;
void RequestPadStateUpdate(u32 npad_id);
void WriteEmptyEntry(NpadInternalState& npad);
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index ac48f96d3..648e69de9 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -1131,18 +1131,18 @@ void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) {
Core::HID::VibrationDeviceInfo vibration_device_info;
switch (vibration_device_handle.npad_type) {
- case Core::HID::NpadType::ProController:
- case Core::HID::NpadType::Handheld:
- case Core::HID::NpadType::JoyconDual:
- case Core::HID::NpadType::JoyconLeft:
- case Core::HID::NpadType::JoyconRight:
+ case Core::HID::NpadStyleIndex::ProController:
+ case Core::HID::NpadStyleIndex::Handheld:
+ case Core::HID::NpadStyleIndex::JoyconDual:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
+ case Core::HID::NpadStyleIndex::JoyconRight:
default:
vibration_device_info.type = Core::HID::VibrationDeviceType::LinearResonantActuator;
break;
- case Core::HID::NpadType::GameCube:
+ case Core::HID::NpadStyleIndex::GameCube:
vibration_device_info.type = Core::HID::VibrationDeviceType::GcErm;
break;
- case Core::HID::NpadType::Pokeball:
+ case Core::HID::NpadStyleIndex::Pokeball:
vibration_device_info.type = Core::HID::VibrationDeviceType::Unknown;
break;
}