mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-08-13 17:03:47 -04:00
eea5135d62
* Rumble indefinitely until turned off * Add rumble cvar * Register CVar * Check if controller can rumble to insert rumble pak * Reduce verbosity of checks * Remove extraneous const_cast * Once again remove extraneous const_cast * Add per-controller settings * Add nice spacing * Only display controller entry if pad connected * Const some stuff
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#pragma once
|
|
#include "Controller.h"
|
|
#include <SDL2/SDL.h>
|
|
|
|
#define INVALID_SDL_CONTROLLER_GUID (std::string("00000000000000000000000000000000"))
|
|
|
|
namespace Ship {
|
|
class SDLController : public Controller {
|
|
public:
|
|
SDLController(int32_t dwControllerNumber);
|
|
~SDLController();
|
|
|
|
void ReadFromSource();
|
|
void WriteToSource(ControllerCallback* controller);
|
|
bool Connected() const { return Cont != nullptr; }
|
|
bool CanRumble() const { return SDL_GameControllerHasRumble(Cont); }
|
|
|
|
std::string GetGuid() { return guid; };
|
|
|
|
bool HasPadConf() const { return true; }
|
|
std::optional<std::string> GetPadConfSection();
|
|
|
|
protected:
|
|
std::string GetControllerType();
|
|
void SetButtonMapping(const std::string& szButtonName, int32_t dwScancode);
|
|
std::string GetConfSection();
|
|
std::string GetBindingConfSection();
|
|
void CreateDefaultBinding();
|
|
void CreateDefaultPadConf();
|
|
static bool IsGuidInUse(const std::string& guid);
|
|
|
|
private:
|
|
std::string guid;
|
|
SDL_GameController* Cont;
|
|
std::map<int32_t, int16_t> ThresholdMapping;
|
|
|
|
void LoadAxisThresholds();
|
|
void NormalizeStickAxis(int16_t wAxisValueX, int16_t wAxisValueY, int16_t wAxisThreshold);
|
|
bool Open();
|
|
bool Close();
|
|
};
|
|
}
|