Skip to content

Commit

Permalink
nothing important
Browse files Browse the repository at this point in the history
  • Loading branch information
IamSanjid committed Feb 9, 2023
1 parent b143e4c commit 26a187c
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions npad_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,19 @@ class StickInputHandler final : public InputHandler
return;
}

if (time_passed != last_update_)
for (int i = 0; i < BUTTONS; i++)
{
for (int i = 0; i < BUTTONS; i++)
if (timeouts_[i] > 0.0f)
{
if (timeouts_[i] > 0.0f)
timeouts_[i] -= time_passed;
if (timeouts_[i] <= 0.001f)
{
timeouts_[i] -= time_passed;
if (timeouts_[i] <= 0.001f)
{
Native::GetInstance()->SendKeysUp(&Config::Current()->RIGHT_STICK_KEYS[i], 1);
timeouts_[i] = 0.0f;
continue;
}
}
}
}
Native::GetInstance()->SendKeysUp(&Config::Current()->RIGHT_STICK_KEYS[i], 1);
timeouts_[i] = 0.0f;
continue;
}
}
}

std::vector<ButtonTimeout> current_timeouts;
if (timeout_queue_.Pop(current_timeouts))
Expand Down Expand Up @@ -119,15 +116,31 @@ class StickInputHandler final : public InputHandler
int button = (index * 2) + (Utils::sign(value) == 1);
int opposite_button = (index * 2) + (Utils::sign(value) != 1);

if (!not_reset) /* branch misses? */
// unnecessary stuff just wanted to test pre-calculated label addresses

#if defined(__clang__) || defined(__GNUC__)
constexpr void* keys_gotos[] = {&&UP, &&DOWN};

goto *keys_gotos[not_reset];
UP:
Native::GetInstance()->SendKeysUp(&Config::Current()->RIGHT_STICK_KEYS[button], 1);
goto ADD;
DOWN:
Native::GetInstance()->SendKeysDown(&Config::Current()->RIGHT_STICK_KEYS[button], 1);
goto ADD;


ADD:
#else
if (!not_reset)
{
Native::GetInstance()->SendKeysUp(&Config::Current()->RIGHT_STICK_KEYS[button], 1);
}
}
else
{
Native::GetInstance()->SendKeysDown(&Config::Current()->RIGHT_STICK_KEYS[button], 1);
}

}
#endif
timeout_queue_.Push({ button, time });
timeout_queue_.Push({ opposite_button, 0.f });
}
Expand Down

0 comments on commit 26a187c

Please sign in to comment.