@@ -112,10 +112,11 @@ std::chrono::time_point<std::chrono::high_resolution_clock> g_lastControllerMove
112112void TasController::ControllerMove (int nSlot, float flFrametime, CUserCmd *cmd) {
113113 // ControllerMove is executed several times for one tick. Most of them
114114 // are called from ExtraMouseSamples with 0 tick count. We want to filter them out.
115- if (cmd->tick_count == 0 ) return ;
115+ bool wasInExtraMouseSamples = inExtraMouseSamples;
116+ inExtraMouseSamples = cmd->tick_count == 0 ;
116117
117118 // doing some debugs to test the behaviour of the real controller
118- if (sar_tas_real_controller_debug.GetBool ()) {
119+ if (sar_tas_real_controller_debug.GetBool () && !inExtraMouseSamples ) {
119120 int debugType = sar_tas_real_controller_debug.GetInt ();
120121 if (debugType == 1 ) {
121122 console->Print (" forwardmove: %.5f, sidemove: %.5f\n " , cmd->forwardmove , cmd->sidemove );
@@ -140,6 +141,23 @@ void TasController::ControllerMove(int nSlot, float flFrametime, CUserCmd *cmd)
140141
141142 // console->Print("TasController::ControllerMove (%d, ", cmd->tick_count);
142143
144+ if (inExtraMouseSamples && !tasPlayer->IsUsingTools ()) {
145+ if (!wasInExtraMouseSamples) {
146+ viewanglesPreExtraMouseSamples = engine->GetAngles (nSlot);
147+ }
148+
149+ extraMouseSamplesAccumulatedTime += flFrametime;
150+
151+ auto extraViewAnalog = tasPlayer->FetchRawExtraViewAnalog (nSlot, extraMouseSamplesAccumulatedTime);
152+ ApplyViewAnalog (nSlot, nullptr , extraViewAnalog, true );
153+
154+ return ;
155+ }
156+
157+ if (wasInExtraMouseSamples) {
158+ extraMouseSamplesAccumulatedTime = 0 .0f ;
159+ }
160+
143161 tasPlayer->FetchInputs (nSlot, this , cmd);
144162
145163 // TAS is now controlling inputs. Reset everything we can.
@@ -197,17 +215,7 @@ void TasController::ControllerMove(int nSlot, float flFrametime, CUserCmd *cmd)
197215 // don't do this part if tools are enabled.
198216 // tools processing will do it instead
199217 if (!tasPlayer->IsUsingTools ()) {
200- QAngle viewangles;
201- viewangles = engine->GetAngles (nSlot);
202-
203- viewangles.y -= viewAnalog.x ; // positive values should rotate right.
204- viewangles.x -= viewAnalog.y ; // positive values should rotate up.
205- viewangles.x = std::min (std::max (viewangles.x , -cl_pitchdown.GetFloat ()), cl_pitchup.GetFloat ());
206-
207- cmd->mousedx = (int )(-viewAnalog.x );
208- cmd->mousedy = (int )(-viewAnalog.y );
209-
210- engine->SetAngles (nSlot, viewangles);
218+ ApplyViewAnalog (nSlot, cmd, viewAnalog, wasInExtraMouseSamples);
211219 }
212220
213221 {
@@ -219,3 +227,23 @@ void TasController::ControllerMove(int nSlot, float flFrametime, CUserCmd *cmd)
219227 tasPlayer->DumpUsercmd (nSlot, &tmp, tasPlayer->GetTick () + 1 , " client" ); // off-by-one bullshit on tick count
220228 }
221229}
230+
231+ void TasController::ApplyViewAnalog (int nSlot, CUserCmd *cmd, Vector analog, bool usePreExtraMouseSampleAngles) {
232+ QAngle viewangles;
233+ viewangles = engine->GetAngles (nSlot);
234+
235+ if (usePreExtraMouseSampleAngles) {
236+ viewangles = viewanglesPreExtraMouseSamples;
237+ }
238+
239+ viewangles.y -= analog.x ; // positive values should rotate right.
240+ viewangles.x -= analog.y ; // positive values should rotate up.
241+ viewangles.x = std::min (std::max (viewangles.x , -cl_pitchdown.GetFloat ()), cl_pitchup.GetFloat ());
242+
243+ if (cmd != nullptr ) {
244+ cmd->mousedx = (int )(-analog.x );
245+ cmd->mousedy = (int )(-analog.y );
246+ }
247+
248+ engine->SetAngles (nSlot, viewangles);
249+ }
0 commit comments