core/hid: Rename NpadType to NpadStyleIndex
This commit is contained in:
parent
84c58666a4
commit
5d0f3540c4
15 changed files with 228 additions and 215 deletions
|
@ -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};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue