mirror of
https://github.com/love2d/love.git
synced 2026-08-18 11:44:15 +02:00
Add Joystick:set/getPlayerIndex
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user