Add Joystick:set/getPlayerIndex

This commit is contained in:
Alex Szpakowski
2021-02-15 16:08:23 -04:00
parent 5e411f607f
commit b1b70a83db
4 changed files with 48 additions and 0 deletions
+24
View File
@@ -195,6 +195,30 @@ bool Joystick::isDown(const std::vector<int> &buttonlist) const
return false;
}
void Joystick::setPlayerIndex(int index)
{
if (!isConnected())
return;
#if SDL_VERSION_ATLEAST(2, 0, 12)
SDL_JoystickSetPlayerIndex(joyhandle, index);
#else
LOVE_UNUSED(index);
#endif
}
int Joystick::getPlayerIndex() const
{
if (!isConnected())
return -1;
#if SDL_VERSION_ATLEAST(2, 0, 12)
return SDL_JoystickGetPlayerIndex(joyhandle);
#else
return -1;
#endif
}
bool Joystick::openGamepad(int deviceindex)
{
if (!SDL_IsGameController(deviceindex))
+3
View File
@@ -61,6 +61,9 @@ public:
bool isDown(const std::vector<int> &buttonlist) const override;
void setPlayerIndex(int index) override;
int getPlayerIndex() const override;
bool openGamepad(int deviceindex) override;
bool isGamepad() const override;