diff options
Diffstat (limited to 'src/input_common')
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/sdl_driver.h | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/tas_input.cpp | 38 | ||||
| -rw-r--r-- | src/input_common/drivers/udp_client.cpp | 24 |
4 files changed, 47 insertions, 19 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 0cda9df62..757117f2b 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp | |||
| @@ -663,6 +663,7 @@ ButtonBindings SDLDriver::GetDefaultButtonBinding() const { | |||
| 663 | {Settings::NativeButton::SL, SDL_CONTROLLER_BUTTON_LEFTSHOULDER}, | 663 | {Settings::NativeButton::SL, SDL_CONTROLLER_BUTTON_LEFTSHOULDER}, |
| 664 | {Settings::NativeButton::SR, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER}, | 664 | {Settings::NativeButton::SR, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER}, |
| 665 | {Settings::NativeButton::Home, SDL_CONTROLLER_BUTTON_GUIDE}, | 665 | {Settings::NativeButton::Home, SDL_CONTROLLER_BUTTON_GUIDE}, |
| 666 | {Settings::NativeButton::Screenshot, SDL_CONTROLLER_BUTTON_MISC1}, | ||
| 666 | }; | 667 | }; |
| 667 | } | 668 | } |
| 668 | 669 | ||
| @@ -699,6 +700,7 @@ ButtonBindings SDLDriver::GetNintendoButtonBinding( | |||
| 699 | {Settings::NativeButton::SL, sl_button}, | 700 | {Settings::NativeButton::SL, sl_button}, |
| 700 | {Settings::NativeButton::SR, sr_button}, | 701 | {Settings::NativeButton::SR, sr_button}, |
| 701 | {Settings::NativeButton::Home, SDL_CONTROLLER_BUTTON_GUIDE}, | 702 | {Settings::NativeButton::Home, SDL_CONTROLLER_BUTTON_GUIDE}, |
| 703 | {Settings::NativeButton::Screenshot, SDL_CONTROLLER_BUTTON_MISC1}, | ||
| 702 | }; | 704 | }; |
| 703 | } | 705 | } |
| 704 | 706 | ||
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h index e9a5d2e26..4cde3606f 100644 --- a/src/input_common/drivers/sdl_driver.h +++ b/src/input_common/drivers/sdl_driver.h | |||
| @@ -24,7 +24,7 @@ namespace InputCommon { | |||
| 24 | class SDLJoystick; | 24 | class SDLJoystick; |
| 25 | 25 | ||
| 26 | using ButtonBindings = | 26 | using ButtonBindings = |
| 27 | std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerButton>, 17>; | 27 | std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerButton>, 18>; |
| 28 | using ZButtonBindings = | 28 | using ZButtonBindings = |
| 29 | std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerAxis>, 2>; | 29 | std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerAxis>, 2>; |
| 30 | 30 | ||
diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp index 5bdd5dac3..944e141bf 100644 --- a/src/input_common/drivers/tas_input.cpp +++ b/src/input_common/drivers/tas_input.cpp | |||
| @@ -23,7 +23,7 @@ enum class Tas::TasAxis : u8 { | |||
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| 25 | // Supported keywords and buttons from a TAS file | 25 | // Supported keywords and buttons from a TAS file |
| 26 | constexpr std::array<std::pair<std::string_view, TasButton>, 20> text_to_tas_button = { | 26 | constexpr std::array<std::pair<std::string_view, TasButton>, 18> text_to_tas_button = { |
| 27 | std::pair{"KEY_A", TasButton::BUTTON_A}, | 27 | std::pair{"KEY_A", TasButton::BUTTON_A}, |
| 28 | {"KEY_B", TasButton::BUTTON_B}, | 28 | {"KEY_B", TasButton::BUTTON_B}, |
| 29 | {"KEY_X", TasButton::BUTTON_X}, | 29 | {"KEY_X", TasButton::BUTTON_X}, |
| @@ -40,8 +40,9 @@ constexpr std::array<std::pair<std::string_view, TasButton>, 20> text_to_tas_but | |||
| 40 | {"KEY_DDOWN", TasButton::BUTTON_DOWN}, | 40 | {"KEY_DDOWN", TasButton::BUTTON_DOWN}, |
| 41 | {"KEY_SL", TasButton::BUTTON_SL}, | 41 | {"KEY_SL", TasButton::BUTTON_SL}, |
| 42 | {"KEY_SR", TasButton::BUTTON_SR}, | 42 | {"KEY_SR", TasButton::BUTTON_SR}, |
| 43 | {"KEY_CAPTURE", TasButton::BUTTON_CAPTURE}, | 43 | // These buttons are disabled to avoid TAS input from activating hotkeys |
| 44 | {"KEY_HOME", TasButton::BUTTON_HOME}, | 44 | // {"KEY_CAPTURE", TasButton::BUTTON_CAPTURE}, |
| 45 | // {"KEY_HOME", TasButton::BUTTON_HOME}, | ||
| 45 | {"KEY_ZL", TasButton::TRIGGER_ZL}, | 46 | {"KEY_ZL", TasButton::TRIGGER_ZL}, |
| 46 | {"KEY_ZR", TasButton::TRIGGER_ZR}, | 47 | {"KEY_ZR", TasButton::TRIGGER_ZR}, |
| 47 | }; | 48 | }; |
| @@ -105,10 +106,16 @@ void Tas::LoadTasFile(size_t player_index, size_t file_index) { | |||
| 105 | continue; | 106 | continue; |
| 106 | } | 107 | } |
| 107 | 108 | ||
| 108 | const auto num_frames = std::stoi(seg_list[0]); | 109 | try { |
| 109 | while (frame_no < num_frames) { | 110 | const auto num_frames = std::stoi(seg_list[0]); |
| 110 | commands[player_index].emplace_back(); | 111 | while (frame_no < num_frames) { |
| 111 | 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); | ||
| 112 | } | 119 | } |
| 113 | 120 | ||
| 114 | TASCommand command = { | 121 | TASCommand command = { |
| @@ -233,10 +240,21 @@ TasAnalog Tas::ReadCommandAxis(const std::string& line) const { | |||
| 233 | } | 240 | } |
| 234 | } | 241 | } |
| 235 | 242 | ||
| 236 | const float x = std::stof(seg_list.at(0)) / 32767.0f; | 243 | if (seg_list.size() < 2) { |
| 237 | const float y = std::stof(seg_list.at(1)) / 32767.0f; | 244 | LOG_ERROR(Input, "Invalid axis data: '{}'", line); |
| 245 | return {}; | ||
| 246 | } | ||
| 238 | 247 | ||
| 239 | 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 {}; | ||
| 240 | } | 258 | } |
| 241 | 259 | ||
| 242 | 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 | ||