diff options
| author | 2022-05-21 16:48:05 -0500 | |
|---|---|---|
| committer | 2022-05-27 10:21:10 -0500 | |
| commit | 390d49c5f17f12f98c80867915bb30991a40ea31 (patch) | |
| tree | a061c6d1385f8b9555ab59b2fce37ba0ddf409f9 /src | |
| parent | service: hid: Implement MergeSingleJoyAsDualJoy according to RE (diff) | |
| download | yuzu-390d49c5f17f12f98c80867915bb30991a40ea31.tar.gz yuzu-390d49c5f17f12f98c80867915bb30991a40ea31.tar.xz yuzu-390d49c5f17f12f98c80867915bb30991a40ea31.zip | |
service: hid: Refractor sixaxis functions
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 250 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 23 |
2 files changed, 88 insertions, 185 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 4095a0a3c..8badefdec 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -582,6 +582,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
| 582 | UNREACHABLE(); | 582 | UNREACHABLE(); |
| 583 | break; | 583 | break; |
| 584 | case Core::HID::NpadStyleIndex::ProController: | 584 | case Core::HID::NpadStyleIndex::ProController: |
| 585 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 585 | set_motion_state(sixaxis_fullkey_state, motion_state[0]); | 586 | set_motion_state(sixaxis_fullkey_state, motion_state[0]); |
| 586 | break; | 587 | break; |
| 587 | case Core::HID::NpadStyleIndex::Handheld: | 588 | case Core::HID::NpadStyleIndex::Handheld: |
| @@ -1007,96 +1008,47 @@ ResultCode Controller_NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) { | |||
| 1007 | WriteEmptyEntry(shared_memory); | 1008 | WriteEmptyEntry(shared_memory); |
| 1008 | return ResultSuccess; | 1009 | return ResultSuccess; |
| 1009 | } | 1010 | } |
| 1010 | 1011 | ResultCode Controller_NPad::SetGyroscopeZeroDriftMode( | |
| 1011 | ResultCode Controller_NPad::SetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle, | 1012 | const Core::HID::SixAxisSensorHandle& sixaxis_handle, GyroscopeZeroDriftMode drift_mode) { |
| 1012 | GyroscopeZeroDriftMode drift_mode) { | ||
| 1013 | if (!IsDeviceHandleValid(sixaxis_handle)) { | 1013 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
| 1014 | LOG_ERROR(Service_HID, "Invalid handle"); | 1014 | LOG_ERROR(Service_HID, "Invalid handle"); |
| 1015 | return NpadInvalidHandle; | 1015 | return NpadInvalidHandle; |
| 1016 | } | 1016 | } |
| 1017 | 1017 | ||
| 1018 | auto& controller = GetControllerFromHandle(sixaxis_handle); | 1018 | auto& sixaxis = GetSixaxisState(sixaxis_handle); |
| 1019 | switch (sixaxis_handle.npad_type) { | 1019 | sixaxis.gyroscope_zero_drift_mode = drift_mode; |
| 1020 | case Core::HID::NpadStyleIndex::ProController: | ||
| 1021 | controller.sixaxis_fullkey.gyroscope_zero_drift_mode = drift_mode; | ||
| 1022 | break; | ||
| 1023 | case Core::HID::NpadStyleIndex::Handheld: | ||
| 1024 | controller.sixaxis_handheld.gyroscope_zero_drift_mode = drift_mode; | ||
| 1025 | break; | ||
| 1026 | case Core::HID::NpadStyleIndex::JoyconDual: | ||
| 1027 | case Core::HID::NpadStyleIndex::GameCube: | ||
| 1028 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 1029 | if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) { | ||
| 1030 | controller.sixaxis_dual_left.gyroscope_zero_drift_mode = drift_mode; | ||
| 1031 | break; | ||
| 1032 | } | ||
| 1033 | controller.sixaxis_dual_right.gyroscope_zero_drift_mode = drift_mode; | ||
| 1034 | break; | ||
| 1035 | case Core::HID::NpadStyleIndex::JoyconLeft: | ||
| 1036 | controller.sixaxis_left.gyroscope_zero_drift_mode = drift_mode; | ||
| 1037 | break; | ||
| 1038 | case Core::HID::NpadStyleIndex::JoyconRight: | ||
| 1039 | controller.sixaxis_right.gyroscope_zero_drift_mode = drift_mode; | ||
| 1040 | break; | ||
| 1041 | default: | ||
| 1042 | LOG_ERROR(Service_HID, "Invalid Npad type {}", sixaxis_handle.npad_type); | ||
| 1043 | return NpadInvalidHandle; | ||
| 1044 | } | ||
| 1045 | 1020 | ||
| 1046 | return ResultSuccess; | 1021 | return ResultSuccess; |
| 1047 | } | 1022 | } |
| 1048 | 1023 | ||
| 1049 | ResultCode Controller_NPad::GetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle, | 1024 | ResultCode Controller_NPad::GetGyroscopeZeroDriftMode( |
| 1050 | GyroscopeZeroDriftMode& drift_mode) const { | 1025 | const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 1026 | GyroscopeZeroDriftMode& drift_mode) const { | ||
| 1051 | if (!IsDeviceHandleValid(sixaxis_handle)) { | 1027 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
| 1052 | LOG_ERROR(Service_HID, "Invalid handle"); | 1028 | LOG_ERROR(Service_HID, "Invalid handle"); |
| 1053 | return NpadInvalidHandle; | 1029 | return NpadInvalidHandle; |
| 1054 | } | 1030 | } |
| 1055 | 1031 | ||
| 1056 | auto& controller = GetControllerFromHandle(sixaxis_handle); | 1032 | const auto& sixaxis = GetSixaxisState(sixaxis_handle); |
| 1057 | switch (sixaxis_handle.npad_type) { | 1033 | drift_mode = sixaxis.gyroscope_zero_drift_mode; |
| 1058 | case Core::HID::NpadStyleIndex::ProController: | ||
| 1059 | drift_mode = controller.sixaxis_fullkey.gyroscope_zero_drift_mode; | ||
| 1060 | break; | ||
| 1061 | case Core::HID::NpadStyleIndex::Handheld: | ||
| 1062 | drift_mode = controller.sixaxis_handheld.gyroscope_zero_drift_mode; | ||
| 1063 | break; | ||
| 1064 | case Core::HID::NpadStyleIndex::JoyconDual: | ||
| 1065 | case Core::HID::NpadStyleIndex::GameCube: | ||
| 1066 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 1067 | if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) { | ||
| 1068 | drift_mode = controller.sixaxis_dual_left.gyroscope_zero_drift_mode; | ||
| 1069 | break; | ||
| 1070 | } | ||
| 1071 | drift_mode = controller.sixaxis_dual_right.gyroscope_zero_drift_mode; | ||
| 1072 | break; | ||
| 1073 | case Core::HID::NpadStyleIndex::JoyconLeft: | ||
| 1074 | drift_mode = controller.sixaxis_left.gyroscope_zero_drift_mode; | ||
| 1075 | break; | ||
| 1076 | case Core::HID::NpadStyleIndex::JoyconRight: | ||
| 1077 | drift_mode = controller.sixaxis_right.gyroscope_zero_drift_mode; | ||
| 1078 | break; | ||
| 1079 | default: | ||
| 1080 | LOG_ERROR(Service_HID, "Invalid Npad type {}", sixaxis_handle.npad_type); | ||
| 1081 | return NpadInvalidHandle; | ||
| 1082 | } | ||
| 1083 | 1034 | ||
| 1084 | return ResultSuccess; | 1035 | return ResultSuccess; |
| 1085 | } | 1036 | } |
| 1086 | 1037 | ||
| 1087 | ResultCode Controller_NPad::IsSixAxisSensorAtRest(Core::HID::SixAxisSensorHandle sixaxis_handle, | 1038 | ResultCode Controller_NPad::IsSixAxisSensorAtRest( |
| 1088 | bool& is_at_rest) const { | 1039 | const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_at_rest) const { |
| 1089 | if (!IsDeviceHandleValid(sixaxis_handle)) { | 1040 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
| 1090 | LOG_ERROR(Service_HID, "Invalid handle"); | 1041 | LOG_ERROR(Service_HID, "Invalid handle"); |
| 1091 | return NpadInvalidHandle; | 1042 | return NpadInvalidHandle; |
| 1092 | } | 1043 | } |
| 1044 | |||
| 1093 | const auto& controller = GetControllerFromHandle(sixaxis_handle); | 1045 | const auto& controller = GetControllerFromHandle(sixaxis_handle); |
| 1094 | is_at_rest = controller.sixaxis_at_rest; | 1046 | is_at_rest = controller.sixaxis_at_rest; |
| 1095 | return ResultSuccess; | 1047 | return ResultSuccess; |
| 1096 | } | 1048 | } |
| 1097 | 1049 | ||
| 1098 | ResultCode Controller_NPad::IsFirmwareUpdateAvailableForSixAxisSensor( | 1050 | ResultCode Controller_NPad::IsFirmwareUpdateAvailableForSixAxisSensor( |
| 1099 | Core::HID::SixAxisSensorHandle sixaxis_handle, bool& is_firmware_available) const { | 1051 | const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const { |
| 1100 | if (!IsDeviceHandleValid(sixaxis_handle)) { | 1052 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
| 1101 | LOG_ERROR(Service_HID, "Invalid handle"); | 1053 | LOG_ERROR(Service_HID, "Invalid handle"); |
| 1102 | return NpadInvalidHandle; | 1054 | return NpadInvalidHandle; |
| @@ -1107,7 +1059,7 @@ ResultCode Controller_NPad::IsFirmwareUpdateAvailableForSixAxisSensor( | |||
| 1107 | return ResultSuccess; | 1059 | return ResultSuccess; |
| 1108 | } | 1060 | } |
| 1109 | 1061 | ||
| 1110 | ResultCode Controller_NPad::SetSixAxisEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle, | 1062 | ResultCode Controller_NPad::SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 1111 | bool sixaxis_status) { | 1063 | bool sixaxis_status) { |
| 1112 | if (!IsDeviceHandleValid(sixaxis_handle)) { | 1064 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
| 1113 | LOG_ERROR(Service_HID, "Invalid handle"); | 1065 | LOG_ERROR(Service_HID, "Invalid handle"); |
| @@ -1119,82 +1071,32 @@ ResultCode Controller_NPad::SetSixAxisEnabled(Core::HID::SixAxisSensorHandle six | |||
| 1119 | } | 1071 | } |
| 1120 | 1072 | ||
| 1121 | ResultCode Controller_NPad::IsSixAxisSensorFusionEnabled( | 1073 | ResultCode Controller_NPad::IsSixAxisSensorFusionEnabled( |
| 1122 | Core::HID::SixAxisSensorHandle sixaxis_handle, bool& is_fusion_enabled) const { | 1074 | const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_fusion_enabled) const { |
| 1123 | if (!IsDeviceHandleValid(sixaxis_handle)) { | 1075 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
| 1124 | LOG_ERROR(Service_HID, "Invalid handle"); | 1076 | LOG_ERROR(Service_HID, "Invalid handle"); |
| 1125 | return NpadInvalidHandle; | 1077 | return NpadInvalidHandle; |
| 1126 | } | 1078 | } |
| 1127 | 1079 | ||
| 1128 | auto& controller = GetControllerFromHandle(sixaxis_handle); | 1080 | const auto& sixaxis = GetSixaxisState(sixaxis_handle); |
| 1129 | switch (sixaxis_handle.npad_type) { | 1081 | is_fusion_enabled = sixaxis.is_fusion_enabled; |
| 1130 | case Core::HID::NpadStyleIndex::ProController: | ||
| 1131 | is_fusion_enabled = controller.sixaxis_fullkey.is_fusion_enabled; | ||
| 1132 | break; | ||
| 1133 | case Core::HID::NpadStyleIndex::Handheld: | ||
| 1134 | is_fusion_enabled = controller.sixaxis_handheld.is_fusion_enabled; | ||
| 1135 | break; | ||
| 1136 | case Core::HID::NpadStyleIndex::JoyconDual: | ||
| 1137 | case Core::HID::NpadStyleIndex::GameCube: | ||
| 1138 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 1139 | if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) { | ||
| 1140 | is_fusion_enabled = controller.sixaxis_dual_left.is_fusion_enabled; | ||
| 1141 | break; | ||
| 1142 | } | ||
| 1143 | is_fusion_enabled = controller.sixaxis_dual_right.is_fusion_enabled; | ||
| 1144 | break; | ||
| 1145 | case Core::HID::NpadStyleIndex::JoyconLeft: | ||
| 1146 | is_fusion_enabled = controller.sixaxis_left.is_fusion_enabled; | ||
| 1147 | break; | ||
| 1148 | case Core::HID::NpadStyleIndex::JoyconRight: | ||
| 1149 | is_fusion_enabled = controller.sixaxis_right.is_fusion_enabled; | ||
| 1150 | break; | ||
| 1151 | default: | ||
| 1152 | LOG_ERROR(Service_HID, "Invalid Npad type {}", sixaxis_handle.npad_type); | ||
| 1153 | return NpadInvalidHandle; | ||
| 1154 | } | ||
| 1155 | 1082 | ||
| 1156 | return ResultSuccess; | 1083 | return ResultSuccess; |
| 1157 | } | 1084 | } |
| 1158 | ResultCode Controller_NPad::SetSixAxisFusionEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle, | 1085 | ResultCode Controller_NPad::SetSixAxisFusionEnabled( |
| 1159 | bool is_fusion_enabled) { | 1086 | const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_fusion_enabled) { |
| 1160 | if (!IsDeviceHandleValid(sixaxis_handle)) { | 1087 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
| 1161 | LOG_ERROR(Service_HID, "Invalid handle"); | 1088 | LOG_ERROR(Service_HID, "Invalid handle"); |
| 1162 | return NpadInvalidHandle; | 1089 | return NpadInvalidHandle; |
| 1163 | } | 1090 | } |
| 1164 | 1091 | ||
| 1165 | auto& controller = GetControllerFromHandle(sixaxis_handle); | 1092 | auto& sixaxis = GetSixaxisState(sixaxis_handle); |
| 1166 | switch (sixaxis_handle.npad_type) { | 1093 | sixaxis.is_fusion_enabled = is_fusion_enabled; |
| 1167 | case Core::HID::NpadStyleIndex::ProController: | ||
| 1168 | controller.sixaxis_fullkey.is_fusion_enabled = is_fusion_enabled; | ||
| 1169 | break; | ||
| 1170 | case Core::HID::NpadStyleIndex::Handheld: | ||
| 1171 | controller.sixaxis_handheld.is_fusion_enabled = is_fusion_enabled; | ||
| 1172 | break; | ||
| 1173 | case Core::HID::NpadStyleIndex::JoyconDual: | ||
| 1174 | case Core::HID::NpadStyleIndex::GameCube: | ||
| 1175 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 1176 | if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) { | ||
| 1177 | controller.sixaxis_dual_left.is_fusion_enabled = is_fusion_enabled; | ||
| 1178 | break; | ||
| 1179 | } | ||
| 1180 | controller.sixaxis_dual_right.is_fusion_enabled = is_fusion_enabled; | ||
| 1181 | break; | ||
| 1182 | case Core::HID::NpadStyleIndex::JoyconLeft: | ||
| 1183 | controller.sixaxis_left.is_fusion_enabled = is_fusion_enabled; | ||
| 1184 | break; | ||
| 1185 | case Core::HID::NpadStyleIndex::JoyconRight: | ||
| 1186 | controller.sixaxis_right.is_fusion_enabled = is_fusion_enabled; | ||
| 1187 | break; | ||
| 1188 | default: | ||
| 1189 | LOG_ERROR(Service_HID, "Invalid Npad type {}", sixaxis_handle.npad_type); | ||
| 1190 | return NpadInvalidHandle; | ||
| 1191 | } | ||
| 1192 | 1094 | ||
| 1193 | return ResultSuccess; | 1095 | return ResultSuccess; |
| 1194 | } | 1096 | } |
| 1195 | 1097 | ||
| 1196 | ResultCode Controller_NPad::SetSixAxisFusionParameters( | 1098 | ResultCode Controller_NPad::SetSixAxisFusionParameters( |
| 1197 | Core::HID::SixAxisSensorHandle sixaxis_handle, | 1099 | const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 1198 | Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters) { | 1100 | Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters) { |
| 1199 | if (!IsDeviceHandleValid(sixaxis_handle)) { | 1101 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
| 1200 | LOG_ERROR(Service_HID, "Invalid handle"); | 1102 | LOG_ERROR(Service_HID, "Invalid handle"); |
| @@ -1205,72 +1107,22 @@ ResultCode Controller_NPad::SetSixAxisFusionParameters( | |||
| 1205 | return InvalidSixAxisFusionRange; | 1107 | return InvalidSixAxisFusionRange; |
| 1206 | } | 1108 | } |
| 1207 | 1109 | ||
| 1208 | auto& controller = GetControllerFromHandle(sixaxis_handle); | 1110 | auto& sixaxis = GetSixaxisState(sixaxis_handle); |
| 1209 | switch (sixaxis_handle.npad_type) { | 1111 | sixaxis.fusion = sixaxis_fusion_parameters; |
| 1210 | case Core::HID::NpadStyleIndex::ProController: | ||
| 1211 | controller.sixaxis_fullkey.fusion = sixaxis_fusion_parameters; | ||
| 1212 | break; | ||
| 1213 | case Core::HID::NpadStyleIndex::Handheld: | ||
| 1214 | controller.sixaxis_handheld.fusion = sixaxis_fusion_parameters; | ||
| 1215 | break; | ||
| 1216 | case Core::HID::NpadStyleIndex::JoyconDual: | ||
| 1217 | case Core::HID::NpadStyleIndex::GameCube: | ||
| 1218 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 1219 | if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) { | ||
| 1220 | controller.sixaxis_dual_left.fusion = sixaxis_fusion_parameters; | ||
| 1221 | break; | ||
| 1222 | } | ||
| 1223 | controller.sixaxis_dual_right.fusion = sixaxis_fusion_parameters; | ||
| 1224 | break; | ||
| 1225 | case Core::HID::NpadStyleIndex::JoyconLeft: | ||
| 1226 | controller.sixaxis_left.fusion = sixaxis_fusion_parameters; | ||
| 1227 | break; | ||
| 1228 | case Core::HID::NpadStyleIndex::JoyconRight: | ||
| 1229 | controller.sixaxis_right.fusion = sixaxis_fusion_parameters; | ||
| 1230 | break; | ||
| 1231 | default: | ||
| 1232 | LOG_ERROR(Service_HID, "Invalid Npad type {}", sixaxis_handle.npad_type); | ||
| 1233 | return NpadInvalidHandle; | ||
| 1234 | } | ||
| 1235 | 1112 | ||
| 1236 | return ResultSuccess; | 1113 | return ResultSuccess; |
| 1237 | } | 1114 | } |
| 1238 | 1115 | ||
| 1239 | ResultCode Controller_NPad::GetSixAxisFusionParameters( | 1116 | ResultCode Controller_NPad::GetSixAxisFusionParameters( |
| 1240 | Core::HID::SixAxisSensorHandle sixaxis_handle, | 1117 | const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 1241 | Core::HID::SixAxisSensorFusionParameters& parameters) const { | 1118 | Core::HID::SixAxisSensorFusionParameters& parameters) const { |
| 1242 | if (!IsDeviceHandleValid(sixaxis_handle)) { | 1119 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
| 1243 | LOG_ERROR(Service_HID, "Invalid handle"); | 1120 | LOG_ERROR(Service_HID, "Invalid handle"); |
| 1244 | return NpadInvalidHandle; | 1121 | return NpadInvalidHandle; |
| 1245 | } | 1122 | } |
| 1246 | 1123 | ||
| 1247 | const auto& controller = GetControllerFromHandle(sixaxis_handle); | 1124 | const auto& sixaxis = GetSixaxisState(sixaxis_handle); |
| 1248 | switch (sixaxis_handle.npad_type) { | 1125 | parameters = sixaxis.fusion; |
| 1249 | case Core::HID::NpadStyleIndex::ProController: | ||
| 1250 | parameters = controller.sixaxis_fullkey.fusion; | ||
| 1251 | break; | ||
| 1252 | case Core::HID::NpadStyleIndex::Handheld: | ||
| 1253 | parameters = controller.sixaxis_handheld.fusion; | ||
| 1254 | break; | ||
| 1255 | case Core::HID::NpadStyleIndex::JoyconDual: | ||
| 1256 | case Core::HID::NpadStyleIndex::GameCube: | ||
| 1257 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 1258 | if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) { | ||
| 1259 | parameters = controller.sixaxis_dual_left.fusion; | ||
| 1260 | break; | ||
| 1261 | } | ||
| 1262 | parameters = controller.sixaxis_dual_right.fusion; | ||
| 1263 | break; | ||
| 1264 | case Core::HID::NpadStyleIndex::JoyconLeft: | ||
| 1265 | parameters = controller.sixaxis_left.fusion; | ||
| 1266 | break; | ||
| 1267 | case Core::HID::NpadStyleIndex::JoyconRight: | ||
| 1268 | parameters = controller.sixaxis_right.fusion; | ||
| 1269 | break; | ||
| 1270 | default: | ||
| 1271 | LOG_ERROR(Service_HID, "Invalid Npad type {}", sixaxis_handle.npad_type); | ||
| 1272 | return NpadInvalidHandle; | ||
| 1273 | } | ||
| 1274 | 1126 | ||
| 1275 | return ResultSuccess; | 1127 | return ResultSuccess; |
| 1276 | } | 1128 | } |
| @@ -1547,4 +1399,50 @@ const Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromNpa | |||
| 1547 | return controller_data[npad_index]; | 1399 | return controller_data[npad_index]; |
| 1548 | } | 1400 | } |
| 1549 | 1401 | ||
| 1402 | Controller_NPad::SixaxisParameters& Controller_NPad::GetSixaxisState( | ||
| 1403 | const Core::HID::SixAxisSensorHandle& sixaxis_handle) { | ||
| 1404 | auto& controller = GetControllerFromHandle(sixaxis_handle); | ||
| 1405 | switch (sixaxis_handle.npad_type) { | ||
| 1406 | case Core::HID::NpadStyleIndex::ProController: | ||
| 1407 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 1408 | return controller.sixaxis_fullkey; | ||
| 1409 | case Core::HID::NpadStyleIndex::Handheld: | ||
| 1410 | return controller.sixaxis_handheld; | ||
| 1411 | case Core::HID::NpadStyleIndex::JoyconDual: | ||
| 1412 | if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) { | ||
| 1413 | return controller.sixaxis_dual_left; | ||
| 1414 | } | ||
| 1415 | return controller.sixaxis_dual_right; | ||
| 1416 | case Core::HID::NpadStyleIndex::JoyconLeft: | ||
| 1417 | return controller.sixaxis_left; | ||
| 1418 | case Core::HID::NpadStyleIndex::JoyconRight: | ||
| 1419 | return controller.sixaxis_right; | ||
| 1420 | default: | ||
| 1421 | return controller.sixaxis_unknown; | ||
| 1422 | } | ||
| 1423 | } | ||
| 1424 | |||
| 1425 | const Controller_NPad::SixaxisParameters& Controller_NPad::GetSixaxisState( | ||
| 1426 | const Core::HID::SixAxisSensorHandle& sixaxis_handle) const { | ||
| 1427 | const auto& controller = GetControllerFromHandle(sixaxis_handle); | ||
| 1428 | switch (sixaxis_handle.npad_type) { | ||
| 1429 | case Core::HID::NpadStyleIndex::ProController: | ||
| 1430 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 1431 | return controller.sixaxis_fullkey; | ||
| 1432 | case Core::HID::NpadStyleIndex::Handheld: | ||
| 1433 | return controller.sixaxis_handheld; | ||
| 1434 | case Core::HID::NpadStyleIndex::JoyconDual: | ||
| 1435 | if (sixaxis_handle.device_index == Core::HID::DeviceIndex::Left) { | ||
| 1436 | return controller.sixaxis_dual_left; | ||
| 1437 | } | ||
| 1438 | return controller.sixaxis_dual_right; | ||
| 1439 | case Core::HID::NpadStyleIndex::JoyconLeft: | ||
| 1440 | return controller.sixaxis_left; | ||
| 1441 | case Core::HID::NpadStyleIndex::JoyconRight: | ||
| 1442 | return controller.sixaxis_right; | ||
| 1443 | default: | ||
| 1444 | return controller.sixaxis_unknown; | ||
| 1445 | } | ||
| 1446 | } | ||
| 1447 | |||
| 1550 | } // namespace Service::HID | 1448 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 5305e8cf8..dfb4de740 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -143,25 +143,25 @@ public: | |||
| 143 | 143 | ||
| 144 | ResultCode DisconnectNpad(Core::HID::NpadIdType npad_id); | 144 | ResultCode DisconnectNpad(Core::HID::NpadIdType npad_id); |
| 145 | 145 | ||
| 146 | ResultCode SetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle, | 146 | ResultCode SetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 147 | GyroscopeZeroDriftMode drift_mode); | 147 | GyroscopeZeroDriftMode drift_mode); |
| 148 | ResultCode GetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle, | 148 | ResultCode GetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 149 | GyroscopeZeroDriftMode& drift_mode) const; | 149 | GyroscopeZeroDriftMode& drift_mode) const; |
| 150 | ResultCode IsSixAxisSensorAtRest(Core::HID::SixAxisSensorHandle sixaxis_handle, | 150 | ResultCode IsSixAxisSensorAtRest(const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 151 | bool& is_at_rest) const; | 151 | bool& is_at_rest) const; |
| 152 | ResultCode IsFirmwareUpdateAvailableForSixAxisSensor( | 152 | ResultCode IsFirmwareUpdateAvailableForSixAxisSensor( |
| 153 | Core::HID::SixAxisSensorHandle sixaxis_handle, bool& is_firmware_available) const; | 153 | const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const; |
| 154 | ResultCode SetSixAxisEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle, | 154 | ResultCode SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 155 | bool sixaxis_status); | 155 | bool sixaxis_status); |
| 156 | ResultCode IsSixAxisSensorFusionEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle, | 156 | ResultCode IsSixAxisSensorFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 157 | bool& is_fusion_enabled) const; | 157 | bool& is_fusion_enabled) const; |
| 158 | ResultCode SetSixAxisFusionEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle, | 158 | ResultCode SetSixAxisFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 159 | bool is_fusion_enabled); | 159 | bool is_fusion_enabled); |
| 160 | ResultCode SetSixAxisFusionParameters( | 160 | ResultCode SetSixAxisFusionParameters( |
| 161 | Core::HID::SixAxisSensorHandle sixaxis_handle, | 161 | const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 162 | Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters); | 162 | Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters); |
| 163 | ResultCode GetSixAxisFusionParameters( | 163 | ResultCode GetSixAxisFusionParameters( |
| 164 | Core::HID::SixAxisSensorHandle sixaxis_handle, | 164 | const Core::HID::SixAxisSensorHandle& sixaxis_handle, |
| 165 | Core::HID::SixAxisSensorFusionParameters& parameters) const; | 165 | Core::HID::SixAxisSensorFusionParameters& parameters) const; |
| 166 | ResultCode GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const; | 166 | ResultCode GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const; |
| 167 | ResultCode IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id, | 167 | ResultCode IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id, |
| @@ -493,6 +493,7 @@ private: | |||
| 493 | SixaxisParameters sixaxis_dual_right{}; | 493 | SixaxisParameters sixaxis_dual_right{}; |
| 494 | SixaxisParameters sixaxis_left{}; | 494 | SixaxisParameters sixaxis_left{}; |
| 495 | SixaxisParameters sixaxis_right{}; | 495 | SixaxisParameters sixaxis_right{}; |
| 496 | SixaxisParameters sixaxis_unknown{}; | ||
| 496 | 497 | ||
| 497 | // Current pad state | 498 | // Current pad state |
| 498 | NPadGenericState npad_pad_state{}; | 499 | NPadGenericState npad_pad_state{}; |
| @@ -524,6 +525,10 @@ private: | |||
| 524 | NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id); | 525 | NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id); |
| 525 | const NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) const; | 526 | const NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) const; |
| 526 | 527 | ||
| 528 | SixaxisParameters& GetSixaxisState(const Core::HID::SixAxisSensorHandle& device_handle); | ||
| 529 | const SixaxisParameters& GetSixaxisState( | ||
| 530 | const Core::HID::SixAxisSensorHandle& device_handle) const; | ||
| 531 | |||
| 527 | std::atomic<u64> press_state{}; | 532 | std::atomic<u64> press_state{}; |
| 528 | 533 | ||
| 529 | std::array<NpadControllerData, NPAD_COUNT> controller_data{}; | 534 | std::array<NpadControllerData, NPAD_COUNT> controller_data{}; |