diff options
| author | 2021-11-04 12:08:54 -0600 | |
|---|---|---|
| committer | 2021-11-24 20:30:27 -0600 | |
| commit | 5d0f3540c4b085103afa27d6120ea29e0324a5a2 (patch) | |
| tree | 9cdfe756391969476385d3f391d74a6e75aa5889 /src/core/hid | |
| parent | config: Cleanup and documentation (diff) | |
| download | yuzu-5d0f3540c4b085103afa27d6120ea29e0324a5a2.tar.gz yuzu-5d0f3540c4b085103afa27d6120ea29e0324a5a2.tar.xz yuzu-5d0f3540c4b085103afa27d6120ea29e0324a5a2.zip | |
core/hid: Rename NpadType to NpadStyleIndex
Diffstat (limited to 'src/core/hid')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 44 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 18 | ||||
| -rw-r--r-- | src/core/hid/hid_types.h | 13 |
3 files changed, 41 insertions, 34 deletions
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( | |||
| 13 | 13 | ||
| 14 | EmulatedController::~EmulatedController() = default; | 14 | EmulatedController::~EmulatedController() = default; |
| 15 | 15 | ||
| 16 | NpadType EmulatedController::MapSettingsTypeToNPad(Settings::ControllerType type) { | 16 | NpadStyleIndex EmulatedController::MapSettingsTypeToNPad(Settings::ControllerType type) { |
| 17 | switch (type) { | 17 | switch (type) { |
| 18 | case Settings::ControllerType::ProController: | 18 | case Settings::ControllerType::ProController: |
| 19 | return NpadType::ProController; | 19 | return NpadStyleIndex::ProController; |
| 20 | case Settings::ControllerType::DualJoyconDetached: | 20 | case Settings::ControllerType::DualJoyconDetached: |
| 21 | return NpadType::JoyconDual; | 21 | return NpadStyleIndex::JoyconDual; |
| 22 | case Settings::ControllerType::LeftJoycon: | 22 | case Settings::ControllerType::LeftJoycon: |
| 23 | return NpadType::JoyconLeft; | 23 | return NpadStyleIndex::JoyconLeft; |
| 24 | case Settings::ControllerType::RightJoycon: | 24 | case Settings::ControllerType::RightJoycon: |
| 25 | return NpadType::JoyconRight; | 25 | return NpadStyleIndex::JoyconRight; |
| 26 | case Settings::ControllerType::Handheld: | 26 | case Settings::ControllerType::Handheld: |
| 27 | return NpadType::Handheld; | 27 | return NpadStyleIndex::Handheld; |
| 28 | case Settings::ControllerType::GameCube: | 28 | case Settings::ControllerType::GameCube: |
| 29 | return NpadType::GameCube; | 29 | return NpadStyleIndex::GameCube; |
| 30 | default: | 30 | default: |
| 31 | return NpadType::ProController; | 31 | return NpadStyleIndex::ProController; |
| 32 | } | 32 | } |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadType type) { | 35 | Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadStyleIndex type) { |
| 36 | switch (type) { | 36 | switch (type) { |
| 37 | case NpadType::ProController: | 37 | case NpadStyleIndex::ProController: |
| 38 | return Settings::ControllerType::ProController; | 38 | return Settings::ControllerType::ProController; |
| 39 | case NpadType::JoyconDual: | 39 | case NpadStyleIndex::JoyconDual: |
| 40 | return Settings::ControllerType::DualJoyconDetached; | 40 | return Settings::ControllerType::DualJoyconDetached; |
| 41 | case NpadType::JoyconLeft: | 41 | case NpadStyleIndex::JoyconLeft: |
| 42 | return Settings::ControllerType::LeftJoycon; | 42 | return Settings::ControllerType::LeftJoycon; |
| 43 | case NpadType::JoyconRight: | 43 | case NpadStyleIndex::JoyconRight: |
| 44 | return Settings::ControllerType::RightJoycon; | 44 | return Settings::ControllerType::RightJoycon; |
| 45 | case NpadType::Handheld: | 45 | case NpadStyleIndex::Handheld: |
| 46 | return Settings::ControllerType::Handheld; | 46 | return Settings::ControllerType::Handheld; |
| 47 | case NpadType::GameCube: | 47 | case NpadStyleIndex::GameCube: |
| 48 | return Settings::ControllerType::GameCube; | 48 | return Settings::ControllerType::GameCube; |
| 49 | default: | 49 | default: |
| 50 | return Settings::ControllerType::ProController; | 50 | return Settings::ControllerType::ProController; |
| @@ -79,9 +79,9 @@ void EmulatedController::ReloadFromSettings() { | |||
| 79 | 79 | ||
| 80 | // Other or debug controller should always be a pro controller | 80 | // Other or debug controller should always be a pro controller |
| 81 | if (npad_id_type != NpadIdType::Other) { | 81 | if (npad_id_type != NpadIdType::Other) { |
| 82 | SetNpadType(MapSettingsTypeToNPad(player.controller_type)); | 82 | SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); |
| 83 | } else { | 83 | } else { |
| 84 | SetNpadType(NpadType::ProController); | 84 | SetNpadStyleIndex(NpadStyleIndex::ProController); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | if (player.connected) { | 87 | if (player.connected) { |
| @@ -306,7 +306,7 @@ void EmulatedController::DisableConfiguration() { | |||
| 306 | if (is_connected) { | 306 | if (is_connected) { |
| 307 | Disconnect(); | 307 | Disconnect(); |
| 308 | } | 308 | } |
| 309 | SetNpadType(tmp_npad_type); | 309 | SetNpadStyleIndex(tmp_npad_type); |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | // Apply temporary connected status to the real controller | 312 | // Apply temporary connected status to the real controller |
| @@ -569,10 +569,10 @@ void EmulatedController::SetButton(Common::Input::CallbackStatus callback, std:: | |||
| 569 | } | 569 | } |
| 570 | } | 570 | } |
| 571 | if (!is_connected) { | 571 | if (!is_connected) { |
| 572 | if (npad_id_type == NpadIdType::Player1 && npad_type != NpadType::Handheld) { | 572 | if (npad_id_type == NpadIdType::Player1 && npad_type != NpadStyleIndex::Handheld) { |
| 573 | Connect(); | 573 | Connect(); |
| 574 | } | 574 | } |
| 575 | if (npad_id_type == NpadIdType::Handheld && npad_type == NpadType::Handheld) { | 575 | if (npad_id_type == NpadIdType::Handheld && npad_type == NpadStyleIndex::Handheld) { |
| 576 | Connect(); | 576 | Connect(); |
| 577 | } | 577 | } |
| 578 | } | 578 | } |
| @@ -896,14 +896,14 @@ NpadIdType EmulatedController::GetNpadIdType() const { | |||
| 896 | return npad_id_type; | 896 | return npad_id_type; |
| 897 | } | 897 | } |
| 898 | 898 | ||
| 899 | NpadType EmulatedController::GetNpadType(bool get_temporary_value) const { | 899 | NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) const { |
| 900 | if (get_temporary_value) { | 900 | if (get_temporary_value) { |
| 901 | return tmp_npad_type; | 901 | return tmp_npad_type; |
| 902 | } | 902 | } |
| 903 | return npad_type; | 903 | return npad_type; |
| 904 | } | 904 | } |
| 905 | 905 | ||
| 906 | void EmulatedController::SetNpadType(NpadType npad_type_) { | 906 | void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) { |
| 907 | { | 907 | { |
| 908 | std::lock_guard lock{mutex}; | 908 | std::lock_guard lock{mutex}; |
| 909 | 909 | ||
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: | |||
| 142 | YUZU_NON_MOVEABLE(EmulatedController); | 142 | YUZU_NON_MOVEABLE(EmulatedController); |
| 143 | 143 | ||
| 144 | /// Converts the controller type from settings to npad type | 144 | /// Converts the controller type from settings to npad type |
| 145 | static NpadType MapSettingsTypeToNPad(Settings::ControllerType type); | 145 | static NpadStyleIndex MapSettingsTypeToNPad(Settings::ControllerType type); |
| 146 | 146 | ||
| 147 | /// Converts npad type to the equivalent of controller type from settings | 147 | /// Converts npad type to the equivalent of controller type from settings |
| 148 | static Settings::ControllerType MapNPadToSettingsType(NpadType type); | 148 | static Settings::ControllerType MapNPadToSettingsType(NpadStyleIndex type); |
| 149 | 149 | ||
| 150 | /// Gets the NpadIdType for this controller | 150 | /// Gets the NpadIdType for this controller |
| 151 | NpadIdType GetNpadIdType() const; | 151 | NpadIdType GetNpadIdType() const; |
| 152 | 152 | ||
| 153 | /// Sets the NpadType for this controller | 153 | /// Sets the NpadStyleIndex for this controller |
| 154 | void SetNpadType(NpadType npad_type_); | 154 | void SetNpadStyleIndex(NpadStyleIndex npad_type_); |
| 155 | 155 | ||
| 156 | /** | 156 | /** |
| 157 | * Gets the NpadType for this controller | 157 | * Gets the NpadStyleIndex for this controller |
| 158 | * @param If true tmp_npad_type will be returned | 158 | * @param If true tmp_npad_type will be returned |
| 159 | * @return NpadType set on the controller | 159 | * @return NpadStyleIndex set on the controller |
| 160 | */ | 160 | */ |
| 161 | NpadType GetNpadType(bool get_temporary_value = false) const; | 161 | NpadStyleIndex GetNpadStyleIndex(bool get_temporary_value = false) const; |
| 162 | 162 | ||
| 163 | /// Sets the connected status to true | 163 | /// Sets the connected status to true |
| 164 | void Connect(); | 164 | void Connect(); |
| @@ -351,14 +351,14 @@ private: | |||
| 351 | void TriggerOnChange(ControllerTriggerType type, bool is_service_update); | 351 | void TriggerOnChange(ControllerTriggerType type, bool is_service_update); |
| 352 | 352 | ||
| 353 | NpadIdType npad_id_type; | 353 | NpadIdType npad_id_type; |
| 354 | NpadType npad_type{NpadType::None}; | 354 | NpadStyleIndex npad_type{NpadStyleIndex::None}; |
| 355 | bool is_connected{false}; | 355 | bool is_connected{false}; |
| 356 | bool is_configuring{false}; | 356 | bool is_configuring{false}; |
| 357 | f32 motion_sensitivity{0.01f}; | 357 | f32 motion_sensitivity{0.01f}; |
| 358 | bool force_update_motion{false}; | 358 | bool force_update_motion{false}; |
| 359 | 359 | ||
| 360 | // Temporary values to avoid doing changes while the controller is on configuration mode | 360 | // Temporary values to avoid doing changes while the controller is on configuration mode |
| 361 | NpadType tmp_npad_type{NpadType::None}; | 361 | NpadStyleIndex tmp_npad_type{NpadStyleIndex::None}; |
| 362 | bool tmp_is_connected{false}; | 362 | bool tmp_is_connected{false}; |
| 363 | 363 | ||
| 364 | ButtonParams button_params; | 364 | 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) { | |||
| 84 | } | 84 | } |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | // This is nn::hid::NpadType | 87 | // This is nn::hid::NpadStyleIndex |
| 88 | enum class NpadType : u8 { | 88 | enum class NpadStyleIndex : u8 { |
| 89 | None = 0, | 89 | None = 0, |
| 90 | ProController = 3, | 90 | ProController = 3, |
| 91 | Handheld = 4, | 91 | Handheld = 4, |
| @@ -94,7 +94,14 @@ enum class NpadType : u8 { | |||
| 94 | JoyconRight = 7, | 94 | JoyconRight = 7, |
| 95 | GameCube = 8, | 95 | GameCube = 8, |
| 96 | Pokeball = 9, | 96 | Pokeball = 9, |
| 97 | MaxNpadType = 10, | 97 | NES = 10, |
| 98 | HandheldNES = 11, | ||
| 99 | SNES = 12, | ||
| 100 | N64 = 13, | ||
| 101 | SegaGenesis = 14, | ||
| 102 | SystemExt = 32, | ||
| 103 | System = 33, | ||
| 104 | MaxNpadType = 34, | ||
| 98 | }; | 105 | }; |
| 99 | 106 | ||
| 100 | // This is nn::hid::NpadStyleTag | 107 | // This is nn::hid::NpadStyleTag |