From 88c01588aa0830e219eaa62588839e4d1e2883ce Mon Sep 17 00:00:00 2001 From: untodesu Date: Wed, 25 Jun 2025 00:44:36 +0500 Subject: Clang-format the entire source code --- game/client/gamepad_button.cc | 59 +++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 30 deletions(-) (limited to 'game/client/gamepad_button.cc') diff --git a/game/client/gamepad_button.cc b/game/client/gamepad_button.cc index e22f7e7..c236054 100644 --- a/game/client/gamepad_button.cc +++ b/game/client/gamepad_button.cc @@ -1,36 +1,37 @@ #include "client/pch.hh" + #include "client/gamepad_button.hh" #include "core/constexpr.hh" #include "client/gamepad.hh" -constexpr static const char *UNKNOWN_BUTTON_NAME = "UNKNOWN"; - -static const std::pair button_names[] = { - { GLFW_GAMEPAD_BUTTON_A, "A" }, - { GLFW_GAMEPAD_BUTTON_B, "B" }, - { GLFW_GAMEPAD_BUTTON_X, "X" }, - { GLFW_GAMEPAD_BUTTON_Y, "Y" }, - { GLFW_GAMEPAD_BUTTON_LEFT_BUMPER, "L_BUMP" }, - { GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER, "R_BUMP" }, - { GLFW_GAMEPAD_BUTTON_BACK, "BACK" }, - { GLFW_GAMEPAD_BUTTON_START, "START" }, - { GLFW_GAMEPAD_BUTTON_GUIDE, "GUIDE" }, - { GLFW_GAMEPAD_BUTTON_LEFT_THUMB, "L_THUMB" }, - { GLFW_GAMEPAD_BUTTON_RIGHT_THUMB, "R_THUMB" }, - { GLFW_GAMEPAD_BUTTON_DPAD_UP, "DPAD_UP" }, - { GLFW_GAMEPAD_BUTTON_DPAD_RIGHT, "DPAD_RIGHT" }, - { GLFW_GAMEPAD_BUTTON_DPAD_DOWN, "DPAD_DOWN" }, - { GLFW_GAMEPAD_BUTTON_DPAD_LEFT, "DPAD_LEFT" }, +constexpr static const char* UNKNOWN_BUTTON_NAME = "UNKNOWN"; + +static const std::pair button_names[] = { + { GLFW_GAMEPAD_BUTTON_A, "A" }, + { GLFW_GAMEPAD_BUTTON_B, "B" }, + { GLFW_GAMEPAD_BUTTON_X, "X" }, + { GLFW_GAMEPAD_BUTTON_Y, "Y" }, + { GLFW_GAMEPAD_BUTTON_LEFT_BUMPER, "L_BUMP" }, + { GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER, "R_BUMP" }, + { GLFW_GAMEPAD_BUTTON_BACK, "BACK" }, + { GLFW_GAMEPAD_BUTTON_START, "START" }, + { GLFW_GAMEPAD_BUTTON_GUIDE, "GUIDE" }, + { GLFW_GAMEPAD_BUTTON_LEFT_THUMB, "L_THUMB" }, + { GLFW_GAMEPAD_BUTTON_RIGHT_THUMB, "R_THUMB" }, + { GLFW_GAMEPAD_BUTTON_DPAD_UP, "DPAD_UP" }, + { GLFW_GAMEPAD_BUTTON_DPAD_RIGHT, "DPAD_RIGHT" }, + { GLFW_GAMEPAD_BUTTON_DPAD_DOWN, "DPAD_DOWN" }, + { GLFW_GAMEPAD_BUTTON_DPAD_LEFT, "DPAD_LEFT" }, }; -static const char *get_button_name(int button) +static const char* get_button_name(int button) { - for(const auto &it : button_names) { - if(it.first != button) - continue; - return it.second; + for(const auto& it : button_names) { + if(it.first == button) { + return it.second; + } } return UNKNOWN_BUTTON_NAME; @@ -48,14 +49,14 @@ ConfigGamepadButton::ConfigGamepadButton(int button) m_name = get_button_name(button); } -const char *ConfigGamepadButton::get(void) const +const char* ConfigGamepadButton::get(void) const { return m_name; } -void ConfigGamepadButton::set(const char *value) +void ConfigGamepadButton::set(const char* value) { - for(const auto &it : button_names) { + for(const auto& it : button_names) { if(!std::strcmp(it.second, value)) { m_gamepad_button = it.first; m_name = it.second; @@ -83,9 +84,7 @@ bool ConfigGamepadButton::equals(int button) const return m_gamepad_button == button; } -bool ConfigGamepadButton::is_pressed(const GLFWgamepadstate &state) const +bool ConfigGamepadButton::is_pressed(const GLFWgamepadstate& state) const { - if((m_gamepad_button < cxpr::array_size(state.buttons)) && (state.buttons[m_gamepad_button] == GLFW_PRESS)) - return true; - return false; + return m_gamepad_button < cxpr::array_size(state.buttons) && state.buttons[m_gamepad_button] == GLFW_PRESS; } -- cgit