mirror of
https://github.com/love2d/love.git
synced 2026-08-18 11:44:15 +02:00
Add Joystick:getDeviceInfo(). Returns USB vendor id, product id, and product version numbers (consistent across operating systems).
Can be used to show different icons, etc. for different gamepads.
This commit is contained in:
@@ -322,6 +322,24 @@ int Joystick::getID() const
|
||||
return id;
|
||||
}
|
||||
|
||||
void Joystick::getDeviceInfo(int &vendorID, int &productID, int &productVersion) const
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 6)
|
||||
if (joyhandle != nullptr)
|
||||
{
|
||||
vendorID = SDL_JoystickGetVendor(joyhandle);
|
||||
productID = SDL_JoystickGetProduct(joyhandle);
|
||||
productVersion = SDL_JoystickGetProductVersion(joyhandle);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
vendorID = 0;
|
||||
productID = 0;
|
||||
productVersion = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool Joystick::checkCreateHaptic()
|
||||
{
|
||||
if (!isConnected())
|
||||
|
||||
@@ -75,6 +75,8 @@ public:
|
||||
int getInstanceID() const override;
|
||||
int getID() const override;
|
||||
|
||||
void getDeviceInfo(int &vendorID, int &productID, int &productVersion) const override;
|
||||
|
||||
bool isVibrationSupported() override;
|
||||
bool setVibration(float left, float right, float duration = -1.0f) override;
|
||||
bool setVibration() override;
|
||||
|
||||
Reference in New Issue
Block a user