diff options
| author | 2023-11-26 21:08:53 -0500 | |
|---|---|---|
| committer | 2023-11-26 21:08:53 -0500 | |
| commit | 1d11fe00a3000efbf6a0a4bb690e0d544a1b7b4a (patch) | |
| tree | c219aacab776c0a1e3956614b60a01fa2f6164cb /src/core/hid/emulated_controller.cpp | |
| parent | shader_recompiler: Align SSBO offsets in GlobalMemory functions (diff) | |
| parent | Merge pull request #11535 from GPUCode/upload_cmdbuf (diff) | |
| download | yuzu-1d11fe00a3000efbf6a0a4bb690e0d544a1b7b4a.tar.gz yuzu-1d11fe00a3000efbf6a0a4bb690e0d544a1b7b4a.tar.xz yuzu-1d11fe00a3000efbf6a0a4bb690e0d544a1b7b4a.zip | |
Merge branch 'master' into ssbo-align
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 144 |
1 files changed, 110 insertions, 34 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 2af3f06fc..a6e681e15 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "common/thread.h" | 8 | #include "common/thread.h" |
| 9 | #include "core/hid/emulated_controller.h" | 9 | #include "core/hid/emulated_controller.h" |
| 10 | #include "core/hid/input_converter.h" | 10 | #include "core/hid/input_converter.h" |
| 11 | #include "core/hle/service/hid/hid_util.h" | ||
| 11 | 12 | ||
| 12 | namespace Core::HID { | 13 | namespace Core::HID { |
| 13 | constexpr s32 HID_JOYSTICK_MAX = 0x7fff; | 14 | constexpr s32 HID_JOYSTICK_MAX = 0x7fff; |
| @@ -82,7 +83,7 @@ Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadStyleInde | |||
| 82 | } | 83 | } |
| 83 | 84 | ||
| 84 | void EmulatedController::ReloadFromSettings() { | 85 | void EmulatedController::ReloadFromSettings() { |
| 85 | const auto player_index = NpadIdTypeToIndex(npad_id_type); | 86 | const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type); |
| 86 | const auto& player = Settings::values.players.GetValue()[player_index]; | 87 | const auto& player = Settings::values.players.GetValue()[player_index]; |
| 87 | 88 | ||
| 88 | for (std::size_t index = 0; index < player.buttons.size(); ++index) { | 89 | for (std::size_t index = 0; index < player.buttons.size(); ++index) { |
| @@ -96,18 +97,7 @@ void EmulatedController::ReloadFromSettings() { | |||
| 96 | } | 97 | } |
| 97 | 98 | ||
| 98 | controller.color_values = {}; | 99 | controller.color_values = {}; |
| 99 | controller.colors_state.fullkey = { | 100 | ReloadColorsFromSettings(); |
| 100 | .body = GetNpadColor(player.body_color_left), | ||
| 101 | .button = GetNpadColor(player.button_color_left), | ||
| 102 | }; | ||
| 103 | controller.colors_state.left = { | ||
| 104 | .body = GetNpadColor(player.body_color_left), | ||
| 105 | .button = GetNpadColor(player.button_color_left), | ||
| 106 | }; | ||
| 107 | controller.colors_state.right = { | ||
| 108 | .body = GetNpadColor(player.body_color_right), | ||
| 109 | .button = GetNpadColor(player.button_color_right), | ||
| 110 | }; | ||
| 111 | 101 | ||
| 112 | ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs); | 102 | ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs); |
| 113 | 103 | ||
| @@ -128,6 +118,30 @@ void EmulatedController::ReloadFromSettings() { | |||
| 128 | ReloadInput(); | 118 | ReloadInput(); |
| 129 | } | 119 | } |
| 130 | 120 | ||
| 121 | void EmulatedController::ReloadColorsFromSettings() { | ||
| 122 | const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type); | ||
| 123 | const auto& player = Settings::values.players.GetValue()[player_index]; | ||
| 124 | |||
| 125 | // Avoid updating colors if overridden by physical controller | ||
| 126 | if (controller.color_values[LeftIndex].body != 0 && | ||
| 127 | controller.color_values[RightIndex].body != 0) { | ||
| 128 | return; | ||
| 129 | } | ||
| 130 | |||
| 131 | controller.colors_state.fullkey = { | ||
| 132 | .body = GetNpadColor(player.body_color_left), | ||
| 133 | .button = GetNpadColor(player.button_color_left), | ||
| 134 | }; | ||
| 135 | controller.colors_state.left = { | ||
| 136 | .body = GetNpadColor(player.body_color_left), | ||
| 137 | .button = GetNpadColor(player.button_color_left), | ||
| 138 | }; | ||
| 139 | controller.colors_state.right = { | ||
| 140 | .body = GetNpadColor(player.body_color_right), | ||
| 141 | .button = GetNpadColor(player.button_color_right), | ||
| 142 | }; | ||
| 143 | } | ||
| 144 | |||
| 131 | void EmulatedController::LoadDevices() { | 145 | void EmulatedController::LoadDevices() { |
| 132 | // TODO(german77): Use more buttons to detect the correct device | 146 | // TODO(german77): Use more buttons to detect the correct device |
| 133 | const auto left_joycon = button_params[Settings::NativeButton::DRight]; | 147 | const auto left_joycon = button_params[Settings::NativeButton::DRight]; |
| @@ -202,7 +216,7 @@ void EmulatedController::LoadDevices() { | |||
| 202 | } | 216 | } |
| 203 | 217 | ||
| 204 | void EmulatedController::LoadTASParams() { | 218 | void EmulatedController::LoadTASParams() { |
| 205 | const auto player_index = NpadIdTypeToIndex(npad_id_type); | 219 | const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type); |
| 206 | Common::ParamPackage common_params{}; | 220 | Common::ParamPackage common_params{}; |
| 207 | common_params.Set("engine", "tas"); | 221 | common_params.Set("engine", "tas"); |
| 208 | common_params.Set("port", static_cast<int>(player_index)); | 222 | common_params.Set("port", static_cast<int>(player_index)); |
| @@ -230,10 +244,12 @@ void EmulatedController::LoadTASParams() { | |||
| 230 | tas_button_params[Settings::NativeButton::DUp].Set("button", 13); | 244 | tas_button_params[Settings::NativeButton::DUp].Set("button", 13); |
| 231 | tas_button_params[Settings::NativeButton::DRight].Set("button", 14); | 245 | tas_button_params[Settings::NativeButton::DRight].Set("button", 14); |
| 232 | tas_button_params[Settings::NativeButton::DDown].Set("button", 15); | 246 | tas_button_params[Settings::NativeButton::DDown].Set("button", 15); |
| 233 | tas_button_params[Settings::NativeButton::SL].Set("button", 16); | 247 | tas_button_params[Settings::NativeButton::SLLeft].Set("button", 16); |
| 234 | tas_button_params[Settings::NativeButton::SR].Set("button", 17); | 248 | tas_button_params[Settings::NativeButton::SRLeft].Set("button", 17); |
| 235 | tas_button_params[Settings::NativeButton::Home].Set("button", 18); | 249 | tas_button_params[Settings::NativeButton::Home].Set("button", 18); |
| 236 | tas_button_params[Settings::NativeButton::Screenshot].Set("button", 19); | 250 | tas_button_params[Settings::NativeButton::Screenshot].Set("button", 19); |
| 251 | tas_button_params[Settings::NativeButton::SLRight].Set("button", 20); | ||
| 252 | tas_button_params[Settings::NativeButton::SRRight].Set("button", 21); | ||
| 237 | 253 | ||
| 238 | tas_stick_params[Settings::NativeAnalog::LStick].Set("axis_x", 0); | 254 | tas_stick_params[Settings::NativeAnalog::LStick].Set("axis_x", 0); |
| 239 | tas_stick_params[Settings::NativeAnalog::LStick].Set("axis_y", 1); | 255 | tas_stick_params[Settings::NativeAnalog::LStick].Set("axis_y", 1); |
| @@ -249,7 +265,7 @@ void EmulatedController::LoadTASParams() { | |||
| 249 | } | 265 | } |
| 250 | 266 | ||
| 251 | void EmulatedController::LoadVirtualGamepadParams() { | 267 | void EmulatedController::LoadVirtualGamepadParams() { |
| 252 | const auto player_index = NpadIdTypeToIndex(npad_id_type); | 268 | const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type); |
| 253 | Common::ParamPackage common_params{}; | 269 | Common::ParamPackage common_params{}; |
| 254 | common_params.Set("engine", "virtual_gamepad"); | 270 | common_params.Set("engine", "virtual_gamepad"); |
| 255 | common_params.Set("port", static_cast<int>(player_index)); | 271 | common_params.Set("port", static_cast<int>(player_index)); |
| @@ -283,10 +299,12 @@ void EmulatedController::LoadVirtualGamepadParams() { | |||
| 283 | virtual_button_params[Settings::NativeButton::DUp].Set("button", 13); | 299 | virtual_button_params[Settings::NativeButton::DUp].Set("button", 13); |
| 284 | virtual_button_params[Settings::NativeButton::DRight].Set("button", 14); | 300 | virtual_button_params[Settings::NativeButton::DRight].Set("button", 14); |
| 285 | virtual_button_params[Settings::NativeButton::DDown].Set("button", 15); | 301 | virtual_button_params[Settings::NativeButton::DDown].Set("button", 15); |
| 286 | virtual_button_params[Settings::NativeButton::SL].Set("button", 16); | 302 | virtual_button_params[Settings::NativeButton::SLLeft].Set("button", 16); |
| 287 | virtual_button_params[Settings::NativeButton::SR].Set("button", 17); | 303 | virtual_button_params[Settings::NativeButton::SRLeft].Set("button", 17); |
| 288 | virtual_button_params[Settings::NativeButton::Home].Set("button", 18); | 304 | virtual_button_params[Settings::NativeButton::Home].Set("button", 18); |
| 289 | virtual_button_params[Settings::NativeButton::Screenshot].Set("button", 19); | 305 | virtual_button_params[Settings::NativeButton::Screenshot].Set("button", 19); |
| 306 | virtual_button_params[Settings::NativeButton::SLRight].Set("button", 20); | ||
| 307 | virtual_button_params[Settings::NativeButton::SRRight].Set("button", 21); | ||
| 290 | 308 | ||
| 291 | virtual_stick_params[Settings::NativeAnalog::LStick].Set("axis_x", 0); | 309 | virtual_stick_params[Settings::NativeAnalog::LStick].Set("axis_x", 0); |
| 292 | virtual_stick_params[Settings::NativeAnalog::LStick].Set("axis_y", 1); | 310 | virtual_stick_params[Settings::NativeAnalog::LStick].Set("axis_y", 1); |
| @@ -491,9 +509,11 @@ void EmulatedController::ReloadInput() { | |||
| 491 | }); | 509 | }); |
| 492 | } | 510 | } |
| 493 | turbo_button_state = 0; | 511 | turbo_button_state = 0; |
| 512 | is_initalized = true; | ||
| 494 | } | 513 | } |
| 495 | 514 | ||
| 496 | void EmulatedController::UnloadInput() { | 515 | void EmulatedController::UnloadInput() { |
| 516 | is_initalized = false; | ||
| 497 | for (auto& button : button_devices) { | 517 | for (auto& button : button_devices) { |
| 498 | button.reset(); | 518 | button.reset(); |
| 499 | } | 519 | } |
| @@ -598,7 +618,7 @@ bool EmulatedController::IsConfiguring() const { | |||
| 598 | } | 618 | } |
| 599 | 619 | ||
| 600 | void EmulatedController::SaveCurrentConfig() { | 620 | void EmulatedController::SaveCurrentConfig() { |
| 601 | const auto player_index = NpadIdTypeToIndex(npad_id_type); | 621 | const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type); |
| 602 | auto& player = Settings::values.players.GetValue()[player_index]; | 622 | auto& player = Settings::values.players.GetValue()[player_index]; |
| 603 | player.connected = is_connected; | 623 | player.connected = is_connected; |
| 604 | player.controller_type = MapNPadToSettingsType(npad_type); | 624 | player.controller_type = MapNPadToSettingsType(npad_type); |
| @@ -854,12 +874,16 @@ void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback | |||
| 854 | controller.npad_button_state.down.Assign(current_status.value); | 874 | controller.npad_button_state.down.Assign(current_status.value); |
| 855 | controller.debug_pad_button_state.d_down.Assign(current_status.value); | 875 | controller.debug_pad_button_state.d_down.Assign(current_status.value); |
| 856 | break; | 876 | break; |
| 857 | case Settings::NativeButton::SL: | 877 | case Settings::NativeButton::SLLeft: |
| 858 | controller.npad_button_state.left_sl.Assign(current_status.value); | 878 | controller.npad_button_state.left_sl.Assign(current_status.value); |
| 879 | break; | ||
| 880 | case Settings::NativeButton::SLRight: | ||
| 859 | controller.npad_button_state.right_sl.Assign(current_status.value); | 881 | controller.npad_button_state.right_sl.Assign(current_status.value); |
| 860 | break; | 882 | break; |
| 861 | case Settings::NativeButton::SR: | 883 | case Settings::NativeButton::SRLeft: |
| 862 | controller.npad_button_state.left_sr.Assign(current_status.value); | 884 | controller.npad_button_state.left_sr.Assign(current_status.value); |
| 885 | break; | ||
| 886 | case Settings::NativeButton::SRRight: | ||
| 863 | controller.npad_button_state.right_sr.Assign(current_status.value); | 887 | controller.npad_button_state.right_sr.Assign(current_status.value); |
| 864 | break; | 888 | break; |
| 865 | case Settings::NativeButton::Home: | 889 | case Settings::NativeButton::Home: |
| @@ -1091,30 +1115,30 @@ void EmulatedController::SetBattery(const Common::Input::CallbackStatus& callbac | |||
| 1091 | 1115 | ||
| 1092 | bool is_charging = false; | 1116 | bool is_charging = false; |
| 1093 | bool is_powered = false; | 1117 | bool is_powered = false; |
| 1094 | NpadBatteryLevel battery_level = 0; | 1118 | NpadBatteryLevel battery_level = NpadBatteryLevel::Empty; |
| 1095 | switch (controller.battery_values[index]) { | 1119 | switch (controller.battery_values[index]) { |
| 1096 | case Common::Input::BatteryLevel::Charging: | 1120 | case Common::Input::BatteryLevel::Charging: |
| 1097 | is_charging = true; | 1121 | is_charging = true; |
| 1098 | is_powered = true; | 1122 | is_powered = true; |
| 1099 | battery_level = 6; | 1123 | battery_level = NpadBatteryLevel::Full; |
| 1100 | break; | 1124 | break; |
| 1101 | case Common::Input::BatteryLevel::Medium: | 1125 | case Common::Input::BatteryLevel::Medium: |
| 1102 | battery_level = 6; | 1126 | battery_level = NpadBatteryLevel::High; |
| 1103 | break; | 1127 | break; |
| 1104 | case Common::Input::BatteryLevel::Low: | 1128 | case Common::Input::BatteryLevel::Low: |
| 1105 | battery_level = 4; | 1129 | battery_level = NpadBatteryLevel::Low; |
| 1106 | break; | 1130 | break; |
| 1107 | case Common::Input::BatteryLevel::Critical: | 1131 | case Common::Input::BatteryLevel::Critical: |
| 1108 | battery_level = 2; | 1132 | battery_level = NpadBatteryLevel::Critical; |
| 1109 | break; | 1133 | break; |
| 1110 | case Common::Input::BatteryLevel::Empty: | 1134 | case Common::Input::BatteryLevel::Empty: |
| 1111 | battery_level = 0; | 1135 | battery_level = NpadBatteryLevel::Empty; |
| 1112 | break; | 1136 | break; |
| 1113 | case Common::Input::BatteryLevel::None: | 1137 | case Common::Input::BatteryLevel::None: |
| 1114 | case Common::Input::BatteryLevel::Full: | 1138 | case Common::Input::BatteryLevel::Full: |
| 1115 | default: | 1139 | default: |
| 1116 | is_powered = true; | 1140 | is_powered = true; |
| 1117 | battery_level = 8; | 1141 | battery_level = NpadBatteryLevel::Full; |
| 1118 | break; | 1142 | break; |
| 1119 | } | 1143 | } |
| 1120 | 1144 | ||
| @@ -1185,13 +1209,16 @@ void EmulatedController::SetNfc(const Common::Input::CallbackStatus& callback) { | |||
| 1185 | } | 1209 | } |
| 1186 | 1210 | ||
| 1187 | bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue vibration) { | 1211 | bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue vibration) { |
| 1212 | if (!is_initalized) { | ||
| 1213 | return false; | ||
| 1214 | } | ||
| 1188 | if (device_index >= output_devices.size()) { | 1215 | if (device_index >= output_devices.size()) { |
| 1189 | return false; | 1216 | return false; |
| 1190 | } | 1217 | } |
| 1191 | if (!output_devices[device_index]) { | 1218 | if (!output_devices[device_index]) { |
| 1192 | return false; | 1219 | return false; |
| 1193 | } | 1220 | } |
| 1194 | const auto player_index = NpadIdTypeToIndex(npad_id_type); | 1221 | const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type); |
| 1195 | const auto& player = Settings::values.players.GetValue()[player_index]; | 1222 | const auto& player = Settings::values.players.GetValue()[player_index]; |
| 1196 | const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f; | 1223 | const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f; |
| 1197 | 1224 | ||
| @@ -1217,9 +1244,13 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v | |||
| 1217 | } | 1244 | } |
| 1218 | 1245 | ||
| 1219 | bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { | 1246 | bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { |
| 1220 | const auto player_index = NpadIdTypeToIndex(npad_id_type); | 1247 | const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type); |
| 1221 | const auto& player = Settings::values.players.GetValue()[player_index]; | 1248 | const auto& player = Settings::values.players.GetValue()[player_index]; |
| 1222 | 1249 | ||
| 1250 | if (!is_initalized) { | ||
| 1251 | return false; | ||
| 1252 | } | ||
| 1253 | |||
| 1223 | if (!player.vibration_enabled) { | 1254 | if (!player.vibration_enabled) { |
| 1224 | return false; | 1255 | return false; |
| 1225 | } | 1256 | } |
| @@ -1239,6 +1270,10 @@ Common::Input::DriverResult EmulatedController::SetPollingMode( | |||
| 1239 | EmulatedDeviceIndex device_index, Common::Input::PollingMode polling_mode) { | 1270 | EmulatedDeviceIndex device_index, Common::Input::PollingMode polling_mode) { |
| 1240 | LOG_INFO(Service_HID, "Set polling mode {}, device_index={}", polling_mode, device_index); | 1271 | LOG_INFO(Service_HID, "Set polling mode {}, device_index={}", polling_mode, device_index); |
| 1241 | 1272 | ||
| 1273 | if (!is_initalized) { | ||
| 1274 | return Common::Input::DriverResult::InvalidHandle; | ||
| 1275 | } | ||
| 1276 | |||
| 1242 | auto& left_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Left)]; | 1277 | auto& left_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Left)]; |
| 1243 | auto& right_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; | 1278 | auto& right_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; |
| 1244 | auto& nfc_output_device = output_devices[3]; | 1279 | auto& nfc_output_device = output_devices[3]; |
| @@ -1284,6 +1319,10 @@ bool EmulatedController::SetCameraFormat( | |||
| 1284 | Core::IrSensor::ImageTransferProcessorFormat camera_format) { | 1319 | Core::IrSensor::ImageTransferProcessorFormat camera_format) { |
| 1285 | LOG_INFO(Service_HID, "Set camera format {}", camera_format); | 1320 | LOG_INFO(Service_HID, "Set camera format {}", camera_format); |
| 1286 | 1321 | ||
| 1322 | if (!is_initalized) { | ||
| 1323 | return false; | ||
| 1324 | } | ||
| 1325 | |||
| 1287 | auto& right_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; | 1326 | auto& right_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; |
| 1288 | auto& camera_output_device = output_devices[2]; | 1327 | auto& camera_output_device = output_devices[2]; |
| 1289 | 1328 | ||
| @@ -1307,6 +1346,11 @@ void EmulatedController::SetRingParam(Common::ParamPackage param) { | |||
| 1307 | } | 1346 | } |
| 1308 | 1347 | ||
| 1309 | bool EmulatedController::HasNfc() const { | 1348 | bool EmulatedController::HasNfc() const { |
| 1349 | |||
| 1350 | if (!is_initalized) { | ||
| 1351 | return false; | ||
| 1352 | } | ||
| 1353 | |||
| 1310 | const auto& nfc_output_device = output_devices[3]; | 1354 | const auto& nfc_output_device = output_devices[3]; |
| 1311 | 1355 | ||
| 1312 | switch (npad_type) { | 1356 | switch (npad_type) { |
| @@ -1344,6 +1388,10 @@ bool EmulatedController::RemoveNfcHandle() { | |||
| 1344 | } | 1388 | } |
| 1345 | 1389 | ||
| 1346 | bool EmulatedController::StartNfcPolling() { | 1390 | bool EmulatedController::StartNfcPolling() { |
| 1391 | if (!is_initalized) { | ||
| 1392 | return false; | ||
| 1393 | } | ||
| 1394 | |||
| 1347 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; | 1395 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; |
| 1348 | auto& nfc_virtual_output_device = output_devices[3]; | 1396 | auto& nfc_virtual_output_device = output_devices[3]; |
| 1349 | 1397 | ||
| @@ -1355,6 +1403,10 @@ bool EmulatedController::StartNfcPolling() { | |||
| 1355 | } | 1403 | } |
| 1356 | 1404 | ||
| 1357 | bool EmulatedController::StopNfcPolling() { | 1405 | bool EmulatedController::StopNfcPolling() { |
| 1406 | if (!is_initalized) { | ||
| 1407 | return false; | ||
| 1408 | } | ||
| 1409 | |||
| 1358 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; | 1410 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; |
| 1359 | auto& nfc_virtual_output_device = output_devices[3]; | 1411 | auto& nfc_virtual_output_device = output_devices[3]; |
| 1360 | 1412 | ||
| @@ -1366,6 +1418,10 @@ bool EmulatedController::StopNfcPolling() { | |||
| 1366 | } | 1418 | } |
| 1367 | 1419 | ||
| 1368 | bool EmulatedController::ReadAmiiboData(std::vector<u8>& data) { | 1420 | bool EmulatedController::ReadAmiiboData(std::vector<u8>& data) { |
| 1421 | if (!is_initalized) { | ||
| 1422 | return false; | ||
| 1423 | } | ||
| 1424 | |||
| 1369 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; | 1425 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; |
| 1370 | auto& nfc_virtual_output_device = output_devices[3]; | 1426 | auto& nfc_virtual_output_device = output_devices[3]; |
| 1371 | 1427 | ||
| @@ -1378,6 +1434,10 @@ bool EmulatedController::ReadAmiiboData(std::vector<u8>& data) { | |||
| 1378 | 1434 | ||
| 1379 | bool EmulatedController::ReadMifareData(const Common::Input::MifareRequest& request, | 1435 | bool EmulatedController::ReadMifareData(const Common::Input::MifareRequest& request, |
| 1380 | Common::Input::MifareRequest& out_data) { | 1436 | Common::Input::MifareRequest& out_data) { |
| 1437 | if (!is_initalized) { | ||
| 1438 | return false; | ||
| 1439 | } | ||
| 1440 | |||
| 1381 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; | 1441 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; |
| 1382 | auto& nfc_virtual_output_device = output_devices[3]; | 1442 | auto& nfc_virtual_output_device = output_devices[3]; |
| 1383 | 1443 | ||
| @@ -1390,6 +1450,10 @@ bool EmulatedController::ReadMifareData(const Common::Input::MifareRequest& requ | |||
| 1390 | } | 1450 | } |
| 1391 | 1451 | ||
| 1392 | bool EmulatedController::WriteMifareData(const Common::Input::MifareRequest& request) { | 1452 | bool EmulatedController::WriteMifareData(const Common::Input::MifareRequest& request) { |
| 1453 | if (!is_initalized) { | ||
| 1454 | return false; | ||
| 1455 | } | ||
| 1456 | |||
| 1393 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; | 1457 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; |
| 1394 | auto& nfc_virtual_output_device = output_devices[3]; | 1458 | auto& nfc_virtual_output_device = output_devices[3]; |
| 1395 | 1459 | ||
| @@ -1401,6 +1465,10 @@ bool EmulatedController::WriteMifareData(const Common::Input::MifareRequest& req | |||
| 1401 | } | 1465 | } |
| 1402 | 1466 | ||
| 1403 | bool EmulatedController::WriteNfc(const std::vector<u8>& data) { | 1467 | bool EmulatedController::WriteNfc(const std::vector<u8>& data) { |
| 1468 | if (!is_initalized) { | ||
| 1469 | return false; | ||
| 1470 | } | ||
| 1471 | |||
| 1404 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; | 1472 | auto& nfc_output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; |
| 1405 | auto& nfc_virtual_output_device = output_devices[3]; | 1473 | auto& nfc_virtual_output_device = output_devices[3]; |
| 1406 | 1474 | ||
| @@ -1412,6 +1480,10 @@ bool EmulatedController::WriteNfc(const std::vector<u8>& data) { | |||
| 1412 | } | 1480 | } |
| 1413 | 1481 | ||
| 1414 | void EmulatedController::SetLedPattern() { | 1482 | void EmulatedController::SetLedPattern() { |
| 1483 | if (!is_initalized) { | ||
| 1484 | return; | ||
| 1485 | } | ||
| 1486 | |||
| 1415 | for (auto& device : output_devices) { | 1487 | for (auto& device : output_devices) { |
| 1416 | if (!device) { | 1488 | if (!device) { |
| 1417 | continue; | 1489 | continue; |
| @@ -1627,7 +1699,7 @@ void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) { | |||
| 1627 | } | 1699 | } |
| 1628 | if (is_connected) { | 1700 | if (is_connected) { |
| 1629 | LOG_WARNING(Service_HID, "Controller {} type changed while it's connected", | 1701 | LOG_WARNING(Service_HID, "Controller {} type changed while it's connected", |
| 1630 | NpadIdTypeToIndex(npad_id_type)); | 1702 | Service::HID::NpadIdTypeToIndex(npad_id_type)); |
| 1631 | } | 1703 | } |
| 1632 | npad_type = npad_type_; | 1704 | npad_type = npad_type_; |
| 1633 | } | 1705 | } |
| @@ -1877,12 +1949,16 @@ NpadButton EmulatedController::GetTurboButtonMask() const { | |||
| 1877 | case Settings::NativeButton::DDown: | 1949 | case Settings::NativeButton::DDown: |
| 1878 | button_mask.down.Assign(1); | 1950 | button_mask.down.Assign(1); |
| 1879 | break; | 1951 | break; |
| 1880 | case Settings::NativeButton::SL: | 1952 | case Settings::NativeButton::SLLeft: |
| 1881 | button_mask.left_sl.Assign(1); | 1953 | button_mask.left_sl.Assign(1); |
| 1954 | break; | ||
| 1955 | case Settings::NativeButton::SLRight: | ||
| 1882 | button_mask.right_sl.Assign(1); | 1956 | button_mask.right_sl.Assign(1); |
| 1883 | break; | 1957 | break; |
| 1884 | case Settings::NativeButton::SR: | 1958 | case Settings::NativeButton::SRLeft: |
| 1885 | button_mask.left_sr.Assign(1); | 1959 | button_mask.left_sr.Assign(1); |
| 1960 | break; | ||
| 1961 | case Settings::NativeButton::SRRight: | ||
| 1886 | button_mask.right_sr.Assign(1); | 1962 | button_mask.right_sr.Assign(1); |
| 1887 | break; | 1963 | break; |
| 1888 | default: | 1964 | default: |