diff options
| -rw-r--r-- | src/core/hid/hid_core.cpp | 8 | ||||
| -rw-r--r-- | src/core/hid/hid_core.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 2 |
4 files changed, 20 insertions, 1 deletions
diff --git a/src/core/hid/hid_core.cpp b/src/core/hid/hid_core.cpp index 7d6373414..cf53c04d9 100644 --- a/src/core/hid/hid_core.cpp +++ b/src/core/hid/hid_core.cpp | |||
| @@ -154,6 +154,14 @@ NpadIdType HIDCore::GetFirstDisconnectedNpadId() const { | |||
| 154 | return NpadIdType::Player1; | 154 | return NpadIdType::Player1; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | void HIDCore::SetLastActiveController(NpadIdType npad_id) { | ||
| 158 | last_active_controller = npad_id; | ||
| 159 | } | ||
| 160 | |||
| 161 | NpadIdType HIDCore::GetLastActiveController() const { | ||
| 162 | return last_active_controller; | ||
| 163 | } | ||
| 164 | |||
| 157 | void HIDCore::EnableAllControllerConfiguration() { | 165 | void HIDCore::EnableAllControllerConfiguration() { |
| 158 | player_1->EnableConfiguration(); | 166 | player_1->EnableConfiguration(); |
| 159 | player_2->EnableConfiguration(); | 167 | player_2->EnableConfiguration(); |
diff --git a/src/core/hid/hid_core.h b/src/core/hid/hid_core.h index 5fe36551e..80abab18b 100644 --- a/src/core/hid/hid_core.h +++ b/src/core/hid/hid_core.h | |||
| @@ -48,6 +48,12 @@ public: | |||
| 48 | /// Returns the first disconnected npad id | 48 | /// Returns the first disconnected npad id |
| 49 | NpadIdType GetFirstDisconnectedNpadId() const; | 49 | NpadIdType GetFirstDisconnectedNpadId() const; |
| 50 | 50 | ||
| 51 | /// Sets the npad id of the last active controller | ||
| 52 | void SetLastActiveController(NpadIdType npad_id); | ||
| 53 | |||
| 54 | /// Returns the npad id of the last controller that pushed a button | ||
| 55 | NpadIdType GetLastActiveController() const; | ||
| 56 | |||
| 51 | /// Sets all emulated controllers into configuring mode. | 57 | /// Sets all emulated controllers into configuring mode. |
| 52 | void EnableAllControllerConfiguration(); | 58 | void EnableAllControllerConfiguration(); |
| 53 | 59 | ||
| @@ -77,6 +83,7 @@ private: | |||
| 77 | std::unique_ptr<EmulatedConsole> console; | 83 | std::unique_ptr<EmulatedConsole> console; |
| 78 | std::unique_ptr<EmulatedDevices> devices; | 84 | std::unique_ptr<EmulatedDevices> devices; |
| 79 | NpadStyleTag supported_style_tag{NpadStyleSet::All}; | 85 | NpadStyleTag supported_style_tag{NpadStyleSet::All}; |
| 86 | NpadIdType last_active_controller{NpadIdType::Handheld}; | ||
| 80 | }; | 87 | }; |
| 81 | 88 | ||
| 82 | } // namespace Core::HID | 89 | } // namespace Core::HID |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index a894af8ea..da3220ddc 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -476,6 +476,10 @@ void Controller_NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) { | |||
| 476 | pad_entry.npad_buttons.l.Assign(button_state.zl); | 476 | pad_entry.npad_buttons.l.Assign(button_state.zl); |
| 477 | pad_entry.npad_buttons.r.Assign(button_state.zr); | 477 | pad_entry.npad_buttons.r.Assign(button_state.zr); |
| 478 | } | 478 | } |
| 479 | |||
| 480 | if (pad_entry.npad_buttons.raw != Core::HID::NpadButton::None) { | ||
| 481 | hid_core.SetLastActiveController(npad_id); | ||
| 482 | } | ||
| 479 | } | 483 | } |
| 480 | 484 | ||
| 481 | void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | 485 | void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) { |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index fd466db7b..3657e61d3 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -2768,7 +2768,7 @@ private: | |||
| 2768 | 2768 | ||
| 2769 | IPC::ResponseBuilder rb{ctx, 3}; | 2769 | IPC::ResponseBuilder rb{ctx, 3}; |
| 2770 | rb.Push(ResultSuccess); | 2770 | rb.Push(ResultSuccess); |
| 2771 | rb.PushEnum(Core::HID::NpadIdType::Handheld); | 2771 | rb.PushEnum(system.HIDCore().GetLastActiveController()); |
| 2772 | } | 2772 | } |
| 2773 | 2773 | ||
| 2774 | void GetUniquePadsFromNpad(HLERequestContext& ctx) { | 2774 | void GetUniquePadsFromNpad(HLERequestContext& ctx) { |