diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/hid/hid_types.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 34 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/hid/errors.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 75 |
5 files changed, 76 insertions, 40 deletions
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h index 9f76f9bcb..e49223016 100644 --- a/src/core/hid/hid_types.h +++ b/src/core/hid/hid_types.h | |||
| @@ -272,6 +272,7 @@ enum class VibrationDeviceType : u32 { | |||
| 272 | Unknown = 0, | 272 | Unknown = 0, |
| 273 | LinearResonantActuator = 1, | 273 | LinearResonantActuator = 1, |
| 274 | GcErm = 2, | 274 | GcErm = 2, |
| 275 | N64 = 3, | ||
| 275 | }; | 276 | }; |
| 276 | 277 | ||
| 277 | // This is nn::hid::VibrationGcErmCommand | 278 | // This is nn::hid::VibrationGcErmCommand |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index c08b0a5dc..aa7189bda 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -49,28 +49,41 @@ bool Controller_NPad::IsNpadIdValid(Core::HID::NpadIdType npad_id) { | |||
| 49 | } | 49 | } |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | bool Controller_NPad::IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle) { | 52 | Result Controller_NPad::IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle) { |
| 53 | const auto npad_id = IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id)); | 53 | const auto npad_id = IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id)); |
| 54 | const bool npad_type = device_handle.npad_type < Core::HID::NpadStyleIndex::MaxNpadType; | 54 | const bool npad_type = device_handle.npad_type < Core::HID::NpadStyleIndex::MaxNpadType; |
| 55 | const bool device_index = device_handle.device_index < Core::HID::DeviceIndex::MaxDeviceIndex; | 55 | const bool device_index = device_handle.device_index < Core::HID::DeviceIndex::MaxDeviceIndex; |
| 56 | return npad_id && npad_type && device_index; | 56 | |
| 57 | if (!npad_type) { | ||
| 58 | return VibrationInvalidStyleIndex; | ||
| 59 | } | ||
| 60 | if (!npad_id) { | ||
| 61 | return VibrationInvalidNpadId; | ||
| 62 | } | ||
| 63 | if (!device_index) { | ||
| 64 | return VibrationDeviceIndexOutOfRange; | ||
| 65 | } | ||
| 66 | |||
| 67 | return ResultSuccess; | ||
| 57 | } | 68 | } |
| 58 | 69 | ||
| 59 | Result Controller_NPad::VerifyValidSixAxisSensorHandle( | 70 | Result Controller_NPad::VerifyValidSixAxisSensorHandle( |
| 60 | const Core::HID::SixAxisSensorHandle& device_handle) { | 71 | const Core::HID::SixAxisSensorHandle& device_handle) { |
| 61 | const auto npad_id = IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id)); | 72 | const auto npad_id = IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id)); |
| 73 | const bool device_index = device_handle.device_index < Core::HID::DeviceIndex::MaxDeviceIndex; | ||
| 74 | const bool npad_type = device_handle.npad_type < Core::HID::NpadStyleIndex::MaxNpadType; | ||
| 75 | |||
| 62 | if (!npad_id) { | 76 | if (!npad_id) { |
| 63 | return InvalidNpadId; | 77 | return InvalidNpadId; |
| 64 | } | 78 | } |
| 65 | const bool device_index = device_handle.device_index < Core::HID::DeviceIndex::MaxDeviceIndex; | ||
| 66 | if (!device_index) { | 79 | if (!device_index) { |
| 67 | return NpadDeviceIndexOutOfRange; | 80 | return NpadDeviceIndexOutOfRange; |
| 68 | } | 81 | } |
| 69 | // This doesn't get validated on nnsdk | 82 | // This doesn't get validated on nnsdk |
| 70 | const bool npad_type = device_handle.npad_type < Core::HID::NpadStyleIndex::MaxNpadType; | ||
| 71 | if (!npad_type) { | 83 | if (!npad_type) { |
| 72 | return NpadInvalidHandle; | 84 | return NpadInvalidHandle; |
| 73 | } | 85 | } |
| 86 | |||
| 74 | return ResultSuccess; | 87 | return ResultSuccess; |
| 75 | } | 88 | } |
| 76 | 89 | ||
| @@ -705,6 +718,11 @@ Controller_NPad::NpadJoyHoldType Controller_NPad::GetHoldType() const { | |||
| 705 | } | 718 | } |
| 706 | 719 | ||
| 707 | void Controller_NPad::SetNpadHandheldActivationMode(NpadHandheldActivationMode activation_mode) { | 720 | void Controller_NPad::SetNpadHandheldActivationMode(NpadHandheldActivationMode activation_mode) { |
| 721 | if (activation_mode >= NpadHandheldActivationMode::MaxActivationMode) { | ||
| 722 | ASSERT_MSG(false, "Activation mode should be always None, Single or Dual"); | ||
| 723 | return; | ||
| 724 | } | ||
| 725 | |||
| 708 | handheld_activation_mode = activation_mode; | 726 | handheld_activation_mode = activation_mode; |
| 709 | } | 727 | } |
| 710 | 728 | ||
| @@ -840,7 +858,7 @@ bool Controller_NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, | |||
| 840 | void Controller_NPad::VibrateController( | 858 | void Controller_NPad::VibrateController( |
| 841 | const Core::HID::VibrationDeviceHandle& vibration_device_handle, | 859 | const Core::HID::VibrationDeviceHandle& vibration_device_handle, |
| 842 | const Core::HID::VibrationValue& vibration_value) { | 860 | const Core::HID::VibrationValue& vibration_value) { |
| 843 | if (!IsDeviceHandleValid(vibration_device_handle)) { | 861 | if (IsDeviceHandleValid(vibration_device_handle).IsError()) { |
| 844 | return; | 862 | return; |
| 845 | } | 863 | } |
| 846 | 864 | ||
| @@ -903,7 +921,7 @@ void Controller_NPad::VibrateControllers( | |||
| 903 | 921 | ||
| 904 | Core::HID::VibrationValue Controller_NPad::GetLastVibration( | 922 | Core::HID::VibrationValue Controller_NPad::GetLastVibration( |
| 905 | const Core::HID::VibrationDeviceHandle& vibration_device_handle) const { | 923 | const Core::HID::VibrationDeviceHandle& vibration_device_handle) const { |
| 906 | if (!IsDeviceHandleValid(vibration_device_handle)) { | 924 | if (IsDeviceHandleValid(vibration_device_handle).IsError()) { |
| 907 | return {}; | 925 | return {}; |
| 908 | } | 926 | } |
| 909 | 927 | ||
| @@ -914,7 +932,7 @@ Core::HID::VibrationValue Controller_NPad::GetLastVibration( | |||
| 914 | 932 | ||
| 915 | void Controller_NPad::InitializeVibrationDevice( | 933 | void Controller_NPad::InitializeVibrationDevice( |
| 916 | const Core::HID::VibrationDeviceHandle& vibration_device_handle) { | 934 | const Core::HID::VibrationDeviceHandle& vibration_device_handle) { |
| 917 | if (!IsDeviceHandleValid(vibration_device_handle)) { | 935 | if (IsDeviceHandleValid(vibration_device_handle).IsError()) { |
| 918 | return; | 936 | return; |
| 919 | } | 937 | } |
| 920 | 938 | ||
| @@ -941,7 +959,7 @@ void Controller_NPad::SetPermitVibrationSession(bool permit_vibration_session) { | |||
| 941 | 959 | ||
| 942 | bool Controller_NPad::IsVibrationDeviceMounted( | 960 | bool Controller_NPad::IsVibrationDeviceMounted( |
| 943 | const Core::HID::VibrationDeviceHandle& vibration_device_handle) const { | 961 | const Core::HID::VibrationDeviceHandle& vibration_device_handle) const { |
| 944 | if (!IsDeviceHandleValid(vibration_device_handle)) { | 962 | if (IsDeviceHandleValid(vibration_device_handle).IsError()) { |
| 945 | return false; | 963 | return false; |
| 946 | } | 964 | } |
| 947 | 965 | ||
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 8b54724ed..1a589cca2 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -81,6 +81,7 @@ public: | |||
| 81 | Dual = 0, | 81 | Dual = 0, |
| 82 | Single = 1, | 82 | Single = 1, |
| 83 | None = 2, | 83 | None = 2, |
| 84 | MaxActivationMode = 3, | ||
| 84 | }; | 85 | }; |
| 85 | 86 | ||
| 86 | // This is nn::hid::NpadCommunicationMode | 87 | // This is nn::hid::NpadCommunicationMode |
| @@ -196,7 +197,7 @@ public: | |||
| 196 | Core::HID::NpadButton GetAndResetPressState(); | 197 | Core::HID::NpadButton GetAndResetPressState(); |
| 197 | 198 | ||
| 198 | static bool IsNpadIdValid(Core::HID::NpadIdType npad_id); | 199 | static bool IsNpadIdValid(Core::HID::NpadIdType npad_id); |
| 199 | static bool IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle); | 200 | static Result IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle); |
| 200 | static Result VerifyValidSixAxisSensorHandle( | 201 | static Result VerifyValidSixAxisSensorHandle( |
| 201 | const Core::HID::SixAxisSensorHandle& device_handle); | 202 | const Core::HID::SixAxisSensorHandle& device_handle); |
| 202 | 203 | ||
diff --git a/src/core/hle/service/hid/errors.h b/src/core/hle/service/hid/errors.h index 615c23b84..46282f42e 100644 --- a/src/core/hle/service/hid/errors.h +++ b/src/core/hle/service/hid/errors.h | |||
| @@ -9,6 +9,9 @@ namespace Service::HID { | |||
| 9 | 9 | ||
| 10 | constexpr Result NpadInvalidHandle{ErrorModule::HID, 100}; | 10 | constexpr Result NpadInvalidHandle{ErrorModule::HID, 100}; |
| 11 | constexpr Result NpadDeviceIndexOutOfRange{ErrorModule::HID, 107}; | 11 | constexpr Result NpadDeviceIndexOutOfRange{ErrorModule::HID, 107}; |
| 12 | constexpr Result VibrationInvalidStyleIndex{ErrorModule::HID, 122}; | ||
| 13 | constexpr Result VibrationInvalidNpadId{ErrorModule::HID, 123}; | ||
| 14 | constexpr Result VibrationDeviceIndexOutOfRange{ErrorModule::HID, 124}; | ||
| 12 | constexpr Result InvalidSixAxisFusionRange{ErrorModule::HID, 423}; | 15 | constexpr Result InvalidSixAxisFusionRange{ErrorModule::HID, 423}; |
| 13 | constexpr Result NpadIsDualJoycon{ErrorModule::HID, 601}; | 16 | constexpr Result NpadIsDualJoycon{ErrorModule::HID, 601}; |
| 14 | constexpr Result NpadIsSameType{ErrorModule::HID, 602}; | 17 | constexpr Result NpadIsSameType{ErrorModule::HID, 602}; |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index dc5d0366d..78efffc50 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -778,7 +778,7 @@ void Hid::IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx) { | |||
| 778 | 778 | ||
| 779 | bool is_at_rest{}; | 779 | bool is_at_rest{}; |
| 780 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 780 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); |
| 781 | const auto result = controller.IsSixAxisSensorAtRest(parameters.sixaxis_handle, is_at_rest); | 781 | controller.IsSixAxisSensorAtRest(parameters.sixaxis_handle, is_at_rest); |
| 782 | 782 | ||
| 783 | LOG_DEBUG(Service_HID, | 783 | LOG_DEBUG(Service_HID, |
| 784 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 784 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", |
| @@ -786,7 +786,7 @@ void Hid::IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx) { | |||
| 786 | parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 786 | parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); |
| 787 | 787 | ||
| 788 | IPC::ResponseBuilder rb{ctx, 3}; | 788 | IPC::ResponseBuilder rb{ctx, 3}; |
| 789 | rb.Push(result); | 789 | rb.Push(ResultSuccess); |
| 790 | rb.Push(is_at_rest); | 790 | rb.Push(is_at_rest); |
| 791 | } | 791 | } |
| 792 | 792 | ||
| @@ -803,8 +803,8 @@ void Hid::IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& c | |||
| 803 | 803 | ||
| 804 | bool is_firmware_available{}; | 804 | bool is_firmware_available{}; |
| 805 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 805 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); |
| 806 | const auto result = controller.IsFirmwareUpdateAvailableForSixAxisSensor( | 806 | controller.IsFirmwareUpdateAvailableForSixAxisSensor(parameters.sixaxis_handle, |
| 807 | parameters.sixaxis_handle, is_firmware_available); | 807 | is_firmware_available); |
| 808 | 808 | ||
| 809 | LOG_WARNING( | 809 | LOG_WARNING( |
| 810 | Service_HID, | 810 | Service_HID, |
| @@ -813,7 +813,7 @@ void Hid::IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& c | |||
| 813 | parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 813 | parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); |
| 814 | 814 | ||
| 815 | IPC::ResponseBuilder rb{ctx, 3}; | 815 | IPC::ResponseBuilder rb{ctx, 3}; |
| 816 | rb.Push(result); | 816 | rb.Push(ResultSuccess); |
| 817 | rb.Push(is_firmware_available); | 817 | rb.Push(is_firmware_available); |
| 818 | } | 818 | } |
| 819 | 819 | ||
| @@ -1083,13 +1083,13 @@ void Hid::DisconnectNpad(Kernel::HLERequestContext& ctx) { | |||
| 1083 | const auto parameters{rp.PopRaw<Parameters>()}; | 1083 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 1084 | 1084 | ||
| 1085 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 1085 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); |
| 1086 | const auto result = controller.DisconnectNpad(parameters.npad_id); | 1086 | controller.DisconnectNpad(parameters.npad_id); |
| 1087 | 1087 | ||
| 1088 | LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, | 1088 | LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, |
| 1089 | parameters.applet_resource_user_id); | 1089 | parameters.applet_resource_user_id); |
| 1090 | 1090 | ||
| 1091 | IPC::ResponseBuilder rb{ctx, 2}; | 1091 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1092 | rb.Push(result); | 1092 | rb.Push(ResultSuccess); |
| 1093 | } | 1093 | } |
| 1094 | 1094 | ||
| 1095 | void Hid::GetPlayerLedPattern(Kernel::HLERequestContext& ctx) { | 1095 | void Hid::GetPlayerLedPattern(Kernel::HLERequestContext& ctx) { |
| @@ -1165,15 +1165,14 @@ void Hid::SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx | |||
| 1165 | const auto parameters{rp.PopRaw<Parameters>()}; | 1165 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 1166 | 1166 | ||
| 1167 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 1167 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); |
| 1168 | const auto result = | 1168 | controller.SetNpadMode(parameters.npad_id, Controller_NPad::NpadJoyDeviceType::Left, |
| 1169 | controller.SetNpadMode(parameters.npad_id, Controller_NPad::NpadJoyDeviceType::Left, | 1169 | Controller_NPad::NpadJoyAssignmentMode::Single); |
| 1170 | Controller_NPad::NpadJoyAssignmentMode::Single); | ||
| 1171 | 1170 | ||
| 1172 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, | 1171 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, |
| 1173 | parameters.applet_resource_user_id); | 1172 | parameters.applet_resource_user_id); |
| 1174 | 1173 | ||
| 1175 | IPC::ResponseBuilder rb{ctx, 2}; | 1174 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1176 | rb.Push(result); | 1175 | rb.Push(ResultSuccess); |
| 1177 | } | 1176 | } |
| 1178 | 1177 | ||
| 1179 | void Hid::SetNpadJoyAssignmentModeSingle(Kernel::HLERequestContext& ctx) { | 1178 | void Hid::SetNpadJoyAssignmentModeSingle(Kernel::HLERequestContext& ctx) { |
| @@ -1189,15 +1188,15 @@ void Hid::SetNpadJoyAssignmentModeSingle(Kernel::HLERequestContext& ctx) { | |||
| 1189 | const auto parameters{rp.PopRaw<Parameters>()}; | 1188 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 1190 | 1189 | ||
| 1191 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 1190 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); |
| 1192 | const auto result = controller.SetNpadMode(parameters.npad_id, parameters.npad_joy_device_type, | 1191 | controller.SetNpadMode(parameters.npad_id, parameters.npad_joy_device_type, |
| 1193 | Controller_NPad::NpadJoyAssignmentMode::Single); | 1192 | Controller_NPad::NpadJoyAssignmentMode::Single); |
| 1194 | 1193 | ||
| 1195 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", | 1194 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", |
| 1196 | parameters.npad_id, parameters.applet_resource_user_id, | 1195 | parameters.npad_id, parameters.applet_resource_user_id, |
| 1197 | parameters.npad_joy_device_type); | 1196 | parameters.npad_joy_device_type); |
| 1198 | 1197 | ||
| 1199 | IPC::ResponseBuilder rb{ctx, 2}; | 1198 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1200 | rb.Push(result); | 1199 | rb.Push(ResultSuccess); |
| 1201 | } | 1200 | } |
| 1202 | 1201 | ||
| 1203 | void Hid::SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) { | 1202 | void Hid::SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) { |
| @@ -1212,14 +1211,13 @@ void Hid::SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) { | |||
| 1212 | const auto parameters{rp.PopRaw<Parameters>()}; | 1211 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 1213 | 1212 | ||
| 1214 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 1213 | auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); |
| 1215 | const auto result = controller.SetNpadMode(parameters.npad_id, {}, | 1214 | controller.SetNpadMode(parameters.npad_id, {}, Controller_NPad::NpadJoyAssignmentMode::Dual); |
| 1216 | Controller_NPad::NpadJoyAssignmentMode::Dual); | ||
| 1217 | 1215 | ||
| 1218 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, | 1216 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, |
| 1219 | parameters.applet_resource_user_id); | 1217 | parameters.applet_resource_user_id); |
| 1220 | 1218 | ||
| 1221 | IPC::ResponseBuilder rb{ctx, 2}; | 1219 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1222 | rb.Push(result); | 1220 | rb.Push(ResultSuccess); |
| 1223 | } | 1221 | } |
| 1224 | 1222 | ||
| 1225 | void Hid::MergeSingleJoyAsDualJoy(Kernel::HLERequestContext& ctx) { | 1223 | void Hid::MergeSingleJoyAsDualJoy(Kernel::HLERequestContext& ctx) { |
| @@ -1412,8 +1410,11 @@ void Hid::ClearNpadCaptureButtonAssignment(Kernel::HLERequestContext& ctx) { | |||
| 1412 | void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) { | 1410 | void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) { |
| 1413 | IPC::RequestParser rp{ctx}; | 1411 | IPC::RequestParser rp{ctx}; |
| 1414 | const auto vibration_device_handle{rp.PopRaw<Core::HID::VibrationDeviceHandle>()}; | 1412 | const auto vibration_device_handle{rp.PopRaw<Core::HID::VibrationDeviceHandle>()}; |
| 1413 | const auto& controller = | ||
| 1414 | GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | ||
| 1415 | 1415 | ||
| 1416 | Core::HID::VibrationDeviceInfo vibration_device_info; | 1416 | Core::HID::VibrationDeviceInfo vibration_device_info; |
| 1417 | bool check_device_index = false; | ||
| 1417 | 1418 | ||
| 1418 | switch (vibration_device_handle.npad_type) { | 1419 | switch (vibration_device_handle.npad_type) { |
| 1419 | case Core::HID::NpadStyleIndex::ProController: | 1420 | case Core::HID::NpadStyleIndex::ProController: |
| @@ -1421,34 +1422,46 @@ void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) { | |||
| 1421 | case Core::HID::NpadStyleIndex::JoyconDual: | 1422 | case Core::HID::NpadStyleIndex::JoyconDual: |
| 1422 | case Core::HID::NpadStyleIndex::JoyconLeft: | 1423 | case Core::HID::NpadStyleIndex::JoyconLeft: |
| 1423 | case Core::HID::NpadStyleIndex::JoyconRight: | 1424 | case Core::HID::NpadStyleIndex::JoyconRight: |
| 1424 | default: | ||
| 1425 | vibration_device_info.type = Core::HID::VibrationDeviceType::LinearResonantActuator; | 1425 | vibration_device_info.type = Core::HID::VibrationDeviceType::LinearResonantActuator; |
| 1426 | check_device_index = true; | ||
| 1426 | break; | 1427 | break; |
| 1427 | case Core::HID::NpadStyleIndex::GameCube: | 1428 | case Core::HID::NpadStyleIndex::GameCube: |
| 1428 | vibration_device_info.type = Core::HID::VibrationDeviceType::GcErm; | 1429 | vibration_device_info.type = Core::HID::VibrationDeviceType::GcErm; |
| 1429 | break; | 1430 | break; |
| 1430 | case Core::HID::NpadStyleIndex::Pokeball: | 1431 | case Core::HID::NpadStyleIndex::N64: |
| 1432 | vibration_device_info.type = Core::HID::VibrationDeviceType::N64; | ||
| 1433 | break; | ||
| 1434 | default: | ||
| 1431 | vibration_device_info.type = Core::HID::VibrationDeviceType::Unknown; | 1435 | vibration_device_info.type = Core::HID::VibrationDeviceType::Unknown; |
| 1432 | break; | 1436 | break; |
| 1433 | } | 1437 | } |
| 1434 | 1438 | ||
| 1435 | switch (vibration_device_handle.device_index) { | 1439 | vibration_device_info.position = Core::HID::VibrationDevicePosition::None; |
| 1436 | case Core::HID::DeviceIndex::Left: | 1440 | if (check_device_index) { |
| 1437 | vibration_device_info.position = Core::HID::VibrationDevicePosition::Left; | 1441 | switch (vibration_device_handle.device_index) { |
| 1438 | break; | 1442 | case Core::HID::DeviceIndex::Left: |
| 1439 | case Core::HID::DeviceIndex::Right: | 1443 | vibration_device_info.position = Core::HID::VibrationDevicePosition::Left; |
| 1440 | vibration_device_info.position = Core::HID::VibrationDevicePosition::Right; | 1444 | break; |
| 1441 | break; | 1445 | case Core::HID::DeviceIndex::Right: |
| 1442 | case Core::HID::DeviceIndex::None: | 1446 | vibration_device_info.position = Core::HID::VibrationDevicePosition::Right; |
| 1443 | default: | 1447 | break; |
| 1444 | ASSERT_MSG(false, "DeviceIndex should never be None!"); | 1448 | case Core::HID::DeviceIndex::None: |
| 1445 | vibration_device_info.position = Core::HID::VibrationDevicePosition::None; | 1449 | default: |
| 1446 | break; | 1450 | ASSERT_MSG(false, "DeviceIndex should never be None!"); |
| 1451 | break; | ||
| 1452 | } | ||
| 1447 | } | 1453 | } |
| 1448 | 1454 | ||
| 1449 | LOG_DEBUG(Service_HID, "called, vibration_device_type={}, vibration_device_position={}", | 1455 | LOG_DEBUG(Service_HID, "called, vibration_device_type={}, vibration_device_position={}", |
| 1450 | vibration_device_info.type, vibration_device_info.position); | 1456 | vibration_device_info.type, vibration_device_info.position); |
| 1451 | 1457 | ||
| 1458 | const auto result = controller.IsDeviceHandleValid(vibration_device_handle); | ||
| 1459 | if (result.IsError()) { | ||
| 1460 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 1461 | rb.Push(result); | ||
| 1462 | return; | ||
| 1463 | } | ||
| 1464 | |||
| 1452 | IPC::ResponseBuilder rb{ctx, 4}; | 1465 | IPC::ResponseBuilder rb{ctx, 4}; |
| 1453 | rb.Push(ResultSuccess); | 1466 | rb.Push(ResultSuccess); |
| 1454 | rb.PushRaw(vibration_device_info); | 1467 | rb.PushRaw(vibration_device_info); |