|
@@ -25,22 +25,12 @@
|
|
|
#include "sensor/sdl/Sensor.h"
|
|
|
|
|
|
// SDL
|
|
|
-#if __has_include(<SDL3/SDL_version.h>)
|
|
|
-#include <SDL3/SDL_version.h>
|
|
|
-#else
|
|
|
-#include <SDL_version.h>
|
|
|
-#endif
|
|
|
+#include <SDL3/SDL_guid.h>
|
|
|
|
|
|
// C++
|
|
|
#include <algorithm>
|
|
|
#include <limits>
|
|
|
|
|
|
-#if !SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
-
|
|
|
-#ifndef SDL_TICKS_PASSED
|
|
|
-#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0)
|
|
|
-#endif
|
|
|
-
|
|
|
namespace love
|
|
|
{
|
|
|
namespace joystick
|
|
@@ -51,23 +41,10 @@ namespace sdl
|
|
|
Joystick::Joystick(int id)
|
|
|
: joyhandle(nullptr)
|
|
|
, controller(nullptr)
|
|
|
- , haptic(nullptr)
|
|
|
, joystickType(JOYSTICK_TYPE_UNKNOWN)
|
|
|
, instanceid(-1)
|
|
|
, id(id)
|
|
|
- , vibration()
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
-Joystick::Joystick(int id, int joyindex)
|
|
|
- : joyhandle(nullptr)
|
|
|
- , controller(nullptr)
|
|
|
- , haptic(nullptr)
|
|
|
- , instanceid(-1)
|
|
|
- , id(id)
|
|
|
- , vibration()
|
|
|
{
|
|
|
- open(joyindex);
|
|
|
}
|
|
|
|
|
|
Joystick::~Joystick()
|
|
@@ -77,38 +54,36 @@ Joystick::~Joystick()
|
|
|
|
|
|
bool Joystick::open(int64 deviceid)
|
|
|
{
|
|
|
- int deviceindex = (int) deviceid;
|
|
|
-
|
|
|
close();
|
|
|
|
|
|
- joyhandle = SDL_JoystickOpen(deviceindex);
|
|
|
+ joyhandle = SDL_OpenJoystick((SDL_JoystickID) deviceid);
|
|
|
|
|
|
if (joyhandle)
|
|
|
{
|
|
|
- instanceid = SDL_JoystickInstanceID(joyhandle);
|
|
|
+ instanceid = SDL_GetJoystickID(joyhandle);
|
|
|
|
|
|
// SDL_JoystickGetGUIDString uses 32 bytes plus the null terminator.
|
|
|
char cstr[33];
|
|
|
|
|
|
- SDL_JoystickGUID sdlguid = SDL_JoystickGetGUID(joyhandle);
|
|
|
- SDL_JoystickGetGUIDString(sdlguid, cstr, (int) sizeof(cstr));
|
|
|
+ SDL_GUID sdlguid = SDL_GetJoystickGUID(joyhandle);
|
|
|
+ SDL_GUIDToString(sdlguid, cstr, (int) sizeof(cstr));
|
|
|
|
|
|
pguid = std::string(cstr);
|
|
|
|
|
|
// See if SDL thinks this is a Game Controller.
|
|
|
- openGamepad(deviceindex);
|
|
|
+ openGamepad(deviceid);
|
|
|
|
|
|
// Prefer the Joystick name for consistency.
|
|
|
- const char *joyname = SDL_JoystickName(joyhandle);
|
|
|
+ const char *joyname = SDL_GetJoystickName(joyhandle);
|
|
|
if (!joyname && controller)
|
|
|
- joyname = SDL_GameControllerName(controller);
|
|
|
+ joyname = SDL_GetGamepadName(controller);
|
|
|
|
|
|
if (joyname)
|
|
|
name = joyname;
|
|
|
|
|
|
- switch (SDL_JoystickGetType(joyhandle))
|
|
|
+ switch (SDL_GetJoystickType(joyhandle))
|
|
|
{
|
|
|
- case SDL_JOYSTICK_TYPE_GAMECONTROLLER:
|
|
|
+ case SDL_JOYSTICK_TYPE_GAMEPAD:
|
|
|
joystickType = JOYSTICK_TYPE_GAMEPAD;
|
|
|
break;
|
|
|
case SDL_JOYSTICK_TYPE_WHEEL:
|
|
@@ -146,25 +121,20 @@ bool Joystick::open(int64 deviceid)
|
|
|
|
|
|
void Joystick::close()
|
|
|
{
|
|
|
- if (haptic)
|
|
|
- SDL_HapticClose(haptic);
|
|
|
-
|
|
|
if (controller)
|
|
|
- SDL_GameControllerClose(controller);
|
|
|
+ SDL_CloseGamepad(controller);
|
|
|
|
|
|
if (joyhandle)
|
|
|
- SDL_JoystickClose(joyhandle);
|
|
|
+ SDL_CloseJoystick(joyhandle);
|
|
|
|
|
|
joyhandle = nullptr;
|
|
|
controller = nullptr;
|
|
|
- haptic = nullptr;
|
|
|
instanceid = -1;
|
|
|
- vibration = Vibration();
|
|
|
}
|
|
|
|
|
|
bool Joystick::isConnected() const
|
|
|
{
|
|
|
- return joyhandle != nullptr && SDL_JoystickGetAttached(joyhandle);
|
|
|
+ return joyhandle != nullptr && SDL_JoystickConnected(joyhandle);
|
|
|
}
|
|
|
|
|
|
const char *Joystick::getName() const
|
|
@@ -179,17 +149,17 @@ Joystick::JoystickType Joystick::getJoystickType() const
|
|
|
|
|
|
int Joystick::getAxisCount() const
|
|
|
{
|
|
|
- return isConnected() ? SDL_JoystickNumAxes(joyhandle) : 0;
|
|
|
+ return isConnected() ? SDL_GetNumJoystickAxes(joyhandle) : 0;
|
|
|
}
|
|
|
|
|
|
int Joystick::getButtonCount() const
|
|
|
{
|
|
|
- return isConnected() ? SDL_JoystickNumButtons(joyhandle) : 0;
|
|
|
+ return isConnected() ? SDL_GetNumJoystickButtons(joyhandle) : 0;
|
|
|
}
|
|
|
|
|
|
int Joystick::getHatCount() const
|
|
|
{
|
|
|
- return isConnected() ? SDL_JoystickNumHats(joyhandle) : 0;
|
|
|
+ return isConnected() ? SDL_GetNumJoystickHats(joyhandle) : 0;
|
|
|
}
|
|
|
|
|
|
float Joystick::getAxis(int axisindex) const
|
|
@@ -197,7 +167,7 @@ float Joystick::getAxis(int axisindex) const
|
|
|
if (!isConnected() || axisindex < 0 || axisindex >= getAxisCount())
|
|
|
return 0;
|
|
|
|
|
|
- return clampval(((float) SDL_JoystickGetAxis(joyhandle, axisindex))/32768.0f);
|
|
|
+ return clampval(((float) SDL_GetJoystickAxis(joyhandle, axisindex))/32768.0f);
|
|
|
}
|
|
|
|
|
|
std::vector<float> Joystick::getAxes() const
|
|
@@ -211,7 +181,7 @@ std::vector<float> Joystick::getAxes() const
|
|
|
axes.reserve(count);
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
- axes.push_back(clampval(((float) SDL_JoystickGetAxis(joyhandle, i))/32768.0f));
|
|
|
+ axes.push_back(clampval(((float) SDL_GetJoystickAxis(joyhandle, i))/32768.0f));
|
|
|
|
|
|
return axes;
|
|
|
}
|
|
@@ -223,7 +193,7 @@ Joystick::Hat Joystick::getHat(int hatindex) const
|
|
|
if (!isConnected() || hatindex < 0 || hatindex >= getHatCount())
|
|
|
return h;
|
|
|
|
|
|
- getConstant(SDL_JoystickGetHat(joyhandle, hatindex), h);
|
|
|
+ getConstant(SDL_GetJoystickHat(joyhandle, hatindex), h);
|
|
|
|
|
|
return h;
|
|
|
}
|
|
@@ -240,7 +210,7 @@ bool Joystick::isDown(const std::vector<int> &buttonlist) const
|
|
|
if (button < 0 || button >= numbuttons)
|
|
|
continue;
|
|
|
|
|
|
- if (SDL_JoystickGetButton(joyhandle, button) == 1)
|
|
|
+ if (SDL_GetJoystickButton(joyhandle, button))
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -252,11 +222,7 @@ void Joystick::setPlayerIndex(int index)
|
|
|
if (!isConnected())
|
|
|
return;
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(2, 0, 12)
|
|
|
- SDL_JoystickSetPlayerIndex(joyhandle, index);
|
|
|
-#else
|
|
|
- LOVE_UNUSED(index);
|
|
|
-#endif
|
|
|
+ SDL_SetJoystickPlayerIndex(joyhandle, index);
|
|
|
}
|
|
|
|
|
|
int Joystick::getPlayerIndex() const
|
|
@@ -264,27 +230,21 @@ int Joystick::getPlayerIndex() const
|
|
|
if (!isConnected())
|
|
|
return -1;
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(2, 0, 12)
|
|
|
- return SDL_JoystickGetPlayerIndex(joyhandle);
|
|
|
-#else
|
|
|
- return -1;
|
|
|
-#endif
|
|
|
+ return SDL_GetJoystickPlayerIndex(joyhandle);
|
|
|
}
|
|
|
|
|
|
bool Joystick::openGamepad(int64 deviceid)
|
|
|
{
|
|
|
- int deviceindex = (int) deviceid;
|
|
|
-
|
|
|
- if (!SDL_IsGameController(deviceindex))
|
|
|
+ if (!SDL_IsGamepad((SDL_JoystickID)deviceid))
|
|
|
return false;
|
|
|
|
|
|
if (isGamepad())
|
|
|
{
|
|
|
- SDL_GameControllerClose(controller);
|
|
|
+ SDL_CloseGamepad(controller);
|
|
|
controller = nullptr;
|
|
|
}
|
|
|
|
|
|
- controller = SDL_GameControllerOpen(deviceindex);
|
|
|
+ controller = SDL_OpenGamepad((SDL_JoystickID)deviceid);
|
|
|
return isGamepad();
|
|
|
}
|
|
|
|
|
@@ -298,31 +258,20 @@ Joystick::GamepadType Joystick::getGamepadType() const
|
|
|
if (controller == nullptr)
|
|
|
return GAMEPAD_TYPE_UNKNOWN;
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(2, 0, 12)
|
|
|
- switch (SDL_GameControllerGetType(controller))
|
|
|
+ switch (SDL_GetGamepadType(controller))
|
|
|
{
|
|
|
- case SDL_CONTROLLER_TYPE_UNKNOWN: return GAMEPAD_TYPE_UNKNOWN;
|
|
|
- case SDL_CONTROLLER_TYPE_XBOX360: return GAMEPAD_TYPE_XBOX360;
|
|
|
- case SDL_CONTROLLER_TYPE_XBOXONE: return GAMEPAD_TYPE_XBOXONE;
|
|
|
- case SDL_CONTROLLER_TYPE_PS3: return GAMEPAD_TYPE_PS3;
|
|
|
- case SDL_CONTROLLER_TYPE_PS4: return GAMEPAD_TYPE_PS4;
|
|
|
- case SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO: return GAMEPAD_TYPE_NINTENDO_SWITCH_PRO;
|
|
|
-#if SDL_VERSION_ATLEAST(2, 0, 14)
|
|
|
- case SDL_CONTROLLER_TYPE_VIRTUAL: return GAMEPAD_TYPE_VIRTUAL;
|
|
|
- case SDL_CONTROLLER_TYPE_PS5: return GAMEPAD_TYPE_PS5;
|
|
|
-#endif
|
|
|
-#if SDL_VERSION_ATLEAST(2, 0, 16)
|
|
|
- case SDL_CONTROLLER_TYPE_AMAZON_LUNA: return GAMEPAD_TYPE_AMAZON_LUNA;
|
|
|
- case SDL_CONTROLLER_TYPE_GOOGLE_STADIA: return GAMEPAD_TYPE_STADIA;
|
|
|
-#endif
|
|
|
-#if SDL_VERSION_ATLEAST(2, 24, 0)
|
|
|
- case SDL_CONTROLLER_TYPE_NVIDIA_SHIELD: return GAMEPAD_TYPE_NVIDIA_SHIELD;
|
|
|
- case SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT: return GAMEPAD_TYPE_JOYCON_LEFT;
|
|
|
- case SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT: return GAMEPAD_TYPE_JOYCON_RIGHT;
|
|
|
- case SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR: return GAMEPAD_TYPE_JOYCON_PAIR;
|
|
|
-#endif
|
|
|
+ case SDL_GAMEPAD_TYPE_UNKNOWN: return GAMEPAD_TYPE_UNKNOWN;
|
|
|
+ case SDL_GAMEPAD_TYPE_XBOX360: return GAMEPAD_TYPE_XBOX360;
|
|
|
+ case SDL_GAMEPAD_TYPE_XBOXONE: return GAMEPAD_TYPE_XBOXONE;
|
|
|
+ case SDL_GAMEPAD_TYPE_PS3: return GAMEPAD_TYPE_PS3;
|
|
|
+ case SDL_GAMEPAD_TYPE_PS4: return GAMEPAD_TYPE_PS4;
|
|
|
+ case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO: return GAMEPAD_TYPE_NINTENDO_SWITCH_PRO;
|
|
|
+ case SDL_GAMEPAD_TYPE_PS5: return GAMEPAD_TYPE_PS5;
|
|
|
+ case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT: return GAMEPAD_TYPE_JOYCON_LEFT;
|
|
|
+ case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT: return GAMEPAD_TYPE_JOYCON_RIGHT;
|
|
|
+ case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR: return GAMEPAD_TYPE_JOYCON_PAIR;
|
|
|
+ default: return GAMEPAD_TYPE_UNKNOWN;
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
return GAMEPAD_TYPE_UNKNOWN;
|
|
|
}
|
|
@@ -332,11 +281,11 @@ float Joystick::getGamepadAxis(love::joystick::Joystick::GamepadAxis axis) const
|
|
|
if (!isConnected() || !isGamepad())
|
|
|
return 0.f;
|
|
|
|
|
|
- SDL_GameControllerAxis sdlaxis;
|
|
|
+ SDL_GamepadAxis sdlaxis;
|
|
|
if (!getConstant(axis, sdlaxis))
|
|
|
return 0.f;
|
|
|
|
|
|
- Sint16 value = SDL_GameControllerGetAxis(controller, sdlaxis);
|
|
|
+ Sint16 value = SDL_GetGamepadAxis(controller, sdlaxis);
|
|
|
|
|
|
return clampval((float) value / 32768.0f);
|
|
|
}
|
|
@@ -346,14 +295,14 @@ bool Joystick::isGamepadDown(const std::vector<GamepadButton> &blist) const
|
|
|
if (!isConnected() || !isGamepad())
|
|
|
return false;
|
|
|
|
|
|
- SDL_GameControllerButton sdlbutton;
|
|
|
+ SDL_GamepadButton sdlbutton;
|
|
|
|
|
|
for (GamepadButton button : blist)
|
|
|
{
|
|
|
if (!getConstant(button, sdlbutton))
|
|
|
continue;
|
|
|
|
|
|
- if (SDL_GameControllerGetButton(controller, sdlbutton) == 1)
|
|
|
+ if (SDL_GetGamepadButton(controller, sdlbutton))
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -368,48 +317,57 @@ Joystick::JoystickInput Joystick::getGamepadMapping(const GamepadInput &input) c
|
|
|
if (!isGamepad())
|
|
|
return jinput;
|
|
|
|
|
|
- SDL_GameControllerButtonBind sdlbind = {};
|
|
|
- sdlbind.bindType = SDL_CONTROLLER_BINDTYPE_NONE;
|
|
|
-
|
|
|
- SDL_GameControllerButton sdlbutton;
|
|
|
- SDL_GameControllerAxis sdlaxis;
|
|
|
+ SDL_GamepadButton sdlbutton = SDL_GAMEPAD_BUTTON_INVALID;
|
|
|
+ SDL_GamepadAxis sdlaxis = SDL_GAMEPAD_AXIS_INVALID;
|
|
|
|
|
|
switch (input.type)
|
|
|
{
|
|
|
case INPUT_TYPE_BUTTON:
|
|
|
- if (getConstant(input.button, sdlbutton))
|
|
|
- sdlbind = SDL_GameControllerGetBindForButton(controller, sdlbutton);
|
|
|
+ getConstant(input.button, sdlbutton);
|
|
|
break;
|
|
|
case INPUT_TYPE_AXIS:
|
|
|
- if (getConstant(input.axis, sdlaxis))
|
|
|
- sdlbind = SDL_GameControllerGetBindForAxis(controller, sdlaxis);
|
|
|
+ getConstant(input.axis, sdlaxis);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- switch (sdlbind.bindType)
|
|
|
+ int bindcount = 0;
|
|
|
+ SDL_GamepadBinding **sdlbindings = SDL_GetGamepadBindings(controller, &bindcount);
|
|
|
+ for (int i = 0; i < bindcount; i++)
|
|
|
{
|
|
|
- case SDL_CONTROLLER_BINDTYPE_BUTTON:
|
|
|
- jinput.type = INPUT_TYPE_BUTTON;
|
|
|
- jinput.button = sdlbind.value.button;
|
|
|
- break;
|
|
|
- case SDL_CONTROLLER_BINDTYPE_AXIS:
|
|
|
- jinput.type = INPUT_TYPE_AXIS;
|
|
|
- jinput.axis = sdlbind.value.axis;
|
|
|
- break;
|
|
|
- case SDL_CONTROLLER_BINDTYPE_HAT:
|
|
|
- if (getConstant(sdlbind.value.hat.hat_mask, jinput.hat.value))
|
|
|
+ const SDL_GamepadBinding *b = sdlbindings[i];
|
|
|
+ if ((input.type == INPUT_TYPE_BUTTON && b->output_type == SDL_GAMEPAD_BINDTYPE_BUTTON && b->output.button == sdlbutton)
|
|
|
+ || (input.type == INPUT_TYPE_AXIS && b->output_type == SDL_GAMEPAD_BINDTYPE_AXIS && b->output.axis.axis == sdlaxis))
|
|
|
{
|
|
|
- jinput.type = INPUT_TYPE_HAT;
|
|
|
- jinput.hat.index = sdlbind.value.hat.hat;
|
|
|
+ switch (b->input_type)
|
|
|
+ {
|
|
|
+ case SDL_GAMEPAD_BINDTYPE_BUTTON:
|
|
|
+ jinput.type = INPUT_TYPE_BUTTON;
|
|
|
+ jinput.button = b->input.button;
|
|
|
+ break;
|
|
|
+ case SDL_GAMEPAD_BINDTYPE_AXIS:
|
|
|
+ jinput.type = INPUT_TYPE_AXIS;
|
|
|
+ jinput.axis = b->input.axis.axis;
|
|
|
+ break;
|
|
|
+ case SDL_GAMEPAD_BINDTYPE_HAT:
|
|
|
+ if (getConstant(b->input.hat.hat_mask, jinput.hat.value))
|
|
|
+ {
|
|
|
+ jinput.type = INPUT_TYPE_HAT;
|
|
|
+ jinput.hat.index = b->input.hat.hat;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case SDL_GAMEPAD_BINDTYPE_NONE:
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
- case SDL_CONTROLLER_BINDTYPE_NONE:
|
|
|
- default:
|
|
|
- break;
|
|
|
}
|
|
|
|
|
|
+ SDL_free(sdlbindings);
|
|
|
+
|
|
|
return jinput;
|
|
|
}
|
|
|
|
|
@@ -418,12 +376,12 @@ std::string Joystick::getGamepadMappingString() const
|
|
|
char *sdlmapping = nullptr;
|
|
|
|
|
|
if (controller != nullptr)
|
|
|
- sdlmapping = SDL_GameControllerMapping(controller);
|
|
|
+ sdlmapping = SDL_GetGamepadMapping(controller);
|
|
|
|
|
|
if (sdlmapping == nullptr)
|
|
|
{
|
|
|
- SDL_JoystickGUID sdlguid = SDL_JoystickGetGUIDFromString(pguid.c_str());
|
|
|
- sdlmapping = SDL_GameControllerMappingForGUID(sdlguid);
|
|
|
+ SDL_GUID sdlguid = SDL_StringToGUID(pguid.c_str());
|
|
|
+ sdlmapping = SDL_GetGamepadMappingForGUID(sdlguid);
|
|
|
}
|
|
|
|
|
|
if (sdlmapping == nullptr)
|
|
@@ -467,9 +425,9 @@ void Joystick::getDeviceInfo(int &vendorID, int &productID, int &productVersion)
|
|
|
{
|
|
|
if (joyhandle != nullptr)
|
|
|
{
|
|
|
- vendorID = SDL_JoystickGetVendor(joyhandle);
|
|
|
- productID = SDL_JoystickGetProduct(joyhandle);
|
|
|
- productVersion = SDL_JoystickGetProductVersion(joyhandle);
|
|
|
+ vendorID = SDL_GetJoystickVendor(joyhandle);
|
|
|
+ productID = SDL_GetJoystickProduct(joyhandle);
|
|
|
+ productVersion = SDL_GetJoystickProductVersion(joyhandle);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -479,76 +437,13 @@ void Joystick::getDeviceInfo(int &vendorID, int &productID, int &productVersion)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-bool Joystick::checkCreateHaptic()
|
|
|
-{
|
|
|
- if (!isConnected())
|
|
|
- return false;
|
|
|
-
|
|
|
- if (!SDL_WasInit(SDL_INIT_HAPTIC) && SDL_InitSubSystem(SDL_INIT_HAPTIC) < 0)
|
|
|
- return false;
|
|
|
-
|
|
|
- if (haptic && SDL_HapticIndex(haptic) != -1)
|
|
|
- return true;
|
|
|
-
|
|
|
- if (haptic)
|
|
|
- {
|
|
|
- SDL_HapticClose(haptic);
|
|
|
- haptic = nullptr;
|
|
|
- }
|
|
|
-
|
|
|
- haptic = SDL_HapticOpenFromJoystick(joyhandle);
|
|
|
- vibration = Vibration();
|
|
|
-
|
|
|
- return haptic != nullptr;
|
|
|
-}
|
|
|
-
|
|
|
bool Joystick::isVibrationSupported()
|
|
|
{
|
|
|
-#if SDL_VERSION_ATLEAST(2, 0, 18)
|
|
|
- if (isConnected() && SDL_JoystickHasRumble(joyhandle) == SDL_TRUE)
|
|
|
- return true;
|
|
|
-#endif
|
|
|
-
|
|
|
- if (!checkCreateHaptic())
|
|
|
+ if (!isConnected())
|
|
|
return false;
|
|
|
|
|
|
- unsigned int features = SDL_HapticQuery(haptic);
|
|
|
-
|
|
|
- if ((features & SDL_HAPTIC_LEFTRIGHT) != 0)
|
|
|
- return true;
|
|
|
-
|
|
|
- // Some gamepad drivers only support left/right motors via a custom effect.
|
|
|
- if (isGamepad() && (features & SDL_HAPTIC_CUSTOM) != 0)
|
|
|
- return true;
|
|
|
-
|
|
|
- // Test for simple sine wave support as a last resort.
|
|
|
- if ((features & SDL_HAPTIC_SINE) != 0)
|
|
|
- return true;
|
|
|
-
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
-bool Joystick::runVibrationEffect()
|
|
|
-{
|
|
|
- if (vibration.id != -1)
|
|
|
- {
|
|
|
- if (SDL_HapticUpdateEffect(haptic, vibration.id, &vibration.effect) == 0)
|
|
|
- {
|
|
|
- if (SDL_HapticRunEffect(haptic, vibration.id, 1) == 0)
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- // If the effect fails to update, we should destroy and re-create it.
|
|
|
- SDL_HapticDestroyEffect(haptic, vibration.id);
|
|
|
- vibration.id = -1;
|
|
|
- }
|
|
|
-
|
|
|
- vibration.id = SDL_HapticNewEffect(haptic, &vibration.effect);
|
|
|
-
|
|
|
- if (vibration.id != -1 && SDL_HapticRunEffect(haptic, vibration.id, 1) == 0)
|
|
|
- return true;
|
|
|
-
|
|
|
- return false;
|
|
|
+ SDL_PropertiesID props = SDL_GetJoystickProperties(joyhandle);
|
|
|
+ return SDL_GetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, false);
|
|
|
}
|
|
|
|
|
|
bool Joystick::setVibration(float left, float right, float duration)
|
|
@@ -560,148 +455,39 @@ bool Joystick::setVibration(float left, float right, float duration)
|
|
|
return setVibration();
|
|
|
|
|
|
if (!isConnected())
|
|
|
- {
|
|
|
- vibration.left = vibration.right = 0.0f;
|
|
|
- vibration.endtime = SDL_HAPTIC_INFINITY;
|
|
|
return false;
|
|
|
- }
|
|
|
|
|
|
- Uint32 length = SDL_HAPTIC_INFINITY;
|
|
|
+ Uint32 length = LOVE_UINT32_MAX;
|
|
|
if (duration >= 0.0f)
|
|
|
{
|
|
|
float maxduration = (float) (std::numeric_limits<Uint32>::max() / 1000.0);
|
|
|
length = Uint32(std::min(duration, maxduration) * 1000);
|
|
|
}
|
|
|
|
|
|
- bool success = false;
|
|
|
-
|
|
|
- if (SDL_JoystickRumble(joyhandle, (Uint16)(left * LOVE_UINT16_MAX), (Uint16)(right * LOVE_UINT16_MAX), length) == 0)
|
|
|
- success = true;
|
|
|
-
|
|
|
- if (!success && !checkCreateHaptic())
|
|
|
- return false;
|
|
|
-
|
|
|
- unsigned int features = SDL_HapticQuery(haptic);
|
|
|
- int axes = SDL_HapticNumAxes(haptic);
|
|
|
-
|
|
|
- if (!success && (features & SDL_HAPTIC_LEFTRIGHT) != 0)
|
|
|
- {
|
|
|
- memset(&vibration.effect, 0, sizeof(SDL_HapticEffect));
|
|
|
- vibration.effect.type = SDL_HAPTIC_LEFTRIGHT;
|
|
|
-
|
|
|
- vibration.effect.leftright.length = length;
|
|
|
- vibration.effect.leftright.large_magnitude = Uint16(left * LOVE_UINT16_MAX);
|
|
|
- vibration.effect.leftright.small_magnitude = Uint16(right * LOVE_UINT16_MAX);
|
|
|
-
|
|
|
- success = runVibrationEffect();
|
|
|
- }
|
|
|
-
|
|
|
- // Some gamepad drivers only give support for controlling individual motors
|
|
|
- // through a custom FF effect.
|
|
|
- if (!success && isGamepad() && (features & SDL_HAPTIC_CUSTOM) && axes == 2)
|
|
|
- {
|
|
|
- // NOTE: this may cause issues with drivers which support custom effects
|
|
|
- // but aren't similar to https://github.com/d235j/360Controller .
|
|
|
-
|
|
|
- // Custom effect data is clamped to 0x7FFF in SDL.
|
|
|
- vibration.data[0] = vibration.data[2] = Uint16(left * 0x7FFF);
|
|
|
- vibration.data[1] = vibration.data[3] = Uint16(right * 0x7FFF);
|
|
|
-
|
|
|
- memset(&vibration.effect, 0, sizeof(SDL_HapticEffect));
|
|
|
- vibration.effect.type = SDL_HAPTIC_CUSTOM;
|
|
|
-
|
|
|
- vibration.effect.custom.length = length;
|
|
|
- vibration.effect.custom.channels = 2;
|
|
|
- vibration.effect.custom.period = 10;
|
|
|
- vibration.effect.custom.samples = 2;
|
|
|
- vibration.effect.custom.data = vibration.data;
|
|
|
-
|
|
|
- success = runVibrationEffect();
|
|
|
- }
|
|
|
-
|
|
|
- // Fall back to a simple sine wave if all else fails. This only supports a
|
|
|
- // single strength value.
|
|
|
- if (!success && (features & SDL_HAPTIC_SINE) != 0)
|
|
|
- {
|
|
|
- memset(&vibration.effect, 0, sizeof(SDL_HapticEffect));
|
|
|
- vibration.effect.type = SDL_HAPTIC_SINE;
|
|
|
-
|
|
|
- vibration.effect.periodic.length = length;
|
|
|
- vibration.effect.periodic.period = 10;
|
|
|
-
|
|
|
- float strength = std::max(left, right);
|
|
|
- vibration.effect.periodic.magnitude = Sint16(strength * 0x7FFF);
|
|
|
-
|
|
|
- success = runVibrationEffect();
|
|
|
- }
|
|
|
-
|
|
|
- if (success)
|
|
|
- {
|
|
|
- vibration.left = left;
|
|
|
- vibration.right = right;
|
|
|
-
|
|
|
- if (length == SDL_HAPTIC_INFINITY)
|
|
|
- vibration.endtime = SDL_HAPTIC_INFINITY;
|
|
|
- else
|
|
|
- vibration.endtime = SDL_GetTicks() + length;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- vibration.left = vibration.right = 0.0f;
|
|
|
- vibration.endtime = SDL_HAPTIC_INFINITY;
|
|
|
- }
|
|
|
-
|
|
|
- return success;
|
|
|
+ return SDL_RumbleJoystick(joyhandle, (Uint16)(left * LOVE_UINT16_MAX), (Uint16)(right * LOVE_UINT16_MAX), length) == 0;
|
|
|
}
|
|
|
|
|
|
bool Joystick::setVibration()
|
|
|
{
|
|
|
- bool success = false;
|
|
|
-
|
|
|
- if (!success)
|
|
|
- success = isConnected() && SDL_JoystickRumble(joyhandle, 0, 0, 0) == 0;
|
|
|
-
|
|
|
- if (!success && SDL_WasInit(SDL_INIT_HAPTIC) && haptic && SDL_HapticIndex(haptic) != -1)
|
|
|
- success = (SDL_HapticStopEffect(haptic, vibration.id) == 0);
|
|
|
-
|
|
|
- if (success)
|
|
|
- vibration.left = vibration.right = 0.0f;
|
|
|
-
|
|
|
- return success;
|
|
|
+ return isConnected() && SDL_RumbleJoystick(joyhandle, 0, 0, 0) == 0;
|
|
|
}
|
|
|
|
|
|
void Joystick::getVibration(float &left, float &right)
|
|
|
{
|
|
|
- if (vibration.endtime != SDL_HAPTIC_INFINITY)
|
|
|
- {
|
|
|
- // With some drivers, the effect physically stops at the right time, but
|
|
|
- // SDL_HapticGetEffectStatus still thinks it's playing. So we explicitly
|
|
|
- // stop it once it's done, just to be sure.
|
|
|
- if (SDL_TICKS_PASSED(SDL_GetTicks(), vibration.endtime))
|
|
|
- {
|
|
|
- setVibration();
|
|
|
- vibration.endtime = SDL_HAPTIC_INFINITY;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Check if the haptic effect has stopped playing.
|
|
|
- int id = vibration.id;
|
|
|
- if (!haptic || id == -1 || SDL_HapticGetEffectStatus(haptic, id) != 1)
|
|
|
- vibration.left = vibration.right = 0.0f;
|
|
|
-
|
|
|
- left = vibration.left;
|
|
|
- right = vibration.right;
|
|
|
+ // Deprecated.
|
|
|
+ left = 0.0f;
|
|
|
+ right = 0.0f;
|
|
|
}
|
|
|
|
|
|
bool Joystick::hasSensor(Sensor::SensorType type) const
|
|
|
{
|
|
|
-#if SDL_VERSION_ATLEAST(2, 0, 14) && defined(LOVE_ENABLE_SENSOR)
|
|
|
+#if defined(LOVE_ENABLE_SENSOR)
|
|
|
using SDLSensor = love::sensor::sdl::Sensor;
|
|
|
|
|
|
if (!isGamepad())
|
|
|
return false;
|
|
|
|
|
|
- return SDL_GameControllerHasSensor(controller, SDLSensor::convert(type)) == SDL_TRUE;
|
|
|
+ return SDL_GamepadHasSensor(controller, SDLSensor::convert(type));
|
|
|
#else
|
|
|
return false;
|
|
|
#endif
|
|
@@ -709,13 +495,13 @@ bool Joystick::hasSensor(Sensor::SensorType type) const
|
|
|
|
|
|
bool Joystick::isSensorEnabled(Sensor::SensorType type) const
|
|
|
{
|
|
|
-#if SDL_VERSION_ATLEAST(2, 0, 14) && defined(LOVE_ENABLE_SENSOR)
|
|
|
+#if defined(LOVE_ENABLE_SENSOR)
|
|
|
using SDLSensor = love::sensor::sdl::Sensor;
|
|
|
|
|
|
if (!isGamepad())
|
|
|
return false;
|
|
|
|
|
|
- return SDL_GameControllerIsSensorEnabled(controller, SDLSensor::convert(type)) == SDL_TRUE;
|
|
|
+ return SDL_GamepadSensorEnabled(controller, SDLSensor::convert(type));
|
|
|
#else
|
|
|
return false;
|
|
|
#endif
|
|
@@ -723,13 +509,13 @@ bool Joystick::isSensorEnabled(Sensor::SensorType type) const
|
|
|
|
|
|
void Joystick::setSensorEnabled(Sensor::SensorType type, bool enabled)
|
|
|
{
|
|
|
-#if SDL_VERSION_ATLEAST(2, 0, 14) && defined(LOVE_ENABLE_SENSOR)
|
|
|
+#if defined(LOVE_ENABLE_SENSOR)
|
|
|
using SDLSensor = love::sensor::sdl::Sensor;
|
|
|
|
|
|
if (!isGamepad())
|
|
|
throw love::Exception("Sensor is only supported on gamepad");
|
|
|
|
|
|
- if (SDL_GameControllerSetSensorEnabled(controller, SDLSensor::convert(type), enabled ? SDL_TRUE : SDL_FALSE) != 0)
|
|
|
+ if (!SDL_SetGamepadSensorEnabled(controller, SDLSensor::convert(type), enabled))
|
|
|
{
|
|
|
const char *name = nullptr;
|
|
|
SDLSensor::getConstant(type, name);
|
|
@@ -737,13 +523,13 @@ void Joystick::setSensorEnabled(Sensor::SensorType type, bool enabled)
|
|
|
throw love::Exception("Could not open \"%s\" SDL gamepad sensor (%s)", name, SDL_GetError());
|
|
|
}
|
|
|
#else
|
|
|
- throw love::Exception("Compiled version of SDL or LOVE does not support gamepad sensor");
|
|
|
+ throw love::Exception("Compiled version of LOVE does not support gamepad sensor");
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
std::vector<float> Joystick::getSensorData(Sensor::SensorType type) const
|
|
|
{
|
|
|
-#if SDL_VERSION_ATLEAST(2, 0, 14) && defined(LOVE_ENABLE_SENSOR)
|
|
|
+#if defined(LOVE_ENABLE_SENSOR)
|
|
|
using SDLSensor = love::sensor::sdl::Sensor;
|
|
|
|
|
|
if (!isGamepad())
|
|
@@ -759,7 +545,7 @@ std::vector<float> Joystick::getSensorData(Sensor::SensorType type) const
|
|
|
throw love::Exception("\"%s\" gamepad sensor is not enabled", name);
|
|
|
}
|
|
|
|
|
|
- if (SDL_GameControllerGetSensorData(controller, SDLSensor::convert(type), data.data(), (int) data.size()) != 0)
|
|
|
+ if (!SDL_GetGamepadSensorData(controller, SDLSensor::convert(type), data.data(), (int) data.size()))
|
|
|
{
|
|
|
const char *name = nullptr;
|
|
|
SDLSensor::getConstant(type, name);
|
|
@@ -769,7 +555,7 @@ std::vector<float> Joystick::getSensorData(Sensor::SensorType type) const
|
|
|
|
|
|
return data;
|
|
|
#else
|
|
|
- throw love::Exception("Compiled version of SDL or LOVE does not support gamepad sensor");
|
|
|
+ throw love::Exception("Compiled version of LOVE does not support gamepad sensor");
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -783,22 +569,22 @@ bool Joystick::getConstant(Joystick::Hat in, Uint8 &out)
|
|
|
return hats.find(in, out);
|
|
|
}
|
|
|
|
|
|
-bool Joystick::getConstant(SDL_GameControllerAxis in, Joystick::GamepadAxis &out)
|
|
|
+bool Joystick::getConstant(SDL_GamepadAxis in, Joystick::GamepadAxis &out)
|
|
|
{
|
|
|
return gpAxes.find(in, out);
|
|
|
}
|
|
|
|
|
|
-bool Joystick::getConstant(Joystick::GamepadAxis in, SDL_GameControllerAxis &out)
|
|
|
+bool Joystick::getConstant(Joystick::GamepadAxis in, SDL_GamepadAxis &out)
|
|
|
{
|
|
|
return gpAxes.find(in, out);
|
|
|
}
|
|
|
|
|
|
-bool Joystick::getConstant(SDL_GameControllerButton in, Joystick::GamepadButton &out)
|
|
|
+bool Joystick::getConstant(SDL_GamepadButton in, Joystick::GamepadButton &out)
|
|
|
{
|
|
|
return gpButtons.find(in, out);
|
|
|
}
|
|
|
|
|
|
-bool Joystick::getConstant(Joystick::GamepadButton in, SDL_GameControllerButton &out)
|
|
|
+bool Joystick::getConstant(Joystick::GamepadButton in, SDL_GamepadButton &out)
|
|
|
{
|
|
|
return gpButtons.find(in, out);
|
|
|
}
|
|
@@ -818,49 +604,45 @@ EnumMap<Joystick::Hat, Uint8, Joystick::HAT_MAX_ENUM>::Entry Joystick::hatEntrie
|
|
|
|
|
|
EnumMap<Joystick::Hat, Uint8, Joystick::HAT_MAX_ENUM> Joystick::hats(Joystick::hatEntries, sizeof(Joystick::hatEntries));
|
|
|
|
|
|
-EnumMap<Joystick::GamepadAxis, SDL_GameControllerAxis, Joystick::GAMEPAD_AXIS_MAX_ENUM>::Entry Joystick::gpAxisEntries[] =
|
|
|
+EnumMap<Joystick::GamepadAxis, SDL_GamepadAxis, Joystick::GAMEPAD_AXIS_MAX_ENUM>::Entry Joystick::gpAxisEntries[] =
|
|
|
{
|
|
|
- {Joystick::GAMEPAD_AXIS_LEFTX, SDL_CONTROLLER_AXIS_LEFTX},
|
|
|
- {Joystick::GAMEPAD_AXIS_LEFTY, SDL_CONTROLLER_AXIS_LEFTY},
|
|
|
- {Joystick::GAMEPAD_AXIS_RIGHTX, SDL_CONTROLLER_AXIS_RIGHTX},
|
|
|
- {Joystick::GAMEPAD_AXIS_RIGHTY, SDL_CONTROLLER_AXIS_RIGHTY},
|
|
|
- {Joystick::GAMEPAD_AXIS_TRIGGERLEFT, SDL_CONTROLLER_AXIS_TRIGGERLEFT},
|
|
|
- {Joystick::GAMEPAD_AXIS_TRIGGERRIGHT, SDL_CONTROLLER_AXIS_TRIGGERRIGHT},
|
|
|
+ {Joystick::GAMEPAD_AXIS_LEFTX, SDL_GAMEPAD_AXIS_LEFTX},
|
|
|
+ {Joystick::GAMEPAD_AXIS_LEFTY, SDL_GAMEPAD_AXIS_LEFTY},
|
|
|
+ {Joystick::GAMEPAD_AXIS_RIGHTX, SDL_GAMEPAD_AXIS_RIGHTX},
|
|
|
+ {Joystick::GAMEPAD_AXIS_RIGHTY, SDL_GAMEPAD_AXIS_RIGHTY},
|
|
|
+ {Joystick::GAMEPAD_AXIS_TRIGGERLEFT, SDL_GAMEPAD_AXIS_LEFT_TRIGGER},
|
|
|
+ {Joystick::GAMEPAD_AXIS_TRIGGERRIGHT, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER},
|
|
|
};
|
|
|
|
|
|
-EnumMap<Joystick::GamepadAxis, SDL_GameControllerAxis, Joystick::GAMEPAD_AXIS_MAX_ENUM> Joystick::gpAxes(Joystick::gpAxisEntries, sizeof(Joystick::gpAxisEntries));
|
|
|
-
|
|
|
-EnumMap<Joystick::GamepadButton, SDL_GameControllerButton, Joystick::GAMEPAD_BUTTON_MAX_ENUM>::Entry Joystick::gpButtonEntries[] =
|
|
|
-{
|
|
|
- {Joystick::GAMEPAD_BUTTON_A, SDL_CONTROLLER_BUTTON_A},
|
|
|
- {Joystick::GAMEPAD_BUTTON_B, SDL_CONTROLLER_BUTTON_B},
|
|
|
- {Joystick::GAMEPAD_BUTTON_X, SDL_CONTROLLER_BUTTON_X},
|
|
|
- {Joystick::GAMEPAD_BUTTON_Y, SDL_CONTROLLER_BUTTON_Y},
|
|
|
- {Joystick::GAMEPAD_BUTTON_BACK, SDL_CONTROLLER_BUTTON_BACK},
|
|
|
- {Joystick::GAMEPAD_BUTTON_GUIDE, SDL_CONTROLLER_BUTTON_GUIDE},
|
|
|
- {Joystick::GAMEPAD_BUTTON_START, SDL_CONTROLLER_BUTTON_START},
|
|
|
- {Joystick::GAMEPAD_BUTTON_LEFTSTICK, SDL_CONTROLLER_BUTTON_LEFTSTICK},
|
|
|
- {Joystick::GAMEPAD_BUTTON_RIGHTSTICK, SDL_CONTROLLER_BUTTON_RIGHTSTICK},
|
|
|
- {Joystick::GAMEPAD_BUTTON_LEFTSHOULDER, SDL_CONTROLLER_BUTTON_LEFTSHOULDER},
|
|
|
- {Joystick::GAMEPAD_BUTTON_RIGHTSHOULDER, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER},
|
|
|
- {Joystick::GAMEPAD_BUTTON_DPAD_UP, SDL_CONTROLLER_BUTTON_DPAD_UP},
|
|
|
- {Joystick::GAMEPAD_BUTTON_DPAD_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN},
|
|
|
- {Joystick::GAMEPAD_BUTTON_DPAD_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT},
|
|
|
- {Joystick::GAMEPAD_BUTTON_DPAD_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT},
|
|
|
-#if SDL_VERSION_ATLEAST(2, 0, 14)
|
|
|
- {Joystick::GAMEPAD_BUTTON_MISC1, SDL_CONTROLLER_BUTTON_MISC1},
|
|
|
- {Joystick::GAMEPAD_BUTTON_PADDLE1, SDL_CONTROLLER_BUTTON_PADDLE1},
|
|
|
- {Joystick::GAMEPAD_BUTTON_PADDLE2, SDL_CONTROLLER_BUTTON_PADDLE2},
|
|
|
- {Joystick::GAMEPAD_BUTTON_PADDLE3, SDL_CONTROLLER_BUTTON_PADDLE3},
|
|
|
- {Joystick::GAMEPAD_BUTTON_PADDLE4, SDL_CONTROLLER_BUTTON_PADDLE4},
|
|
|
- {Joystick::GAMEPAD_BUTTON_TOUCHPAD, SDL_CONTROLLER_BUTTON_TOUCHPAD},
|
|
|
-#endif
|
|
|
+EnumMap<Joystick::GamepadAxis, SDL_GamepadAxis, Joystick::GAMEPAD_AXIS_MAX_ENUM> Joystick::gpAxes(Joystick::gpAxisEntries, sizeof(Joystick::gpAxisEntries));
|
|
|
+
|
|
|
+EnumMap<Joystick::GamepadButton, SDL_GamepadButton, Joystick::GAMEPAD_BUTTON_MAX_ENUM>::Entry Joystick::gpButtonEntries[] =
|
|
|
+{
|
|
|
+ {Joystick::GAMEPAD_BUTTON_A, SDL_GAMEPAD_BUTTON_SOUTH},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_B, SDL_GAMEPAD_BUTTON_EAST},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_X, SDL_GAMEPAD_BUTTON_WEST},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_Y, SDL_GAMEPAD_BUTTON_NORTH},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_BACK, SDL_GAMEPAD_BUTTON_BACK},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_GUIDE, SDL_GAMEPAD_BUTTON_GUIDE},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_START, SDL_GAMEPAD_BUTTON_START},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_LEFTSTICK, SDL_GAMEPAD_BUTTON_LEFT_STICK},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_RIGHTSTICK, SDL_GAMEPAD_BUTTON_RIGHT_STICK},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_LEFTSHOULDER, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_RIGHTSHOULDER, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_DPAD_UP, SDL_GAMEPAD_BUTTON_DPAD_UP},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_DPAD_DOWN, SDL_GAMEPAD_BUTTON_DPAD_DOWN},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_DPAD_LEFT, SDL_GAMEPAD_BUTTON_DPAD_LEFT},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_DPAD_RIGHT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_MISC1, SDL_GAMEPAD_BUTTON_MISC1},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_PADDLE1, SDL_GAMEPAD_BUTTON_LEFT_PADDLE1},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_PADDLE2, SDL_GAMEPAD_BUTTON_LEFT_PADDLE2},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_PADDLE3, SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_PADDLE4, SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2},
|
|
|
+ {Joystick::GAMEPAD_BUTTON_TOUCHPAD, SDL_GAMEPAD_BUTTON_TOUCHPAD},
|
|
|
};
|
|
|
|
|
|
-EnumMap<Joystick::GamepadButton, SDL_GameControllerButton, Joystick::GAMEPAD_BUTTON_MAX_ENUM> Joystick::gpButtons(Joystick::gpButtonEntries, sizeof(Joystick::gpButtonEntries));
|
|
|
+EnumMap<Joystick::GamepadButton, SDL_GamepadButton, Joystick::GAMEPAD_BUTTON_MAX_ENUM> Joystick::gpButtons(Joystick::gpButtonEntries, sizeof(Joystick::gpButtonEntries));
|
|
|
|
|
|
} // sdl
|
|
|
} // joystick
|
|
|
} // love
|
|
|
-
|
|
|
-#endif // !SDL_VERSION_ATLEAST(3, 0, 0)
|