mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-06 18:06:26 +00:00
Added support for gamepad rumble on Android
Tested with the DualSense controller over Bluetooth on Android 12 Fixes https://github.com/libsdl-org/SDL/issues/7847
This commit is contained in:
@@ -25,8 +25,6 @@
|
||||
#include "SDL_syshaptic_c.h"
|
||||
#include "../SDL_syshaptic.h"
|
||||
#include "../../core/android/SDL_android.h"
|
||||
#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
|
||||
#include "../../joystick/android/SDL_sysjoystick_c.h" /* For joystick hwdata */
|
||||
|
||||
typedef struct SDL_hapticlist_item
|
||||
{
|
||||
@@ -78,18 +76,6 @@ static SDL_hapticlist_item *HapticByInstanceID(SDL_HapticID instance_id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SDL_hapticlist_item *HapticByDevId(int device_id)
|
||||
{
|
||||
SDL_hapticlist_item *item;
|
||||
for (item = SDL_hapticlist; item; item = item->next) {
|
||||
if (device_id == item->device_id) {
|
||||
/*SDL_Log("=+=+=+=+=+= HapticByDevId id [%d]", device_id);*/
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_HapticID SDL_SYS_HapticInstanceID(int index)
|
||||
{
|
||||
SDL_hapticlist_item *item = HapticByOrder(index);
|
||||
@@ -142,11 +128,6 @@ static SDL_hapticlist_item *OpenHapticByInstanceID(SDL_Haptic *haptic, SDL_Hapti
|
||||
return OpenHaptic(haptic, HapticByInstanceID(instance_id));
|
||||
}
|
||||
|
||||
static SDL_hapticlist_item *OpenHapticByDevId(SDL_Haptic *haptic, int device_id)
|
||||
{
|
||||
return OpenHaptic(haptic, HapticByDevId(device_id));
|
||||
}
|
||||
|
||||
int SDL_SYS_HapticOpen(SDL_Haptic *haptic)
|
||||
{
|
||||
return OpenHapticByInstanceID(haptic, haptic->instance_id) == NULL ? -1 : 0;
|
||||
@@ -159,19 +140,17 @@ int SDL_SYS_HapticMouse(void)
|
||||
|
||||
int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_hapticlist_item *item;
|
||||
item = HapticByDevId(((joystick_hwdata *)joystick->hwdata)->device_id);
|
||||
return (item) ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
return OpenHapticByDevId(haptic, ((joystick_hwdata *)joystick->hwdata)->device_id) == NULL ? -1 : 0;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
return ((SDL_hapticlist_item *)haptic->hwdata)->device_id == ((joystick_hwdata *)joystick->hwdata)->device_id ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_SYS_HapticClose(SDL_Haptic *haptic)
|
||||
|
Reference in New Issue
Block a user