From eb46ba9968769ed520c3e6cc26e2809a0bca24de Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Fri, 31 Jan 2025 15:00:07 +0100 Subject: [PATCH] Clang --- src/input/input_handler.cpp | 50 ++++++++++++++++------------------ src/input/input_handler.h | 7 +++-- src/qt_gui/kbm_config_dialog.h | 4 +-- src/sdl_window.h | 2 +- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/input/input_handler.cpp b/src/input/input_handler.cpp index b5ac4df39..bed02a6e6 100644 --- a/src/input/input_handler.cpp +++ b/src/input/input_handler.cpp @@ -68,20 +68,20 @@ auto output_array = std::array{ ControllerOutput(KEY_TOGGLE), // Button mappings - ControllerOutput(SDL_GAMEPAD_BUTTON_NORTH), // Triangle - ControllerOutput(SDL_GAMEPAD_BUTTON_EAST), // Circle - ControllerOutput(SDL_GAMEPAD_BUTTON_SOUTH), // Cross - ControllerOutput(SDL_GAMEPAD_BUTTON_WEST), // Square + ControllerOutput(SDL_GAMEPAD_BUTTON_NORTH), // Triangle + ControllerOutput(SDL_GAMEPAD_BUTTON_EAST), // Circle + ControllerOutput(SDL_GAMEPAD_BUTTON_SOUTH), // Cross + ControllerOutput(SDL_GAMEPAD_BUTTON_WEST), // Square ControllerOutput(SDL_GAMEPAD_BUTTON_LEFT_SHOULDER), // L1 ControllerOutput(SDL_GAMEPAD_BUTTON_LEFT_STICK), // L3 ControllerOutput(SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER), // R1 ControllerOutput(SDL_GAMEPAD_BUTTON_RIGHT_STICK), // R3 - ControllerOutput(SDL_GAMEPAD_BUTTON_START), // Options - ControllerOutput(SDL_GAMEPAD_BUTTON_TOUCHPAD), // TouchPad - ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_UP), // Up - ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_DOWN),// Down - ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_LEFT),// Left - ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_RIGHT),// Right + ControllerOutput(SDL_GAMEPAD_BUTTON_START), // Options + ControllerOutput(SDL_GAMEPAD_BUTTON_TOUCHPAD), // TouchPad + ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_UP), // Up + ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_DOWN), // Down + ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_LEFT), // Left + ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_RIGHT), // Right // Axis mappings // ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_LEFTX, false), @@ -146,8 +146,7 @@ static OrbisPadButtonDataOffset SDLGamepadToOrbisButton(u8 button) { } Axis GetAxisFromSDLAxis(u8 sdl_axis) { - switch (sdl_axis) - { + switch (sdl_axis) { case SDL_GAMEPAD_AXIS_LEFTX: return Axis::LeftX; case SDL_GAMEPAD_AXIS_LEFTY: @@ -278,8 +277,8 @@ void ParseInputConfig(const std::string game_id = "") { line); continue; } - ControllerOutput* toggle_out = &*std::ranges::find( - output_array, ControllerOutput(KEY_TOGGLE)); + ControllerOutput* toggle_out = + &*std::ranges::find(output_array, ControllerOutput(KEY_TOGGLE)); BindingConnection toggle_connection = BindingConnection( InputBinding(toggle_keys.keys[0]), toggle_out, 0, toggle_keys.keys[1]); connections.insert(connections.end(), toggle_connection); @@ -348,7 +347,8 @@ void ParseInputConfig(const std::string game_id = "") { connection = BindingConnection( binding, &*std::ranges::find(output_array, ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, - axis_it->second.axis, axis_it->second.value >= 0)), + axis_it->second.axis, + axis_it->second.value >= 0)), value_to_set); connections.insert(connections.end(), connection); } else { @@ -390,16 +390,14 @@ InputEvent InputBinding::GetInputEventFromSDLEvent(const SDL_Event& e) { return InputEvent(InputType::KeyboardMouse, e.key.key, e.key.down, 0); case SDL_EVENT_MOUSE_BUTTON_DOWN: case SDL_EVENT_MOUSE_BUTTON_UP: - return InputEvent(InputType::KeyboardMouse, (u32)e.button.button, - e.button.down, 0); + return InputEvent(InputType::KeyboardMouse, (u32)e.button.button, e.button.down, 0); case SDL_EVENT_MOUSE_WHEEL: case SDL_EVENT_MOUSE_WHEEL_OFF: return InputEvent(InputType::KeyboardMouse, GetMouseWheelEvent(e), e.type == SDL_EVENT_MOUSE_WHEEL, 0); case SDL_EVENT_GAMEPAD_BUTTON_DOWN: case SDL_EVENT_GAMEPAD_BUTTON_UP: - return InputEvent(InputType::Controller, (u32)e.gbutton.button, - e.gbutton.down, 0); + return InputEvent(InputType::Controller, (u32)e.gbutton.button, e.gbutton.down, 0); case SDL_EVENT_GAMEPAD_AXIS_MOTION: return InputEvent(InputType::Axis, (u32)e.gaxis.axis, true, e.gaxis.value / 256); default: @@ -467,7 +465,7 @@ void ControllerOutput::FinalizeUpdate() { if (!state_changed) { // return; } - + old_button_state = new_button_state; old_param = *new_param; float touchpad_x = 0; @@ -545,9 +543,9 @@ bool UpdatePressedKeys(InputEvent event) { // and from there, it only changes the parameter auto it = std::lower_bound(pressed_keys.begin(), pressed_keys.end(), input, [](const std::pair& e, InputID i) { - return std::tie(e.first.input.type, e.first.input.sdl_id) < - std::tie(i.type, i.sdl_id); - }); + return std::tie(e.first.input.type, e.first.input.sdl_id) < + std::tie(i.type, i.sdl_id); + }); if (it == pressed_keys.end() || it->first.input != input) { pressed_keys.insert(it, {event, false}); LOG_DEBUG(Input, "Added axis {} to the input list", event.input.sdl_id); @@ -559,9 +557,9 @@ bool UpdatePressedKeys(InputEvent event) { // Find the correct position for insertion to maintain order auto it = std::lower_bound(pressed_keys.begin(), pressed_keys.end(), input, [](const std::pair& e, InputID i) { - return std::tie(e.first.input.type, e.first.input.sdl_id) < - std::tie(i.type, i.sdl_id); - }); + return std::tie(e.first.input.type, e.first.input.sdl_id) < + std::tie(i.type, i.sdl_id); + }); // Insert only if 'value' is not already in the list if (it == pressed_keys.end() || it->first.input != input) { diff --git a/src/input/input_handler.h b/src/input/input_handler.h index 15e530a88..0178e7937 100644 --- a/src/input/input_handler.h +++ b/src/input/input_handler.h @@ -43,7 +43,7 @@ struct AxisMapping { }; enum class InputType { Axis, KeyboardMouse, Controller, Count }; -const std::array input_type_names = { "Axis", "KBM", "Controller", "Unknown"}; +const std::array input_type_names = {"Axis", "KBM", "Controller", "Unknown"}; class InputID { public: @@ -310,7 +310,8 @@ public: case 2: return fmt::format("({}, {})", keys[0].ToString(), keys[1].ToString()); case 3: - return fmt::format("({}, {}, {})", keys[0].ToString(), keys[1].ToString(), keys[2].ToString()); + return fmt::format("({}, {}, {})", keys[0].ToString(), keys[1].ToString(), + keys[2].ToString()); default: return "Empty"; } @@ -331,7 +332,7 @@ public: // these are only used as s8, // but I added some padding to avoid overflow if it's activated by multiple inputs // axis_plus and axis_minus pairs share a common new_param, the other outputs have their own - s16 old_param; + s16 old_param; s16* new_param; bool old_button_state, new_button_state, state_changed, positive_axis; diff --git a/src/qt_gui/kbm_config_dialog.h b/src/qt_gui/kbm_config_dialog.h index f436b4a71..cc334b082 100644 --- a/src/qt_gui/kbm_config_dialog.h +++ b/src/qt_gui/kbm_config_dialog.h @@ -9,8 +9,8 @@ #include "string" class EditorDialog : public QDialog { - Q_OBJECT // Necessary for using Qt's meta-object system (signals/slots) - public : explicit EditorDialog(QWidget* parent = nullptr); // Constructor +Q_OBJECT // Necessary for using Qt's meta-object system (signals/slots) + public : explicit EditorDialog(QWidget* parent = nullptr); // Constructor protected: void closeEvent(QCloseEvent* event) override; // Override close event diff --git a/src/sdl_window.h b/src/sdl_window.h index 677a11aca..9acd2b16b 100644 --- a/src/sdl_window.h +++ b/src/sdl_window.h @@ -5,8 +5,8 @@ #include "common/types.h" #include "core/libraries/pad/pad.h" -#include "string" #include "input/controller.h" +#include "string" struct SDL_Window; struct SDL_Gamepad;