Minor input fixes, restore controller name in input viewer

This commit is contained in:
Phillip Stephens 2022-03-22 12:44:35 -07:00
parent 42dde9187b
commit 7cf863983a
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
7 changed files with 17 additions and 11 deletions

View File

@ -924,15 +924,16 @@ void ImGuiConsole::ShowInputViewer() {
return; return;
} }
auto input = g_InputGenerator->GetLastInput(); auto input = g_InputGenerator->GetLastInput();
if (input.x4_controllerIdx != 0) { if (input.ControllerIdx() != 0) {
return; return;
} }
#if 0
if (m_whichController != input.m_which) { u32 thisWhich = aurora::get_which_controller_for_player(input.ControllerIdx());
m_controllerName = static_cast<std::string>(aurora::get_controller_name(input.m_which)); if (m_whichController != thisWhich) {
m_whichController = input.m_which; m_controllerName = static_cast<std::string>(aurora::get_controller_name(thisWhich));
m_whichController = thisWhich;
} }
#endif
// Code -stolen- borrowed from Practice Mod // Code -stolen- borrowed from Practice Mod
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |

View File

@ -132,7 +132,7 @@ void CDolphinController::ProcessDigitalButton(u32 controller, CControllerButton&
} }
void CDolphinController::ProcessAnalogButton(float value, CControllerAxis& axis) { void CDolphinController::ProcessAnalogButton(float value, CControllerAxis& axis) {
float absolute = value * (1 / 150.f); float absolute = value * (1 / 150.f);
if (value * (1 / 150.f) > 1.f) { if (value * (1 / 150.f) > kAbsoluteMaximum) {
absolute = kAbsoluteMaximum; absolute = kAbsoluteMaximum;
} }

View File

@ -96,8 +96,8 @@ struct CFinalInput {
bool PDPLeft() const { return x2e_b30_PDPLeft; } bool PDPLeft() const { return x2e_b30_PDPLeft; }
bool PDPDown() const { return x2e_b29_PDPDown; } bool PDPDown() const { return x2e_b29_PDPDown; }
bool PDPUp() const { return x2e_b27_PDPUp; } bool PDPUp() const { return x2e_b27_PDPUp; }
bool PRTrigger() const { return x28_anaRightTriggerP > 0.5f; } bool PRTrigger() const { return x28_anaRightTriggerP > 0.05f; }
bool PLTrigger() const { return x24_anaLeftTriggerP > 0.5f; } bool PLTrigger() const { return x24_anaLeftTriggerP > 0.05f; }
bool PRARight() const { return x10_anaRightX > 0.7f && x22_enableAnaRightXP; } bool PRARight() const { return x10_anaRightX > 0.7f && x22_enableAnaRightXP; }
bool PRALeft() 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; } bool PRADown() const { return x14_anaRightY < -0.7f && x23_enableAnaRightYP; }

View File

@ -249,6 +249,7 @@ void set_window_title(zstring_view title) noexcept;
[[nodiscard]] Backend get_backend() noexcept; [[nodiscard]] Backend get_backend() noexcept;
[[nodiscard]] std::string_view get_backend_string() noexcept; [[nodiscard]] std::string_view get_backend_string() noexcept;
void set_fullscreen(bool fullscreen) 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; [[nodiscard]] int32_t get_controller_player_index(uint32_t which) noexcept;
void set_controller_player_index(uint32_t which, int32_t index) noexcept; void set_controller_player_index(uint32_t which, int32_t index) noexcept;
[[nodiscard]] bool is_controller_gamecube(uint32_t which) noexcept; [[nodiscard]] bool is_controller_gamecube(uint32_t which) noexcept;

View File

@ -414,6 +414,9 @@ void set_fullscreen(bool fullscreen) noexcept {
SDL_SetWindowFullscreen(g_window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0); 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); } 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 { void set_controller_player_index(uint32_t instance, int32_t index) noexcept {

View File

@ -20,7 +20,7 @@ struct GameController {
}; };
absl::flat_hash_map<Uint32, GameController> g_GameControllers; absl::flat_hash_map<Uint32, GameController> g_GameControllers;
GameController get_controller_for_player(u32 player) { GameController get_controller_for_player(u32 player) noexcept {
for (const auto& [which, controller] : g_GameControllers) { for (const auto& [which, controller] : g_GameControllers) {
if (player_index(which) == player) { if (player_index(which) == player) {
return controller; return controller;
@ -30,7 +30,7 @@ GameController get_controller_for_player(u32 player) {
return {}; return {};
} }
Sint32 get_instance_for_player(u32 player) { Sint32 get_instance_for_player(u32 player) noexcept {
for (const auto& [which, controller] : g_GameControllers) { for (const auto& [which, controller] : g_GameControllers) {
if (player_index(which) == player) { if (player_index(which) == player) {
return which; return which;

View File

@ -7,6 +7,7 @@
#include "SDL_mouse.h" #include "SDL_mouse.h"
namespace aurora::input { namespace aurora::input {
Sint32 get_instance_for_player(u32 player) noexcept;
Sint32 add_controller(Sint32 which) noexcept; Sint32 add_controller(Sint32 which) noexcept;
void remove_controller(Uint32 instance) noexcept; void remove_controller(Uint32 instance) noexcept;
Sint32 player_index(Uint32 instance) noexcept; Sint32 player_index(Uint32 instance) noexcept;