diff options
Diffstat (limited to 'src/input_common/drivers')
| -rw-r--r-- | src/input_common/drivers/tas_input.cpp | 31 | ||||
| -rw-r--r-- | src/input_common/drivers/udp_client.cpp | 24 |
2 files changed, 40 insertions, 15 deletions
diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp index 579fd9473..944e141bf 100644 --- a/src/input_common/drivers/tas_input.cpp +++ b/src/input_common/drivers/tas_input.cpp | |||
| @@ -106,10 +106,16 @@ void Tas::LoadTasFile(size_t player_index, size_t file_index) { | |||
| 106 | continue; | 106 | continue; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | const auto num_frames = std::stoi(seg_list[0]); | 109 | try { |
| 110 | while (frame_no < num_frames) { | 110 | const auto num_frames = std::stoi(seg_list[0]); |
| 111 | commands[player_index].emplace_back(); | 111 | while (frame_no < num_frames) { |
| 112 | frame_no++; | 112 | commands[player_index].emplace_back(); |
| 113 | frame_no++; | ||
| 114 | } | ||
| 115 | } catch (const std::invalid_argument&) { | ||
| 116 | LOG_ERROR(Input, "Invalid argument: '{}' at command {}", seg_list[0], frame_no); | ||
| 117 | } catch (const std::out_of_range&) { | ||
| 118 | LOG_ERROR(Input, "Out of range: '{}' at command {}", seg_list[0], frame_no); | ||
| 113 | } | 119 | } |
| 114 | 120 | ||
| 115 | TASCommand command = { | 121 | TASCommand command = { |
| @@ -234,10 +240,21 @@ TasAnalog Tas::ReadCommandAxis(const std::string& line) const { | |||
| 234 | } | 240 | } |
| 235 | } | 241 | } |
| 236 | 242 | ||
| 237 | const float x = std::stof(seg_list.at(0)) / 32767.0f; | 243 | if (seg_list.size() < 2) { |
| 238 | const float y = std::stof(seg_list.at(1)) / 32767.0f; | 244 | LOG_ERROR(Input, "Invalid axis data: '{}'", line); |
| 245 | return {}; | ||
| 246 | } | ||
| 239 | 247 | ||
| 240 | return {x, y}; | 248 | try { |
| 249 | const float x = std::stof(seg_list.at(0)) / 32767.0f; | ||
| 250 | const float y = std::stof(seg_list.at(1)) / 32767.0f; | ||
| 251 | return {x, y}; | ||
| 252 | } catch (const std::invalid_argument&) { | ||
| 253 | LOG_ERROR(Input, "Invalid argument: '{}'", line); | ||
| 254 | } catch (const std::out_of_range&) { | ||
| 255 | LOG_ERROR(Input, "Out of range: '{}'", line); | ||
| 256 | } | ||
| 257 | return {}; | ||
| 241 | } | 258 | } |
| 242 | 259 | ||
| 243 | u64 Tas::ReadCommandButtons(const std::string& line) const { | 260 | u64 Tas::ReadCommandButtons(const std::string& line) const { |
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index a1ce4525d..c8a12c7d5 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp | |||
| @@ -442,14 +442,22 @@ MotionMapping UDPClient::GetMotionMappingForDevice(const Common::ParamPackage& p | |||
| 442 | } | 442 | } |
| 443 | 443 | ||
| 444 | MotionMapping mapping = {}; | 444 | MotionMapping mapping = {}; |
| 445 | Common::ParamPackage motion_params; | 445 | Common::ParamPackage left_motion_params; |
| 446 | motion_params.Set("engine", GetEngineName()); | 446 | left_motion_params.Set("engine", GetEngineName()); |
| 447 | motion_params.Set("guid", params.Get("guid", "")); | 447 | left_motion_params.Set("guid", params.Get("guid", "")); |
| 448 | motion_params.Set("port", params.Get("port", 0)); | 448 | left_motion_params.Set("port", params.Get("port", 0)); |
| 449 | motion_params.Set("pad", params.Get("pad", 0)); | 449 | left_motion_params.Set("pad", params.Get("pad", 0)); |
| 450 | motion_params.Set("motion", 0); | 450 | left_motion_params.Set("motion", 0); |
| 451 | mapping.insert_or_assign(Settings::NativeMotion::MotionLeft, std::move(motion_params)); | 451 | |
| 452 | mapping.insert_or_assign(Settings::NativeMotion::MotionRight, std::move(motion_params)); | 452 | Common::ParamPackage right_motion_params; |
| 453 | right_motion_params.Set("engine", GetEngineName()); | ||
| 454 | right_motion_params.Set("guid", params.Get("guid", "")); | ||
| 455 | right_motion_params.Set("port", params.Get("port", 0)); | ||
| 456 | right_motion_params.Set("pad", params.Get("pad", 0)); | ||
| 457 | right_motion_params.Set("motion", 0); | ||
| 458 | |||
| 459 | mapping.insert_or_assign(Settings::NativeMotion::MotionLeft, std::move(left_motion_params)); | ||
| 460 | mapping.insert_or_assign(Settings::NativeMotion::MotionRight, std::move(right_motion_params)); | ||
| 453 | return mapping; | 461 | return mapping; |
| 454 | } | 462 | } |
| 455 | 463 | ||