6#include <SDL2/SDL_haptic.h>
16 Pad(
int id,
int joyindex);
19 bool open(
int deviceindex)
override;
20 void close()
override;
23 std::string
getName()
const override;
29 float getAxis(
int axisindex)
const override;
30 std::vector<float>
getAxes()
const override;
31 std::string
getHat(
int hatindex)
const override;
33 bool isDown(
int button)
const override;
34 bool isDown(
const std::vector<int>& buttons)
const override;
41 bool isGamepadDown(
const std::vector<std::string>& buttons)
const override;
46 std::string
getGUID()
const override;
48 int getID()
const override;
50 void getDeviceInfo(
int& vendorID,
int& productID,
int& productVersion)
const override;
53 bool setVibration(
float left,
float right,
float duration = -1.0f)
override;
58 bool checkCreateHaptic();
59 bool runVibrationEffect();
61 SDL_Joystick* joyhandle_ =
nullptr;
62 SDL_GameController* controller_ =
nullptr;
63 SDL_Haptic* haptic_ =
nullptr;
65 SDL_JoystickID instanceid_ = -1;
73 SDL_HapticEffect effect{};
76 Uint32 endtime = SDL_HAPTIC_INFINITY;
One connected (or previously connected) joystick / gamepad device. Gamepad axis/button names follow S...
SDL 手柄/摇杆后端实现(含 GameController 与振动)。
int getID() const override
void getVibration(float &left, float &right) override
bool isGamepad() const override
float getGamepadAxis(const std::string &axis) const override
bool isVibrationSupported() override
bool isConnected() const override
bool isGamepadDown(const std::string &button) const override
std::vector< float > getAxes() const override
int getAxisCount() const override
std::string getGamepadMappingString() const override
bool setVibration() override
std::string getName() const override
int getHatCount() const override
bool open(int deviceindex) override
int getButtonCount() const override
std::string getHat(int hatindex) const override
int getInstanceID() const override
bool openGamepad(int deviceindex) override
void getDeviceInfo(int &vendorID, int &productID, int &productVersion) const override
std::string getGUID() const override
void * getHandle() const override
bool isDown(int button) const override
float getAxis(int axisindex) const override