diff --git a/Runtime/ImGuiConsole.cpp b/Runtime/ImGuiConsole.cpp index 3cb94ef02..249b996e0 100644 --- a/Runtime/ImGuiConsole.cpp +++ b/Runtime/ImGuiConsole.cpp @@ -924,15 +924,16 @@ void ImGuiConsole::ShowInputViewer() { return; } auto input = g_InputGenerator->GetLastInput(); - if (input.x4_controllerIdx != 0) { + if (input.ControllerIdx() != 0) { return; } -#if 0 - if (m_whichController != input.m_which) { - m_controllerName = static_cast(aurora::get_controller_name(input.m_which)); - m_whichController = input.m_which; + + u32 thisWhich = aurora::get_which_controller_for_player(input.ControllerIdx()); + if (m_whichController != thisWhich) { + m_controllerName = static_cast(aurora::get_controller_name(thisWhich)); + m_whichController = thisWhich; } -#endif + // Code -stolen- borrowed from Practice Mod ImGuiIO& io = ImGui::GetIO(); ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | diff --git a/Runtime/Input/CDolphinController.cpp b/Runtime/Input/CDolphinController.cpp index 663672c10..471255a45 100644 --- a/Runtime/Input/CDolphinController.cpp +++ b/Runtime/Input/CDolphinController.cpp @@ -132,7 +132,7 @@ void CDolphinController::ProcessDigitalButton(u32 controller, CControllerButton& } void CDolphinController::ProcessAnalogButton(float value, CControllerAxis& axis) { float absolute = value * (1 / 150.f); - if (value * (1 / 150.f) > 1.f) { + if (value * (1 / 150.f) > kAbsoluteMaximum) { absolute = kAbsoluteMaximum; } diff --git a/Runtime/Input/CFinalInput.hpp b/Runtime/Input/CFinalInput.hpp index d3255eb33..15a9afe00 100644 --- a/Runtime/Input/CFinalInput.hpp +++ b/Runtime/Input/CFinalInput.hpp @@ -96,8 +96,8 @@ struct CFinalInput { bool PDPLeft() const { return x2e_b30_PDPLeft; } bool PDPDown() const { return x2e_b29_PDPDown; } bool PDPUp() const { return x2e_b27_PDPUp; } - bool PRTrigger() const { return x28_anaRightTriggerP > 0.5f; } - bool PLTrigger() const { return x24_anaLeftTriggerP > 0.5f; } + bool PRTrigger() const { return x28_anaRightTriggerP > 0.05f; } + bool PLTrigger() const { return x24_anaLeftTriggerP > 0.05f; } bool PRARight() const { return x10_anaRightX > 0.7f && x22_enableAnaRightXP; } bool PRALeft() const { return x10_anaRightX < -0.7f && x22_enableAnaRightXP; } bool PRADown() const { return x14_anaRightY < -0.7f && x23_enableAnaRightYP; } diff --git a/aurora/include/aurora/aurora.hpp b/aurora/include/aurora/aurora.hpp index d29e7a4d1..6ca1594bd 100644 --- a/aurora/include/aurora/aurora.hpp +++ b/aurora/include/aurora/aurora.hpp @@ -249,6 +249,7 @@ void set_window_title(zstring_view title) noexcept; [[nodiscard]] Backend get_backend() noexcept; [[nodiscard]] std::string_view get_backend_string() noexcept; void set_fullscreen(bool fullscreen) noexcept; +[[nodiscard]] uint32_t get_which_controller_for_player(int32_t index) noexcept; [[nodiscard]] int32_t get_controller_player_index(uint32_t which) noexcept; void set_controller_player_index(uint32_t which, int32_t index) noexcept; [[nodiscard]] bool is_controller_gamecube(uint32_t which) noexcept; diff --git a/aurora/lib/aurora.cpp b/aurora/lib/aurora.cpp index fcaf9f907..75506f7b1 100644 --- a/aurora/lib/aurora.cpp +++ b/aurora/lib/aurora.cpp @@ -414,6 +414,9 @@ void set_fullscreen(bool fullscreen) noexcept { SDL_SetWindowFullscreen(g_window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0); } +uint32_t get_which_controller_for_player(int32_t index) noexcept { + return input::get_instance_for_player(index); +} int32_t get_controller_player_index(uint32_t instance) noexcept { return input::player_index(instance); } void set_controller_player_index(uint32_t instance, int32_t index) noexcept { diff --git a/aurora/lib/input.cpp b/aurora/lib/input.cpp index 621da3359..cee410780 100644 --- a/aurora/lib/input.cpp +++ b/aurora/lib/input.cpp @@ -20,7 +20,7 @@ struct GameController { }; absl::flat_hash_map g_GameControllers; -GameController get_controller_for_player(u32 player) { +GameController get_controller_for_player(u32 player) noexcept { for (const auto& [which, controller] : g_GameControllers) { if (player_index(which) == player) { return controller; @@ -30,7 +30,7 @@ GameController get_controller_for_player(u32 player) { return {}; } -Sint32 get_instance_for_player(u32 player) { +Sint32 get_instance_for_player(u32 player) noexcept { for (const auto& [which, controller] : g_GameControllers) { if (player_index(which) == player) { return which; diff --git a/aurora/lib/input.hpp b/aurora/lib/input.hpp index e2fcaf508..0f2d2222e 100644 --- a/aurora/lib/input.hpp +++ b/aurora/lib/input.hpp @@ -7,6 +7,7 @@ #include "SDL_mouse.h" namespace aurora::input { +Sint32 get_instance_for_player(u32 player) noexcept; Sint32 add_controller(Sint32 which) noexcept; void remove_controller(Uint32 instance) noexcept; Sint32 player_index(Uint32 instance) noexcept;