Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TAS input window breaks when running scripts and vice versa #44

Open
Felk opened this issue Sep 24, 2023 · 0 comments
Open

TAS input window breaks when running scripts and vice versa #44

Felk opened this issue Sep 24, 2023 · 0 comments

Comments

@Felk
Copy link
Owner

Felk commented Sep 24, 2023

The way input overrides via scripting are handled right now causes the TAS input window to not register any inputs anymore. Also, if a script is executed before the TAS input window is opened, opening it makes the TAS input window work, but Scripting controller inputs not work anymore.

This is due to a limitation on how the new input override system was implemented, namely that it is not designed for multiple "hijackers" to exist simultaneously. More technically, I use SetInputOverrideFunction, which replaces the TAS input window's override function, and vice versa.

This needs to be fixed eventually. There's a TODO in the code:
https://github.com/Felk/dolphin/blob/master/Source/Core/Core/API/Controller.cpp#L31

BaseManip::BaseManip(API::EventHub& event_hub,
          const std::vector<ControllerEmu::EmulatedController*> controllers)
    : m_event_hub(event_hub), m_controllers(controllers)
{
  m_frame_advanced_listener = m_event_hub.ListenEvent<API::Events::FrameAdvance>(
      [&](const API::Events::FrameAdvance&) { NotifyFrameAdvanced(); });
  for (auto i = 0; i < m_controllers.size(); i++)
  {
    // TODO felk: find a more robust way to set the input override functions.
    //   This way scripting breaks once the TAS input window is opened,
    //   and vice versa, the TAS window breaks once scripting starts.
    m_controllers[i]->SetInputOverrideFunction([=](const std::string_view group_name,
                                                   const std::string_view control_name,
                                                   ControlState orig_state) {
      const InputKey input_key = {group_name, control_name};
      std::optional<ControlState> manip = this->PerformInputManip(i, input_key, orig_state);
      m_last_seen_input[{i, input_key}] = manip.value_or(orig_state);
      return manip;
    });
  }
}

I considered this not a priority right now, as I think people are likely not TASing and Scripting at the same time. But yeah, needs to be fixed eventually...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant