diff options
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 17 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 10 | ||||
| -rw-r--r-- | src/core/hid/hid_types.h | 20 |
3 files changed, 46 insertions, 1 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 71fc05807..9f68a41cc 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -596,7 +596,10 @@ void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback | |||
| 596 | controller.npad_button_state.right_sr.Assign(current_status.value); | 596 | controller.npad_button_state.right_sr.Assign(current_status.value); |
| 597 | break; | 597 | break; |
| 598 | case Settings::NativeButton::Home: | 598 | case Settings::NativeButton::Home: |
| 599 | controller.home_button_state.home.Assign(current_status.value); | ||
| 600 | break; | ||
| 599 | case Settings::NativeButton::Screenshot: | 601 | case Settings::NativeButton::Screenshot: |
| 602 | controller.capture_button_state.capture.Assign(current_status.value); | ||
| 600 | break; | 603 | break; |
| 601 | } | 604 | } |
| 602 | } | 605 | } |
| @@ -1077,6 +1080,20 @@ BatteryValues EmulatedController::GetBatteryValues() const { | |||
| 1077 | return controller.battery_values; | 1080 | return controller.battery_values; |
| 1078 | } | 1081 | } |
| 1079 | 1082 | ||
| 1083 | HomeButtonState EmulatedController::GetHomeButtons() const { | ||
| 1084 | if (is_configuring) { | ||
| 1085 | return {}; | ||
| 1086 | } | ||
| 1087 | return controller.home_button_state; | ||
| 1088 | } | ||
| 1089 | |||
| 1090 | CaptureButtonState EmulatedController::GetCaptureButtons() const { | ||
| 1091 | if (is_configuring) { | ||
| 1092 | return {}; | ||
| 1093 | } | ||
| 1094 | return controller.capture_button_state; | ||
| 1095 | } | ||
| 1096 | |||
| 1080 | NpadButtonState EmulatedController::GetNpadButtons() const { | 1097 | NpadButtonState EmulatedController::GetNpadButtons() const { |
| 1081 | if (is_configuring) { | 1098 | if (is_configuring) { |
| 1082 | return {}; | 1099 | return {}; |
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index c0994ab4d..bee16a8ed 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -101,6 +101,8 @@ struct ControllerStatus { | |||
| 101 | VibrationValues vibration_values{}; | 101 | VibrationValues vibration_values{}; |
| 102 | 102 | ||
| 103 | // Data for HID serices | 103 | // Data for HID serices |
| 104 | HomeButtonState home_button_state{}; | ||
| 105 | CaptureButtonState capture_button_state{}; | ||
| 104 | NpadButtonState npad_button_state{}; | 106 | NpadButtonState npad_button_state{}; |
| 105 | DebugPadButton debug_pad_button_state{}; | 107 | DebugPadButton debug_pad_button_state{}; |
| 106 | AnalogSticks analog_stick_state{}; | 108 | AnalogSticks analog_stick_state{}; |
| @@ -261,7 +263,13 @@ public: | |||
| 261 | /// Returns the latest battery status from the controller with parameters | 263 | /// Returns the latest battery status from the controller with parameters |
| 262 | BatteryValues GetBatteryValues() const; | 264 | BatteryValues GetBatteryValues() const; |
| 263 | 265 | ||
| 264 | /// Returns the latest status of button input for the npad service | 266 | /// Returns the latest status of button input for the hid::HomeButton service |
| 267 | HomeButtonState GetHomeButtons() const; | ||
| 268 | |||
| 269 | /// Returns the latest status of button input for the hid::CaptureButton service | ||
| 270 | CaptureButtonState GetCaptureButtons() const; | ||
| 271 | |||
| 272 | /// Returns the latest status of button input for the hid::Npad service | ||
| 265 | NpadButtonState GetNpadButtons() const; | 273 | NpadButtonState GetNpadButtons() const; |
| 266 | 274 | ||
| 267 | /// Returns the latest status of button input for the debug pad service | 275 | /// Returns the latest status of button input for the debug pad service |
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h index 4eca68533..778b328b9 100644 --- a/src/core/hid/hid_types.h +++ b/src/core/hid/hid_types.h | |||
| @@ -378,6 +378,26 @@ struct LedPattern { | |||
| 378 | }; | 378 | }; |
| 379 | }; | 379 | }; |
| 380 | 380 | ||
| 381 | struct HomeButtonState { | ||
| 382 | union { | ||
| 383 | u64 raw{}; | ||
| 384 | |||
| 385 | // Buttons | ||
| 386 | BitField<0, 1, u64> home; | ||
| 387 | }; | ||
| 388 | }; | ||
| 389 | static_assert(sizeof(HomeButtonState) == 0x8, "HomeButtonState has incorrect size."); | ||
| 390 | |||
| 391 | struct CaptureButtonState { | ||
| 392 | union { | ||
| 393 | u64 raw{}; | ||
| 394 | |||
| 395 | // Buttons | ||
| 396 | BitField<0, 1, u64> capture; | ||
| 397 | }; | ||
| 398 | }; | ||
| 399 | static_assert(sizeof(CaptureButtonState) == 0x8, "CaptureButtonState has incorrect size."); | ||
| 400 | |||
| 381 | struct NpadButtonState { | 401 | struct NpadButtonState { |
| 382 | union { | 402 | union { |
| 383 | NpadButton raw{}; | 403 | NpadButton raw{}; |