Basic gamepad support through SDL (#407)

* Add basic gamepad support through SDL

* lightbar, vibration, code style changes

* okay fine

* one day clang format will finally pass
This commit is contained in:
counter185 2024-08-13 11:54:08 +02:00 committed by GitHub
parent d1a033b6af
commit bb159eafb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 128 additions and 4 deletions

View file

@ -6,6 +6,8 @@
#include <mutex>
#include "common/types.h"
struct SDL_Gamepad;
namespace Input {
enum class Axis {
@ -43,6 +45,9 @@ public:
void CheckButton(int id, u32 button, bool isPressed);
void AddState(const State& state);
void Axis(int id, Input::Axis axis, int value);
void SetLightBarRGB(u8 r, u8 g, u8 b);
bool SetVibration(u8 smallMotor, u8 largeMotor);
void TryOpenSDLController();
private:
struct StateInternal {
@ -57,6 +62,8 @@ private:
u32 m_first_state = 0;
std::array<State, MAX_STATES> m_states;
std::array<StateInternal, MAX_STATES> m_private;
SDL_Gamepad* m_sdl_gamepad = nullptr;
};
} // namespace Input