mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-29 07:59:11 +00:00
SDL API renaming: internal functions
This commit is contained in:
parent
25336d053a
commit
36d4395c97
92 changed files with 1164 additions and 1164 deletions
108
src/SDL.c
108
src/SDL.c
|
@ -112,7 +112,7 @@ static SDL_bool SDL_bInMainQuit = SDL_FALSE;
|
|||
static Uint8 SDL_SubsystemRefCount[32];
|
||||
|
||||
/* Private helper to increment a subsystem's ref counter. */
|
||||
static void SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
|
||||
static void SDL_IncrementSubsystemRefCount(Uint32 subsystem)
|
||||
{
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
||||
|
@ -122,7 +122,7 @@ static void SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
|
|||
}
|
||||
|
||||
/* Private helper to decrement a subsystem's ref counter. */
|
||||
static void SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
|
||||
static void SDL_DecrementSubsystemRefCount(Uint32 subsystem)
|
||||
{
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
|
||||
|
@ -131,7 +131,7 @@ static void SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
|
|||
}
|
||||
|
||||
/* Private helper to check if a system needs init. */
|
||||
static SDL_bool SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
|
||||
static SDL_bool SDL_ShouldInitSubsystem(Uint32 subsystem)
|
||||
{
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
||||
|
@ -139,7 +139,7 @@ static SDL_bool SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
|
|||
}
|
||||
|
||||
/* Private helper to check if a system needs to be quit. */
|
||||
static SDL_bool SDL_PrivateShouldQuitSubsystem(Uint32 subsystem)
|
||||
static SDL_bool SDL_ShouldQuitSubsystem(Uint32 subsystem)
|
||||
{
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
|
||||
|
@ -165,7 +165,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||
return SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
|
||||
}
|
||||
|
||||
SDL_LogInit();
|
||||
SDL_InitLog();
|
||||
|
||||
/* Clear the error message */
|
||||
SDL_ClearError();
|
||||
|
@ -193,18 +193,18 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||
#endif
|
||||
|
||||
#if !SDL_TIMERS_DISABLED
|
||||
SDL_TicksInit();
|
||||
SDL_InitTicks();
|
||||
#endif
|
||||
|
||||
/* Initialize the event subsystem */
|
||||
if ((flags & SDL_INIT_EVENTS)) {
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
|
||||
if (SDL_EventsInit() < 0) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_EVENTS)) {
|
||||
if (SDL_InitEvents() < 0) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_EVENTS);
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_EVENTS);
|
||||
flags_initialized |= SDL_INIT_EVENTS;
|
||||
#else
|
||||
SDL_SetError("SDL not built with events support");
|
||||
|
@ -215,12 +215,12 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||
/* Initialize the timer subsystem */
|
||||
if ((flags & SDL_INIT_TIMER)) {
|
||||
#if !SDL_TIMERS_DISABLED && !SDL_TIMER_DUMMY
|
||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
|
||||
if (SDL_TimerInit() < 0) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_TIMER)) {
|
||||
if (SDL_InitTimers() < 0) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_TIMER);
|
||||
flags_initialized |= SDL_INIT_TIMER;
|
||||
#else
|
||||
SDL_SetError("SDL not built with timer support");
|
||||
|
@ -231,12 +231,12 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||
/* Initialize the video subsystem */
|
||||
if ((flags & SDL_INIT_VIDEO)) {
|
||||
#if !SDL_VIDEO_DISABLED
|
||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_VIDEO)) {
|
||||
if (SDL_VideoInit(NULL) < 0) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_VIDEO);
|
||||
flags_initialized |= SDL_INIT_VIDEO;
|
||||
#else
|
||||
SDL_SetError("SDL not built with video support");
|
||||
|
@ -247,12 +247,12 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||
/* Initialize the audio subsystem */
|
||||
if ((flags & SDL_INIT_AUDIO)) {
|
||||
#if !SDL_AUDIO_DISABLED
|
||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
|
||||
if (SDL_AudioInit(NULL) < 0) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_AUDIO)) {
|
||||
if (SDL_InitAudio(NULL) < 0) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_AUDIO);
|
||||
flags_initialized |= SDL_INIT_AUDIO;
|
||||
#else
|
||||
SDL_SetError("SDL not built with audio support");
|
||||
|
@ -263,12 +263,12 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||
/* Initialize the joystick subsystem */
|
||||
if ((flags & SDL_INIT_JOYSTICK)) {
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
|
||||
if (SDL_JoystickInit() < 0) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
|
||||
if (SDL_InitJoysticks() < 0) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_JOYSTICK);
|
||||
flags_initialized |= SDL_INIT_JOYSTICK;
|
||||
#else
|
||||
SDL_SetError("SDL not built with joystick support");
|
||||
|
@ -278,12 +278,12 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||
|
||||
if ((flags & SDL_INIT_GAMEPAD)) {
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMEPAD)) {
|
||||
if (SDL_GamepadInit() < 0) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_GAMEPAD)) {
|
||||
if (SDL_InitGamepads() < 0) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMEPAD);
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_GAMEPAD);
|
||||
flags_initialized |= SDL_INIT_GAMEPAD;
|
||||
#else
|
||||
SDL_SetError("SDL not built with joystick support");
|
||||
|
@ -294,12 +294,12 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||
/* Initialize the haptic subsystem */
|
||||
if ((flags & SDL_INIT_HAPTIC)) {
|
||||
#if !SDL_HAPTIC_DISABLED
|
||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
|
||||
if (SDL_HapticInit() < 0) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_HAPTIC)) {
|
||||
if (SDL_InitHaptics() < 0) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_HAPTIC);
|
||||
flags_initialized |= SDL_INIT_HAPTIC;
|
||||
#else
|
||||
SDL_SetError("SDL not built with haptic (force feedback) support");
|
||||
|
@ -310,12 +310,12 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||
/* Initialize the sensor subsystem */
|
||||
if ((flags & SDL_INIT_SENSOR)) {
|
||||
#if !SDL_SENSOR_DISABLED
|
||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_SENSOR)) {
|
||||
if (SDL_SensorInit() < 0) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_SENSOR)) {
|
||||
if (SDL_InitSensors() < 0) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_SENSOR);
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_SENSOR);
|
||||
flags_initialized |= SDL_INIT_SENSOR;
|
||||
#else
|
||||
SDL_SetError("SDL not built with sensor support");
|
||||
|
@ -342,10 +342,10 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||
/* Shut down requested initialized subsystems */
|
||||
#if !SDL_SENSOR_DISABLED
|
||||
if ((flags & SDL_INIT_SENSOR)) {
|
||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_SENSOR)) {
|
||||
SDL_SensorQuit();
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_SENSOR)) {
|
||||
SDL_QuitSensors();
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_SENSOR);
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_SENSOR);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -354,29 +354,29 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||
/* game controller implies joystick */
|
||||
flags |= SDL_INIT_JOYSTICK;
|
||||
|
||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMEPAD)) {
|
||||
SDL_GamepadQuit();
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_GAMEPAD)) {
|
||||
SDL_QuitGamepads();
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMEPAD);
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_GAMEPAD);
|
||||
}
|
||||
|
||||
if ((flags & SDL_INIT_JOYSTICK)) {
|
||||
/* joystick implies events */
|
||||
flags |= SDL_INIT_EVENTS;
|
||||
|
||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
|
||||
SDL_JoystickQuit();
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
|
||||
SDL_QuitJoysticks();
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_JOYSTICK);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !SDL_HAPTIC_DISABLED
|
||||
if ((flags & SDL_INIT_HAPTIC)) {
|
||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
|
||||
SDL_HapticQuit();
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
|
||||
SDL_QuitHaptics();
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_HAPTIC);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -385,10 +385,10 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||
/* audio implies events */
|
||||
flags |= SDL_INIT_EVENTS;
|
||||
|
||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
|
||||
SDL_AudioQuit();
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_AUDIO)) {
|
||||
SDL_QuitAudio();
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_AUDIO);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -397,28 +397,28 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||
/* video implies events */
|
||||
flags |= SDL_INIT_EVENTS;
|
||||
|
||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_VIDEO)) {
|
||||
SDL_VideoQuit();
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_VIDEO);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !SDL_TIMERS_DISABLED && !SDL_TIMER_DUMMY
|
||||
if ((flags & SDL_INIT_TIMER)) {
|
||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
|
||||
SDL_TimerQuit();
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_TIMER)) {
|
||||
SDL_QuitTimers();
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_TIMER);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
if ((flags & SDL_INIT_EVENTS)) {
|
||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
|
||||
SDL_EventsQuit();
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_EVENTS)) {
|
||||
SDL_QuitEvents();
|
||||
}
|
||||
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_EVENTS);
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_EVENTS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ void SDL_Quit(void)
|
|||
SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
|
||||
|
||||
#if !SDL_TIMERS_DISABLED
|
||||
SDL_TicksQuit();
|
||||
SDL_QuitTicks();
|
||||
#endif
|
||||
|
||||
SDL_ClearHints();
|
||||
|
@ -475,7 +475,7 @@ void SDL_Quit(void)
|
|||
SDL_DBus_Quit();
|
||||
#endif
|
||||
|
||||
SDL_LogQuit();
|
||||
SDL_QuitLog();
|
||||
|
||||
/* Now that every subsystem has been quit, we reset the subsystem refcount
|
||||
* and the list of initialized subsystems.
|
||||
|
|
|
@ -51,7 +51,7 @@ static void SDL_FreeDataQueueList(SDL_DataQueuePacket *packet)
|
|||
/* this all expects that you managed thread safety elsewhere. */
|
||||
|
||||
SDL_DataQueue *
|
||||
SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack)
|
||||
SDL_CreateDataQueue(const size_t _packetlen, const size_t initialslack)
|
||||
{
|
||||
SDL_DataQueue *queue = (SDL_DataQueue *)SDL_malloc(sizeof(SDL_DataQueue));
|
||||
|
||||
|
@ -80,7 +80,7 @@ SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack)
|
|||
return queue;
|
||||
}
|
||||
|
||||
void SDL_FreeDataQueue(SDL_DataQueue *queue)
|
||||
void SDL_DestroyDataQueue(SDL_DataQueue *queue)
|
||||
{
|
||||
if (queue) {
|
||||
SDL_FreeDataQueueList(queue->head);
|
||||
|
@ -282,7 +282,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
|
|||
}
|
||||
|
||||
size_t
|
||||
SDL_CountDataQueue(SDL_DataQueue *queue)
|
||||
SDL_GetDataQueueSize(SDL_DataQueue *queue)
|
||||
{
|
||||
return queue ? queue->queued_bytes : 0;
|
||||
}
|
||||
|
|
|
@ -26,13 +26,13 @@
|
|||
struct SDL_DataQueue;
|
||||
typedef struct SDL_DataQueue SDL_DataQueue;
|
||||
|
||||
SDL_DataQueue *SDL_NewDataQueue(const size_t packetlen, const size_t initialslack);
|
||||
void SDL_FreeDataQueue(SDL_DataQueue *queue);
|
||||
SDL_DataQueue *SDL_CreateDataQueue(const size_t packetlen, const size_t initialslack);
|
||||
void SDL_DestroyDataQueue(SDL_DataQueue *queue);
|
||||
void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack);
|
||||
int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *data, const size_t len);
|
||||
size_t SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *buf, const size_t len);
|
||||
size_t SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *buf, const size_t len);
|
||||
size_t SDL_CountDataQueue(SDL_DataQueue *queue);
|
||||
size_t SDL_GetDataQueueSize(SDL_DataQueue *queue);
|
||||
|
||||
/* this sets a section of the data queue aside (possibly allocating memory for it)
|
||||
as if it's been written to, but returns a pointer to that space. You may write
|
||||
|
@ -41,7 +41,7 @@ size_t SDL_CountDataQueue(SDL_DataQueue *queue);
|
|||
be in flight at the same time. There is no thread safety.
|
||||
If there isn't an existing block of memory that can contain the reserved
|
||||
space, one will be allocated for it. You can not (currently) allocate
|
||||
a space larger than the packetlen requested in SDL_NewDataQueue.
|
||||
a space larger than the packetlen requested in SDL_CreateDataQueue.
|
||||
Returned buffer is uninitialized.
|
||||
This lets you avoid an extra copy in some cases, but it's safer to use
|
||||
SDL_WriteToDataQueue() unless you know what you're doing.
|
||||
|
|
|
@ -101,7 +101,7 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = {
|
|||
};
|
||||
#endif /* __ANDROID__ */
|
||||
|
||||
void SDL_LogInit(void)
|
||||
void SDL_InitLog(void)
|
||||
{
|
||||
if (log_function_mutex == NULL) {
|
||||
/* if this fails we'll try to continue without it. */
|
||||
|
@ -109,7 +109,7 @@ void SDL_LogInit(void)
|
|||
}
|
||||
}
|
||||
|
||||
void SDL_LogQuit(void)
|
||||
void SDL_QuitLog(void)
|
||||
{
|
||||
SDL_LogResetPriorities();
|
||||
if (log_function_mutex) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#ifndef SDL_log_c_h_
|
||||
#define SDL_log_c_h_
|
||||
|
||||
extern void SDL_LogInit(void);
|
||||
extern void SDL_LogQuit(void);
|
||||
extern void SDL_InitLog(void);
|
||||
extern void SDL_QuitLog(void);
|
||||
|
||||
#endif /* SDL_log_c_h_ */
|
||||
|
|
|
@ -527,7 +527,7 @@ static void SDLCALL SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream,
|
|||
len -= (int)dequeued;
|
||||
|
||||
if (len > 0) { /* fill any remaining space in the stream with silence. */
|
||||
SDL_assert(SDL_CountDataQueue(device->buffer_queue) == 0);
|
||||
SDL_assert(SDL_GetDataQueueSize(device->buffer_queue) == 0);
|
||||
SDL_memset(stream, device->callbackspec.silence, len);
|
||||
}
|
||||
}
|
||||
|
@ -602,7 +602,7 @@ SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid)
|
|||
if (device->callbackspec.callback == SDL_BufferQueueDrainCallback ||
|
||||
device->callbackspec.callback == SDL_BufferQueueFillCallback) {
|
||||
current_audio.impl.LockDevice(device);
|
||||
retval = (Uint32)SDL_CountDataQueue(device->buffer_queue);
|
||||
retval = (Uint32)SDL_GetDataQueueSize(device->buffer_queue);
|
||||
current_audio.impl.UnlockDevice(device);
|
||||
}
|
||||
|
||||
|
@ -879,13 +879,13 @@ SDL_GetAudioDriver(int index)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int SDL_AudioInit(const char *driver_name)
|
||||
int SDL_InitAudio(const char *driver_name)
|
||||
{
|
||||
int i;
|
||||
SDL_bool initialized = SDL_FALSE, tried_to_init = SDL_FALSE;
|
||||
|
||||
if (SDL_GetCurrentAudioDriver()) {
|
||||
SDL_AudioQuit(); /* shutdown driver if already running. */
|
||||
SDL_QuitAudio(); /* shutdown driver if already running. */
|
||||
}
|
||||
|
||||
SDL_zeroa(open_devices);
|
||||
|
@ -1152,7 +1152,7 @@ static void close_audio_device(SDL_AudioDevice *device)
|
|||
current_audio.impl.CloseDevice(device);
|
||||
}
|
||||
|
||||
SDL_FreeDataQueue(device->buffer_queue);
|
||||
SDL_DestroyDataQueue(device->buffer_queue);
|
||||
|
||||
SDL_free(device);
|
||||
}
|
||||
|
@ -1441,7 +1441,7 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture,
|
|||
|
||||
if (device->spec.callback == NULL) { /* use buffer queueing? */
|
||||
/* pool a few packets to start. Enough for two callbacks. */
|
||||
device->buffer_queue = SDL_NewDataQueue(SDL_AUDIOBUFFERQUEUE_PACKETLEN, obtained->size * 2);
|
||||
device->buffer_queue = SDL_CreateDataQueue(SDL_AUDIOBUFFERQUEUE_PACKETLEN, obtained->size * 2);
|
||||
if (!device->buffer_queue) {
|
||||
close_audio_device(device);
|
||||
SDL_UnlockMutex(current_audio.detectionLock);
|
||||
|
@ -1609,7 +1609,7 @@ void SDL_CloseAudio(void)
|
|||
SDL_CloseAudioDevice(1);
|
||||
}
|
||||
|
||||
void SDL_AudioQuit(void)
|
||||
void SDL_QuitAudio(void)
|
||||
{
|
||||
SDL_AudioDeviceID i;
|
||||
|
||||
|
@ -1664,7 +1664,7 @@ static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS] = {
|
|||
};
|
||||
|
||||
SDL_AudioFormat
|
||||
SDL_FirstAudioFormat(SDL_AudioFormat format)
|
||||
SDL_GetFirstAudioFormat(SDL_AudioFormat format)
|
||||
{
|
||||
for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) {
|
||||
if (format_list[format_idx][0] == format) {
|
||||
|
@ -1672,11 +1672,11 @@ SDL_FirstAudioFormat(SDL_AudioFormat format)
|
|||
}
|
||||
}
|
||||
format_idx_sub = 0;
|
||||
return SDL_NextAudioFormat();
|
||||
return SDL_GetNextAudioFormat();
|
||||
}
|
||||
|
||||
SDL_AudioFormat
|
||||
SDL_NextAudioFormat(void)
|
||||
SDL_GetNextAudioFormat(void)
|
||||
{
|
||||
if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
|
||||
return 0;
|
||||
|
@ -1684,7 +1684,7 @@ SDL_NextAudioFormat(void)
|
|||
return format_list[format_idx][format_idx_sub++];
|
||||
}
|
||||
|
||||
Uint8 SDL_SilenceValueForFormat(const SDL_AudioFormat format)
|
||||
Uint8 SDL_GetSilenceValueForFormat(const SDL_AudioFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
/* !!! FIXME: 0x80 isn't perfect for U16, but we can't fit 0x8000 in a
|
||||
|
@ -1704,7 +1704,7 @@ Uint8 SDL_SilenceValueForFormat(const SDL_AudioFormat format)
|
|||
|
||||
void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
|
||||
{
|
||||
spec->silence = SDL_SilenceValueForFormat(spec->format);
|
||||
spec->silence = SDL_GetSilenceValueForFormat(spec->format);
|
||||
spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8;
|
||||
spec->size *= spec->channels;
|
||||
spec->size *= spec->samples;
|
||||
|
|
|
@ -49,11 +49,11 @@ extern int (*SRC_src_simple)(SRC_DATA *data, int converter_type, int channels);
|
|||
#endif
|
||||
|
||||
/* Functions to get a list of "close" audio formats */
|
||||
extern SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format);
|
||||
extern SDL_AudioFormat SDL_NextAudioFormat(void);
|
||||
extern SDL_AudioFormat SDL_GetFirstAudioFormat(SDL_AudioFormat format);
|
||||
extern SDL_AudioFormat SDL_GetNextAudioFormat(void);
|
||||
|
||||
/* Function to calculate the size and silence for a SDL_AudioSpec */
|
||||
extern Uint8 SDL_SilenceValueForFormat(const SDL_AudioFormat format);
|
||||
extern Uint8 SDL_GetSilenceValueForFormat(const SDL_AudioFormat format);
|
||||
extern void SDL_CalculateAudioSpec(SDL_AudioSpec *spec);
|
||||
|
||||
/* Choose the audio filter functions below */
|
||||
|
@ -82,15 +82,15 @@ extern SDL_AudioFilter SDL_Convert_F32_to_S32;
|
|||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*/
|
||||
extern int SDL_AudioInit(const char *driver_name);
|
||||
extern int SDL_InitAudio(const char *driver_name);
|
||||
|
||||
/**
|
||||
* Use this function to shut down audio if you initialized it with SDL_AudioInit().
|
||||
* Use this function to shut down audio if you initialized it with SDL_InitAudio().
|
||||
*
|
||||
* This function is used internally, and should not be used unless you have a
|
||||
* specific need to specify the audio driver you want to use. You should
|
||||
* normally use SDL_Quit() or SDL_QuitSubSystem().
|
||||
*/
|
||||
extern void SDL_AudioQuit(void);
|
||||
extern void SDL_QuitAudio(void);
|
||||
|
||||
#endif /* SDL_audio_c_h_ */
|
||||
|
|
|
@ -178,7 +178,7 @@ static void SDLCALL SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT *cvt, SDL_AudioForm
|
|||
|
||||
#include "SDL_audio_resampler_filter.h"
|
||||
|
||||
static int ResamplerPadding(const int inrate, const int outrate)
|
||||
static int GetResamplerPadding(const int inrate, const int outrate)
|
||||
{
|
||||
if (inrate == outrate) {
|
||||
return 0;
|
||||
|
@ -202,7 +202,7 @@ static int SDL_ResampleAudio(const int chans, const int inrate, const int outrat
|
|||
|
||||
const ResampleFloatType finrate = (ResampleFloatType)inrate;
|
||||
const ResampleFloatType ratio = ((float)outrate) / ((float)inrate);
|
||||
const int paddinglen = ResamplerPadding(inrate, outrate);
|
||||
const int paddinglen = GetResamplerPadding(inrate, outrate);
|
||||
const int framelen = chans * (int)sizeof(float);
|
||||
const int inframes = inbuflen / framelen;
|
||||
const int wantedoutframes = (int)(inframes * ratio); /* outbuflen isn't total to write, it's total available. */
|
||||
|
@ -495,7 +495,7 @@ static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioF
|
|||
/* !!! FIXME: remove this if we can get the resampler to work in-place again. */
|
||||
float *dst = (float *)(cvt->buf + srclen);
|
||||
const int dstlen = (cvt->len * cvt->len_mult) - srclen;
|
||||
const int requestedpadding = ResamplerPadding(inrate, outrate);
|
||||
const int requestedpadding = GetResamplerPadding(inrate, outrate);
|
||||
int paddingsamples;
|
||||
float *padding;
|
||||
|
||||
|
@ -639,7 +639,7 @@ static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels,
|
|||
return 1; /* added a converter. */
|
||||
}
|
||||
|
||||
static SDL_bool SDL_SupportedAudioFormat(const SDL_AudioFormat fmt)
|
||||
static SDL_bool SDL_IsSupportedAudioFormat(const SDL_AudioFormat fmt)
|
||||
{
|
||||
switch (fmt) {
|
||||
case AUDIO_U8:
|
||||
|
@ -661,7 +661,7 @@ static SDL_bool SDL_SupportedAudioFormat(const SDL_AudioFormat fmt)
|
|||
return SDL_FALSE; /* unsupported. */
|
||||
}
|
||||
|
||||
static SDL_bool SDL_SupportedChannelCount(const int channels)
|
||||
static SDL_bool SDL_IsSupportedChannelCount(const int channels)
|
||||
{
|
||||
return ((channels >= 1) && (channels <= 8)) ? SDL_TRUE : SDL_FALSE;
|
||||
}
|
||||
|
@ -685,16 +685,16 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||
/* Make sure we zero out the audio conversion before error checking */
|
||||
SDL_zerop(cvt);
|
||||
|
||||
if (!SDL_SupportedAudioFormat(src_format)) {
|
||||
if (!SDL_IsSupportedAudioFormat(src_format)) {
|
||||
return SDL_SetError("Invalid source format");
|
||||
}
|
||||
if (!SDL_SupportedAudioFormat(dst_format)) {
|
||||
if (!SDL_IsSupportedAudioFormat(dst_format)) {
|
||||
return SDL_SetError("Invalid destination format");
|
||||
}
|
||||
if (!SDL_SupportedChannelCount(src_channels)) {
|
||||
if (!SDL_IsSupportedChannelCount(src_channels)) {
|
||||
return SDL_SetError("Invalid source channels");
|
||||
}
|
||||
if (!SDL_SupportedChannelCount(dst_channels)) {
|
||||
if (!SDL_IsSupportedChannelCount(dst_channels)) {
|
||||
return SDL_SetError("Invalid destination channels");
|
||||
}
|
||||
if (src_rate <= 0) {
|
||||
|
@ -768,7 +768,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||
|
||||
/* Channel conversion */
|
||||
|
||||
/* SDL_SupportedChannelCount should have caught these asserts, or we added a new format and forgot to update the table. */
|
||||
/* SDL_IsSupportedChannelCount should have caught these asserts, or we added a new format and forgot to update the table. */
|
||||
SDL_assert(src_channels <= SDL_arraysize(channel_converters));
|
||||
SDL_assert(dst_channels <= SDL_arraysize(channel_converters[0]));
|
||||
|
||||
|
@ -1032,7 +1032,7 @@ SDL_CreateAudioStream(SDL_AudioFormat src_format,
|
|||
retval->pre_resample_channels = pre_resample_channels;
|
||||
retval->packetlen = packetlen;
|
||||
retval->rate_incr = ((double)dst_rate) / ((double)src_rate);
|
||||
retval->resampler_padding_samples = ResamplerPadding(retval->src_rate, retval->dst_rate) * pre_resample_channels;
|
||||
retval->resampler_padding_samples = GetResamplerPadding(retval->src_rate, retval->dst_rate) * pre_resample_channels;
|
||||
retval->resampler_padding = (float *)SDL_calloc(retval->resampler_padding_samples ? retval->resampler_padding_samples : 1, sizeof(float));
|
||||
|
||||
if (retval->resampler_padding == NULL) {
|
||||
|
@ -1090,16 +1090,16 @@ SDL_CreateAudioStream(SDL_AudioFormat src_format,
|
|||
}
|
||||
}
|
||||
|
||||
retval->queue = SDL_NewDataQueue(packetlen, (size_t)packetlen * 2);
|
||||
retval->queue = SDL_CreateDataQueue(packetlen, (size_t)packetlen * 2);
|
||||
if (!retval->queue) {
|
||||
SDL_DestroyAudioStream(retval);
|
||||
return NULL; /* SDL_NewDataQueue should have called SDL_SetError. */
|
||||
return NULL; /* SDL_CreateDataQueue should have called SDL_SetError. */
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, int *maxputbytes)
|
||||
static int SDL_PutAudioStreamInternal(SDL_AudioStream *stream, const void *buf, int len, int *maxputbytes)
|
||||
{
|
||||
int buflen = len;
|
||||
int workbuflen;
|
||||
|
@ -1271,7 +1271,7 @@ int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
|
|||
we don't need to store it for later, skip the staging process.
|
||||
*/
|
||||
if (!stream->staging_buffer_filled && len >= stream->staging_buffer_size) {
|
||||
return SDL_AudioStreamPutInternal(stream, buf, len, NULL);
|
||||
return SDL_PutAudioStreamInternal(stream, buf, len, NULL);
|
||||
}
|
||||
|
||||
/* If there's not enough data to fill the staging buffer, just save it */
|
||||
|
@ -1286,7 +1286,7 @@ int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
|
|||
SDL_assert(amount > 0);
|
||||
SDL_memcpy(stream->staging_buffer + stream->staging_buffer_filled, buf, amount);
|
||||
stream->staging_buffer_filled = 0;
|
||||
if (SDL_AudioStreamPutInternal(stream, stream->staging_buffer, stream->staging_buffer_size, NULL) < 0) {
|
||||
if (SDL_PutAudioStreamInternal(stream, stream->staging_buffer, stream->staging_buffer_size, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
buf = (void *)((Uint8 *)buf + amount);
|
||||
|
@ -1328,7 +1328,7 @@ int SDL_FlushAudioStream(SDL_AudioStream *stream)
|
|||
#endif
|
||||
|
||||
SDL_memset(stream->staging_buffer + filled, '\0', stream->staging_buffer_size - filled);
|
||||
if (SDL_AudioStreamPutInternal(stream, stream->staging_buffer, stream->staging_buffer_size, &flush_remaining) < 0) {
|
||||
if (SDL_PutAudioStreamInternal(stream, stream->staging_buffer, stream->staging_buffer_size, &flush_remaining) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1336,7 +1336,7 @@ int SDL_FlushAudioStream(SDL_AudioStream *stream)
|
|||
resampler padding, but we need to push more silence to guarantee
|
||||
the staging buffer is fully flushed out, too. */
|
||||
SDL_memset(stream->staging_buffer, '\0', filled);
|
||||
if (SDL_AudioStreamPutInternal(stream, stream->staging_buffer, stream->staging_buffer_size, &flush_remaining) < 0) {
|
||||
if (SDL_PutAudioStreamInternal(stream, stream->staging_buffer, stream->staging_buffer_size, &flush_remaining) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1374,7 +1374,7 @@ int SDL_GetAudioStreamData(SDL_AudioStream *stream, void *buf, int len)
|
|||
/* number of converted/resampled bytes available */
|
||||
int SDL_GetAudioStreamAvailable(SDL_AudioStream *stream)
|
||||
{
|
||||
return stream ? (int)SDL_CountDataQueue(stream->queue) : 0;
|
||||
return stream ? (int)SDL_GetDataQueueSize(stream->queue) : 0;
|
||||
}
|
||||
|
||||
void SDL_ClearAudioStream(SDL_AudioStream *stream)
|
||||
|
@ -1398,7 +1398,7 @@ void SDL_DestroyAudioStream(SDL_AudioStream *stream)
|
|||
if (stream->cleanup_resampler_func) {
|
||||
stream->cleanup_resampler_func(stream);
|
||||
}
|
||||
SDL_FreeDataQueue(stream->queue);
|
||||
SDL_DestroyDataQueue(stream->queue);
|
||||
SDL_free(stream->staging_buffer);
|
||||
SDL_free(stream->work_buffer_base);
|
||||
SDL_free(stream->resampler_padding);
|
||||
|
|
|
@ -2063,7 +2063,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 *
|
|||
break;
|
||||
}
|
||||
|
||||
spec->silence = SDL_SilenceValueForFormat(spec->format);
|
||||
spec->silence = SDL_GetSilenceValueForFormat(spec->format);
|
||||
|
||||
/* Report the end position back to the cleanup code. */
|
||||
if (RIFFlengthknown) {
|
||||
|
|
|
@ -570,7 +570,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname)
|
|||
}
|
||||
|
||||
/* Try for a closest match on audio format */
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
switch (test_format) {
|
||||
case AUDIO_U8:
|
||||
format = SND_PCM_FORMAT_U8;
|
||||
|
|
|
@ -54,7 +54,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
|
|||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
if ((test_format == AUDIO_U8) ||
|
||||
(test_format == AUDIO_S16) ||
|
||||
(test_format == AUDIO_F32)) {
|
||||
|
|
|
@ -1066,7 +1066,7 @@ static int COREAUDIO_OpenDevice(_THIS, const char *devname)
|
|||
strdesc->mSampleRate = this->spec.freq;
|
||||
strdesc->mFramesPerPacket = 1;
|
||||
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
/* CoreAudio handles most of SDL's formats natively, but not U16, apparently. */
|
||||
switch (test_format) {
|
||||
case AUDIO_U8:
|
||||
|
|
|
@ -515,7 +515,7 @@ static int DSOUND_OpenDevice(_THIS, const char *devname)
|
|||
}
|
||||
}
|
||||
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
switch (test_format) {
|
||||
case AUDIO_U8:
|
||||
case AUDIO_S16:
|
||||
|
|
|
@ -114,7 +114,7 @@ static int DSP_OpenDevice(_THIS, const char *devname)
|
|||
|
||||
/* Try for a closest match on audio format */
|
||||
format = 0;
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format);
|
||||
!format && test_format;) {
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
|
||||
|
@ -161,7 +161,7 @@ static int DSP_OpenDevice(_THIS, const char *devname)
|
|||
break;
|
||||
}
|
||||
if (!format) {
|
||||
test_format = SDL_NextAudioFormat();
|
||||
test_format = SDL_GetNextAudioFormat();
|
||||
}
|
||||
}
|
||||
if (format == 0) {
|
||||
|
|
|
@ -235,7 +235,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
|
|||
return SDL_SetError("Web Audio API is not available!");
|
||||
}
|
||||
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
switch (test_format) {
|
||||
case AUDIO_F32: /* web audio only supports floats */
|
||||
break;
|
||||
|
|
|
@ -132,7 +132,7 @@ static int HAIKUAUDIO_OpenDevice(_THIS, const char *devname)
|
|||
format.byte_order = B_MEDIA_LITTLE_ENDIAN;
|
||||
format.frame_rate = (float) _this->spec.freq;
|
||||
format.channel_count = _this->spec.channels; /* !!! FIXME: support > 2? */
|
||||
for (test_format = SDL_FirstAudioFormat(_this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(_this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
switch (test_format) {
|
||||
case AUDIO_S8:
|
||||
format.format = media_raw_audio_format::B_AUDIO_CHAR;
|
||||
|
|
|
@ -311,7 +311,7 @@ static void FreePrivateData(_THIS)
|
|||
static int FindAudioFormat(_THIS)
|
||||
{
|
||||
SDL_bool found_valid_format = SDL_FALSE;
|
||||
Uint16 test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
Uint16 test_format = SDL_GetFirstAudioFormat(this->spec.format);
|
||||
|
||||
while (!found_valid_format && test_format) {
|
||||
this->spec.format = test_format;
|
||||
|
@ -331,7 +331,7 @@ static int FindAudioFormat(_THIS)
|
|||
found_valid_format = SDL_TRUE;
|
||||
break;
|
||||
default:
|
||||
test_format = SDL_NextAudioFormat();
|
||||
test_format = SDL_GetNextAudioFormat();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
|
|||
prinfo->sample_rate = this->spec.freq;
|
||||
prinfo->channels = this->spec.channels;
|
||||
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
switch (test_format) {
|
||||
case AUDIO_U8:
|
||||
encoding = AUDIO_ENCODING_ULINEAR;
|
||||
|
|
|
@ -418,7 +418,7 @@ static int openslES_CreatePCMPlayer(_THIS)
|
|||
*/
|
||||
if (SDL_GetAndroidSDKVersion() >= 21) {
|
||||
SDL_AudioFormat test_format;
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
if (SDL_AUDIO_ISSIGNED(test_format)) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1047,7 +1047,7 @@ static void input_callback(void *data)
|
|||
/* Pipewire can vary the latency, so buffer all incoming data */
|
||||
SDL_WriteToDataQueue(this->hidden->buffer, src, size);
|
||||
|
||||
while (SDL_CountDataQueue(this->hidden->buffer) >= this->callbackspec.size) {
|
||||
while (SDL_GetDataQueueSize(this->hidden->buffer) >= this->callbackspec.size) {
|
||||
SDL_ReadFromDataQueue(this->hidden->buffer, this->work_buffer, this->callbackspec.size);
|
||||
|
||||
SDL_LockMutex(this->mixer_lock);
|
||||
|
@ -1055,7 +1055,7 @@ static void input_callback(void *data)
|
|||
SDL_UnlockMutex(this->mixer_lock);
|
||||
}
|
||||
} else if (this->hidden->buffer) { /* Flush the buffer when paused */
|
||||
if (SDL_CountDataQueue(this->hidden->buffer) != 0) {
|
||||
if (SDL_GetDataQueueSize(this->hidden->buffer) != 0) {
|
||||
SDL_ClearDataQueue(this->hidden->buffer, this->hidden->input_buffer_packet_size);
|
||||
}
|
||||
}
|
||||
|
@ -1086,7 +1086,7 @@ static void stream_add_buffer_callback(void *data, struct pw_buffer *buffer)
|
|||
* A packet size of 2 periods should be more than is ever needed.
|
||||
*/
|
||||
this->hidden->input_buffer_packet_size = SPA_MAX(this->spec.size, buffer->buffer->datas[0].maxsize) * 2;
|
||||
this->hidden->buffer = SDL_NewDataQueue(this->hidden->input_buffer_packet_size, this->hidden->input_buffer_packet_size);
|
||||
this->hidden->buffer = SDL_CreateDataQueue(this->hidden->input_buffer_packet_size, this->hidden->input_buffer_packet_size);
|
||||
}
|
||||
|
||||
this->hidden->stream_init_status |= PW_READY_FLAG_BUFFER_ADDED;
|
||||
|
@ -1295,7 +1295,7 @@ static void PIPEWIRE_CloseDevice(_THIS)
|
|||
}
|
||||
|
||||
if (this->hidden->buffer) {
|
||||
SDL_FreeDataQueue(this->hidden->buffer);
|
||||
SDL_DestroyDataQueue(this->hidden->buffer);
|
||||
}
|
||||
|
||||
SDL_free(this->hidden);
|
||||
|
|
|
@ -537,7 +537,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
|
|||
SDL_zerop(this->hidden);
|
||||
|
||||
/* Try for a closest match on audio format */
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
|
||||
#endif
|
||||
|
|
|
@ -258,7 +258,7 @@ static int SNDIO_OpenDevice(_THIS, const char *devname)
|
|||
par.appbufsz = par.round * 2;
|
||||
|
||||
/* Try for a closest match on audio format */
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
if (!SDL_AUDIO_ISFLOAT(test_format)) {
|
||||
par.le = SDL_AUDIO_ISLITTLEENDIAN(test_format) ? 1 : 0;
|
||||
par.sig = SDL_AUDIO_ISSIGNED(test_format) ? 1 : 0;
|
||||
|
|
|
@ -69,7 +69,7 @@ static int VITAAUD_OpenDevice(_THIS, const char *devname)
|
|||
}
|
||||
SDL_memset(this->hidden, 0, sizeof(*this->hidden));
|
||||
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
if (test_format == AUDIO_S16LSB) {
|
||||
this->spec.format = test_format;
|
||||
break;
|
||||
|
|
|
@ -424,7 +424,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
|
|||
/* Make sure we have a valid format that we can convert to whatever WASAPI wants. */
|
||||
wasapi_format = WaveFormatToSDLFormat(waveformat);
|
||||
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
for (test_format = SDL_GetFirstAudioFormat(this->spec.format); test_format; test_format = SDL_GetNextAudioFormat()) {
|
||||
if (test_format == wasapi_format) {
|
||||
this->spec.format = test_format;
|
||||
break;
|
||||
|
|
|
@ -77,7 +77,7 @@ static int kbd_cleanup_atexit_installed = 0;
|
|||
static struct sigaction old_sigaction[NSIG];
|
||||
|
||||
static int fatal_signals[] = {
|
||||
/* Handlers for SIGTERM and SIGINT are installed in SDL_QuitInit. */
|
||||
/* Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit. */
|
||||
SIGHUP, SIGQUIT, SIGILL, SIGABRT,
|
||||
SIGFPE, SIGSEGV, SIGPIPE, SIGBUS,
|
||||
SIGSYS
|
||||
|
|
|
@ -198,7 +198,7 @@ static int kbd_cleanup_atexit_installed = 0;
|
|||
static struct sigaction old_sigaction[NSIG];
|
||||
|
||||
static int fatal_signals[] = {
|
||||
/* Handlers for SIGTERM and SIGINT are installed in SDL_QuitInit. */
|
||||
/* Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit. */
|
||||
SIGHUP, SIGQUIT, SIGILL, SIGABRT,
|
||||
SIGFPE, SIGSEGV, SIGPIPE, SIGBUS,
|
||||
SIGSYS
|
||||
|
|
|
@ -1374,7 +1374,7 @@ int SDL_SendLocaleChangedEvent(void)
|
|||
return SDL_SendAppEvent(SDL_LOCALECHANGED);
|
||||
}
|
||||
|
||||
int SDL_EventsInit(void)
|
||||
int SDL_InitEvents(void)
|
||||
{
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
SDL_AddHintCallback(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_AutoUpdateJoysticksChanged, NULL);
|
||||
|
@ -1389,12 +1389,12 @@ int SDL_EventsInit(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
SDL_QuitInit();
|
||||
SDL_InitQuit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_EventsQuit(void)
|
||||
void SDL_QuitEvents(void)
|
||||
{
|
||||
SDL_QuitQuit();
|
||||
SDL_StopEventLoop();
|
||||
|
|
|
@ -47,12 +47,12 @@ extern int SDL_SendLocaleChangedEvent(void);
|
|||
|
||||
extern int SDL_SendQuit(void);
|
||||
|
||||
extern int SDL_EventsInit(void);
|
||||
extern void SDL_EventsQuit(void);
|
||||
extern int SDL_InitEvents(void);
|
||||
extern void SDL_QuitEvents(void);
|
||||
|
||||
extern void SDL_SendPendingSignalEvents(void);
|
||||
|
||||
extern int SDL_QuitInit(void);
|
||||
extern int SDL_InitQuit(void);
|
||||
extern void SDL_QuitQuit(void);
|
||||
|
||||
#endif /* SDL_events_c_h_ */
|
||||
|
|
|
@ -664,7 +664,7 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst)
|
|||
}
|
||||
|
||||
/* Public functions */
|
||||
int SDL_KeyboardInit(void)
|
||||
int SDL_InitKeyboard(void)
|
||||
{
|
||||
/* Set the default keymap */
|
||||
SDL_SetKeymap(0, SDL_default_keymap, SDL_NUM_SCANCODES, SDL_FALSE);
|
||||
|
@ -1065,7 +1065,7 @@ int SDL_SendEditingText(const char *text, int start, int length)
|
|||
return posted;
|
||||
}
|
||||
|
||||
void SDL_KeyboardQuit(void)
|
||||
void SDL_QuitKeyboard(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#define SDL_keyboard_c_h_
|
||||
|
||||
/* Initialize the keyboard subsystem */
|
||||
extern int SDL_KeyboardInit(void);
|
||||
extern int SDL_InitKeyboard(void);
|
||||
|
||||
/* Get the default keymap */
|
||||
extern void SDL_GetDefaultKeymap(SDL_Keycode *keymap);
|
||||
|
@ -70,7 +70,7 @@ extern int SDL_SendKeyboardText(const char *text);
|
|||
extern int SDL_SendEditingText(const char *text, int start, int length);
|
||||
|
||||
/* Shutdown the keyboard subsystem */
|
||||
extern void SDL_KeyboardQuit(void);
|
||||
extern void SDL_QuitKeyboard(void);
|
||||
|
||||
/* Convert to UTF-8 */
|
||||
extern char *SDL_UCS4ToUTF8(Uint32 ch, char *dst);
|
||||
|
|
|
@ -162,7 +162,7 @@ static void SDLCALL SDL_MouseRelativeWarpMotionChanged(void *userdata, const cha
|
|||
}
|
||||
|
||||
/* Public functions */
|
||||
int SDL_MouseInit(void)
|
||||
int SDL_InitMouse(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
|
@ -868,7 +868,7 @@ int SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID
|
|||
return posted;
|
||||
}
|
||||
|
||||
void SDL_MouseQuit(void)
|
||||
void SDL_QuitMouse(void)
|
||||
{
|
||||
SDL_Cursor *cursor, *next;
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
@ -1049,7 +1049,7 @@ int SDL_WarpMouseGlobal(int x, int y)
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool ShouldUseRelativeModeWarp(SDL_Mouse *mouse)
|
||||
static SDL_bool SDL_ShouldUseRelativeModeWarp(SDL_Mouse *mouse)
|
||||
{
|
||||
if (!mouse->WarpMouse) {
|
||||
/* Need this functionality for relative mode warp implementation */
|
||||
|
@ -1071,7 +1071,7 @@ int SDL_SetRelativeMouseMode(SDL_bool enabled)
|
|||
/* Set the relative mode */
|
||||
if (!enabled && mouse->relative_mode_warp) {
|
||||
mouse->relative_mode_warp = SDL_FALSE;
|
||||
} else if (enabled && ShouldUseRelativeModeWarp(mouse)) {
|
||||
} else if (enabled && SDL_ShouldUseRelativeModeWarp(mouse)) {
|
||||
mouse->relative_mode_warp = SDL_TRUE;
|
||||
} else if (!mouse->SetRelativeMouseMode || mouse->SetRelativeMouseMode(enabled) < 0) {
|
||||
if (enabled) {
|
||||
|
|
|
@ -127,7 +127,7 @@ typedef struct
|
|||
} SDL_Mouse;
|
||||
|
||||
/* Initialize the mouse subsystem */
|
||||
extern int SDL_MouseInit(void);
|
||||
extern int SDL_InitMouse(void);
|
||||
|
||||
/* Get the mouse state structure */
|
||||
SDL_Mouse *SDL_GetMouse(void);
|
||||
|
@ -165,6 +165,6 @@ extern void SDL_ResetMouse(void);
|
|||
#endif /* 0 */
|
||||
|
||||
/* Shutdown the mouse subsystem */
|
||||
extern void SDL_MouseQuit(void);
|
||||
extern void SDL_QuitMouse(void);
|
||||
|
||||
#endif /* SDL_mouse_c_h_ */
|
||||
|
|
|
@ -142,7 +142,7 @@ static void SDL_QuitQuit_Internal(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
int SDL_QuitInit(void)
|
||||
int SDL_InitQuit(void)
|
||||
{
|
||||
#ifdef HAVE_SIGNAL_SUPPORT
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
|
||||
|
|
|
@ -39,7 +39,7 @@ static SDL_TouchID track_touchid;
|
|||
#endif
|
||||
|
||||
/* Public functions */
|
||||
int SDL_TouchInit(void)
|
||||
int SDL_InitTouch(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ void SDL_DelTouch(SDL_TouchID id)
|
|||
SDL_touchDevices[index] = SDL_touchDevices[SDL_num_touch];
|
||||
}
|
||||
|
||||
void SDL_TouchQuit(void)
|
||||
void SDL_QuitTouch(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ typedef struct SDL_Touch
|
|||
} SDL_Touch;
|
||||
|
||||
/* Initialize the touch subsystem */
|
||||
extern int SDL_TouchInit(void);
|
||||
extern int SDL_InitTouch(void);
|
||||
|
||||
/* Add a touch, returning the index of the touch, or -1 if there was an error. */
|
||||
extern int SDL_AddTouch(SDL_TouchID id, SDL_TouchDeviceType type, const char *name);
|
||||
|
@ -52,6 +52,6 @@ extern int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fi
|
|||
extern void SDL_DelTouch(SDL_TouchID id);
|
||||
|
||||
/* Shutdown the touch subsystem */
|
||||
extern void SDL_TouchQuit(void);
|
||||
extern void SDL_QuitTouch(void);
|
||||
|
||||
#endif /* SDL_touch_c_h_ */
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "SDL_syshaptic.h"
|
||||
#include "SDL_haptic_c.h"
|
||||
#include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */
|
||||
#include "../joystick/SDL_joystick_c.h" /* For SDL_IsJoystickValid */
|
||||
|
||||
/* Global for SDL_windowshaptic.c */
|
||||
#if (defined(SDL_HAPTIC_DINPUT) && SDL_HAPTIC_DINPUT) || (defined(SDL_HAPTIC_XINPUT) && SDL_HAPTIC_XINPUT)
|
||||
|
@ -34,7 +34,7 @@ static SDL_Haptic *SDL_haptics = NULL;
|
|||
/*
|
||||
* Initializes the Haptic devices.
|
||||
*/
|
||||
int SDL_HapticInit(void)
|
||||
int SDL_InitHaptics(void)
|
||||
{
|
||||
int status;
|
||||
|
||||
|
@ -236,7 +236,7 @@ int SDL_JoystickIsHaptic(SDL_Joystick *joystick)
|
|||
SDL_LockJoysticks();
|
||||
{
|
||||
/* Must be a valid joystick */
|
||||
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||
if (!SDL_IsJoystickValid(joystick)) {
|
||||
SDL_UnlockJoysticks();
|
||||
return -1;
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
|
|||
SDL_LockJoysticks();
|
||||
{
|
||||
/* Must be a valid joystick */
|
||||
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||
if (!SDL_IsJoystickValid(joystick)) {
|
||||
SDL_SetError("Haptic: Joystick isn't valid.");
|
||||
SDL_UnlockJoysticks();
|
||||
return NULL;
|
||||
|
@ -379,7 +379,7 @@ void SDL_HapticClose(SDL_Haptic *haptic)
|
|||
/*
|
||||
* Cleans up after the subsystem.
|
||||
*/
|
||||
void SDL_HapticQuit(void)
|
||||
void SDL_QuitHaptics(void)
|
||||
{
|
||||
while (SDL_haptics) {
|
||||
SDL_HapticClose(SDL_haptics);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef SDL_haptic_c_h_
|
||||
#define SDL_haptic_c_h_
|
||||
|
||||
extern int SDL_HapticInit(void);
|
||||
extern void SDL_HapticQuit(void);
|
||||
extern int SDL_InitHaptics(void);
|
||||
extern void SDL_QuitHaptics(void);
|
||||
|
||||
#endif /* SDL_haptic_c_h_ */
|
||||
|
|
|
@ -98,25 +98,25 @@ typedef enum
|
|||
SDL_GAMEPAD_MAPPING_PRIORITY_DEFAULT,
|
||||
SDL_GAMEPAD_MAPPING_PRIORITY_API,
|
||||
SDL_GAMEPAD_MAPPING_PRIORITY_USER,
|
||||
} SDL_ControllerMappingPriority;
|
||||
} SDL_GamepadMappingPriority;
|
||||
|
||||
#define _guarded SDL_GUARDED_BY(SDL_joystick_lock)
|
||||
|
||||
typedef struct _ControllerMapping_t
|
||||
typedef struct GamepadMapping_t
|
||||
{
|
||||
SDL_JoystickGUID guid _guarded;
|
||||
char *name _guarded;
|
||||
char *mapping _guarded;
|
||||
SDL_ControllerMappingPriority priority _guarded;
|
||||
struct _ControllerMapping_t *next _guarded;
|
||||
} ControllerMapping_t;
|
||||
SDL_GamepadMappingPriority priority _guarded;
|
||||
struct GamepadMapping_t *next _guarded;
|
||||
} GamepadMapping_t;
|
||||
|
||||
#undef _guarded
|
||||
|
||||
static SDL_JoystickGUID s_zeroGUID;
|
||||
static ControllerMapping_t *s_pSupportedControllers SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
|
||||
static ControllerMapping_t *s_pDefaultMapping SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
|
||||
static ControllerMapping_t *s_pXInputMapping SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
|
||||
static GamepadMapping_t *s_pSupportedGamepads SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
|
||||
static GamepadMapping_t *s_pDefaultMapping SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
|
||||
static GamepadMapping_t *s_pXInputMapping SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
|
||||
static char gamepad_magic;
|
||||
|
||||
#define _guarded SDL_GUARDED_BY(SDL_joystick_lock)
|
||||
|
@ -130,7 +130,7 @@ struct SDL_Gamepad
|
|||
int ref_count _guarded;
|
||||
|
||||
const char *name _guarded;
|
||||
ControllerMapping_t *mapping _guarded;
|
||||
GamepadMapping_t *mapping _guarded;
|
||||
int num_bindings _guarded;
|
||||
SDL_ExtendedGamepadBind *bindings _guarded;
|
||||
SDL_ExtendedGamepadBind **last_match_axis _guarded;
|
||||
|
@ -144,7 +144,7 @@ struct SDL_Gamepad
|
|||
|
||||
#define CHECK_GAMEPAD_MAGIC(gamepad, retval) \
|
||||
if (!gamepad || gamepad->magic != &gamepad_magic || \
|
||||
!SDL_PrivateJoystickValid(gamepad->joystick)) { \
|
||||
!SDL_IsJoystickValid(gamepad->joystick)) { \
|
||||
SDL_InvalidParamError("gamepad"); \
|
||||
SDL_UnlockJoysticks(); \
|
||||
return retval; \
|
||||
|
@ -215,9 +215,9 @@ static void SDLCALL SDL_GamepadIgnoreDevicesExceptChanged(void *userdata, const
|
|||
SDL_LoadVIDPIDListFromHint(hint, &SDL_allowed_gamepads);
|
||||
}
|
||||
|
||||
static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, SDL_bool *existing, SDL_ControllerMappingPriority priority);
|
||||
static int SDL_PrivateGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadAxis axis, Sint16 value);
|
||||
static int SDL_PrivateGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadButton button, Uint8 state);
|
||||
static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, SDL_bool *existing, SDL_GamepadMappingPriority priority);
|
||||
static int SDL_SendGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadAxis axis, Sint16 value);
|
||||
static int SDL_SendGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadButton button, Uint8 state);
|
||||
|
||||
static SDL_bool HasSameOutput(SDL_ExtendedGamepadBind *a, SDL_ExtendedGamepadBind *b)
|
||||
{
|
||||
|
@ -235,9 +235,9 @@ static SDL_bool HasSameOutput(SDL_ExtendedGamepadBind *a, SDL_ExtendedGamepadBin
|
|||
static void ResetOutput(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_ExtendedGamepadBind *bind)
|
||||
{
|
||||
if (bind->outputType == SDL_GAMEPAD_BINDTYPE_AXIS) {
|
||||
SDL_PrivateGamepadAxis(timestamp, gamepad, bind->output.axis.axis, 0);
|
||||
SDL_SendGamepadAxis(timestamp, gamepad, bind->output.axis.axis, 0);
|
||||
} else {
|
||||
SDL_PrivateGamepadButton(timestamp, gamepad, bind->output.button, SDL_RELEASED);
|
||||
SDL_SendGamepadButton(timestamp, gamepad, bind->output.button, SDL_RELEASED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ static void HandleJoystickAxis(Uint64 timestamp, SDL_Gamepad *gamepad, int axis,
|
|||
float normalized_value = (float)(value - match->input.axis.axis_min) / (match->input.axis.axis_max - match->input.axis.axis_min);
|
||||
value = match->output.axis.axis_min + (int)(normalized_value * (match->output.axis.axis_max - match->output.axis.axis_min));
|
||||
}
|
||||
SDL_PrivateGamepadAxis(timestamp, gamepad, match->output.axis.axis, (Sint16)value);
|
||||
SDL_SendGamepadAxis(timestamp, gamepad, match->output.axis.axis, (Sint16)value);
|
||||
} else {
|
||||
Uint8 state;
|
||||
int threshold = match->input.axis.axis_min + (match->input.axis.axis_max - match->input.axis.axis_min) / 2;
|
||||
|
@ -290,7 +290,7 @@ static void HandleJoystickAxis(Uint64 timestamp, SDL_Gamepad *gamepad, int axis,
|
|||
} else {
|
||||
state = (value >= threshold) ? SDL_PRESSED : SDL_RELEASED;
|
||||
}
|
||||
SDL_PrivateGamepadButton(timestamp, gamepad, match->output.button, state);
|
||||
SDL_SendGamepadButton(timestamp, gamepad, match->output.button, state);
|
||||
}
|
||||
}
|
||||
gamepad->last_match_axis[axis] = match;
|
||||
|
@ -308,9 +308,9 @@ static void HandleJoystickButton(Uint64 timestamp, SDL_Gamepad *gamepad, int but
|
|||
button == binding->input.button) {
|
||||
if (binding->outputType == SDL_GAMEPAD_BINDTYPE_AXIS) {
|
||||
int value = state ? binding->output.axis.axis_max : binding->output.axis.axis_min;
|
||||
SDL_PrivateGamepadAxis(timestamp, gamepad, binding->output.axis.axis, (Sint16)value);
|
||||
SDL_SendGamepadAxis(timestamp, gamepad, binding->output.axis.axis, (Sint16)value);
|
||||
} else {
|
||||
SDL_PrivateGamepadButton(timestamp, gamepad, binding->output.button, state);
|
||||
SDL_SendGamepadButton(timestamp, gamepad, binding->output.button, state);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -332,9 +332,9 @@ static void HandleJoystickHat(Uint64 timestamp, SDL_Gamepad *gamepad, int hat, U
|
|||
if ((changed_mask & binding->input.hat.hat_mask) != 0) {
|
||||
if (value & binding->input.hat.hat_mask) {
|
||||
if (binding->outputType == SDL_GAMEPAD_BINDTYPE_AXIS) {
|
||||
SDL_PrivateGamepadAxis(timestamp, gamepad, binding->output.axis.axis, (Sint16)binding->output.axis.axis_max);
|
||||
SDL_SendGamepadAxis(timestamp, gamepad, binding->output.axis.axis, (Sint16)binding->output.axis.axis_max);
|
||||
} else {
|
||||
SDL_PrivateGamepadButton(timestamp, gamepad, binding->output.button, SDL_PRESSED);
|
||||
SDL_SendGamepadButton(timestamp, gamepad, binding->output.button, SDL_PRESSED);
|
||||
}
|
||||
} else {
|
||||
ResetOutput(timestamp, gamepad, binding);
|
||||
|
@ -359,13 +359,13 @@ static void RecenterGamepad(SDL_Gamepad *gamepad)
|
|||
|
||||
for (button = (SDL_GamepadButton)0; button < SDL_GAMEPAD_BUTTON_MAX; button++) {
|
||||
if (SDL_GetGamepadButton(gamepad, button)) {
|
||||
SDL_PrivateGamepadButton(timestamp, gamepad, button, SDL_RELEASED);
|
||||
SDL_SendGamepadButton(timestamp, gamepad, button, SDL_RELEASED);
|
||||
}
|
||||
}
|
||||
|
||||
for (axis = (SDL_GamepadAxis)0; axis < SDL_GAMEPAD_AXIS_MAX; axis++) {
|
||||
if (SDL_GetGamepadAxis(gamepad, axis) != 0) {
|
||||
SDL_PrivateGamepadAxis(timestamp, gamepad, axis, 0);
|
||||
SDL_SendGamepadAxis(timestamp, gamepad, axis, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ static int SDLCALL SDL_GamepadEventWatcher(void *userdata, SDL_Event *event)
|
|||
/*
|
||||
* Helper function to guess at a mapping based on the elements reported for this gamepad
|
||||
*/
|
||||
static ControllerMapping_t *SDL_CreateMappingForAndroidController(SDL_JoystickGUID guid)
|
||||
static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_JoystickGUID guid)
|
||||
{
|
||||
const int face_button_mask = ((1 << SDL_GAMEPAD_BUTTON_A) |
|
||||
(1 << SDL_GAMEPAD_BUTTON_B) |
|
||||
|
@ -557,7 +557,7 @@ static ControllerMapping_t *SDL_CreateMappingForAndroidController(SDL_JoystickGU
|
|||
/*
|
||||
* Helper function to guess at a mapping for HIDAPI gamepads
|
||||
*/
|
||||
static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUID guid)
|
||||
static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid)
|
||||
{
|
||||
SDL_bool existing;
|
||||
char mapping_string[1024];
|
||||
|
@ -690,7 +690,7 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI
|
|||
/*
|
||||
* Helper function to guess at a mapping for RAWINPUT gamepads
|
||||
*/
|
||||
static ControllerMapping_t *SDL_CreateMappingForRAWINPUTController(SDL_JoystickGUID guid)
|
||||
static GamepadMapping_t *SDL_CreateMappingForRAWINPUTGamepad(SDL_JoystickGUID guid)
|
||||
{
|
||||
SDL_bool existing;
|
||||
char mapping_string[1024];
|
||||
|
@ -704,7 +704,7 @@ static ControllerMapping_t *SDL_CreateMappingForRAWINPUTController(SDL_JoystickG
|
|||
/*
|
||||
* Helper function to guess at a mapping for WGI gamepads
|
||||
*/
|
||||
static ControllerMapping_t *SDL_CreateMappingForWGIController(SDL_JoystickGUID guid)
|
||||
static GamepadMapping_t *SDL_CreateMappingForWGIGamepad(SDL_JoystickGUID guid)
|
||||
{
|
||||
SDL_bool existing;
|
||||
char mapping_string[1024];
|
||||
|
@ -722,9 +722,9 @@ static ControllerMapping_t *SDL_CreateMappingForWGIController(SDL_JoystickGUID g
|
|||
/*
|
||||
* Helper function to scan the mappings database for a gamepad with the specified GUID
|
||||
*/
|
||||
static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_JoystickGUID guid, SDL_bool match_crc, SDL_bool match_version)
|
||||
static GamepadMapping_t *SDL_PrivateMatchGamepadMappingForGUID(SDL_JoystickGUID guid, SDL_bool match_crc, SDL_bool match_version)
|
||||
{
|
||||
ControllerMapping_t *mapping;
|
||||
GamepadMapping_t *mapping;
|
||||
Uint16 crc = 0;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
@ -740,7 +740,7 @@ static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_Joystic
|
|||
SDL_SetJoystickGUIDVersion(&guid, 0);
|
||||
}
|
||||
|
||||
for (mapping = s_pSupportedControllers; mapping; mapping = mapping->next) {
|
||||
for (mapping = s_pSupportedGamepads; mapping; mapping = mapping->next) {
|
||||
SDL_JoystickGUID mapping_guid;
|
||||
|
||||
if (SDL_memcmp(&mapping->guid, &s_zeroGUID, sizeof(mapping->guid)) == 0) {
|
||||
|
@ -772,22 +772,22 @@ static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_Joystic
|
|||
/*
|
||||
* Helper function to scan the mappings database for a gamepad with the specified GUID
|
||||
*/
|
||||
static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID guid, SDL_bool create_mapping)
|
||||
static GamepadMapping_t *SDL_PrivateGetGamepadMappingForGUID(SDL_JoystickGUID guid, SDL_bool create_mapping)
|
||||
{
|
||||
ControllerMapping_t *mapping;
|
||||
GamepadMapping_t *mapping;
|
||||
Uint16 vendor, product, crc;
|
||||
|
||||
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, &crc);
|
||||
if (crc) {
|
||||
/* First check for exact CRC matching */
|
||||
mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_TRUE, SDL_TRUE);
|
||||
mapping = SDL_PrivateMatchGamepadMappingForGUID(guid, SDL_TRUE, SDL_TRUE);
|
||||
if (mapping) {
|
||||
return mapping;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now check for a mapping without CRC */
|
||||
mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_FALSE, SDL_TRUE);
|
||||
mapping = SDL_PrivateMatchGamepadMappingForGUID(guid, SDL_FALSE, SDL_TRUE);
|
||||
if (mapping) {
|
||||
return mapping;
|
||||
}
|
||||
|
@ -795,13 +795,13 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG
|
|||
if (vendor && product) {
|
||||
/* Try again, ignoring the version */
|
||||
if (crc) {
|
||||
mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_TRUE, SDL_FALSE);
|
||||
mapping = SDL_PrivateMatchGamepadMappingForGUID(guid, SDL_TRUE, SDL_FALSE);
|
||||
if (mapping) {
|
||||
return mapping;
|
||||
}
|
||||
}
|
||||
|
||||
mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_FALSE, SDL_FALSE);
|
||||
mapping = SDL_PrivateMatchGamepadMappingForGUID(guid, SDL_FALSE, SDL_FALSE);
|
||||
if (mapping) {
|
||||
return mapping;
|
||||
}
|
||||
|
@ -819,23 +819,23 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG
|
|||
#endif
|
||||
if (mapping == NULL) {
|
||||
if (SDL_IsJoystickHIDAPI(guid)) {
|
||||
mapping = SDL_CreateMappingForHIDAPIController(guid);
|
||||
mapping = SDL_CreateMappingForHIDAPIGamepad(guid);
|
||||
} else if (SDL_IsJoystickRAWINPUT(guid)) {
|
||||
mapping = SDL_CreateMappingForRAWINPUTController(guid);
|
||||
mapping = SDL_CreateMappingForRAWINPUTGamepad(guid);
|
||||
} else if (SDL_IsJoystickWGI(guid)) {
|
||||
mapping = SDL_CreateMappingForWGIController(guid);
|
||||
mapping = SDL_CreateMappingForWGIGamepad(guid);
|
||||
} else if (SDL_IsJoystickVIRTUAL(guid)) {
|
||||
/* We'll pick up a robust mapping in VIRTUAL_JoystickGetGamepadMapping */
|
||||
#ifdef __ANDROID__
|
||||
} else {
|
||||
mapping = SDL_CreateMappingForAndroidController(guid);
|
||||
mapping = SDL_CreateMappingForAndroidGamepad(guid);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
static const char *map_StringForControllerAxis[] = {
|
||||
static const char *map_StringForGamepadAxis[] = {
|
||||
"leftx",
|
||||
"lefty",
|
||||
"rightx",
|
||||
|
@ -860,8 +860,8 @@ SDL_GamepadAxis SDL_GetGamepadAxisFromString(const char *str)
|
|||
++str;
|
||||
}
|
||||
|
||||
for (entry = 0; map_StringForControllerAxis[entry]; ++entry) {
|
||||
if (SDL_strcasecmp(str, map_StringForControllerAxis[entry]) == 0) {
|
||||
for (entry = 0; map_StringForGamepadAxis[entry]; ++entry) {
|
||||
if (SDL_strcasecmp(str, map_StringForGamepadAxis[entry]) == 0) {
|
||||
return (SDL_GamepadAxis)entry;
|
||||
}
|
||||
}
|
||||
|
@ -874,12 +874,12 @@ SDL_GamepadAxis SDL_GetGamepadAxisFromString(const char *str)
|
|||
const char *SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis)
|
||||
{
|
||||
if (axis > SDL_GAMEPAD_AXIS_INVALID && axis < SDL_GAMEPAD_AXIS_MAX) {
|
||||
return map_StringForControllerAxis[axis];
|
||||
return map_StringForGamepadAxis[axis];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *map_StringForControllerButton[] = {
|
||||
static const char *map_StringForGamepadButton[] = {
|
||||
"a",
|
||||
"b",
|
||||
"x",
|
||||
|
@ -914,8 +914,8 @@ SDL_GamepadButton SDL_GetGamepadButtonFromString(const char *str)
|
|||
return SDL_GAMEPAD_BUTTON_INVALID;
|
||||
}
|
||||
|
||||
for (entry = 0; map_StringForControllerButton[entry]; ++entry) {
|
||||
if (SDL_strcasecmp(str, map_StringForControllerButton[entry]) == 0) {
|
||||
for (entry = 0; map_StringForGamepadButton[entry]; ++entry) {
|
||||
if (SDL_strcasecmp(str, map_StringForGamepadButton[entry]) == 0) {
|
||||
return (SDL_GamepadButton)entry;
|
||||
}
|
||||
}
|
||||
|
@ -928,7 +928,7 @@ SDL_GamepadButton SDL_GetGamepadButtonFromString(const char *str)
|
|||
const char *SDL_GetGamepadStringForButton(SDL_GamepadButton button)
|
||||
{
|
||||
if (button > SDL_GAMEPAD_BUTTON_INVALID && button < SDL_GAMEPAD_BUTTON_MAX) {
|
||||
return map_StringForControllerButton[button];
|
||||
return map_StringForGamepadButton[button];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -936,7 +936,7 @@ const char *SDL_GetGamepadStringForButton(SDL_GamepadButton button)
|
|||
/*
|
||||
* given a gamepad button name and a joystick name update our mapping structure with it
|
||||
*/
|
||||
static void SDL_PrivateGamepadParseElement(SDL_Gamepad *gamepad, const char *szGameButton, const char *szJoystickButton)
|
||||
static void SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char *szGameButton, const char *szJoystickButton)
|
||||
{
|
||||
SDL_ExtendedGamepadBind bind;
|
||||
SDL_GamepadButton button;
|
||||
|
@ -1032,7 +1032,7 @@ static void SDL_PrivateGamepadParseElement(SDL_Gamepad *gamepad, const char *szG
|
|||
/*
|
||||
* given a gamepad mapping string update our mapping object
|
||||
*/
|
||||
static void SDL_PrivateGamepadParseControllerConfigString(SDL_Gamepad *gamepad, const char *pchString)
|
||||
static void SDL_PrivateParseGamepadConfigString(SDL_Gamepad *gamepad, const char *pchString)
|
||||
{
|
||||
char szGameButton[20];
|
||||
char szJoystickButton[20];
|
||||
|
@ -1052,7 +1052,7 @@ static void SDL_PrivateGamepadParseControllerConfigString(SDL_Gamepad *gamepad,
|
|||
} else if (*pchPos == ',') {
|
||||
i = 0;
|
||||
bGameButton = SDL_TRUE;
|
||||
SDL_PrivateGamepadParseElement(gamepad, szGameButton, szJoystickButton);
|
||||
SDL_PrivateParseGamepadElement(gamepad, szGameButton, szJoystickButton);
|
||||
SDL_zeroa(szGameButton);
|
||||
SDL_zeroa(szJoystickButton);
|
||||
|
||||
|
@ -1076,27 +1076,27 @@ static void SDL_PrivateGamepadParseControllerConfigString(SDL_Gamepad *gamepad,
|
|||
|
||||
/* No more values if the string was terminated by a comma. Don't report an error. */
|
||||
if (szGameButton[0] != '\0' || szJoystickButton[0] != '\0') {
|
||||
SDL_PrivateGamepadParseElement(gamepad, szGameButton, szJoystickButton);
|
||||
SDL_PrivateParseGamepadElement(gamepad, szGameButton, szJoystickButton);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a new button mapping struct
|
||||
*/
|
||||
static void SDL_PrivateLoadButtonMapping(SDL_Gamepad *gamepad, ControllerMapping_t *pControllerMapping)
|
||||
static void SDL_PrivateLoadButtonMapping(SDL_Gamepad *gamepad, GamepadMapping_t *pGamepadMapping)
|
||||
{
|
||||
int i;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
gamepad->name = pControllerMapping->name;
|
||||
gamepad->name = pGamepadMapping->name;
|
||||
gamepad->num_bindings = 0;
|
||||
gamepad->mapping = pControllerMapping;
|
||||
gamepad->mapping = pGamepadMapping;
|
||||
if (gamepad->joystick->naxes != 0 && gamepad->last_match_axis != NULL) {
|
||||
SDL_memset(gamepad->last_match_axis, 0, gamepad->joystick->naxes * sizeof(*gamepad->last_match_axis));
|
||||
}
|
||||
|
||||
SDL_PrivateGamepadParseControllerConfigString(gamepad, pControllerMapping->mapping);
|
||||
SDL_PrivateParseGamepadConfigString(gamepad, pGamepadMapping->mapping);
|
||||
|
||||
/* Set the zero point for triggers */
|
||||
for (i = 0; i < gamepad->num_bindings; ++i) {
|
||||
|
@ -1116,7 +1116,7 @@ static void SDL_PrivateLoadButtonMapping(SDL_Gamepad *gamepad, ControllerMapping
|
|||
/*
|
||||
* grab the guid string from a mapping string
|
||||
*/
|
||||
static char *SDL_PrivateGetControllerGUIDFromMappingString(const char *pMapping)
|
||||
static char *SDL_PrivateGetGamepadGUIDFromMappingString(const char *pMapping)
|
||||
{
|
||||
const char *pFirstComma = SDL_strchr(pMapping, ',');
|
||||
if (pFirstComma) {
|
||||
|
@ -1154,7 +1154,7 @@ static char *SDL_PrivateGetControllerGUIDFromMappingString(const char *pMapping)
|
|||
/*
|
||||
* grab the name string from a mapping string
|
||||
*/
|
||||
static char *SDL_PrivateGetControllerNameFromMappingString(const char *pMapping)
|
||||
static char *SDL_PrivateGetGamepadNameFromMappingString(const char *pMapping)
|
||||
{
|
||||
const char *pFirstComma, *pSecondComma;
|
||||
char *pchName;
|
||||
|
@ -1182,7 +1182,7 @@ static char *SDL_PrivateGetControllerNameFromMappingString(const char *pMapping)
|
|||
/*
|
||||
* grab the button mapping string from a mapping string
|
||||
*/
|
||||
static char *SDL_PrivateGetControllerMappingFromMappingString(const char *pMapping)
|
||||
static char *SDL_PrivateGetGamepadMappingFromMappingString(const char *pMapping)
|
||||
{
|
||||
const char *pFirstComma, *pSecondComma;
|
||||
|
||||
|
@ -1202,15 +1202,15 @@ static char *SDL_PrivateGetControllerMappingFromMappingString(const char *pMappi
|
|||
/*
|
||||
* Helper function to refresh a mapping
|
||||
*/
|
||||
static void SDL_PrivateGamepadRefreshMapping(ControllerMapping_t *pControllerMapping)
|
||||
static void SDL_PrivateRefreshGamepadMapping(GamepadMapping_t *pGamepadMapping)
|
||||
{
|
||||
SDL_Gamepad *gamepad;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
for (gamepad = SDL_gamepads; gamepad; gamepad = gamepad->next) {
|
||||
if (gamepad->mapping == pControllerMapping) {
|
||||
SDL_PrivateLoadButtonMapping(gamepad, pControllerMapping);
|
||||
if (gamepad->mapping == pGamepadMapping) {
|
||||
SDL_PrivateLoadButtonMapping(gamepad, pGamepadMapping);
|
||||
|
||||
{
|
||||
SDL_Event event;
|
||||
|
@ -1227,22 +1227,22 @@ static void SDL_PrivateGamepadRefreshMapping(ControllerMapping_t *pControllerMap
|
|||
/*
|
||||
* Helper function to add a mapping for a guid
|
||||
*/
|
||||
static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, SDL_bool *existing, SDL_ControllerMappingPriority priority)
|
||||
static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, SDL_bool *existing, SDL_GamepadMappingPriority priority)
|
||||
{
|
||||
char *pchName;
|
||||
char *pchMapping;
|
||||
ControllerMapping_t *pControllerMapping;
|
||||
GamepadMapping_t *pGamepadMapping;
|
||||
Uint16 crc;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
pchName = SDL_PrivateGetControllerNameFromMappingString(mappingString);
|
||||
pchName = SDL_PrivateGetGamepadNameFromMappingString(mappingString);
|
||||
if (pchName == NULL) {
|
||||
SDL_SetError("Couldn't parse name from %s", mappingString);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pchMapping = SDL_PrivateGetControllerMappingFromMappingString(mappingString);
|
||||
pchMapping = SDL_PrivateGetGamepadMappingFromMappingString(mappingString);
|
||||
if (pchMapping == NULL) {
|
||||
SDL_free(pchName);
|
||||
SDL_SetError("Couldn't parse %s", mappingString);
|
||||
|
@ -1281,26 +1281,26 @@ static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID,
|
|||
}
|
||||
}
|
||||
|
||||
pControllerMapping = SDL_PrivateGetControllerMappingForGUID(jGUID, SDL_FALSE);
|
||||
if (pControllerMapping) {
|
||||
pGamepadMapping = SDL_PrivateGetGamepadMappingForGUID(jGUID, SDL_FALSE);
|
||||
if (pGamepadMapping) {
|
||||
/* Only overwrite the mapping if the priority is the same or higher. */
|
||||
if (pControllerMapping->priority <= priority) {
|
||||
if (pGamepadMapping->priority <= priority) {
|
||||
/* Update existing mapping */
|
||||
SDL_free(pControllerMapping->name);
|
||||
pControllerMapping->name = pchName;
|
||||
SDL_free(pControllerMapping->mapping);
|
||||
pControllerMapping->mapping = pchMapping;
|
||||
pControllerMapping->priority = priority;
|
||||
SDL_free(pGamepadMapping->name);
|
||||
pGamepadMapping->name = pchName;
|
||||
SDL_free(pGamepadMapping->mapping);
|
||||
pGamepadMapping->mapping = pchMapping;
|
||||
pGamepadMapping->priority = priority;
|
||||
/* refresh open gamepads */
|
||||
SDL_PrivateGamepadRefreshMapping(pControllerMapping);
|
||||
SDL_PrivateRefreshGamepadMapping(pGamepadMapping);
|
||||
} else {
|
||||
SDL_free(pchName);
|
||||
SDL_free(pchMapping);
|
||||
}
|
||||
*existing = SDL_TRUE;
|
||||
} else {
|
||||
pControllerMapping = SDL_malloc(sizeof(*pControllerMapping));
|
||||
if (pControllerMapping == NULL) {
|
||||
pGamepadMapping = SDL_malloc(sizeof(*pGamepadMapping));
|
||||
if (pGamepadMapping == NULL) {
|
||||
SDL_free(pchName);
|
||||
SDL_free(pchMapping);
|
||||
SDL_OutOfMemory();
|
||||
|
@ -1310,40 +1310,40 @@ static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID,
|
|||
if (crc) {
|
||||
SDL_SetJoystickGUIDCRC(&jGUID, 0);
|
||||
}
|
||||
pControllerMapping->guid = jGUID;
|
||||
pControllerMapping->name = pchName;
|
||||
pControllerMapping->mapping = pchMapping;
|
||||
pControllerMapping->next = NULL;
|
||||
pControllerMapping->priority = priority;
|
||||
pGamepadMapping->guid = jGUID;
|
||||
pGamepadMapping->name = pchName;
|
||||
pGamepadMapping->mapping = pchMapping;
|
||||
pGamepadMapping->next = NULL;
|
||||
pGamepadMapping->priority = priority;
|
||||
|
||||
if (s_pSupportedControllers) {
|
||||
if (s_pSupportedGamepads) {
|
||||
/* Add the mapping to the end of the list */
|
||||
ControllerMapping_t *pCurrMapping, *pPrevMapping;
|
||||
GamepadMapping_t *pCurrMapping, *pPrevMapping;
|
||||
|
||||
for (pPrevMapping = s_pSupportedControllers, pCurrMapping = pPrevMapping->next;
|
||||
for (pPrevMapping = s_pSupportedGamepads, pCurrMapping = pPrevMapping->next;
|
||||
pCurrMapping;
|
||||
pPrevMapping = pCurrMapping, pCurrMapping = pCurrMapping->next) {
|
||||
/* continue; */
|
||||
}
|
||||
pPrevMapping->next = pControllerMapping;
|
||||
pPrevMapping->next = pGamepadMapping;
|
||||
} else {
|
||||
s_pSupportedControllers = pControllerMapping;
|
||||
s_pSupportedGamepads = pGamepadMapping;
|
||||
}
|
||||
*existing = SDL_FALSE;
|
||||
}
|
||||
return pControllerMapping;
|
||||
return pGamepadMapping;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to determine pre-calculated offset to certain joystick mappings
|
||||
*/
|
||||
static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const char *name, SDL_JoystickGUID guid)
|
||||
static GamepadMapping_t *SDL_PrivateGetGamepadMappingForNameAndGUID(const char *name, SDL_JoystickGUID guid)
|
||||
{
|
||||
ControllerMapping_t *mapping;
|
||||
GamepadMapping_t *mapping;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
mapping = SDL_PrivateGetControllerMappingForGUID(guid, SDL_TRUE);
|
||||
mapping = SDL_PrivateGetGamepadMappingForGUID(guid, SDL_TRUE);
|
||||
#ifdef __LINUX__
|
||||
if (mapping == NULL && name) {
|
||||
if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) {
|
||||
|
@ -1394,7 +1394,7 @@ static void SDL_PrivateAppendToMappingString(char *mapping_string,
|
|||
SDL_strlcat(mapping_string, ",", mapping_string_len);
|
||||
}
|
||||
|
||||
static ControllerMapping_t *SDL_PrivateGenerateAutomaticControllerMapping(const char *name,
|
||||
static GamepadMapping_t *SDL_PrivateGenerateAutomaticGamepadMapping(const char *name,
|
||||
SDL_JoystickGUID guid,
|
||||
SDL_GamepadMapping *raw_map)
|
||||
{
|
||||
|
@ -1443,11 +1443,11 @@ static ControllerMapping_t *SDL_PrivateGenerateAutomaticControllerMapping(const
|
|||
return SDL_PrivateAddMappingForGUID(guid, mapping, &existing, SDL_GAMEPAD_MAPPING_PRIORITY_DEFAULT);
|
||||
}
|
||||
|
||||
static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
|
||||
static GamepadMapping_t *SDL_PrivateGetGamepadMapping(int device_index)
|
||||
{
|
||||
const char *name;
|
||||
SDL_JoystickGUID guid;
|
||||
ControllerMapping_t *mapping;
|
||||
GamepadMapping_t *mapping;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
|
@ -1458,13 +1458,13 @@ static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
|
|||
|
||||
name = SDL_GetJoystickNameForIndex(device_index);
|
||||
guid = SDL_GetJoystickDeviceGUID(device_index);
|
||||
mapping = SDL_PrivateGetControllerMappingForNameAndGUID(name, guid);
|
||||
mapping = SDL_PrivateGetGamepadMappingForNameAndGUID(name, guid);
|
||||
if (mapping == NULL) {
|
||||
SDL_GamepadMapping raw_map;
|
||||
|
||||
SDL_zero(raw_map);
|
||||
if (SDL_PrivateJoystickGetAutoGamepadMapping(device_index, &raw_map)) {
|
||||
mapping = SDL_PrivateGenerateAutomaticControllerMapping(name, guid, &raw_map);
|
||||
mapping = SDL_PrivateGenerateAutomaticGamepadMapping(name, guid, &raw_map);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1544,14 +1544,14 @@ int SDL_AddGamepadMappingsFromRW(SDL_RWops *rw, int freerw)
|
|||
/*
|
||||
* Add or update an entry into the Mappings Database with a priority
|
||||
*/
|
||||
static int SDL_PrivateGamepadAddMapping(const char *mappingString, SDL_ControllerMappingPriority priority)
|
||||
static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMappingPriority priority)
|
||||
{
|
||||
char *pchGUID;
|
||||
SDL_JoystickGUID jGUID;
|
||||
SDL_bool is_default_mapping = SDL_FALSE;
|
||||
SDL_bool is_xinput_mapping = SDL_FALSE;
|
||||
SDL_bool existing = SDL_FALSE;
|
||||
ControllerMapping_t *pControllerMapping;
|
||||
GamepadMapping_t *pGamepadMapping;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
|
@ -1621,7 +1621,7 @@ static int SDL_PrivateGamepadAddMapping(const char *mappingString, SDL_Controlle
|
|||
}
|
||||
#endif
|
||||
|
||||
pchGUID = SDL_PrivateGetControllerGUIDFromMappingString(mappingString);
|
||||
pchGUID = SDL_PrivateGetGamepadGUIDFromMappingString(mappingString);
|
||||
if (pchGUID == NULL) {
|
||||
return SDL_SetError("Couldn't parse GUID from %s", mappingString);
|
||||
}
|
||||
|
@ -1633,8 +1633,8 @@ static int SDL_PrivateGamepadAddMapping(const char *mappingString, SDL_Controlle
|
|||
jGUID = SDL_GetJoystickGUIDFromString(pchGUID);
|
||||
SDL_free(pchGUID);
|
||||
|
||||
pControllerMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing, priority);
|
||||
if (pControllerMapping == NULL) {
|
||||
pGamepadMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing, priority);
|
||||
if (pGamepadMapping == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1642,9 +1642,9 @@ static int SDL_PrivateGamepadAddMapping(const char *mappingString, SDL_Controlle
|
|||
return 0;
|
||||
} else {
|
||||
if (is_default_mapping) {
|
||||
s_pDefaultMapping = pControllerMapping;
|
||||
s_pDefaultMapping = pGamepadMapping;
|
||||
} else if (is_xinput_mapping) {
|
||||
s_pXInputMapping = pControllerMapping;
|
||||
s_pXInputMapping = pGamepadMapping;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -1659,7 +1659,7 @@ int SDL_AddGamepadMapping(const char *mappingString)
|
|||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
retval = SDL_PrivateGamepadAddMapping(mappingString, SDL_GAMEPAD_MAPPING_PRIORITY_API);
|
||||
retval = SDL_PrivateAddGamepadMapping(mappingString, SDL_GAMEPAD_MAPPING_PRIORITY_API);
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
|
@ -1675,9 +1675,9 @@ int SDL_GetNumGamepadMappings(void)
|
|||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
ControllerMapping_t *mapping;
|
||||
GamepadMapping_t *mapping;
|
||||
|
||||
for (mapping = s_pSupportedControllers; mapping; mapping = mapping->next) {
|
||||
for (mapping = s_pSupportedGamepads; mapping; mapping = mapping->next) {
|
||||
if (SDL_memcmp(&mapping->guid, &s_zeroGUID, sizeof(mapping->guid)) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1692,7 +1692,7 @@ int SDL_GetNumGamepadMappings(void)
|
|||
/*
|
||||
* Create a mapping string for a mapping
|
||||
*/
|
||||
static char *CreateMappingString(ControllerMapping_t *mapping, SDL_JoystickGUID guid)
|
||||
static char *CreateMappingString(GamepadMapping_t *mapping, SDL_JoystickGUID guid)
|
||||
{
|
||||
char *pMappingString, *pPlatformString;
|
||||
char pchGUID[33];
|
||||
|
@ -1750,9 +1750,9 @@ char *SDL_GetGamepadMappingForIndex(int mapping_index)
|
|||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
ControllerMapping_t *mapping;
|
||||
GamepadMapping_t *mapping;
|
||||
|
||||
for (mapping = s_pSupportedControllers; mapping; mapping = mapping->next) {
|
||||
for (mapping = s_pSupportedGamepads; mapping; mapping = mapping->next) {
|
||||
if (SDL_memcmp(&mapping->guid, &s_zeroGUID, sizeof(mapping->guid)) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1780,7 +1780,7 @@ char *SDL_GetGamepadMappingForGUID(SDL_JoystickGUID guid)
|
|||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
ControllerMapping_t *mapping = SDL_PrivateGetControllerMappingForGUID(guid, SDL_TRUE);
|
||||
GamepadMapping_t *mapping = SDL_PrivateGetGamepadMappingForGUID(guid, SDL_TRUE);
|
||||
if (mapping) {
|
||||
retval = CreateMappingString(mapping, guid);
|
||||
} else {
|
||||
|
@ -1828,7 +1828,7 @@ static void SDL_LoadGamepadHints()
|
|||
*pchNewLine = '\0';
|
||||
}
|
||||
|
||||
SDL_PrivateGamepadAddMapping(pUserMappings, SDL_GAMEPAD_MAPPING_PRIORITY_USER);
|
||||
SDL_PrivateAddGamepadMapping(pUserMappings, SDL_GAMEPAD_MAPPING_PRIORITY_USER);
|
||||
|
||||
if (pchNewLine) {
|
||||
pUserMappings = pchNewLine + 1;
|
||||
|
@ -1845,7 +1845,7 @@ static void SDL_LoadGamepadHints()
|
|||
* Usually this will just be SDL_HINT_GAMECONTROLLERCONFIG_FILE, but for
|
||||
* Android, we want to get the internal storage path.
|
||||
*/
|
||||
static SDL_bool SDL_GetControllerMappingFilePath(char *path, size_t size)
|
||||
static SDL_bool SDL_GetGamepadMappingFilePath(char *path, size_t size)
|
||||
{
|
||||
const char *hint = SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG_FILE);
|
||||
if (hint && *hint) {
|
||||
|
@ -1862,24 +1862,24 @@ static SDL_bool SDL_GetControllerMappingFilePath(char *path, size_t size)
|
|||
/*
|
||||
* Initialize the gamepad system, mostly load our DB of gamepad config mappings
|
||||
*/
|
||||
int SDL_GamepadInitMappings(void)
|
||||
int SDL_InitGamepadMappings(void)
|
||||
{
|
||||
char szControllerMapPath[1024];
|
||||
char szGamepadMapPath[1024];
|
||||
int i = 0;
|
||||
const char *pMappingString = NULL;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
pMappingString = s_ControllerMappings[i];
|
||||
pMappingString = s_GamepadMappings[i];
|
||||
while (pMappingString) {
|
||||
SDL_PrivateGamepadAddMapping(pMappingString, SDL_GAMEPAD_MAPPING_PRIORITY_DEFAULT);
|
||||
SDL_PrivateAddGamepadMapping(pMappingString, SDL_GAMEPAD_MAPPING_PRIORITY_DEFAULT);
|
||||
|
||||
i++;
|
||||
pMappingString = s_ControllerMappings[i];
|
||||
pMappingString = s_GamepadMappings[i];
|
||||
}
|
||||
|
||||
if (SDL_GetControllerMappingFilePath(szControllerMapPath, sizeof(szControllerMapPath))) {
|
||||
SDL_AddGamepadMappingsFromFile(szControllerMapPath);
|
||||
if (SDL_GetGamepadMappingFilePath(szGamepadMapPath, sizeof(szGamepadMapPath))) {
|
||||
SDL_AddGamepadMappingsFromFile(szGamepadMapPath);
|
||||
}
|
||||
|
||||
/* load in any user supplied config */
|
||||
|
@ -1893,7 +1893,7 @@ int SDL_GamepadInitMappings(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SDL_GamepadInit(void)
|
||||
int SDL_InitGamepads(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1923,7 +1923,7 @@ const char *SDL_GetGamepadNameForIndex(int joystick_index)
|
|||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index);
|
||||
GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(joystick_index);
|
||||
if (mapping != NULL) {
|
||||
if (SDL_strcmp(mapping->name, "*") == 0) {
|
||||
retval = SDL_GetJoystickNameForIndex(joystick_index);
|
||||
|
@ -1946,7 +1946,7 @@ const char *SDL_GetGamepadPathForIndex(int joystick_index)
|
|||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index);
|
||||
GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(joystick_index);
|
||||
if (mapping != NULL) {
|
||||
retval = SDL_GetJoystickPathForIndex(joystick_index);
|
||||
}
|
||||
|
@ -1975,7 +1975,7 @@ char *SDL_GetGamepadMappingForDeviceIndex(int joystick_index)
|
|||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index);
|
||||
GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(joystick_index);
|
||||
if (mapping != NULL) {
|
||||
SDL_JoystickGUID guid;
|
||||
char pchGUID[33];
|
||||
|
@ -2005,7 +2005,7 @@ SDL_bool SDL_IsGamepadNameAndGUID(const char *name, SDL_JoystickGUID guid)
|
|||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
if (SDL_PrivateGetControllerMappingForNameAndGUID(name, guid) != NULL) {
|
||||
if (SDL_PrivateGetGamepadMappingForNameAndGUID(name, guid) != NULL) {
|
||||
retval = SDL_TRUE;
|
||||
} else {
|
||||
retval = SDL_FALSE;
|
||||
|
@ -2025,7 +2025,7 @@ SDL_bool SDL_IsGamepad(int joystick_index)
|
|||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
if (SDL_PrivateGetControllerMapping(joystick_index) != NULL) {
|
||||
if (SDL_PrivateGetGamepadMapping(joystick_index) != NULL) {
|
||||
retval = SDL_TRUE;
|
||||
} else {
|
||||
retval = SDL_FALSE;
|
||||
|
@ -2140,7 +2140,7 @@ SDL_Gamepad *SDL_OpenGamepad(int joystick_index)
|
|||
SDL_JoystickID instance_id;
|
||||
SDL_Gamepad *gamepad;
|
||||
SDL_Gamepad *gamepadlist;
|
||||
ControllerMapping_t *pSupportedController = NULL;
|
||||
GamepadMapping_t *pSupportedGamepad = NULL;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
|
||||
|
@ -2158,8 +2158,8 @@ SDL_Gamepad *SDL_OpenGamepad(int joystick_index)
|
|||
}
|
||||
|
||||
/* Find a gamepad mapping */
|
||||
pSupportedController = SDL_PrivateGetControllerMapping(joystick_index);
|
||||
if (pSupportedController == NULL) {
|
||||
pSupportedGamepad = SDL_PrivateGetGamepadMapping(joystick_index);
|
||||
if (pSupportedGamepad == NULL) {
|
||||
SDL_SetError("Couldn't find mapping for device (%d)", joystick_index);
|
||||
SDL_UnlockJoysticks();
|
||||
return NULL;
|
||||
|
@ -2203,7 +2203,7 @@ SDL_Gamepad *SDL_OpenGamepad(int joystick_index)
|
|||
}
|
||||
}
|
||||
|
||||
SDL_PrivateLoadButtonMapping(gamepad, pSupportedController);
|
||||
SDL_PrivateLoadButtonMapping(gamepad, pSupportedGamepad);
|
||||
|
||||
/* Add the gamepad to list */
|
||||
++gamepad->ref_count;
|
||||
|
@ -2988,7 +2988,7 @@ void SDL_CloseGamepad(SDL_Gamepad *gamepad)
|
|||
/*
|
||||
* Quit the gamepad subsystem
|
||||
*/
|
||||
void SDL_GamepadQuit(void)
|
||||
void SDL_QuitGamepads(void)
|
||||
{
|
||||
SDL_LockJoysticks();
|
||||
while (SDL_gamepads) {
|
||||
|
@ -2998,18 +2998,18 @@ void SDL_GamepadQuit(void)
|
|||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
void SDL_GamepadQuitMappings(void)
|
||||
void SDL_QuitGamepadMappings(void)
|
||||
{
|
||||
ControllerMapping_t *pControllerMap;
|
||||
GamepadMapping_t *pGamepadMap;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
while (s_pSupportedControllers) {
|
||||
pControllerMap = s_pSupportedControllers;
|
||||
s_pSupportedControllers = s_pSupportedControllers->next;
|
||||
SDL_free(pControllerMap->name);
|
||||
SDL_free(pControllerMap->mapping);
|
||||
SDL_free(pControllerMap);
|
||||
while (s_pSupportedGamepads) {
|
||||
pGamepadMap = s_pSupportedGamepads;
|
||||
s_pSupportedGamepads = s_pSupportedGamepads->next;
|
||||
SDL_free(pGamepadMap->name);
|
||||
SDL_free(pGamepadMap->mapping);
|
||||
SDL_free(pGamepadMap);
|
||||
}
|
||||
|
||||
SDL_DelEventWatch(SDL_GamepadEventWatcher, NULL);
|
||||
|
@ -3032,7 +3032,7 @@ void SDL_GamepadQuitMappings(void)
|
|||
/*
|
||||
* Event filter to transform joystick events into appropriate gamepad ones
|
||||
*/
|
||||
static int SDL_PrivateGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadAxis axis, Sint16 value)
|
||||
static int SDL_SendGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadAxis axis, Sint16 value)
|
||||
{
|
||||
int posted;
|
||||
|
||||
|
@ -3057,7 +3057,7 @@ static int SDL_PrivateGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Ga
|
|||
/*
|
||||
* Event filter to transform joystick events into appropriate gamepad ones
|
||||
*/
|
||||
static int SDL_PrivateGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadButton button, Uint8 state)
|
||||
static int SDL_SendGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadButton button, Uint8 state)
|
||||
{
|
||||
int posted;
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
|
@ -3164,7 +3164,7 @@ void SDL_GamepadHandleDelayedGuideButton(SDL_Joystick *joystick)
|
|||
|
||||
for (gamepad = SDL_gamepads; gamepad; gamepad = gamepad->next) {
|
||||
if (gamepad->joystick == joystick) {
|
||||
SDL_PrivateGamepadButton(0, gamepad, SDL_GAMEPAD_BUTTON_GUIDE, SDL_RELEASED);
|
||||
SDL_SendGamepadButton(0, gamepad, SDL_GAMEPAD_BUTTON_GUIDE, SDL_RELEASED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
/* Useful functions and variables from SDL_gamepad.c */
|
||||
|
||||
/* Initialization and shutdown functions */
|
||||
extern int SDL_GamepadInitMappings(void);
|
||||
extern void SDL_GamepadQuitMappings(void);
|
||||
extern int SDL_GamepadInit(void);
|
||||
extern void SDL_GamepadQuit(void);
|
||||
extern int SDL_InitGamepadMappings(void);
|
||||
extern void SDL_QuitGamepadMappings(void);
|
||||
extern int SDL_InitGamepads(void);
|
||||
extern void SDL_QuitGamepads(void);
|
||||
|
||||
|
||||
/* Function to return whether a joystick name and GUID is a gamepad */
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
Alternatively, you can use the app located in test/controllermap
|
||||
*/
|
||||
static const char *s_ControllerMappings[] = {
|
||||
static const char *s_GamepadMappings[] = {
|
||||
#if SDL_JOYSTICK_XINPUT
|
||||
"xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
#endif
|
||||
|
|
|
@ -292,7 +292,7 @@ static void SDLCALL SDL_JoystickAllowBackgroundEventsChanged(void *userdata, con
|
|||
}
|
||||
}
|
||||
|
||||
int SDL_JoystickInit(void)
|
||||
int SDL_InitJoysticks(void)
|
||||
{
|
||||
int i, status;
|
||||
|
||||
|
@ -311,7 +311,7 @@ int SDL_JoystickInit(void)
|
|||
|
||||
SDL_joysticks_initialized = SDL_TRUE;
|
||||
|
||||
SDL_GamepadInitMappings();
|
||||
SDL_InitGamepadMappings();
|
||||
|
||||
/* See if we should allow joystick events while in the background */
|
||||
SDL_AddHintCallback(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,
|
||||
|
@ -326,7 +326,7 @@ int SDL_JoystickInit(void)
|
|||
SDL_UnlockJoysticks();
|
||||
|
||||
if (status < 0) {
|
||||
SDL_JoystickQuit();
|
||||
SDL_QuitJoysticks();
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -561,7 +561,7 @@ SDL_Joystick *SDL_OpenJoystick(int device_index)
|
|||
/* send initial battery event */
|
||||
initial_power_level = joystick->epowerlevel;
|
||||
joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, initial_power_level);
|
||||
SDL_SendJoystickBatteryLevel(joystick, initial_power_level);
|
||||
|
||||
driver->Update(joystick);
|
||||
|
||||
|
@ -648,7 +648,7 @@ int SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value)
|
|||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
#if SDL_JOYSTICK_VIRTUAL
|
||||
retval = SDL_JoystickSetVirtualAxisInner(joystick, axis, value);
|
||||
retval = SDL_SetJoystickVirtualAxisInner(joystick, axis, value);
|
||||
#else
|
||||
retval = SDL_SetError("SDL not built with virtual-joystick support");
|
||||
#endif
|
||||
|
@ -667,7 +667,7 @@ int SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, Uint8 value
|
|||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
#if SDL_JOYSTICK_VIRTUAL
|
||||
retval = SDL_JoystickSetVirtualButtonInner(joystick, button, value);
|
||||
retval = SDL_SetJoystickVirtualButtonInner(joystick, button, value);
|
||||
#else
|
||||
retval = SDL_SetError("SDL not built with virtual-joystick support");
|
||||
#endif
|
||||
|
@ -686,7 +686,7 @@ int SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value)
|
|||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
#if SDL_JOYSTICK_VIRTUAL
|
||||
retval = SDL_JoystickSetVirtualHatInner(joystick, hat, value);
|
||||
retval = SDL_SetJoystickVirtualHatInner(joystick, hat, value);
|
||||
#else
|
||||
retval = SDL_SetError("SDL not built with virtual-joystick support");
|
||||
#endif
|
||||
|
@ -699,7 +699,7 @@ int SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value)
|
|||
/*
|
||||
* Checks to make sure the joystick is valid.
|
||||
*/
|
||||
SDL_bool SDL_PrivateJoystickValid(SDL_Joystick *joystick)
|
||||
SDL_bool SDL_IsJoystickValid(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_AssertJoysticksLocked();
|
||||
return (joystick && joystick->magic == &joystick_magic);
|
||||
|
@ -1238,7 +1238,7 @@ void SDL_CloseJoystick(SDL_Joystick *joystick)
|
|||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
void SDL_JoystickQuit(void)
|
||||
void SDL_QuitJoysticks(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1270,7 +1270,7 @@ void SDL_JoystickQuit(void)
|
|||
SDL_DelHintCallback(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,
|
||||
SDL_JoystickAllowBackgroundEventsChanged, NULL);
|
||||
|
||||
SDL_GamepadQuitMappings();
|
||||
SDL_QuitGamepadMappings();
|
||||
|
||||
SDL_joysticks_quitting = SDL_FALSE;
|
||||
SDL_joysticks_initialized = SDL_FALSE;
|
||||
|
@ -1452,23 +1452,23 @@ void SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick)
|
|||
/* Tell the app that everything is centered/unpressed... */
|
||||
for (i = 0; i < joystick->naxes; i++) {
|
||||
if (joystick->axes[i].has_initial_value) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, i, joystick->axes[i].zero);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, i, joystick->axes[i].zero);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < joystick->nbuttons; i++) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, i, SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, SDL_RELEASED);
|
||||
}
|
||||
|
||||
for (i = 0; i < joystick->nhats; i++) {
|
||||
SDL_PrivateJoystickHat(timestamp, joystick, i, SDL_HAT_CENTERED);
|
||||
SDL_SendJoystickHat(timestamp, joystick, i, SDL_HAT_CENTERED);
|
||||
}
|
||||
|
||||
for (i = 0; i < joystick->ntouchpads; i++) {
|
||||
SDL_JoystickTouchpadInfo *touchpad = &joystick->touchpads[i];
|
||||
|
||||
for (j = 0; j < touchpad->nfingers; ++j) {
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, i, j, SDL_RELEASED, 0.0f, 0.0f, 0.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, i, j, SDL_RELEASED, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1515,7 +1515,7 @@ void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance)
|
|||
}
|
||||
}
|
||||
|
||||
int SDL_PrivateJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, Sint16 value)
|
||||
int SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, Sint16 value)
|
||||
{
|
||||
int posted;
|
||||
SDL_JoystickAxisInfo *info;
|
||||
|
@ -1548,7 +1548,7 @@ int SDL_PrivateJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis
|
|||
}
|
||||
info->sent_initial_value = SDL_TRUE;
|
||||
info->sending_initial_value = SDL_TRUE;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, axis, info->initial_value);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, axis, info->initial_value);
|
||||
info->sending_initial_value = SDL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1582,7 +1582,7 @@ int SDL_PrivateJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis
|
|||
return posted;
|
||||
}
|
||||
|
||||
int SDL_PrivateJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 hat, Uint8 value)
|
||||
int SDL_SendJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 hat, Uint8 value)
|
||||
{
|
||||
int posted;
|
||||
|
||||
|
@ -1624,7 +1624,7 @@ int SDL_PrivateJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 hat,
|
|||
return posted;
|
||||
}
|
||||
|
||||
int SDL_PrivateJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 button, Uint8 state)
|
||||
int SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 button, Uint8 state)
|
||||
{
|
||||
int posted;
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
|
@ -2879,7 +2879,7 @@ SDL_JoystickGUID SDL_GetJoystickGUIDFromString(const char *pchGUID)
|
|||
}
|
||||
|
||||
/* update the power level for this joystick */
|
||||
void SDL_PrivateJoystickBatteryLevel(SDL_Joystick *joystick, SDL_JoystickPowerLevel ePowerLevel)
|
||||
void SDL_SendJoystickBatteryLevel(SDL_Joystick *joystick, SDL_JoystickPowerLevel ePowerLevel)
|
||||
{
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
|
@ -2915,7 +2915,7 @@ SDL_JoystickPowerLevel SDL_GetJoystickPowerLevel(SDL_Joystick *joystick)
|
|||
return retval;
|
||||
}
|
||||
|
||||
int SDL_PrivateJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touchpad, int finger, Uint8 state, float x, float y, float pressure)
|
||||
int SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touchpad, int finger, Uint8 state, float x, float y, float pressure)
|
||||
{
|
||||
SDL_JoystickTouchpadInfo *touchpad_info;
|
||||
SDL_JoystickTouchpadFingerInfo *finger_info;
|
||||
|
@ -3006,7 +3006,7 @@ int SDL_PrivateJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int to
|
|||
return posted;
|
||||
}
|
||||
|
||||
int SDL_PrivateJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values)
|
||||
int SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values)
|
||||
{
|
||||
int i;
|
||||
int posted = 0;
|
||||
|
|
|
@ -34,8 +34,8 @@ extern "C" {
|
|||
struct SDL_JoystickDriver;
|
||||
|
||||
/* Initialization and shutdown functions */
|
||||
extern int SDL_JoystickInit(void);
|
||||
extern void SDL_JoystickQuit(void);
|
||||
extern int SDL_InitJoysticks(void);
|
||||
extern void SDL_QuitJoysticks(void);
|
||||
|
||||
/* Return whether the joystick system is currently initialized */
|
||||
extern SDL_bool SDL_JoysticksInitialized(void);
|
||||
|
@ -137,21 +137,21 @@ extern void SDL_PrivateJoystickAddSensor(SDL_Joystick *joystick, SDL_SensorType
|
|||
extern void SDL_PrivateJoystickAdded(SDL_JoystickID device_instance);
|
||||
extern void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance);
|
||||
extern void SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick);
|
||||
extern int SDL_PrivateJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
extern int SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
Uint8 axis, Sint16 value);
|
||||
extern int SDL_PrivateJoystickHat(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
extern int SDL_SendJoystickHat(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
Uint8 hat, Uint8 value);
|
||||
extern int SDL_PrivateJoystickButton(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
extern int SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
Uint8 button, Uint8 state);
|
||||
extern int SDL_PrivateJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
extern int SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
int touchpad, int finger, Uint8 state, float x, float y, float pressure);
|
||||
extern int SDL_PrivateJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
extern int SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick,
|
||||
SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values);
|
||||
extern void SDL_PrivateJoystickBatteryLevel(SDL_Joystick *joystick,
|
||||
extern void SDL_SendJoystickBatteryLevel(SDL_Joystick *joystick,
|
||||
SDL_JoystickPowerLevel ePowerLevel);
|
||||
|
||||
/* Internal sanity checking functions */
|
||||
extern SDL_bool SDL_PrivateJoystickValid(SDL_Joystick *joystick);
|
||||
extern SDL_bool SDL_IsJoystickValid(SDL_Joystick *joystick);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
|
|
@ -202,7 +202,7 @@ int Android_OnPadDown(int device_id, int keycode)
|
|||
SDL_LockJoysticks();
|
||||
item = JoystickByDeviceId(device_id);
|
||||
if (item && item->joystick) {
|
||||
SDL_PrivateJoystickButton(0, item->joystick, button, SDL_PRESSED);
|
||||
SDL_SendJoystickButton(0, item->joystick, button, SDL_PRESSED);
|
||||
} else {
|
||||
SDL_SendKeyboardKey(0, SDL_PRESSED, button_to_scancode(button));
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ int Android_OnPadUp(int device_id, int keycode)
|
|||
SDL_LockJoysticks();
|
||||
item = JoystickByDeviceId(device_id);
|
||||
if (item && item->joystick) {
|
||||
SDL_PrivateJoystickButton(0, item->joystick, button, SDL_RELEASED);
|
||||
SDL_SendJoystickButton(0, item->joystick, button, SDL_RELEASED);
|
||||
} else {
|
||||
SDL_SendKeyboardKey(0, SDL_RELEASED, button_to_scancode(button));
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ int Android_OnJoy(int device_id, int axis, float value)
|
|||
SDL_LockJoysticks();
|
||||
item = JoystickByDeviceId(device_id);
|
||||
if (item && item->joystick) {
|
||||
SDL_PrivateJoystickAxis(0, item->joystick, axis, (Sint16)(32767. * value));
|
||||
SDL_SendJoystickAxis(0, item->joystick, axis, (Sint16)(32767. * value));
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
|
@ -276,16 +276,16 @@ int Android_OnHat(int device_id, int hat_id, int x, int y)
|
|||
dpad_delta = (dpad_state ^ item->dpad_state);
|
||||
if (dpad_delta) {
|
||||
if (dpad_delta & DPAD_UP_MASK) {
|
||||
SDL_PrivateJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (dpad_state & DPAD_UP_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (dpad_state & DPAD_UP_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
if (dpad_delta & DPAD_DOWN_MASK) {
|
||||
SDL_PrivateJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (dpad_state & DPAD_DOWN_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (dpad_state & DPAD_DOWN_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
if (dpad_delta & DPAD_LEFT_MASK) {
|
||||
SDL_PrivateJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (dpad_state & DPAD_LEFT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (dpad_state & DPAD_LEFT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
if (dpad_delta & DPAD_RIGHT_MASK) {
|
||||
SDL_PrivateJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (dpad_state & DPAD_RIGHT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(0, item->joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (dpad_state & DPAD_RIGHT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
item->dpad_state = dpad_state;
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ static void ANDROID_JoystickDetect(void)
|
|||
}
|
||||
}
|
||||
|
||||
static SDL_joylist_item *JoystickByDevIndex(int device_index)
|
||||
static SDL_joylist_item *GetJoystickByDevIndex(int device_index)
|
||||
{
|
||||
SDL_joylist_item *item = SDL_joylist;
|
||||
|
||||
|
@ -544,7 +544,7 @@ static SDL_joylist_item *JoystickByDeviceId(int device_id)
|
|||
|
||||
static const char *ANDROID_JoystickGetDeviceName(int device_index)
|
||||
{
|
||||
return JoystickByDevIndex(device_index)->name;
|
||||
return GetJoystickByDevIndex(device_index)->name;
|
||||
}
|
||||
|
||||
static const char *ANDROID_JoystickGetDevicePath(int device_index)
|
||||
|
@ -563,17 +563,17 @@ static void ANDROID_JoystickSetDevicePlayerIndex(int device_index, int player_in
|
|||
|
||||
static SDL_JoystickGUID ANDROID_JoystickGetDeviceGUID(int device_index)
|
||||
{
|
||||
return JoystickByDevIndex(device_index)->guid;
|
||||
return GetJoystickByDevIndex(device_index)->guid;
|
||||
}
|
||||
|
||||
static SDL_JoystickID ANDROID_JoystickGetDeviceInstanceID(int device_index)
|
||||
{
|
||||
return JoystickByDevIndex(device_index)->device_instance;
|
||||
return GetJoystickByDevIndex(device_index)->device_instance;
|
||||
}
|
||||
|
||||
static int ANDROID_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
{
|
||||
SDL_joylist_item *item = JoystickByDevIndex(device_index);
|
||||
SDL_joylist_item *item = GetJoystickByDevIndex(device_index);
|
||||
|
||||
if (item == NULL) {
|
||||
return SDL_SetError("No such device");
|
||||
|
@ -646,7 +646,7 @@ static void ANDROID_JoystickUpdate(SDL_Joystick *joystick)
|
|||
}
|
||||
|
||||
value = (Sint16)(values[i] * 32767.0f);
|
||||
SDL_PrivateJoystickAxis(timestamp, item->joystick, i, value);
|
||||
SDL_SendJoystickAxis(timestamp, item->joystick, i, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -869,9 +869,9 @@ static void IOS_AccelerometerUpdate(SDL_Joystick *joystick)
|
|||
accel.z = SDL_clamp(accel.z, -maxgforce, maxgforce);
|
||||
|
||||
/* pass in data mapped to range of SInt16 */
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 0, (accel.x / maxgforce) * maxsint16);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 1, -(accel.y / maxgforce) * maxsint16);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 2, (accel.z / maxgforce) * maxsint16);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 0, (accel.x / maxgforce) * maxsint16);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 1, -(accel.y / maxgforce) * maxsint16);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 2, (accel.z / maxgforce) * maxsint16);
|
||||
#endif /* SDL_JOYSTICK_iOS_ACCELEROMETER */
|
||||
}
|
||||
|
||||
|
@ -990,16 +990,16 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
|||
|
||||
dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadOne];
|
||||
if (dpad.xAxis.value || dpad.yAxis.value) {
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, 0, 0, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f);
|
||||
} else {
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, 0, 0, SDL_RELEASED, 0.0f, 0.0f, 1.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, SDL_RELEASED, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadTwo];
|
||||
if (dpad.xAxis.value || dpad.yAxis.value) {
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, 0, 1, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f);
|
||||
} else {
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, 0, 1, SDL_RELEASED, 0.0f, 0.0f, 1.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, SDL_RELEASED, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1035,11 +1035,11 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
|||
hatstate = IOS_MFIJoystickHatStateForDPad(gamepad.dpad);
|
||||
|
||||
for (i = 0; i < SDL_arraysize(axes); i++) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, i, axes[i]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, i, axes[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < button_count; i++) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, i, buttons[i]);
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, buttons[i]);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MFI_SENSORS
|
||||
|
@ -1053,14 +1053,14 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
|||
data[0] = rate.x;
|
||||
data[1] = rate.z;
|
||||
data[2] = -rate.y;
|
||||
SDL_PrivateJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, timestamp, data, 3);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, timestamp, data, 3);
|
||||
}
|
||||
if (motion.hasGravityAndUserAcceleration) {
|
||||
GCAcceleration accel = motion.acceleration;
|
||||
data[0] = -accel.x * SDL_STANDARD_GRAVITY;
|
||||
data[1] = -accel.y * SDL_STANDARD_GRAVITY;
|
||||
data[2] = -accel.z * SDL_STANDARD_GRAVITY;
|
||||
SDL_PrivateJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, timestamp, data, 3);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, timestamp, data, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1092,7 +1092,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
|||
hatstate = IOS_MFIJoystickHatStateForDPad(gamepad.dpad);
|
||||
|
||||
for (i = 0; i < button_count; i++) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, i, buttons[i]);
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, buttons[i]);
|
||||
}
|
||||
|
||||
SDL_small_free(buttons, isstack);
|
||||
|
@ -1107,7 +1107,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
|||
};
|
||||
|
||||
for (i = 0; i < SDL_arraysize(axes); i++) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, i, axes[i]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, i, axes[i]);
|
||||
}
|
||||
|
||||
Uint8 buttons[joystick->nbuttons];
|
||||
|
@ -1128,19 +1128,19 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
|||
#pragma clang diagnostic pop
|
||||
|
||||
for (i = 0; i < button_count; i++) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, i, buttons[i]);
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, buttons[i]);
|
||||
}
|
||||
}
|
||||
#endif /* TARGET_OS_TV */
|
||||
|
||||
if (joystick->nhats > 0) {
|
||||
SDL_PrivateJoystickHat(timestamp, joystick, 0, hatstate);
|
||||
SDL_SendJoystickHat(timestamp, joystick, 0, hatstate);
|
||||
}
|
||||
|
||||
if (joystick->hwdata->uses_pause_handler) {
|
||||
for (i = 0; i < joystick->hwdata->num_pause_presses; i++) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, pause_button_index, SDL_PRESSED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, pause_button_index, SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, pause_button_index, SDL_PRESSED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, pause_button_index, SDL_RELEASED);
|
||||
}
|
||||
joystick->hwdata->num_pause_presses = 0;
|
||||
}
|
||||
|
@ -1175,7 +1175,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
|||
break;
|
||||
}
|
||||
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, ePowerLevel);
|
||||
SDL_SendJoystickBatteryLevel(joystick, ePowerLevel);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_MFI_BATTERY */
|
||||
|
|
|
@ -546,7 +546,7 @@ static void BSD_JoystickDetect(void)
|
|||
{
|
||||
}
|
||||
|
||||
static SDL_joylist_item *JoystickByDevIndex(int device_index)
|
||||
static SDL_joylist_item *GetJoystickByDevIndex(int device_index)
|
||||
{
|
||||
SDL_joylist_item *item = SDL_joylist;
|
||||
|
||||
|
@ -565,12 +565,12 @@ static SDL_joylist_item *JoystickByDevIndex(int device_index)
|
|||
|
||||
static const char *BSD_JoystickGetDeviceName(int device_index)
|
||||
{
|
||||
return JoystickByDevIndex(device_index)->name;
|
||||
return GetJoystickByDevIndex(device_index)->name;
|
||||
}
|
||||
|
||||
static const char *BSD_JoystickGetDevicePath(int device_index)
|
||||
{
|
||||
return JoystickByDevIndex(device_index)->path;
|
||||
return GetJoystickByDevIndex(device_index)->path;
|
||||
}
|
||||
|
||||
static int BSD_JoystickGetDevicePlayerIndex(int device_index)
|
||||
|
@ -584,13 +584,13 @@ static void BSD_JoystickSetDevicePlayerIndex(int device_index, int player_index)
|
|||
|
||||
static SDL_JoystickGUID BSD_JoystickGetDeviceGUID(int device_index)
|
||||
{
|
||||
return JoystickByDevIndex(device_index)->guid;
|
||||
return GetJoystickByDevIndex(device_index)->guid;
|
||||
}
|
||||
|
||||
/* Function to perform the mapping from device index to the instance id for this index */
|
||||
static SDL_JoystickID BSD_JoystickGetDeviceInstanceID(int device_index)
|
||||
{
|
||||
return JoystickByDevIndex(device_index)->device_instance;
|
||||
return GetJoystickByDevIndex(device_index)->device_instance;
|
||||
}
|
||||
|
||||
static unsigned hatval_to_sdl(Sint32 hatval)
|
||||
|
@ -609,7 +609,7 @@ static unsigned hatval_to_sdl(Sint32 hatval)
|
|||
|
||||
static int BSD_JoystickOpen(SDL_Joystick *joy, int device_index)
|
||||
{
|
||||
SDL_joylist_item *item = JoystickByDevIndex(device_index);
|
||||
SDL_joylist_item *item = GetJoystickByDevIndex(device_index);
|
||||
struct joystick_hwdata *hw;
|
||||
|
||||
if (item == NULL) {
|
||||
|
@ -661,7 +661,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy)
|
|||
xmax++;
|
||||
}
|
||||
v = (((SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) * ((Sint32)x - xmin)) / (xmax - xmin)) + SDL_JOYSTICK_AXIS_MIN;
|
||||
SDL_PrivateJoystickAxis(timestamp, joy, 0, v);
|
||||
SDL_SendJoystickAxis(timestamp, joy, 0, v);
|
||||
}
|
||||
if (SDL_abs(y - gameport.y) > 8) {
|
||||
y = gameport.y;
|
||||
|
@ -676,10 +676,10 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy)
|
|||
ymax++;
|
||||
}
|
||||
v = (((SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) * ((Sint32)y - ymin)) / (ymax - ymin)) + SDL_JOYSTICK_AXIS_MIN;
|
||||
SDL_PrivateJoystickAxis(timestamp, joy, 1, v);
|
||||
SDL_SendJoystickAxis(timestamp, joy, 1, v);
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joy, 0, gameport.b1);
|
||||
SDL_PrivateJoystickButton(timestamp, joy, 1, gameport.b2);
|
||||
SDL_SendJoystickButton(timestamp, joy, 0, gameport.b1);
|
||||
SDL_SendJoystickButton(timestamp, joy, 1, gameport.b2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -711,26 +711,26 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy)
|
|||
/* scaleaxe */
|
||||
v = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem);
|
||||
v = (((SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) * (v - hitem.logical_minimum)) / (hitem.logical_maximum - hitem.logical_minimum)) + SDL_JOYSTICK_AXIS_MIN;
|
||||
SDL_PrivateJoystickAxis(timestamp, joy, naxe, v);
|
||||
SDL_SendJoystickAxis(timestamp, joy, naxe, v);
|
||||
} else if (usage == HUG_HAT_SWITCH) {
|
||||
v = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem);
|
||||
SDL_PrivateJoystickHat(timestamp, joy, 0,
|
||||
SDL_SendJoystickHat(timestamp, joy, 0,
|
||||
hatval_to_sdl(v) -
|
||||
hitem.logical_minimum);
|
||||
}
|
||||
#ifdef __OpenBSD__
|
||||
else if (usage == HUG_DPAD_UP) {
|
||||
dpad[0] = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem);
|
||||
SDL_PrivateJoystickHat(timestamp, joy, 0, dpad_to_sdl(dpad));
|
||||
SDL_SendJoystickHat(timestamp, joy, 0, dpad_to_sdl(dpad));
|
||||
} else if (usage == HUG_DPAD_DOWN) {
|
||||
dpad[1] = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem);
|
||||
SDL_PrivateJoystickHat(timestamp, joy, 0, dpad_to_sdl(dpad));
|
||||
SDL_SendJoystickHat(timestamp, joy, 0, dpad_to_sdl(dpad));
|
||||
} else if (usage == HUG_DPAD_RIGHT) {
|
||||
dpad[2] = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem);
|
||||
SDL_PrivateJoystickHat(timestamp, joy, 0, dpad_to_sdl(dpad));
|
||||
SDL_SendJoystickHat(timestamp, joy, 0, dpad_to_sdl(dpad));
|
||||
} else if (usage == HUG_DPAD_LEFT) {
|
||||
dpad[3] = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem);
|
||||
SDL_PrivateJoystickHat(timestamp, joy, 0, dpad_to_sdl(dpad));
|
||||
SDL_SendJoystickHat(timestamp, joy, 0, dpad_to_sdl(dpad));
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
@ -738,7 +738,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy)
|
|||
case HUP_BUTTON:
|
||||
v = (Sint32)hid_get_data(REP_BUF_DATA(rep), &hitem);
|
||||
nbutton = HID_USAGE(hitem.usage) - 1; /* SDL buttons are zero-based */
|
||||
SDL_PrivateJoystickButton(timestamp, joy, nbutton, v);
|
||||
SDL_SendJoystickButton(timestamp, joy, nbutton, v);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
|
|
|
@ -945,7 +945,7 @@ static void DARWIN_JoystickUpdate(SDL_Joystick *joystick)
|
|||
while (element) {
|
||||
goodRead = GetHIDScaledCalibratedState(device, element, -32768, 32767, &value);
|
||||
if (goodRead) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, i, value);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, i, value);
|
||||
}
|
||||
|
||||
element = element->pNext;
|
||||
|
@ -960,7 +960,7 @@ static void DARWIN_JoystickUpdate(SDL_Joystick *joystick)
|
|||
if (value > 1) { /* handle pressure-sensitive buttons */
|
||||
value = 1;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, i, value);
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, value);
|
||||
}
|
||||
|
||||
element = element->pNext;
|
||||
|
@ -1016,7 +1016,7 @@ static void DARWIN_JoystickUpdate(SDL_Joystick *joystick)
|
|||
break;
|
||||
}
|
||||
|
||||
SDL_PrivateJoystickHat(timestamp, joystick, i, pos);
|
||||
SDL_SendJoystickHat(timestamp, joystick, i, pos);
|
||||
}
|
||||
|
||||
element = element->pNext;
|
||||
|
|
|
@ -337,7 +337,7 @@ static void EMSCRIPTEN_JoystickUpdate(SDL_Joystick *joystick)
|
|||
for (i = 0; i < item->nbuttons; i++) {
|
||||
if (item->digitalButton[i] != gamepadState.digitalButton[i]) {
|
||||
buttonState = gamepadState.digitalButton[i] ? SDL_PRESSED : SDL_RELEASED;
|
||||
SDL_PrivateJoystickButton(timestamp, item->joystick, i, buttonState);
|
||||
SDL_SendJoystickButton(timestamp, item->joystick, i, buttonState);
|
||||
}
|
||||
|
||||
/* store values to compare them in the next update */
|
||||
|
@ -348,7 +348,7 @@ static void EMSCRIPTEN_JoystickUpdate(SDL_Joystick *joystick)
|
|||
for (i = 0; i < item->naxes; i++) {
|
||||
if (item->axis[i] != gamepadState.axis[i]) {
|
||||
/* do we need to do conversion? */
|
||||
SDL_PrivateJoystickAxis(timestamp, item->joystick, i,
|
||||
SDL_SendJoystickAxis(timestamp, item->joystick, i,
|
||||
(Sint16)(32767. * gamepadState.axis[i]));
|
||||
}
|
||||
|
||||
|
|
|
@ -204,17 +204,17 @@ extern "C"
|
|||
|
||||
/* Generate axis motion events */
|
||||
for (i = 0; i < joystick->naxes; ++i) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, i, axes[i]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, i, axes[i]);
|
||||
}
|
||||
|
||||
/* Generate hat change events */
|
||||
for (i = 0; i < joystick->nhats; ++i) {
|
||||
SDL_PrivateJoystickHat(timestamp, joystick, i, hat_map[hats[i]]);
|
||||
SDL_SendJoystickHat(timestamp, joystick, i, hat_map[hats[i]]);
|
||||
}
|
||||
|
||||
/* Generate button events */
|
||||
for (i = 0; i < joystick->nbuttons; ++i) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, i, (buttons & 0x01));
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, (buttons & 0x01));
|
||||
buttons >>= 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device
|
|||
}
|
||||
|
||||
#define READ_BUTTON(off, flag, button) \
|
||||
SDL_PrivateJoystickButton( \
|
||||
SDL_SendJoystickButton( \
|
||||
timestamp, \
|
||||
joystick, \
|
||||
RemapButton(ctx, button), \
|
||||
|
@ -281,7 +281,7 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device
|
|||
if (v > ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis]) \
|
||||
ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis] = v; \
|
||||
axis_value = (Sint16)HIDAPI_RemapVal(v, ctx->min_axis[i * SDL_GAMEPAD_AXIS_MAX + axis], ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \
|
||||
SDL_PrivateJoystickAxis( \
|
||||
SDL_SendJoystickAxis( \
|
||||
timestamp, \
|
||||
joystick, \
|
||||
axis, axis_value);
|
||||
|
@ -334,7 +334,7 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device
|
|||
}
|
||||
|
||||
#define READ_BUTTON(off, flag, button) \
|
||||
SDL_PrivateJoystickButton( \
|
||||
SDL_SendJoystickButton( \
|
||||
timestamp, \
|
||||
joystick, \
|
||||
RemapButton(ctx, button), \
|
||||
|
@ -363,7 +363,7 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device
|
|||
if (curSlot[off] > ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis]) \
|
||||
ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis] = curSlot[off]; \
|
||||
axis_value = (Sint16)HIDAPI_RemapVal(curSlot[off], ctx->min_axis[i * SDL_GAMEPAD_AXIS_MAX + axis], ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \
|
||||
SDL_PrivateJoystickAxis( \
|
||||
SDL_SendJoystickAxis( \
|
||||
timestamp, \
|
||||
joystick, \
|
||||
axis, axis_value);
|
||||
|
|
|
@ -170,20 +170,20 @@ static void HIDAPI_DriverLuna_HandleUSBStatePacket(SDL_Joystick *joystick, SDL_D
|
|||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
if (ctx->last_state[1] != data[1]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[1] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[1] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[1] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[1] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[1] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[1] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[1] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[1] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[1] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[1] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[1] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[1] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
if (ctx->last_state[2] != data[2]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_LUNA_MIC, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[2] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_LUNA_MIC, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[2] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[3] != data[3]) {
|
||||
|
@ -224,23 +224,23 @@ static void HIDAPI_DriverLuna_HandleUSBStatePacket(SDL_Joystick *joystick, SDL_D
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
|
||||
#define READ_STICK_AXIS(offset) \
|
||||
(data[offset] == 0x7f ? 0 : (Sint16)HIDAPI_RemapVal((float)data[offset], 0x00, 0xff, SDL_MIN_SINT16, SDL_MAX_SINT16))
|
||||
{
|
||||
Sint16 axis = READ_STICK_AXIS(4);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = READ_STICK_AXIS(5);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = READ_STICK_AXIS(6);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = READ_STICK_AXIS(7);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
}
|
||||
#undef READ_STICK_AXIS
|
||||
|
||||
|
@ -248,9 +248,9 @@ static void HIDAPI_DriverLuna_HandleUSBStatePacket(SDL_Joystick *joystick, SDL_D
|
|||
(Sint16) HIDAPI_RemapVal((float)data[offset], 0x00, 0xff, SDL_MIN_SINT16, SDL_MAX_SINT16)
|
||||
{
|
||||
Sint16 axis = READ_TRIGGER_AXIS(8);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
axis = READ_TRIGGER_AXIS(9);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
}
|
||||
#undef READ_TRIGGER_AXIS
|
||||
|
||||
|
@ -263,7 +263,7 @@ static void HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick,
|
|||
|
||||
if (size >= 2 && data[0] == 0x02) {
|
||||
/* Home button has dedicated report */
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[1] & 0x1) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[1] & 0x1) ? SDL_PRESSED : SDL_RELEASED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -271,13 +271,13 @@ static void HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick,
|
|||
/* Battery level report */
|
||||
int level = data[1] * 100 / 0xFF;
|
||||
if (level == 0) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
} else if (level <= 20) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
} else if (level <= 70) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
} else {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -326,41 +326,41 @@ static void HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
|
||||
if (ctx->last_state[14] != data[14]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[14] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[14] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[14] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[14] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[14] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[14] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[14] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[14] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[14] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[14] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
if (ctx->last_state[15] != data[15]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[15] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[15] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[15] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[15] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[15] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[15] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
if (ctx->last_state[16] != data[16]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[16] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_LUNA_MIC, (data[16] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[16] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_LUNA_MIC, (data[16] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
#define READ_STICK_AXIS(offset) \
|
||||
(data[offset] == 0x7f ? 0 : (Sint16)HIDAPI_RemapVal((float)data[offset], 0x00, 0xff, SDL_MIN_SINT16, SDL_MAX_SINT16))
|
||||
{
|
||||
Sint16 axis = READ_STICK_AXIS(2);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = READ_STICK_AXIS(4);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = READ_STICK_AXIS(6);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = READ_STICK_AXIS(8);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
}
|
||||
#undef READ_STICK_AXIS
|
||||
|
||||
|
@ -368,9 +368,9 @@ static void HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick,
|
|||
(Sint16) HIDAPI_RemapVal((float)((int)(((data[offset] | (data[offset + 1] << 8)) & 0x3ff) - 0x200)), 0x00 - 0x200, 0x3ff - 0x200, SDL_MIN_SINT16, SDL_MAX_SINT16)
|
||||
{
|
||||
Sint16 axis = READ_TRIGGER_AXIS(9);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
axis = READ_TRIGGER_AXIS(11);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
}
|
||||
#undef READ_TRIGGER_AXIS
|
||||
|
||||
|
|
|
@ -352,36 +352,36 @@ static void HIDAPI_DriverPS3_HandleMiniStatePacket(SDL_Joystick *joystick, SDL_D
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[4] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[4] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[4] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[4] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[4] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[4] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[4] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[4] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[5] != data[5]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[5] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[5] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, (data[5] & 0x04) ? SDL_JOYSTICK_AXIS_MAX : SDL_JOYSTICK_AXIS_MIN);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, (data[5] & 0x08) ? SDL_JOYSTICK_AXIS_MAX : SDL_JOYSTICK_AXIS_MIN);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[5] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[5] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[5] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[5] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[5] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[5] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, (data[5] & 0x04) ? SDL_JOYSTICK_AXIS_MAX : SDL_JOYSTICK_AXIS_MIN);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, (data[5] & 0x08) ? SDL_JOYSTICK_AXIS_MAX : SDL_JOYSTICK_AXIS_MIN);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[5] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[5] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[5] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[5] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
axis = ((int)data[2] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = ((int)data[3] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = ((int)data[0] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = ((int)data[1] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
|
||||
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
|
||||
}
|
||||
|
@ -392,41 +392,41 @@ static void HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_Drive
|
|||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
if (ctx->last_state[2] != data[2]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[2] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[2] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[3] != data[3]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[3] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[3] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[3] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[3] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[4] != data[4]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
axis = ((int)data[18] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
axis = ((int)data[19] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
axis = ((int)data[6] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = ((int)data[7] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = ((int)data[8] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = ((int)data[9] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
|
||||
/* Buttons are mapped as axes in the order they appear in the button enumeration */
|
||||
{
|
||||
|
@ -457,7 +457,7 @@ static void HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_Drive
|
|||
}
|
||||
|
||||
axis = ((int)data[offset] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, axis_index, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, axis_index, axis);
|
||||
++axis_index;
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ static void HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_Drive
|
|||
sensor_data[0] = HIDAPI_DriverPS3_ScaleAccel(LOAD16(data[41], data[42]));
|
||||
sensor_data[1] = -HIDAPI_DriverPS3_ScaleAccel(LOAD16(data[45], data[46]));
|
||||
sensor_data[2] = -HIDAPI_DriverPS3_ScaleAccel(LOAD16(data[43], data[44]));
|
||||
SDL_PrivateJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, timestamp, sensor_data, SDL_arraysize(sensor_data));
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, timestamp, sensor_data, SDL_arraysize(sensor_data));
|
||||
}
|
||||
|
||||
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
|
||||
|
@ -678,20 +678,20 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket(SDL_Joystick *joystick,
|
|||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
if (ctx->last_state[0] != data[0]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[0] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[0] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[0] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[0] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[0] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[0] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[0] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[0] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[0] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[0] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[0] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[0] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[1] != data[1]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[1] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[1] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[1] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[1] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[1] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[1] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[2] != data[2]) {
|
||||
|
@ -732,24 +732,24 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket(SDL_Joystick *joystick,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
|
||||
axis = ((int)data[17] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
axis = ((int)data[18] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
axis = ((int)data[3] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = ((int)data[4] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = ((int)data[5] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = ((int)data[6] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
|
||||
/* Buttons are mapped as axes in the order they appear in the button enumeration */
|
||||
{
|
||||
|
@ -780,7 +780,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket(SDL_Joystick *joystick,
|
|||
}
|
||||
|
||||
axis = ((int)data[offset] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, axis_index, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, axis_index, axis);
|
||||
++axis_index;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -830,10 +830,10 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
|
|||
{
|
||||
Uint8 data = (packet->rgucButtonsHatAndCounter[0] >> 4);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
{
|
||||
Uint8 data = (packet->rgucButtonsHatAndCounter[0] & 0x0F);
|
||||
|
@ -874,22 +874,22 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->last_state.rgucButtonsHatAndCounter[1] != packet->rgucButtonsHatAndCounter[1]) {
|
||||
Uint8 data = packet->rgucButtonsHatAndCounter[1];
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
/* Some fightsticks, ex: Victrix FS Pro will only this these digital trigger bits and not the analog values so this needs to run whenever the
|
||||
|
@ -904,37 +904,37 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
|
|||
if (ctx->last_state.rgucButtonsHatAndCounter[2] != packet->rgucButtonsHatAndCounter[2]) {
|
||||
Uint8 data = (packet->rgucButtonsHatAndCounter[2] & 0x03);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, 15, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, 15, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
axis = ((int)packet->ucTriggerLeft * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
axis = ((int)packet->ucTriggerRight * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
axis = ((int)packet->ucLeftJoystickX * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = ((int)packet->ucLeftJoystickY * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = ((int)packet->ucRightJoystickX * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = ((int)packet->ucRightJoystickY * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
|
||||
if (ctx->device->is_bluetooth && ctx->official_controller) {
|
||||
if (packet->ucBatteryLevel & 0x10) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
|
||||
} else {
|
||||
/* Battery level ranges from 0 to 10 */
|
||||
int level = (packet->ucBatteryLevel & 0xF);
|
||||
if (level == 0) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
} else if (level <= 2) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
} else if (level <= 7) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
} else {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -943,12 +943,12 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
|
|||
touchpad_state = ((packet->ucTouchpadCounter1 & 0x80) == 0) ? SDL_PRESSED : SDL_RELEASED;
|
||||
touchpad_x = packet->rgucTouchpadData1[0] | (((int)packet->rgucTouchpadData1[1] & 0x0F) << 8);
|
||||
touchpad_y = (packet->rgucTouchpadData1[1] >> 4) | ((int)packet->rgucTouchpadData1[2] << 4);
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, 0, 0, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
|
||||
touchpad_state = ((packet->ucTouchpadCounter2 & 0x80) == 0) ? SDL_PRESSED : SDL_RELEASED;
|
||||
touchpad_x = packet->rgucTouchpadData2[0] | (((int)packet->rgucTouchpadData2[1] & 0x0F) << 8);
|
||||
touchpad_y = (packet->rgucTouchpadData2[1] >> 4) | ((int)packet->rgucTouchpadData2[2] << 4);
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, 0, 1, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
if (ctx->report_sensors) {
|
||||
|
@ -972,12 +972,12 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
|
|||
data[0] = HIDAPI_DriverPS4_ApplyCalibrationData(ctx, 0, LOAD16(packet->rgucGyroX[0], packet->rgucGyroX[1]));
|
||||
data[1] = HIDAPI_DriverPS4_ApplyCalibrationData(ctx, 1, LOAD16(packet->rgucGyroY[0], packet->rgucGyroY[1]));
|
||||
data[2] = HIDAPI_DriverPS4_ApplyCalibrationData(ctx, 2, LOAD16(packet->rgucGyroZ[0], packet->rgucGyroZ[1]));
|
||||
SDL_PrivateJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, sensor_timestamp, data, 3);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, sensor_timestamp, data, 3);
|
||||
|
||||
data[0] = HIDAPI_DriverPS4_ApplyCalibrationData(ctx, 3, LOAD16(packet->rgucAccelX[0], packet->rgucAccelX[1]));
|
||||
data[1] = HIDAPI_DriverPS4_ApplyCalibrationData(ctx, 4, LOAD16(packet->rgucAccelY[0], packet->rgucAccelY[1]));
|
||||
data[2] = HIDAPI_DriverPS4_ApplyCalibrationData(ctx, 5, LOAD16(packet->rgucAccelZ[0], packet->rgucAccelZ[1]));
|
||||
SDL_PrivateJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, sensor_timestamp, data, 3);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, sensor_timestamp, data, 3);
|
||||
}
|
||||
|
||||
SDL_memcpy(&ctx->last_state, packet, sizeof(ctx->last_state));
|
||||
|
|
|
@ -1009,10 +1009,10 @@ static void HIDAPI_DriverPS5_HandleSimpleStatePacket(SDL_Joystick *joystick, SDL
|
|||
{
|
||||
Uint8 data = (packet->rgucButtonsHatAndCounter[0] >> 4);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
{
|
||||
Uint8 data = (packet->rgucButtonsHatAndCounter[0] & 0x0F);
|
||||
|
@ -1053,43 +1053,43 @@ static void HIDAPI_DriverPS5_HandleSimpleStatePacket(SDL_Joystick *joystick, SDL
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->last_state.simple.rgucButtonsHatAndCounter[1] != packet->rgucButtonsHatAndCounter[1]) {
|
||||
Uint8 data = packet->rgucButtonsHatAndCounter[1];
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state.simple.rgucButtonsHatAndCounter[2] != packet->rgucButtonsHatAndCounter[2]) {
|
||||
Uint8 data = (packet->rgucButtonsHatAndCounter[2] & 0x03);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
axis = ((int)packet->ucTriggerLeft * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
axis = ((int)packet->ucTriggerRight * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
axis = ((int)packet->ucLeftJoystickX * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = ((int)packet->ucLeftJoystickY * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = ((int)packet->ucRightJoystickX * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = ((int)packet->ucRightJoystickY * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
|
||||
SDL_memcpy(&ctx->last_state.simple, packet, sizeof(ctx->last_state.simple));
|
||||
}
|
||||
|
@ -1103,10 +1103,10 @@ static void HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL
|
|||
{
|
||||
Uint8 data = (packet->rgucButtonsAndHat[0] >> 4);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
{
|
||||
Uint8 data = (packet->rgucButtonsAndHat[0] & 0x0F);
|
||||
|
@ -1147,48 +1147,48 @@ static void HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->last_state.state.rgucButtonsAndHat[1] != packet->rgucButtonsAndHat[1]) {
|
||||
Uint8 data = packet->rgucButtonsAndHat[1];
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state.state.rgucButtonsAndHat[2] != packet->rgucButtonsAndHat[2]) {
|
||||
Uint8 data = packet->rgucButtonsAndHat[2];
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_PS5_TOUCHPAD, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_PS5_LEFT_FUNCTION, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_PS5_RIGHT_FUNCTION, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_PS5_LEFT_PADDLE, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_PS5_RIGHT_PADDLE, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_PS5_TOUCHPAD, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_PS5_LEFT_FUNCTION, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_PS5_RIGHT_FUNCTION, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_PS5_LEFT_PADDLE, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_PS5_RIGHT_PADDLE, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
axis = ((int)packet->ucTriggerLeft * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
axis = ((int)packet->ucTriggerRight * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
axis = ((int)packet->ucLeftJoystickX * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = ((int)packet->ucLeftJoystickY * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = ((int)packet->ucRightJoystickX * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = ((int)packet->ucRightJoystickY * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
|
||||
if (ctx->report_sensors) {
|
||||
Uint32 tick;
|
||||
|
@ -1214,12 +1214,12 @@ static void HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL
|
|||
data[0] = HIDAPI_DriverPS5_ApplyCalibrationData(ctx, 0, LOAD16(packet->rgucGyroX[0], packet->rgucGyroX[1]));
|
||||
data[1] = HIDAPI_DriverPS5_ApplyCalibrationData(ctx, 1, LOAD16(packet->rgucGyroY[0], packet->rgucGyroY[1]));
|
||||
data[2] = HIDAPI_DriverPS5_ApplyCalibrationData(ctx, 2, LOAD16(packet->rgucGyroZ[0], packet->rgucGyroZ[1]));
|
||||
SDL_PrivateJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, sensor_timestamp, data, 3);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, sensor_timestamp, data, 3);
|
||||
|
||||
data[0] = HIDAPI_DriverPS5_ApplyCalibrationData(ctx, 3, LOAD16(packet->rgucAccelX[0], packet->rgucAccelX[1]));
|
||||
data[1] = HIDAPI_DriverPS5_ApplyCalibrationData(ctx, 4, LOAD16(packet->rgucAccelY[0], packet->rgucAccelY[1]));
|
||||
data[2] = HIDAPI_DriverPS5_ApplyCalibrationData(ctx, 5, LOAD16(packet->rgucAccelZ[0], packet->rgucAccelZ[1]));
|
||||
SDL_PrivateJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, sensor_timestamp, data, 3);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, sensor_timestamp, data, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1235,12 +1235,12 @@ static void HIDAPI_DriverPS5_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
|
|||
touchpad_state = ((packet->ucTouchpadCounter1 & 0x80) == 0) ? SDL_PRESSED : SDL_RELEASED;
|
||||
touchpad_x = packet->rgucTouchpadData1[0] | (((int)packet->rgucTouchpadData1[1] & 0x0F) << 8);
|
||||
touchpad_y = (packet->rgucTouchpadData1[1] >> 4) | ((int)packet->rgucTouchpadData1[2] << 4);
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, 0, 0, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
|
||||
touchpad_state = ((packet->ucTouchpadCounter2 & 0x80) == 0) ? SDL_PRESSED : SDL_RELEASED;
|
||||
touchpad_x = packet->rgucTouchpadData2[0] | (((int)packet->rgucTouchpadData2[1] & 0x0F) << 8);
|
||||
touchpad_y = (packet->rgucTouchpadData2[1] >> 4) | ((int)packet->rgucTouchpadData2[2] << 4);
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, 0, 1, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
/* A check of packet->ucBatteryLevel & 0x10 should work as a check for BT vs USB but doesn't
|
||||
|
@ -1248,18 +1248,18 @@ static void HIDAPI_DriverPS5_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
|
|||
*/
|
||||
if (!ctx->device->is_bluetooth) {
|
||||
/* 0x20 set means fully charged */
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
|
||||
} else {
|
||||
/* Battery level ranges from 0 to 10 */
|
||||
int level = (packet->ucBatteryLevel & 0xF);
|
||||
if (level == 0) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
} else if (level <= 2) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
} else if (level <= 7) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
} else {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1278,12 +1278,12 @@ static void HIDAPI_DriverPS5_HandleStatePacketAlt(SDL_Joystick *joystick, SDL_hi
|
|||
touchpad_state = ((packet->ucTouchpadCounter1 & 0x80) == 0) ? SDL_PRESSED : SDL_RELEASED;
|
||||
touchpad_x = packet->rgucTouchpadData1[0] | (((int)packet->rgucTouchpadData1[1] & 0x0F) << 8);
|
||||
touchpad_y = (packet->rgucTouchpadData1[1] >> 4) | ((int)packet->rgucTouchpadData1[2] << 4);
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, 0, 0, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
|
||||
touchpad_state = ((packet->ucTouchpadCounter2 & 0x80) == 0) ? SDL_PRESSED : SDL_RELEASED;
|
||||
touchpad_x = packet->rgucTouchpadData2[0] | (((int)packet->rgucTouchpadData2[1] & 0x0F) << 8);
|
||||
touchpad_y = (packet->rgucTouchpadData2[1] >> 4) | ((int)packet->rgucTouchpadData2[2] << 4);
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, 0, 1, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
SDL_memcpy(&ctx->last_state, packet, sizeof(ctx->last_state));
|
||||
|
|
|
@ -327,40 +327,40 @@ static void HIDAPI_DriverShield_HandleStatePacketV103(SDL_Joystick *joystick, SD
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
|
||||
if (ctx->last_state[1] != data[1]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[1] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[1] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[1] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[1] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[1] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[1] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[1] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[1] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[1] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[1] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[1] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[1] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[2] != data[2]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_SHIELD_V103_PLUS, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_SHIELD_V103_MINUS, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_SHIELD_V103_PLUS, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_SHIELD_V103_MINUS, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, SDL_SwapLE16(*(Sint16 *)&data[4]) - 0x8000);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, SDL_SwapLE16(*(Sint16 *)&data[6]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, SDL_SwapLE16(*(Sint16 *)&data[4]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, SDL_SwapLE16(*(Sint16 *)&data[6]) - 0x8000);
|
||||
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, SDL_SwapLE16(*(Sint16 *)&data[8]) - 0x8000);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, SDL_SwapLE16(*(Sint16 *)&data[10]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, SDL_SwapLE16(*(Sint16 *)&data[8]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, SDL_SwapLE16(*(Sint16 *)&data[10]) - 0x8000);
|
||||
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, SDL_SwapLE16(*(Sint16 *)&data[12]) - 0x8000);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, SDL_SwapLE16(*(Sint16 *)&data[14]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, SDL_SwapLE16(*(Sint16 *)&data[12]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, SDL_SwapLE16(*(Sint16 *)&data[14]) - 0x8000);
|
||||
|
||||
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
|
||||
}
|
||||
|
@ -374,13 +374,13 @@ static void HIDAPI_DriverShield_HandleTouchPacketV103(SDL_Joystick *joystick, SD
|
|||
float touchpad_x, touchpad_y;
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_SHIELD_V103_TOUCHPAD, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_SHIELD_V103_TOUCHPAD, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
/* It's a triangular pad, but just use the center as the usable touch area */
|
||||
touchpad_state = ((data[1] & 0x80) == 0) ? SDL_PRESSED : SDL_RELEASED;
|
||||
touchpad_x = clamp((float)(data[2] - 0x70) / 0x50, 0.0f, 1.0f);
|
||||
touchpad_y = clamp((float)(data[4] - 0x40) / 0x15, 0.0f, 1.0f);
|
||||
SDL_PrivateJoystickTouchpad(timestamp, joystick, 0, 0, touchpad_state, touchpad_x, touchpad_y, touchpad_state ? 1.0f : 0.0f);
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, touchpad_state, touchpad_x, touchpad_y, touchpad_state ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
static void HIDAPI_DriverShield_HandleStatePacketV104(SDL_Joystick *joystick, SDL_DriverShield_Context *ctx, Uint8 *data, int size)
|
||||
|
@ -429,40 +429,40 @@ static void HIDAPI_DriverShield_HandleStatePacketV104(SDL_Joystick *joystick, SD
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
|
||||
if (ctx->last_state[3] != data[3]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[3] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[3] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[3] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[3] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[3] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[3] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[3] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[3] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[4] != data[4]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, SDL_SwapLE16(*(Sint16 *)&data[9]) - 0x8000);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, SDL_SwapLE16(*(Sint16 *)&data[11]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, SDL_SwapLE16(*(Sint16 *)&data[9]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, SDL_SwapLE16(*(Sint16 *)&data[11]) - 0x8000);
|
||||
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, SDL_SwapLE16(*(Sint16 *)&data[13]) - 0x8000);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, SDL_SwapLE16(*(Sint16 *)&data[15]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, SDL_SwapLE16(*(Sint16 *)&data[13]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, SDL_SwapLE16(*(Sint16 *)&data[15]) - 0x8000);
|
||||
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, SDL_SwapLE16(*(Sint16 *)&data[19]) - 0x8000);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, SDL_SwapLE16(*(Sint16 *)&data[21]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, SDL_SwapLE16(*(Sint16 *)&data[19]) - 0x8000);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, SDL_SwapLE16(*(Sint16 *)&data[21]) - 0x8000);
|
||||
|
||||
if (ctx->last_state[17] != data[17]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[17] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[17] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[17] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[17] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[17] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[17] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
|
||||
|
@ -515,7 +515,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device)
|
|||
case CMD_CHARGE_STATE:
|
||||
ctx->charging = cmd_resp_report->payload[0] != 0;
|
||||
if (joystick) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, ctx->charging ? SDL_JOYSTICK_POWER_WIRED : ctx->battery_level);
|
||||
SDL_SendJoystickBatteryLevel(joystick, ctx->charging ? SDL_JOYSTICK_POWER_WIRED : ctx->battery_level);
|
||||
}
|
||||
break;
|
||||
case CMD_BATTERY_STATE:
|
||||
|
@ -539,7 +539,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device)
|
|||
break;
|
||||
}
|
||||
if (joystick) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, ctx->charging ? SDL_JOYSTICK_POWER_WIRED : ctx->battery_level);
|
||||
SDL_SendJoystickBatteryLevel(joystick, ctx->charging ? SDL_JOYSTICK_POWER_WIRED : ctx->battery_level);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -194,42 +194,42 @@ static void HIDAPI_DriverStadia_HandleStatePacket(SDL_Joystick *joystick, SDL_Dr
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
|
||||
if (ctx->last_state[2] != data[2]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_STADIA_SHARE, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_STADIA_GOOGLE_ASSISTANT, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_STADIA_SHARE, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_CONTROLLER_BUTTON_STADIA_GOOGLE_ASSISTANT, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[3] != data[3]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[3] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[3] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[3] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[3] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[3] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[3] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
#define READ_STICK_AXIS(offset) \
|
||||
(data[offset] == 0x80 ? 0 : (Sint16)HIDAPI_RemapVal((float)((int)data[offset] - 0x80), 0x01 - 0x80, 0xff - 0x80, SDL_MIN_SINT16, SDL_MAX_SINT16))
|
||||
{
|
||||
axis = READ_STICK_AXIS(4);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = READ_STICK_AXIS(5);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = READ_STICK_AXIS(6);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = READ_STICK_AXIS(7);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
}
|
||||
#undef READ_STICK_AXIS
|
||||
|
||||
|
@ -237,9 +237,9 @@ static void HIDAPI_DriverStadia_HandleStatePacket(SDL_Joystick *joystick, SDL_Dr
|
|||
(Sint16)(((int)data[offset] * 257) - 32768)
|
||||
{
|
||||
axis = READ_TRIGGER_AXIS(8);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
axis = READ_TRIGGER_AXIS(9);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
}
|
||||
#undef READ_TRIGGER_AXIS
|
||||
|
||||
|
|
|
@ -1122,38 +1122,38 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device)
|
|||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
if (ctx->m_state.ulButtons != ctx->m_last_state.ulButtons) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A,
|
||||
(ctx->m_state.ulButtons & STEAM_BUTTON_3_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B,
|
||||
(ctx->m_state.ulButtons & STEAM_BUTTON_1_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X,
|
||||
(ctx->m_state.ulButtons & STEAM_BUTTON_2_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y,
|
||||
(ctx->m_state.ulButtons & STEAM_BUTTON_0_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,
|
||||
(ctx->m_state.ulButtons & STEAM_LEFT_BUMPER_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,
|
||||
(ctx->m_state.ulButtons & STEAM_RIGHT_BUMPER_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK,
|
||||
(ctx->m_state.ulButtons & STEAM_BUTTON_MENU_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START,
|
||||
(ctx->m_state.ulButtons & STEAM_BUTTON_ESCAPE_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE,
|
||||
(ctx->m_state.ulButtons & STEAM_BUTTON_STEAM_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK,
|
||||
(ctx->m_state.ulButtons & STEAM_JOYSTICK_BUTTON_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1 + 0,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1 + 0,
|
||||
(ctx->m_state.ulButtons & STEAM_BUTTON_BACK_LEFT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1 + 1,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1 + 1,
|
||||
(ctx->m_state.ulButtons & STEAM_BUTTON_BACK_RIGHT_MASK) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
{
|
||||
|
@ -1161,26 +1161,26 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device)
|
|||
const int kPadDeadZone = 10000;
|
||||
|
||||
/* Pad coordinates are like math grid coordinates: negative is bottom left */
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP,
|
||||
(ctx->m_state.sLeftPadY > kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN,
|
||||
(ctx->m_state.sLeftPadY < -kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT,
|
||||
(ctx->m_state.sLeftPadX < -kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
|
||||
(ctx->m_state.sLeftPadX > kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, (int)ctx->m_state.sTriggerL * 2 - 32768);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, (int)ctx->m_state.sTriggerR * 2 - 32768);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, (int)ctx->m_state.sTriggerL * 2 - 32768);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, (int)ctx->m_state.sTriggerR * 2 - 32768);
|
||||
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, ctx->m_state.sLeftStickX);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, ~ctx->m_state.sLeftStickY);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, ctx->m_state.sRightPadX);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, ~ctx->m_state.sRightPadY);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, ctx->m_state.sLeftStickX);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, ~ctx->m_state.sLeftStickY);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, ctx->m_state.sRightPadX);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, ~ctx->m_state.sRightPadY);
|
||||
|
||||
if (ctx->report_sensors) {
|
||||
float values[3];
|
||||
|
@ -1190,12 +1190,12 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device)
|
|||
values[0] = (ctx->m_state.sGyroX / 32768.0f) * (2000.0f * (SDL_PI_F / 180.0f));
|
||||
values[1] = (ctx->m_state.sGyroZ / 32768.0f) * (2000.0f * (SDL_PI_F / 180.0f));
|
||||
values[2] = (ctx->m_state.sGyroY / 32768.0f) * (2000.0f * (SDL_PI_F / 180.0f));
|
||||
SDL_PrivateJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, ctx->sensor_timestamp, values, 3);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, ctx->sensor_timestamp, values, 3);
|
||||
|
||||
values[0] = (ctx->m_state.sAccelX / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
|
||||
values[1] = (ctx->m_state.sAccelZ / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
|
||||
values[2] = (-ctx->m_state.sAccelY / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
|
||||
SDL_PrivateJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, ctx->sensor_timestamp, values, 3);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, ctx->sensor_timestamp, values, 3);
|
||||
}
|
||||
|
||||
ctx->m_last_state = ctx->m_state;
|
||||
|
|
|
@ -1534,28 +1534,28 @@ static void HandleInputOnlyControllerState(SDL_Joystick *joystick, SDL_DriverSwi
|
|||
|
||||
if (packet->rgucButtons[0] != ctx->m_lastInputOnlyState.rgucButtons[0]) {
|
||||
Uint8 data = packet->rgucButtons[0];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
axis = (data & 0x40) ? 32767 : -32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
|
||||
axis = (data & 0x80) ? 32767 : -32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
}
|
||||
|
||||
if (packet->rgucButtons[1] != ctx->m_lastInputOnlyState.rgucButtons[1]) {
|
||||
Uint8 data = packet->rgucButtons[1];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (packet->ucStickHat != ctx->m_lastInputOnlyState.ucStickHat) {
|
||||
|
@ -1596,30 +1596,30 @@ static void HandleInputOnlyControllerState(SDL_Joystick *joystick, SDL_DriverSwi
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
|
||||
if (packet->rgucJoystickLeft[0] != ctx->m_lastInputOnlyState.rgucJoystickLeft[0]) {
|
||||
axis = (Sint16)HIDAPI_RemapVal(packet->rgucJoystickLeft[0], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
}
|
||||
|
||||
if (packet->rgucJoystickLeft[1] != ctx->m_lastInputOnlyState.rgucJoystickLeft[1]) {
|
||||
axis = (Sint16)HIDAPI_RemapVal(packet->rgucJoystickLeft[1], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
}
|
||||
|
||||
if (packet->rgucJoystickRight[0] != ctx->m_lastInputOnlyState.rgucJoystickRight[0]) {
|
||||
axis = (Sint16)HIDAPI_RemapVal(packet->rgucJoystickRight[0], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
}
|
||||
|
||||
if (packet->rgucJoystickRight[1] != ctx->m_lastInputOnlyState.rgucJoystickRight[1]) {
|
||||
axis = (Sint16)HIDAPI_RemapVal(packet->rgucJoystickRight[1], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
}
|
||||
|
||||
ctx->m_lastInputOnlyState = *packet;
|
||||
|
@ -1632,28 +1632,28 @@ static void HandleSimpleControllerState(SDL_Joystick *joystick, SDL_DriverSwitch
|
|||
|
||||
if (packet->rgucButtons[0] != ctx->m_lastSimpleState.rgucButtons[0]) {
|
||||
Uint8 data = packet->rgucButtons[0];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
axis = (data & 0x40) ? 32767 : -32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
|
||||
axis = (data & 0x80) ? 32767 : -32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
}
|
||||
|
||||
if (packet->rgucButtons[1] != ctx->m_lastSimpleState.rgucButtons[1]) {
|
||||
Uint8 data = packet->rgucButtons[1];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (packet->ucStickHat != ctx->m_lastSimpleState.ucStickHat) {
|
||||
|
@ -1694,23 +1694,23 @@ static void HandleSimpleControllerState(SDL_Joystick *joystick, SDL_DriverSwitch
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
|
||||
axis = ApplySimpleStickCalibration(ctx, 0, 0, packet->sJoystickLeft[0]);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
|
||||
axis = ApplySimpleStickCalibration(ctx, 0, 1, packet->sJoystickLeft[1]);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
|
||||
axis = ApplySimpleStickCalibration(ctx, 1, 0, packet->sJoystickRight[0]);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
|
||||
axis = ApplySimpleStickCalibration(ctx, 1, 1, packet->sJoystickRight[1]);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
|
||||
ctx->m_lastSimpleState = *packet;
|
||||
}
|
||||
|
@ -1756,7 +1756,7 @@ SendSensorUpdate(Uint64 timestamp, SDL_Joystick *joystick, SDL_DriverSwitch_Cont
|
|||
data[0] = -tmp;
|
||||
}
|
||||
|
||||
SDL_PrivateJoystickSensor(timestamp, joystick, type, sensor_timestamp, data, 3);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, type, sensor_timestamp, data, 3);
|
||||
}
|
||||
|
||||
static void HandleCombinedControllerStateL(Uint64 timestamp, SDL_Joystick *joystick, SDL_DriverSwitch_Context *ctx, SwitchStatePacket_t *packet)
|
||||
|
@ -1765,31 +1765,31 @@ static void HandleCombinedControllerStateL(Uint64 timestamp, SDL_Joystick *joyst
|
|||
|
||||
if (packet->controllerState.rgucButtons[1] != ctx->m_lastFullState.controllerState.rgucButtons[1]) {
|
||||
Uint8 data = packet->controllerState.rgucButtons[1];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (packet->controllerState.rgucButtons[2] != ctx->m_lastFullState.controllerState.rgucButtons[2]) {
|
||||
Uint8 data = packet->controllerState.rgucButtons[2];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE4, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE2, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE4, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE2, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
axis = (data & 0x80) ? 32767 : -32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
}
|
||||
|
||||
axis = packet->controllerState.rgucJoystickLeft[0] | ((packet->controllerState.rgucJoystickLeft[1] & 0xF) << 8);
|
||||
axis = ApplyStickCalibration(ctx, 0, 0, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
|
||||
axis = ((packet->controllerState.rgucJoystickLeft[1] & 0xF0) >> 4) | (packet->controllerState.rgucJoystickLeft[2] << 4);
|
||||
axis = ApplyStickCalibration(ctx, 0, 1, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, ~axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, ~axis);
|
||||
}
|
||||
|
||||
static void HandleMiniControllerStateL(Uint64 timestamp, SDL_Joystick *joystick, SDL_DriverSwitch_Context *ctx, SwitchStatePacket_t *packet)
|
||||
|
@ -1798,30 +1798,30 @@ static void HandleMiniControllerStateL(Uint64 timestamp, SDL_Joystick *joystick,
|
|||
|
||||
if (packet->controllerState.rgucButtons[1] != ctx->m_lastFullState.controllerState.rgucButtons[1]) {
|
||||
Uint8 data = packet->controllerState.rgucButtons[1];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (packet->controllerState.rgucButtons[2] != ctx->m_lastFullState.controllerState.rgucButtons[2]) {
|
||||
Uint8 data = packet->controllerState.rgucButtons[2];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE2, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE4, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE2, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE4, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
axis = packet->controllerState.rgucJoystickLeft[0] | ((packet->controllerState.rgucJoystickLeft[1] & 0xF) << 8);
|
||||
axis = ApplyStickCalibration(ctx, 0, 0, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, ~axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, ~axis);
|
||||
|
||||
axis = ((packet->controllerState.rgucJoystickLeft[1] & 0xF0) >> 4) | (packet->controllerState.rgucJoystickLeft[2] << 4);
|
||||
axis = ApplyStickCalibration(ctx, 0, 1, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, ~axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, ~axis);
|
||||
}
|
||||
|
||||
static void HandleCombinedControllerStateR(Uint64 timestamp, SDL_Joystick *joystick, SDL_DriverSwitch_Context *ctx, SwitchStatePacket_t *packet)
|
||||
|
@ -1830,31 +1830,31 @@ static void HandleCombinedControllerStateR(Uint64 timestamp, SDL_Joystick *joyst
|
|||
|
||||
if (packet->controllerState.rgucButtons[0] != ctx->m_lastFullState.controllerState.rgucButtons[0]) {
|
||||
Uint8 data = packet->controllerState.rgucButtons[0];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE1, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE3, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE1, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE3, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
axis = (data & 0x80) ? 32767 : -32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
}
|
||||
|
||||
if (packet->controllerState.rgucButtons[1] != ctx->m_lastFullState.controllerState.rgucButtons[1]) {
|
||||
Uint8 data = packet->controllerState.rgucButtons[1];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
axis = packet->controllerState.rgucJoystickRight[0] | ((packet->controllerState.rgucJoystickRight[1] & 0xF) << 8);
|
||||
axis = ApplyStickCalibration(ctx, 1, 0, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
|
||||
axis = ((packet->controllerState.rgucJoystickRight[1] & 0xF0) >> 4) | (packet->controllerState.rgucJoystickRight[2] << 4);
|
||||
axis = ApplyStickCalibration(ctx, 1, 1, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, ~axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, ~axis);
|
||||
}
|
||||
|
||||
static void HandleMiniControllerStateR(Uint64 timestamp, SDL_Joystick *joystick, SDL_DriverSwitch_Context *ctx, SwitchStatePacket_t *packet)
|
||||
|
@ -1863,30 +1863,30 @@ static void HandleMiniControllerStateR(Uint64 timestamp, SDL_Joystick *joystick,
|
|||
|
||||
if (packet->controllerState.rgucButtons[0] != ctx->m_lastFullState.controllerState.rgucButtons[0]) {
|
||||
Uint8 data = packet->controllerState.rgucButtons[0];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE1, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE3, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE1, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_PADDLE3, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (packet->controllerState.rgucButtons[1] != ctx->m_lastFullState.controllerState.rgucButtons[1]) {
|
||||
Uint8 data = packet->controllerState.rgucButtons[1];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
axis = packet->controllerState.rgucJoystickRight[0] | ((packet->controllerState.rgucJoystickRight[1] & 0xF) << 8);
|
||||
axis = ApplyStickCalibration(ctx, 1, 0, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
|
||||
axis = ((packet->controllerState.rgucJoystickRight[1] & 0xF0) >> 4) | (packet->controllerState.rgucJoystickRight[2] << 4);
|
||||
axis = ApplyStickCalibration(ctx, 1, 1, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
}
|
||||
|
||||
static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_Context *ctx, SwitchStatePacket_t *packet) SDL_NO_THREAD_SAFETY_ANALYSIS /* We unlock and lock the device lock to be able to change IMU state */
|
||||
|
@ -1910,72 +1910,72 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C
|
|||
|
||||
if (packet->controllerState.rgucButtons[0] != ctx->m_lastFullState.controllerState.rgucButtons[0]) {
|
||||
Uint8 data = packet->controllerState.rgucButtons[0];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_A), (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_B), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_X), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, RemapButton(ctx, SDL_GAMEPAD_BUTTON_Y), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
axis = (data & 0x80) ? 32767 : -32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
}
|
||||
|
||||
if (packet->controllerState.rgucButtons[1] != ctx->m_lastFullState.controllerState.rgucButtons[1]) {
|
||||
Uint8 data = packet->controllerState.rgucButtons[1];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (packet->controllerState.rgucButtons[2] != ctx->m_lastFullState.controllerState.rgucButtons[2]) {
|
||||
Uint8 data = packet->controllerState.rgucButtons[2];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
axis = (data & 0x80) ? 32767 : -32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
}
|
||||
|
||||
axis = packet->controllerState.rgucJoystickLeft[0] | ((packet->controllerState.rgucJoystickLeft[1] & 0xF) << 8);
|
||||
axis = ApplyStickCalibration(ctx, 0, 0, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
|
||||
axis = ((packet->controllerState.rgucJoystickLeft[1] & 0xF0) >> 4) | (packet->controllerState.rgucJoystickLeft[2] << 4);
|
||||
axis = ApplyStickCalibration(ctx, 0, 1, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, ~axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, ~axis);
|
||||
|
||||
axis = packet->controllerState.rgucJoystickRight[0] | ((packet->controllerState.rgucJoystickRight[1] & 0xF) << 8);
|
||||
axis = ApplyStickCalibration(ctx, 1, 0, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
|
||||
axis = ((packet->controllerState.rgucJoystickRight[1] & 0xF0) >> 4) | (packet->controllerState.rgucJoystickRight[2] << 4);
|
||||
axis = ApplyStickCalibration(ctx, 1, 1, axis);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, ~axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, ~axis);
|
||||
}
|
||||
|
||||
/* High nibble of battery/connection byte is battery level, low nibble is connection status
|
||||
* LSB of connection nibble is USB/Switch connection status
|
||||
*/
|
||||
if (packet->controllerState.ucBatteryAndConnection & 0x1) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
|
||||
} else {
|
||||
/* LSB of the battery nibble is used to report charging.
|
||||
* The battery level is reported from 0(empty)-8(full)
|
||||
*/
|
||||
int level = (packet->controllerState.ucBatteryAndConnection & 0xE0) >> 4;
|
||||
if (level == 0) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
} else if (level <= 2) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
} else if (level <= 6) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
} else {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -493,13 +493,13 @@ static void DeactivateMotionPlus(SDL_DriverWii_Context *ctx)
|
|||
static void UpdatePowerLevelWii(SDL_Joystick *joystick, Uint8 batteryLevelByte)
|
||||
{
|
||||
if (batteryLevelByte > 178) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
} else if (batteryLevelByte > 51) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
} else if (batteryLevelByte > 13) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
} else {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,15 +516,15 @@ static void UpdatePowerLevelWiiU(SDL_Joystick *joystick, Uint8 extensionBatteryB
|
|||
* No value above 4 has been observed.
|
||||
*/
|
||||
if (pluggedIn && !charging) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
|
||||
} else if (batteryLevel >= 4) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
} else if (batteryLevel > 1) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
} else if (batteryLevel == 1) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
} else {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -900,7 +900,7 @@ static void PostStickCalibrated(Uint64 timestamp, SDL_Joystick *joystick, struct
|
|||
value = ~value;
|
||||
}
|
||||
}
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, axis, value);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, axis, value);
|
||||
}
|
||||
|
||||
/* Send button data to SDL
|
||||
|
@ -919,7 +919,7 @@ static void PostPackedButtonData(Uint64 timestamp, SDL_Joystick *joystick, const
|
|||
Uint8 button = defs[i][j];
|
||||
if (button != 0xFF) {
|
||||
Uint8 state = (data[i] >> j) & 1 ? on : off;
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, button, state);
|
||||
SDL_SendJoystickButton(timestamp, joystick, button, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1097,8 +1097,8 @@ static void HandleWiiUProButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *jo
|
|||
/* Triggers */
|
||||
zl = data->rgucExtension[9] & 0x80;
|
||||
zr = data->rgucExtension[9] & 0x04;
|
||||
SDL_PrivateJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, zl ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX);
|
||||
SDL_PrivateJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, zr ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX);
|
||||
SDL_SendJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, zl ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX);
|
||||
SDL_SendJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, zr ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX);
|
||||
|
||||
/* Sticks */
|
||||
for (i = 0; i < 4; i++) {
|
||||
|
@ -1128,8 +1128,8 @@ static void HandleGamepadControllerButtonData(SDL_DriverWii_Context *ctx, SDL_Jo
|
|||
/* Triggers */
|
||||
zl = data->rgucExtension[5] & 0x80;
|
||||
zr = data->rgucExtension[5] & 0x04;
|
||||
SDL_PrivateJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, zl ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX);
|
||||
SDL_PrivateJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, zr ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX);
|
||||
SDL_SendJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, zl ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX);
|
||||
SDL_SendJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, zr ? SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX);
|
||||
|
||||
/* Sticks */
|
||||
if (ctx->m_ucMotionPlusMode == WII_MOTIONPLUS_MODE_GAMEPAD) {
|
||||
|
@ -1224,8 +1224,8 @@ static void HandleNunchuckButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *j
|
|||
c_button = (data->rgucExtension[5] & 0x02) ? SDL_RELEASED : SDL_PRESSED;
|
||||
z_button = (data->rgucExtension[5] & 0x01) ? SDL_RELEASED : SDL_PRESSED;
|
||||
}
|
||||
SDL_PrivateJoystickButton(ctx->timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, c_button);
|
||||
SDL_PrivateJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, z_button ? SDL_JOYSTICK_AXIS_MAX : SDL_JOYSTICK_AXIS_MIN);
|
||||
SDL_SendJoystickButton(ctx->timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, c_button);
|
||||
SDL_SendJoystickAxis(ctx->timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, z_button ? SDL_JOYSTICK_AXIS_MAX : SDL_JOYSTICK_AXIS_MIN);
|
||||
PostStickCalibrated(ctx->timestamp, joystick, &ctx->m_StickCalibrationData[0], SDL_GAMEPAD_AXIS_LEFTX, data->rgucExtension[0]);
|
||||
PostStickCalibrated(ctx->timestamp, joystick, &ctx->m_StickCalibrationData[1], SDL_GAMEPAD_AXIS_LEFTY, data->rgucExtension[1]);
|
||||
|
||||
|
@ -1256,7 +1256,7 @@ static void HandleNunchuckButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *j
|
|||
values[0] = -((float)x / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY;
|
||||
values[1] = ((float)z / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY;
|
||||
values[2] = ((float)y / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY;
|
||||
SDL_PrivateJoystickSensor(ctx->timestamp, joystick, SDL_SENSOR_ACCEL_L, ctx->timestamp, values, 3);
|
||||
SDL_SendJoystickSensor(ctx->timestamp, joystick, SDL_SENSOR_ACCEL_L, ctx->timestamp, values, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1296,7 +1296,7 @@ static void HandleMotionPlusData(SDL_DriverWii_Context *ctx, SDL_Joystick *joyst
|
|||
values[0] = -((float)z / GYRO_RES_PER_DEGREE) * SDL_PI_F / 180.0f;
|
||||
values[1] = ((float)x / GYRO_RES_PER_DEGREE) * SDL_PI_F / 180.0f;
|
||||
values[2] = ((float)y / GYRO_RES_PER_DEGREE) * SDL_PI_F / 180.0f;
|
||||
SDL_PrivateJoystickSensor(ctx->timestamp, joystick, SDL_SENSOR_GYRO, ctx->timestamp, values, 3);
|
||||
SDL_SendJoystickSensor(ctx->timestamp, joystick, SDL_SENSOR_GYRO, ctx->timestamp, values, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1317,7 +1317,7 @@ static void HandleWiiRemoteAccelData(SDL_DriverWii_Context *ctx, SDL_Joystick *j
|
|||
values[0] = -((float)x / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY;
|
||||
values[1] = ((float)z / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY;
|
||||
values[2] = ((float)y / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY;
|
||||
SDL_PrivateJoystickSensor(ctx->timestamp, joystick, SDL_SENSOR_ACCEL, ctx->timestamp, values, 3);
|
||||
SDL_SendJoystickSensor(ctx->timestamp, joystick, SDL_SENSOR_ACCEL, ctx->timestamp, values, 3);
|
||||
}
|
||||
|
||||
static void HandleButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick, WiiButtonData *data)
|
||||
|
|
|
@ -268,44 +268,44 @@ static void HIDAPI_DriverXbox360_HandleStatePacket(SDL_Joystick *joystick, SDL_D
|
|||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
if (ctx->last_state[2] != data[2]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data[2] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data[2] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[3] != data[3]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[3] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[3] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[3] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[3] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[3] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[3] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
axis = ((int)data[4] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
axis = ((int)data[5] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[6]));
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[8]));
|
||||
if (invert_y_axes) {
|
||||
axis = ~axis;
|
||||
}
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[10]));
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[12]));
|
||||
if (invert_y_axes) {
|
||||
axis = ~axis;
|
||||
}
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
|
||||
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
|
||||
}
|
||||
|
|
|
@ -111,13 +111,13 @@ static void UpdatePowerLevel(SDL_Joystick *joystick, Uint8 level)
|
|||
float normalized_level = (float)level / 255.0f;
|
||||
|
||||
if (normalized_level <= 0.05f) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
|
||||
} else if (normalized_level <= 0.20f) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
} else if (normalized_level <= 0.70f) {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
} else {
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,44 +237,44 @@ static void HIDAPI_DriverXbox360W_HandleStatePacket(SDL_Joystick *joystick, SDL_
|
|||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
if (ctx->last_state[2] != data[2]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data[2] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data[2] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[3] != data[3]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[3] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[3] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[3] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[3] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[3] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[3] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
axis = ((int)data[4] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
axis = ((int)data[5] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[6]));
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[8]));
|
||||
if (invert_y_axes) {
|
||||
axis = ~axis;
|
||||
}
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[10]));
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[12]));
|
||||
if (invert_y_axes) {
|
||||
axis = ~axis;
|
||||
}
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
|
||||
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
|
||||
}
|
||||
|
|
|
@ -639,10 +639,10 @@ static void HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(SDL_Joystick *joystic
|
|||
|
||||
if (ctx->last_paddle_state != data[paddle_index]) {
|
||||
int nButton = SDL_GAMEPAD_BUTTON_MISC1 + ctx->has_share_button; /* Next available button */
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button4_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button4_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
ctx->last_paddle_state = data[paddle_index];
|
||||
}
|
||||
ctx->has_unmapped_state = SDL_TRUE;
|
||||
|
@ -654,29 +654,29 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D
|
|||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
if (ctx->last_state[4] != data[4]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[4] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[4] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[4] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[4] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[4] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[4] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[4] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[4] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[4] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[4] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[4] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[4] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[5] != data[5]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data[5] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data[5] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data[5] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data[5] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, (data[5] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, (data[5] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, (data[5] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, (data[5] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
if (ctx->vendor_id == USB_VENDOR_RAZER && ctx->product_id == USB_PRODUCT_RAZER_ATROX) {
|
||||
/* The Razer Atrox has the right and left shoulder bits reversed */
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[5] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[5] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[5] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[5] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
} else {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[5] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[5] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[5] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[5] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[5] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[5] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[5] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[5] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->has_share_button) {
|
||||
|
@ -687,15 +687,15 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D
|
|||
*/
|
||||
if (size < 48) {
|
||||
if (ctx->last_state[18] != data[18]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[18] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[18] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
} else if (size == 48) {
|
||||
if (ctx->last_state[22] != data[22]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[22] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[22] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
} else if (size == 50) {
|
||||
if (ctx->last_state[32] != data[32]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[32] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[32] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -767,10 +767,10 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D
|
|||
|
||||
if (ctx->last_paddle_state != data[paddle_index]) {
|
||||
int nButton = SDL_GAMEPAD_BUTTON_MISC1 + ctx->has_share_button; /* Next available button */
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button4_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button4_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
ctx->last_paddle_state = data[paddle_index];
|
||||
}
|
||||
}
|
||||
|
@ -782,7 +782,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D
|
|||
if (axis == -32768 && size == 30 && (data[22] & 0x80) != 0) {
|
||||
axis = 32767;
|
||||
}
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
|
||||
axis = ((int)SDL_SwapLE16(*(Sint16 *)(&data[8])) * 64) - 32768;
|
||||
if (axis == -32768 && size == 30 && (data[22] & 0x40) != 0) {
|
||||
|
@ -791,16 +791,16 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D
|
|||
if (axis == 32704) {
|
||||
axis = 32767;
|
||||
}
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[10]));
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[12]));
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, ~axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, ~axis);
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[14]));
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = SDL_SwapLE16(*(Sint16 *)(&data[16]));
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, ~axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, ~axis);
|
||||
|
||||
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
|
||||
}
|
||||
|
@ -816,7 +816,7 @@ static void HIDAPI_DriverXboxOne_HandleModePacket(SDL_Joystick *joystick, SDL_Dr
|
|||
{
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -825,19 +825,19 @@ static void HIDAPI_DriverXboxOne_HandleModePacket(SDL_Joystick *joystick, SDL_Dr
|
|||
static void HIDAPI_DriverXboxOneBluetooth_HandleButtons16(Uint64 timestamp, SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, const Uint8 *data, int size)
|
||||
{
|
||||
if (ctx->last_state[14] != data[14]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[14] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[14] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[14] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[14] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[14] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[14] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[14] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[14] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[14] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[14] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[14] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[14] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[14] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[14] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[15] != data[15]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[15] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[15] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[15] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[15] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -852,28 +852,28 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleButtons16(Uint64 timestamp, SDL_
|
|||
static void HIDAPI_DriverXboxOneBluetooth_HandleButtons(Uint64 timestamp, SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
|
||||
{
|
||||
if (ctx->last_state[14] != data[14]) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[14] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[14] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[14] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[14] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[14] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[14] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[14] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[14] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[14] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[14] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[15] != data[15]) {
|
||||
if (!ctx->has_guide_packet) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[15] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[15] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[15] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[15] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[15] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[15] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, (data[15] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[15] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->has_share_button) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[15] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[16] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[15] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[16] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
} else {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, ((data[15] & 0x04) || (data[16] & 0x01)) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, ((data[15] & 0x04) || (data[16] & 0x01)) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -931,10 +931,10 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleButtons(Uint64 timestamp, SDL_Jo
|
|||
|
||||
if (ctx->last_paddle_state != data[paddle_index]) {
|
||||
int nButton = SDL_GAMEPAD_BUTTON_MISC1; /* Next available button */
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button4_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button4_bit) ? SDL_PRESSED : SDL_RELEASED);
|
||||
ctx->last_paddle_state = data[paddle_index];
|
||||
}
|
||||
}
|
||||
|
@ -995,32 +995,32 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleStatePacket(SDL_Joystick *joysti
|
|||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
|
||||
axis = ((int)SDL_SwapLE16(*(Sint16 *)(&data[9])) * 64) - 32768;
|
||||
if (axis == 32704) {
|
||||
axis = 32767;
|
||||
}
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, axis);
|
||||
|
||||
axis = ((int)SDL_SwapLE16(*(Sint16 *)(&data[11])) * 64) - 32768;
|
||||
if (axis == 32704) {
|
||||
axis = 32767;
|
||||
}
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, axis);
|
||||
|
||||
axis = (int)SDL_SwapLE16(*(Uint16 *)(&data[1])) - 0x8000;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTX, axis);
|
||||
axis = (int)SDL_SwapLE16(*(Uint16 *)(&data[3])) - 0x8000;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_LEFTY, axis);
|
||||
axis = (int)SDL_SwapLE16(*(Uint16 *)(&data[5])) - 0x8000;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
||||
axis = (int)SDL_SwapLE16(*(Uint16 *)(&data[7])) - 0x8000;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
|
||||
|
||||
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
|
||||
}
|
||||
|
@ -1030,7 +1030,7 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(SDL_Joystick *joysti
|
|||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
ctx->has_guide_packet = SDL_TRUE;
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
static void HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, const Uint8 *data, int size)
|
||||
|
@ -1040,17 +1040,17 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(SDL_Joystick *joys
|
|||
|
||||
if (on_usb) {
|
||||
/* Does this ever happen? */
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
|
||||
} else {
|
||||
switch ((flags & 0x03)) {
|
||||
case 0:
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
|
||||
break;
|
||||
case 1:
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
|
||||
break;
|
||||
default: /* 2, 3 */
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -797,7 +797,7 @@ static int LINUX_JoystickGetCount(void)
|
|||
return numjoysticks;
|
||||
}
|
||||
|
||||
static SDL_joylist_item *JoystickByDevIndex(int device_index)
|
||||
static SDL_joylist_item *GetJoystickByDevIndex(int device_index)
|
||||
{
|
||||
SDL_joylist_item *item = SDL_joylist;
|
||||
|
||||
|
@ -816,12 +816,12 @@ static SDL_joylist_item *JoystickByDevIndex(int device_index)
|
|||
|
||||
static const char *LINUX_JoystickGetDeviceName(int device_index)
|
||||
{
|
||||
return JoystickByDevIndex(device_index)->name;
|
||||
return GetJoystickByDevIndex(device_index)->name;
|
||||
}
|
||||
|
||||
static const char *LINUX_JoystickGetDevicePath(int device_index)
|
||||
{
|
||||
return JoystickByDevIndex(device_index)->path;
|
||||
return GetJoystickByDevIndex(device_index)->path;
|
||||
}
|
||||
|
||||
static int LINUX_JoystickGetDevicePlayerIndex(int device_index)
|
||||
|
@ -835,13 +835,13 @@ static void LINUX_JoystickSetDevicePlayerIndex(int device_index, int player_inde
|
|||
|
||||
static SDL_JoystickGUID LINUX_JoystickGetDeviceGUID(int device_index)
|
||||
{
|
||||
return JoystickByDevIndex(device_index)->guid;
|
||||
return GetJoystickByDevIndex(device_index)->guid;
|
||||
}
|
||||
|
||||
/* Function to perform the mapping from device index to the instance id for this index */
|
||||
static SDL_JoystickID LINUX_JoystickGetDeviceInstanceID(int device_index)
|
||||
{
|
||||
return JoystickByDevIndex(device_index)->device_instance;
|
||||
return GetJoystickByDevIndex(device_index)->device_instance;
|
||||
}
|
||||
|
||||
static int allocate_hatdata(SDL_Joystick *joystick)
|
||||
|
@ -1155,7 +1155,7 @@ static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item)
|
|||
*/
|
||||
static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
{
|
||||
SDL_joylist_item *item = JoystickByDevIndex(device_index);
|
||||
SDL_joylist_item *item = GetJoystickByDevIndex(device_index);
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
|
@ -1305,7 +1305,7 @@ static void HandleHat(Uint64 timestamp, SDL_Joystick *stick, int hatidx, int axi
|
|||
}
|
||||
if (value != the_hat->axis[axis]) {
|
||||
the_hat->axis[axis] = value;
|
||||
SDL_PrivateJoystickHat(timestamp, stick, hatnum,
|
||||
SDL_SendJoystickHat(timestamp, stick, hatnum,
|
||||
position_map[the_hat->axis[1]][the_hat->axis[0]]);
|
||||
}
|
||||
}
|
||||
|
@ -1364,7 +1364,7 @@ static void PollAllValues(Uint64 timestamp, SDL_Joystick *joystick)
|
|||
SDL_Log("Joystick : Re-read Axis %d (%d) val= %d\n",
|
||||
joystick->hwdata->abs_map[i], i, absinfo.value);
|
||||
#endif
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick,
|
||||
SDL_SendJoystickAxis(timestamp, joystick,
|
||||
joystick->hwdata->abs_map[i],
|
||||
absinfo.value);
|
||||
}
|
||||
|
@ -1395,7 +1395,7 @@ static void PollAllValues(Uint64 timestamp, SDL_Joystick *joystick)
|
|||
SDL_Log("Joystick : Re-read Button %d (%d) val= %d\n",
|
||||
joystick->hwdata->key_map[i], i, value);
|
||||
#endif
|
||||
SDL_PrivateJoystickButton(timestamp, joystick,
|
||||
SDL_SendJoystickButton(timestamp, joystick,
|
||||
joystick->hwdata->key_map[i], value);
|
||||
}
|
||||
}
|
||||
|
@ -1430,7 +1430,7 @@ static void HandleInputEvents(SDL_Joystick *joystick)
|
|||
|
||||
switch (event->type) {
|
||||
case EV_KEY:
|
||||
SDL_PrivateJoystickButton(SDL_EVDEV_GetEventTimestamp(event), joystick,
|
||||
SDL_SendJoystickButton(SDL_EVDEV_GetEventTimestamp(event), joystick,
|
||||
joystick->hwdata->key_map[code],
|
||||
event->value);
|
||||
break;
|
||||
|
@ -1451,7 +1451,7 @@ static void HandleInputEvents(SDL_Joystick *joystick)
|
|||
}
|
||||
default:
|
||||
event->value = AxisCorrect(joystick, code, event->value);
|
||||
SDL_PrivateJoystickAxis(SDL_EVDEV_GetEventTimestamp(event), joystick,
|
||||
SDL_SendJoystickAxis(SDL_EVDEV_GetEventTimestamp(event), joystick,
|
||||
joystick->hwdata->abs_map[code],
|
||||
event->value);
|
||||
break;
|
||||
|
@ -1501,7 +1501,7 @@ static void HandleClassicEvents(SDL_Joystick *joystick)
|
|||
switch (events[i].type) {
|
||||
case JS_EVENT_BUTTON:
|
||||
code = joystick->hwdata->key_pam[events[i].number];
|
||||
SDL_PrivateJoystickButton(timestamp, joystick,
|
||||
SDL_SendJoystickButton(timestamp, joystick,
|
||||
joystick->hwdata->key_map[code],
|
||||
events[i].value);
|
||||
break;
|
||||
|
@ -1522,7 +1522,7 @@ static void HandleClassicEvents(SDL_Joystick *joystick)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick,
|
||||
SDL_SendJoystickAxis(timestamp, joystick,
|
||||
joystick->hwdata->abs_map[code],
|
||||
events[i].value);
|
||||
break;
|
||||
|
@ -1609,7 +1609,7 @@ static void LINUX_JoystickQuit(void)
|
|||
static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
||||
{
|
||||
SDL_Joystick *joystick;
|
||||
SDL_joylist_item *item = JoystickByDevIndex(device_index);
|
||||
SDL_joylist_item *item = GetJoystickByDevIndex(device_index);
|
||||
unsigned int mapped;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
|
|
@ -110,7 +110,7 @@ static void UpdateN3DSPressedButtons(Uint64 timestamp, SDL_Joystick *joystick)
|
|||
if (updated_down) {
|
||||
for (Uint8 i = 0; i < joystick->nbuttons; i++) {
|
||||
if (current_state & BIT(i) & updated_down) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, i, SDL_PRESSED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, SDL_PRESSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ static void UpdateN3DSReleasedButtons(Uint64 timestamp, SDL_Joystick *joystick)
|
|||
if (updated_up) {
|
||||
for (Uint8 i = 0; i < joystick->nbuttons; i++) {
|
||||
if (current_state & BIT(i) & updated_up) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, i, SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, SDL_RELEASED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,12 +139,12 @@ static void UpdateN3DSCircle(Uint64 timestamp, SDL_Joystick *joystick)
|
|||
circlePosition current_state;
|
||||
hidCircleRead(¤t_state);
|
||||
if (previous_state.dx != current_state.dx) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick,
|
||||
SDL_SendJoystickAxis(timestamp, joystick,
|
||||
0,
|
||||
CORRECT_AXIS_X(current_state.dx));
|
||||
}
|
||||
if (previous_state.dy != current_state.dy) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick,
|
||||
SDL_SendJoystickAxis(timestamp, joystick,
|
||||
1,
|
||||
CORRECT_AXIS_Y(current_state.dy));
|
||||
}
|
||||
|
@ -157,12 +157,12 @@ static void UpdateN3DSCStick(Uint64 timestamp, SDL_Joystick *joystick)
|
|||
circlePosition current_state;
|
||||
hidCstickRead(¤t_state);
|
||||
if (previous_state.dx != current_state.dx) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick,
|
||||
SDL_SendJoystickAxis(timestamp, joystick,
|
||||
2,
|
||||
CORRECT_AXIS_X(current_state.dx));
|
||||
}
|
||||
if (previous_state.dy != current_state.dy) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick,
|
||||
SDL_SendJoystickAxis(timestamp, joystick,
|
||||
3,
|
||||
CORRECT_AXIS_Y(current_state.dy));
|
||||
}
|
||||
|
|
|
@ -290,7 +290,7 @@ static void PS2_JoystickUpdate(SDL_Joystick *joystick)
|
|||
previous = info->btns & mask;
|
||||
current = pressed_buttons & mask;
|
||||
if (previous != current) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, i, current ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, current ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ static void PS2_JoystickUpdate(SDL_Joystick *joystick)
|
|||
previous_axis = info->analog_state[i];
|
||||
current_axis = all_axis[i];
|
||||
if (previous_axis != current_axis) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, i, convert_u8_to_s16(current_axis));
|
||||
SDL_SendJoystickAxis(timestamp, joystick, i, convert_u8_to_s16(current_axis));
|
||||
}
|
||||
|
||||
info->analog_state[i] = current_axis;
|
||||
|
|
|
@ -210,11 +210,11 @@ static void PSP_JoystickUpdate(SDL_Joystick *joystick)
|
|||
|
||||
/* Axes */
|
||||
if (old_x != x) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 0, analog_map[x]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 0, analog_map[x]);
|
||||
old_x = x;
|
||||
}
|
||||
if (old_y != y) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 1, analog_map[y]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 1, analog_map[y]);
|
||||
old_y = y;
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ static void PSP_JoystickUpdate(SDL_Joystick *joystick)
|
|||
if (changed) {
|
||||
for (i = 0; i < SDL_arraysize(button_map); i++) {
|
||||
if (changed & button_map[i]) {
|
||||
SDL_PrivateJoystickButton(timestamp,
|
||||
SDL_SendJoystickButton(timestamp,
|
||||
joystick, i,
|
||||
(buttons & button_map[i]) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ int SDL_JoystickDetachVirtualInner(int device_index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 value)
|
||||
int SDL_SetJoystickVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 value)
|
||||
{
|
||||
joystick_hwdata *hwdata;
|
||||
|
||||
|
@ -279,7 +279,7 @@ int SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 val
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 value)
|
||||
int SDL_SetJoystickVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 value)
|
||||
{
|
||||
joystick_hwdata *hwdata;
|
||||
|
||||
|
@ -302,7 +302,7 @@ int SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SDL_JoystickSetVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value)
|
||||
int SDL_SetJoystickVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value)
|
||||
{
|
||||
joystick_hwdata *hwdata;
|
||||
|
||||
|
@ -543,13 +543,13 @@ static void VIRTUAL_JoystickUpdate(SDL_Joystick *joystick)
|
|||
}
|
||||
|
||||
for (i = 0; i < hwdata->desc.naxes; ++i) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, i, hwdata->axes[i]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, i, hwdata->axes[i]);
|
||||
}
|
||||
for (i = 0; i < hwdata->desc.nbuttons; ++i) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, i, hwdata->buttons[i]);
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, hwdata->buttons[i]);
|
||||
}
|
||||
for (i = 0; i < hwdata->desc.nhats; ++i) {
|
||||
SDL_PrivateJoystickHat(timestamp, joystick, i, hwdata->hats[i]);
|
||||
SDL_SendJoystickHat(timestamp, joystick, i, hwdata->hats[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,9 @@ typedef struct joystick_hwdata
|
|||
int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc);
|
||||
int SDL_JoystickDetachVirtualInner(int device_index);
|
||||
|
||||
int SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 value);
|
||||
int SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 value);
|
||||
int SDL_JoystickSetVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value);
|
||||
int SDL_SetJoystickVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 value);
|
||||
int SDL_SetJoystickVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 value);
|
||||
int SDL_SetJoystickVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value);
|
||||
|
||||
#endif /* SDL_JOYSTICK_VIRTUAL */
|
||||
|
||||
|
|
|
@ -260,28 +260,28 @@ static void VITA_JoystickUpdate(SDL_Joystick *joystick)
|
|||
// Axes
|
||||
|
||||
if (old_lx[index] != lx) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 0, analog_map[lx]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 0, analog_map[lx]);
|
||||
old_lx[index] = lx;
|
||||
}
|
||||
if (old_ly[index] != ly) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 1, analog_map[ly]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 1, analog_map[ly]);
|
||||
old_ly[index] = ly;
|
||||
}
|
||||
if (old_rx[index] != rx) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 2, analog_map[rx]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 2, analog_map[rx]);
|
||||
old_rx[index] = rx;
|
||||
}
|
||||
if (old_ry[index] != ry) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 3, analog_map[ry]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 3, analog_map[ry]);
|
||||
old_ry[index] = ry;
|
||||
}
|
||||
|
||||
if (old_lt[index] != lt) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 4, analog_map[lt]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 4, analog_map[lt]);
|
||||
old_lt[index] = lt;
|
||||
}
|
||||
if (old_rt[index] != rt) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 5, analog_map[rt]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 5, analog_map[rt]);
|
||||
old_rt[index] = rt;
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ static void VITA_JoystickUpdate(SDL_Joystick *joystick)
|
|||
if (changed) {
|
||||
for (i = 0; i < SDL_arraysize(ext_button_map); i++) {
|
||||
if (changed & ext_button_map[i]) {
|
||||
SDL_PrivateJoystickButton(timestamp,
|
||||
SDL_SendJoystickButton(timestamp,
|
||||
joystick, i,
|
||||
(buttons & ext_button_map[i]) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
|
|
@ -1010,40 +1010,40 @@ static void UpdateDINPUTJoystickState_Polled(SDL_Joystick *joystick)
|
|||
case AXIS:
|
||||
switch (in->ofs) {
|
||||
case DIJOFS_X:
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lX);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lX);
|
||||
break;
|
||||
case DIJOFS_Y:
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lY);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lY);
|
||||
break;
|
||||
case DIJOFS_Z:
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lZ);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lZ);
|
||||
break;
|
||||
case DIJOFS_RX:
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lRx);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lRx);
|
||||
break;
|
||||
case DIJOFS_RY:
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lRy);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lRy);
|
||||
break;
|
||||
case DIJOFS_RZ:
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lRz);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, in->num, (Sint16)state.lRz);
|
||||
break;
|
||||
case DIJOFS_SLIDER(0):
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, in->num, (Sint16)state.rglSlider[0]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, in->num, (Sint16)state.rglSlider[0]);
|
||||
break;
|
||||
case DIJOFS_SLIDER(1):
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, in->num, (Sint16)state.rglSlider[1]);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, in->num, (Sint16)state.rglSlider[1]);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BUTTON:
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, in->num,
|
||||
SDL_SendJoystickButton(timestamp, joystick, in->num,
|
||||
(Uint8)(state.rgbButtons[in->ofs - DIJOFS_BUTTON0] ? SDL_PRESSED : SDL_RELEASED));
|
||||
break;
|
||||
case HAT:
|
||||
{
|
||||
Uint8 pos = TranslatePOV(state.rgdwPOV[in->ofs - DIJOFS_POV(0)]);
|
||||
SDL_PrivateJoystickHat(timestamp, joystick, in->num, pos);
|
||||
SDL_SendJoystickHat(timestamp, joystick, in->num, pos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1088,16 +1088,16 @@ static void UpdateDINPUTJoystickState_Buffered(SDL_Joystick *joystick)
|
|||
|
||||
switch (in->type) {
|
||||
case AXIS:
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, in->num, (Sint16)evtbuf[i].dwData);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, in->num, (Sint16)evtbuf[i].dwData);
|
||||
break;
|
||||
case BUTTON:
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, in->num,
|
||||
SDL_SendJoystickButton(timestamp, joystick, in->num,
|
||||
(Uint8)(evtbuf[i].dwData ? SDL_PRESSED : SDL_RELEASED));
|
||||
break;
|
||||
case HAT:
|
||||
{
|
||||
Uint8 pos = TranslatePOV(evtbuf[i].dwData);
|
||||
SDL_PrivateJoystickHat(timestamp, joystick, in->num, pos);
|
||||
SDL_SendJoystickHat(timestamp, joystick, in->num, pos);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -964,7 +964,7 @@ static void RAWINPUT_PostUpdate(void)
|
|||
if (ctx->guide_hack) {
|
||||
int guide_button = joystick->nbuttons - 1;
|
||||
|
||||
SDL_PrivateJoystickButton(SDL_GetTicksNS(), guide_button_candidate.joystick, guide_button, SDL_PRESSED);
|
||||
SDL_SendJoystickButton(SDL_GetTicksNS(), guide_button_candidate.joystick, guide_button, SDL_PRESSED);
|
||||
}
|
||||
guide_button_candidate.last_joystick = guide_button_candidate.joystick;
|
||||
}
|
||||
|
@ -974,7 +974,7 @@ static void RAWINPUT_PostUpdate(void)
|
|||
if (ctx->guide_hack) {
|
||||
int guide_button = joystick->nbuttons - 1;
|
||||
|
||||
SDL_PrivateJoystickButton(SDL_GetTicksNS(), joystick, guide_button, SDL_RELEASED);
|
||||
SDL_SendJoystickButton(SDL_GetTicksNS(), joystick, guide_button, SDL_RELEASED);
|
||||
}
|
||||
guide_button_candidate.last_joystick = NULL;
|
||||
}
|
||||
|
@ -1399,22 +1399,22 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int
|
|||
};
|
||||
Uint64 match_state = ctx->match_state;
|
||||
/* Update match_state with button bit, then fall through */
|
||||
#define SDL_PrivateJoystickButton(timestamp, joystick, button, state) \
|
||||
#define SDL_SendJoystickButton(timestamp, joystick, button, state) \
|
||||
if (button < SDL_arraysize(button_map)) { \
|
||||
Uint64 button_bit = 1ull << button_map[button]; \
|
||||
match_state = (match_state & ~button_bit) | (button_bit * (state)); \
|
||||
} \
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, button, state)
|
||||
SDL_SendJoystickButton(timestamp, joystick, button, state)
|
||||
#ifdef SDL_JOYSTICK_RAWINPUT_MATCH_AXES
|
||||
/* Grab high 4 bits of value, then fall through */
|
||||
#define AddAxisToMatchState(axis, value) \
|
||||
{ \
|
||||
match_state = (match_state & ~(0xFull << (4 * axis + 16))) | ((value)&0xF000ull) << (4 * axis + 4); \
|
||||
}
|
||||
#define SDL_PrivateJoystickAxis(timestamp, joystick, axis, value) \
|
||||
#define SDL_SendJoystickAxis(timestamp, joystick, axis, value) \
|
||||
if (axis < 4) \
|
||||
AddAxisToMatchState(axis, value); \
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, axis, value)
|
||||
SDL_SendJoystickAxis(timestamp, joystick, axis, value)
|
||||
#endif
|
||||
#endif /* SDL_JOYSTICK_RAWINPUT_MATCHING */
|
||||
|
||||
|
@ -1437,14 +1437,14 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int
|
|||
}
|
||||
}
|
||||
for (i = 0; i < nbuttons; ++i) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, i, (button_mask & (1 << i)) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, (button_mask & (1 << i)) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
for (i = 0; i < naxes; ++i) {
|
||||
HIDP_DATA *item = GetData(ctx->axis_indices[i], ctx->data, data_length);
|
||||
if (item) {
|
||||
Sint16 axis = (int)(Uint16)item->RawValue - 0x8000;
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, i, axis);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, i, axis);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1472,15 +1472,15 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int
|
|||
#endif
|
||||
hat = hat_states[state];
|
||||
}
|
||||
SDL_PrivateJoystickHat(timestamp, joystick, i, hat);
|
||||
SDL_SendJoystickHat(timestamp, joystick, i, hat);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SDL_PrivateJoystickButton
|
||||
#undef SDL_PrivateJoystickButton
|
||||
#ifdef SDL_SendJoystickButton
|
||||
#undef SDL_SendJoystickButton
|
||||
#endif
|
||||
#ifdef SDL_PrivateJoystickAxis
|
||||
#undef SDL_PrivateJoystickAxis
|
||||
#ifdef SDL_SendJoystickAxis
|
||||
#undef SDL_SendJoystickAxis
|
||||
#endif
|
||||
|
||||
#ifdef SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS
|
||||
|
@ -1525,8 +1525,8 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int
|
|||
if (!has_trigger_data)
|
||||
#endif /* SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS */
|
||||
{
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, left_trigger, left_value);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, right_trigger, right_value);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, left_trigger, left_value);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, right_trigger, right_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1594,7 +1594,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
|
|||
/* It gets left down if we were actually correlated incorrectly and it was released on the WindowsGamingInput
|
||||
device but we didn't get a state packet. */
|
||||
if (ctx->guide_hack) {
|
||||
SDL_PrivateJoystickButton(0, joystick, guide_button, SDL_RELEASED);
|
||||
SDL_SendJoystickButton(0, joystick, guide_button, SDL_RELEASED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1690,7 +1690,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
|
|||
/* It gets left down if we were actually correlated incorrectly and it was released on the XInput
|
||||
device but we didn't get a state packet. */
|
||||
if (ctx->guide_hack) {
|
||||
SDL_PrivateJoystickButton(0, joystick, guide_button, SDL_RELEASED);
|
||||
SDL_SendJoystickButton(0, joystick, guide_button, SDL_RELEASED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1763,11 +1763,11 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
|
|||
}
|
||||
|
||||
if (ctx->guide_hack) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, guide_button, (xinput_state[ctx->xinput_slot].state.Gamepad.wButtons & XINPUT_GAMEPAD_GUIDE) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, guide_button, (xinput_state[ctx->xinput_slot].state.Gamepad.wButtons & XINPUT_GAMEPAD_GUIDE) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
if (ctx->trigger_hack) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, left_trigger, ((int)xinput_state[ctx->xinput_slot].state.Gamepad.bLeftTrigger * 257) - 32768);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, right_trigger, ((int)xinput_state[ctx->xinput_slot].state.Gamepad.bRightTrigger * 257) - 32768);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, left_trigger, ((int)xinput_state[ctx->xinput_slot].state.Gamepad.bLeftTrigger * 257) - 32768);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, right_trigger, ((int)xinput_state[ctx->xinput_slot].state.Gamepad.bRightTrigger * 257) - 32768);
|
||||
}
|
||||
has_trigger_data = SDL_TRUE;
|
||||
|
||||
|
@ -1793,7 +1793,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
|
|||
break;
|
||||
}
|
||||
}
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, ePowerLevel);
|
||||
SDL_SendJoystickBatteryLevel(joystick, ePowerLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1814,11 +1814,11 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
|
|||
}
|
||||
|
||||
if (ctx->guide_hack) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, guide_button, (state->Buttons & GamepadButtons_GUIDE) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, guide_button, (state->Buttons & GamepadButtons_GUIDE) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
if (ctx->trigger_hack) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, left_trigger, ((int)(state->LeftTrigger * SDL_MAX_UINT16)) - 32768);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, right_trigger, ((int)(state->RightTrigger * SDL_MAX_UINT16)) - 32768);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, left_trigger, ((int)(state->LeftTrigger * SDL_MAX_UINT16)) - 32768);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, right_trigger, ((int)(state->RightTrigger * SDL_MAX_UINT16)) - 32768);
|
||||
}
|
||||
has_trigger_data = SDL_TRUE;
|
||||
}
|
||||
|
|
|
@ -850,13 +850,13 @@ static void WGI_JoystickUpdate(SDL_Joystick *joystick)
|
|||
/* FIXME: What units are the timestamp we get from GetCurrentReading()? */
|
||||
timestamp = SDL_GetTicksNS();
|
||||
for (i = 0; i < nbuttons; ++i) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, (Uint8)i, buttons[i]);
|
||||
SDL_SendJoystickButton(timestamp, joystick, (Uint8)i, buttons[i]);
|
||||
}
|
||||
for (i = 0; i < nhats; ++i) {
|
||||
SDL_PrivateJoystickHat(timestamp, joystick, (Uint8)i, ConvertHatValue(hats[i]));
|
||||
SDL_SendJoystickHat(timestamp, joystick, (Uint8)i, ConvertHatValue(hats[i]));
|
||||
}
|
||||
for (i = 0; i < naxes; ++i) {
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, (Uint8)i, (Sint16)((int)(axes[i] * 65535) - 32768));
|
||||
SDL_SendJoystickAxis(timestamp, joystick, (Uint8)i, (Sint16)((int)(axes[i] * 65535) - 32768));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -409,7 +409,7 @@ static void UpdateXInputJoystickBatteryInformation(SDL_Joystick *joystick, XINPU
|
|||
}
|
||||
}
|
||||
|
||||
SDL_PrivateJoystickBatteryLevel(joystick, ePowerLevel);
|
||||
SDL_SendJoystickBatteryLevel(joystick, ePowerLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,15 +426,15 @@ static void UpdateXInputJoystickState_OLD(SDL_Joystick *joystick, XINPUT_STATE_E
|
|||
Uint8 button;
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 1, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbLY)));
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 2, (Sint16)pXInputState->Gamepad.sThumbRX);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 3, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbRY)));
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 4, (Sint16)(((int)pXInputState->Gamepad.bLeftTrigger * 65535 / 255) - 32768));
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 5, (Sint16)(((int)pXInputState->Gamepad.bRightTrigger * 65535 / 255) - 32768));
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 1, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbLY)));
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 2, (Sint16)pXInputState->Gamepad.sThumbRX);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 3, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbRY)));
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 4, (Sint16)(((int)pXInputState->Gamepad.bLeftTrigger * 65535 / 255) - 32768));
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 5, (Sint16)(((int)pXInputState->Gamepad.bRightTrigger * 65535 / 255) - 32768));
|
||||
|
||||
for (button = 0; button < (Uint8)SDL_arraysize(s_XInputButtons); ++button) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
UpdateXInputJoystickBatteryInformation(joystick, pBatteryInformation);
|
||||
|
@ -453,15 +453,15 @@ static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE_EX *p
|
|||
Uint8 hat = SDL_HAT_CENTERED;
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 0, pXInputState->Gamepad.sThumbLX);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 1, ~pXInputState->Gamepad.sThumbLY);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 2, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 3, pXInputState->Gamepad.sThumbRX);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 4, ~pXInputState->Gamepad.sThumbRY);
|
||||
SDL_PrivateJoystickAxis(timestamp, joystick, 5, ((int)pXInputState->Gamepad.bRightTrigger * 257) - 32768);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 0, pXInputState->Gamepad.sThumbLX);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 1, ~pXInputState->Gamepad.sThumbLY);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 2, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 3, pXInputState->Gamepad.sThumbRX);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 4, ~pXInputState->Gamepad.sThumbRY);
|
||||
SDL_SendJoystickAxis(timestamp, joystick, 5, ((int)pXInputState->Gamepad.bRightTrigger * 257) - 32768);
|
||||
|
||||
for (button = 0; button < (Uint8)SDL_arraysize(s_XInputButtons); ++button) {
|
||||
SDL_PrivateJoystickButton(timestamp, joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (wButtons & XINPUT_GAMEPAD_DPAD_UP) {
|
||||
|
@ -476,7 +476,7 @@ static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE_EX *p
|
|||
if (wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) {
|
||||
hat |= SDL_HAT_RIGHT;
|
||||
}
|
||||
SDL_PrivateJoystickHat(timestamp, joystick, 0, hat);
|
||||
SDL_SendJoystickHat(timestamp, joystick, 0, hat);
|
||||
|
||||
UpdateXInputJoystickBatteryInformation(joystick, pBatteryInformation);
|
||||
}
|
||||
|
|
|
@ -2442,7 +2442,7 @@ void SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect)
|
|||
}
|
||||
}
|
||||
|
||||
static void RenderGetViewportSize(SDL_Renderer *renderer, SDL_FRect *rect)
|
||||
static void GetRenderViewportSize(SDL_Renderer *renderer, SDL_FRect *rect)
|
||||
{
|
||||
rect->x = 0.0f;
|
||||
rect->y = 0.0f;
|
||||
|
@ -2622,7 +2622,7 @@ int SDL_RenderPointF(SDL_Renderer *renderer, float x, float y)
|
|||
return SDL_RenderPointsF(renderer, &fpoint, 1);
|
||||
}
|
||||
|
||||
static int RenderDrawPointsWithRects(SDL_Renderer *renderer,
|
||||
static int RenderPointsWithRects(SDL_Renderer *renderer,
|
||||
const SDL_Point *points, const int count)
|
||||
{
|
||||
int retval;
|
||||
|
@ -2678,7 +2678,7 @@ int SDL_RenderPoints(SDL_Renderer *renderer,
|
|||
#endif
|
||||
|
||||
if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
|
||||
retval = RenderDrawPointsWithRects(renderer, points, count);
|
||||
retval = RenderPointsWithRects(renderer, points, count);
|
||||
} else {
|
||||
fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
|
||||
if (fpoints == NULL) {
|
||||
|
@ -2696,7 +2696,7 @@ int SDL_RenderPoints(SDL_Renderer *renderer,
|
|||
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
|
||||
}
|
||||
|
||||
static int RenderDrawPointsWithRectsF(SDL_Renderer *renderer,
|
||||
static int RenderPointsWithRectsF(SDL_Renderer *renderer,
|
||||
const SDL_FPoint *fpoints, const int count)
|
||||
{
|
||||
int retval;
|
||||
|
@ -2749,7 +2749,7 @@ int SDL_RenderPointsF(SDL_Renderer *renderer,
|
|||
#endif
|
||||
|
||||
if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
|
||||
retval = RenderDrawPointsWithRectsF(renderer, points, count);
|
||||
retval = RenderPointsWithRectsF(renderer, points, count);
|
||||
} else {
|
||||
retval = QueueCmdDrawPoints(renderer, points, count);
|
||||
}
|
||||
|
@ -2776,7 +2776,7 @@ int SDL_RenderLineF(SDL_Renderer *renderer, float x1, float y1, float x2, float
|
|||
return SDL_RenderLinesF(renderer, points, 2);
|
||||
}
|
||||
|
||||
static int RenderDrawLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x2, int y2, SDL_bool draw_last)
|
||||
static int RenderLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x2, int y2, SDL_bool draw_last)
|
||||
{
|
||||
int i, deltax, deltay, numpixels;
|
||||
int d, dinc1, dinc2;
|
||||
|
@ -2845,7 +2845,7 @@ static int RenderDrawLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x
|
|||
}
|
||||
|
||||
if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
|
||||
retval = RenderDrawPointsWithRectsF(renderer, points, numpixels);
|
||||
retval = RenderPointsWithRectsF(renderer, points, numpixels);
|
||||
} else {
|
||||
retval = QueueCmdDrawPoints(renderer, points, numpixels);
|
||||
}
|
||||
|
@ -2855,7 +2855,7 @@ static int RenderDrawLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x
|
|||
return retval;
|
||||
}
|
||||
|
||||
static int RenderDrawLinesWithRectsF(SDL_Renderer *renderer,
|
||||
static int RenderLinesWithRectsF(SDL_Renderer *renderer,
|
||||
const SDL_FPoint *points, const int count)
|
||||
{
|
||||
const float scale_x = renderer->scale.x;
|
||||
|
@ -2911,7 +2911,7 @@ static int RenderDrawLinesWithRectsF(SDL_Renderer *renderer,
|
|||
frect->x += scale_x;
|
||||
}
|
||||
} else {
|
||||
retval += RenderDrawLineBresenham(renderer, (int)SDL_roundf(points[i].x), (int)SDL_roundf(points[i].y),
|
||||
retval += RenderLineBresenham(renderer, (int)SDL_roundf(points[i].x), (int)SDL_roundf(points[i].y),
|
||||
(int)SDL_roundf(points[i + 1].x), (int)SDL_roundf(points[i + 1].y), draw_last);
|
||||
}
|
||||
drew_line = SDL_TRUE;
|
||||
|
@ -2992,7 +2992,7 @@ int SDL_RenderLinesF(SDL_Renderer *renderer,
|
|||
#endif
|
||||
|
||||
if (renderer->line_method == SDL_RENDERLINEMETHOD_POINTS) {
|
||||
retval = RenderDrawLinesWithRectsF(renderer, points, count);
|
||||
retval = RenderLinesWithRectsF(renderer, points, count);
|
||||
} else if (renderer->line_method == SDL_RENDERLINEMETHOD_GEOMETRY) {
|
||||
SDL_bool isstack1;
|
||||
SDL_bool isstack2;
|
||||
|
@ -3114,7 +3114,7 @@ int SDL_RenderLinesF(SDL_Renderer *renderer,
|
|||
SDL_small_free(indices, isstack2);
|
||||
|
||||
} else if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
|
||||
retval = RenderDrawLinesWithRectsF(renderer, points, count);
|
||||
retval = RenderLinesWithRectsF(renderer, points, count);
|
||||
} else {
|
||||
retval = QueueCmdDrawLines(renderer, points, count);
|
||||
}
|
||||
|
@ -3147,7 +3147,7 @@ int SDL_RenderRectF(SDL_Renderer *renderer, const SDL_FRect *rect)
|
|||
|
||||
/* If 'rect' == NULL, then outline the whole surface */
|
||||
if (rect == NULL) {
|
||||
RenderGetViewportSize(renderer, &frect);
|
||||
GetRenderViewportSize(renderer, &frect);
|
||||
rect = &frect;
|
||||
}
|
||||
|
||||
|
@ -3235,7 +3235,7 @@ int SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_Rect *rect)
|
|||
frect.w = (float)rect->w;
|
||||
frect.h = (float)rect->h;
|
||||
} else {
|
||||
RenderGetViewportSize(renderer, &frect);
|
||||
GetRenderViewportSize(renderer, &frect);
|
||||
}
|
||||
return SDL_RenderFillRectsF(renderer, &frect, 1);
|
||||
}
|
||||
|
@ -3248,7 +3248,7 @@ int SDL_RenderFillRectF(SDL_Renderer *renderer, const SDL_FRect *rect)
|
|||
|
||||
/* If 'rect' == NULL, then outline the whole surface */
|
||||
if (rect == NULL) {
|
||||
RenderGetViewportSize(renderer, &frect);
|
||||
GetRenderViewportSize(renderer, &frect);
|
||||
rect = &frect;
|
||||
}
|
||||
return SDL_RenderFillRectsF(renderer, rect, 1);
|
||||
|
@ -3387,7 +3387,7 @@ int SDL_RenderTextureF(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||
}
|
||||
}
|
||||
|
||||
RenderGetViewportSize(renderer, &real_dstrect);
|
||||
GetRenderViewportSize(renderer, &real_dstrect);
|
||||
if (dstrect) {
|
||||
if (!SDL_HasRectIntersectionF(dstrect, &real_dstrect)) {
|
||||
return 0;
|
||||
|
@ -3531,7 +3531,7 @@ int SDL_RenderTextureRotatedF(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||
if (dstrect) {
|
||||
real_dstrect = *dstrect;
|
||||
} else {
|
||||
RenderGetViewportSize(renderer, &real_dstrect);
|
||||
GetRenderViewportSize(renderer, &real_dstrect);
|
||||
}
|
||||
|
||||
if (texture->native) {
|
||||
|
@ -4174,7 +4174,7 @@ int SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
|||
format, pixels, pitch);
|
||||
}
|
||||
|
||||
static void SDL_RenderSimulateVSync(SDL_Renderer *renderer)
|
||||
static void SDL_SimulateRenderVSync(SDL_Renderer *renderer)
|
||||
{
|
||||
Uint64 now, elapsed;
|
||||
const Uint64 interval = renderer->simulate_vsync_interval_ns;
|
||||
|
@ -4221,7 +4221,7 @@ void SDL_RenderPresent(SDL_Renderer *renderer)
|
|||
|
||||
if (renderer->simulate_vsync ||
|
||||
(!presented && renderer->wanted_vsync)) {
|
||||
SDL_RenderSimulateVSync(renderer);
|
||||
SDL_SimulateRenderVSync(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -316,8 +316,8 @@ extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode
|
|||
the next call, because it might be in an array that gets realloc()'d. */
|
||||
extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset);
|
||||
|
||||
extern int SDL_PrivateLowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
extern int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
extern int SDL_PrivateBlitSurfaceUncheckedScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
extern int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -297,7 +297,7 @@ static int Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surf
|
|||
r.y = (int)((float)dstrect->y * scale_y);
|
||||
r.w = (int)((float)dstrect->w * scale_x);
|
||||
r.h = (int)((float)dstrect->h * scale_y);
|
||||
retval = SDL_PrivateUpperBlitScaled(src, srcrect, surface, &r, scaleMode);
|
||||
retval = SDL_PrivateBlitSurfaceScaled(src, srcrect, surface, &r, scaleMode);
|
||||
} else {
|
||||
retval = SDL_BlitSurface(src, srcrect, surface, dstrect);
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
|||
retval = -1;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE);
|
||||
retval = SDL_PrivateUpperBlitScaled(src_clone, srcrect, src_scaled, &scale_rect, texture->scaleMode);
|
||||
retval = SDL_PrivateBlitSurfaceScaled(src_clone, srcrect, src_scaled, &scale_rect, texture->scaleMode);
|
||||
SDL_DestroySurface(src_clone);
|
||||
src_clone = src_scaled;
|
||||
src_scaled = NULL;
|
||||
|
@ -832,7 +832,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
|||
SDL_SetSurfaceColorMod(src, 255, 255, 255);
|
||||
SDL_SetSurfaceAlphaMod(src, 255);
|
||||
|
||||
SDL_PrivateUpperBlitScaled(src, srcrect, tmp, &r, texture->scaleMode);
|
||||
SDL_PrivateBlitSurfaceScaled(src, srcrect, tmp, &r, texture->scaleMode);
|
||||
|
||||
SDL_SetSurfaceColorMod(tmp, rMod, gMod, bMod);
|
||||
SDL_SetSurfaceAlphaMod(tmp, alphaMod);
|
||||
|
@ -843,7 +843,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
|||
/* No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy() */
|
||||
}
|
||||
} else {
|
||||
SDL_PrivateUpperBlitScaled(src, srcrect, surface, dstrect, texture->scaleMode);
|
||||
SDL_PrivateBlitSurfaceScaled(src, srcrect, surface, dstrect, texture->scaleMode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -63,7 +63,7 @@ void SDL_UnlockSensors(void) SDL_RELEASE(SDL_sensor_lock)
|
|||
SDL_UnlockMutex(SDL_sensor_lock);
|
||||
}
|
||||
|
||||
int SDL_SensorInit(void)
|
||||
int SDL_InitSensors(void)
|
||||
{
|
||||
int i, status;
|
||||
|
||||
|
@ -290,7 +290,7 @@ SDL_Sensor *SDL_GetSensorFromInstanceID(SDL_SensorID instance_id)
|
|||
/*
|
||||
* Checks to make sure the sensor is valid.
|
||||
*/
|
||||
static int SDL_PrivateSensorValid(SDL_Sensor *sensor)
|
||||
static int SDL_IsSensorValid(SDL_Sensor *sensor)
|
||||
{
|
||||
int valid;
|
||||
|
||||
|
@ -309,7 +309,7 @@ static int SDL_PrivateSensorValid(SDL_Sensor *sensor)
|
|||
*/
|
||||
const char *SDL_GetSensorName(SDL_Sensor *sensor)
|
||||
{
|
||||
if (!SDL_PrivateSensorValid(sensor)) {
|
||||
if (!SDL_IsSensorValid(sensor)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ const char *SDL_GetSensorName(SDL_Sensor *sensor)
|
|||
*/
|
||||
SDL_SensorType SDL_GetSensorType(SDL_Sensor *sensor)
|
||||
{
|
||||
if (!SDL_PrivateSensorValid(sensor)) {
|
||||
if (!SDL_IsSensorValid(sensor)) {
|
||||
return SDL_SENSOR_INVALID;
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,7 @@ SDL_SensorType SDL_GetSensorType(SDL_Sensor *sensor)
|
|||
*/
|
||||
int SDL_GetSensorNonPortableType(SDL_Sensor *sensor)
|
||||
{
|
||||
if (!SDL_PrivateSensorValid(sensor)) {
|
||||
if (!SDL_IsSensorValid(sensor)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ int SDL_GetSensorNonPortableType(SDL_Sensor *sensor)
|
|||
*/
|
||||
SDL_SensorID SDL_GetSensorInstanceID(SDL_Sensor *sensor)
|
||||
{
|
||||
if (!SDL_PrivateSensorValid(sensor)) {
|
||||
if (!SDL_IsSensorValid(sensor)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ SDL_SensorID SDL_GetSensorInstanceID(SDL_Sensor *sensor)
|
|||
*/
|
||||
int SDL_GetSensorData(SDL_Sensor *sensor, float *data, int num_values)
|
||||
{
|
||||
if (!SDL_PrivateSensorValid(sensor)) {
|
||||
if (!SDL_IsSensorValid(sensor)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ void SDL_CloseSensor(SDL_Sensor *sensor)
|
|||
SDL_Sensor *sensorlist;
|
||||
SDL_Sensor *sensorlistprev;
|
||||
|
||||
if (!SDL_PrivateSensorValid(sensor)) {
|
||||
if (!SDL_IsSensorValid(sensor)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ void SDL_CloseSensor(SDL_Sensor *sensor)
|
|||
SDL_UnlockSensors();
|
||||
}
|
||||
|
||||
void SDL_SensorQuit(void)
|
||||
void SDL_QuitSensors(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -452,7 +452,7 @@ void SDL_SensorQuit(void)
|
|||
|
||||
/* These are global for SDL_syssensor.c and SDL_events.c */
|
||||
|
||||
int SDL_PrivateSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_timestamp, float *data, int num_values)
|
||||
int SDL_SendSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_timestamp, float *data, int num_values)
|
||||
{
|
||||
int posted;
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ struct _SDL_SensorDriver;
|
|||
extern SDL_SensorID SDL_GetNextSensorInstanceID(void);
|
||||
|
||||
/* Initialization and shutdown functions */
|
||||
extern int SDL_SensorInit(void);
|
||||
extern void SDL_SensorQuit(void);
|
||||
extern int SDL_InitSensors(void);
|
||||
extern void SDL_QuitSensors(void);
|
||||
|
||||
/* Internal event queueing functions */
|
||||
extern int SDL_PrivateSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_timestamp, float *data, int num_values);
|
||||
extern int SDL_SendSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_timestamp, float *data, int num_values);
|
||||
|
||||
#endif /* SDL_sensor_c_h_ */
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef struct _SDL_SensorDriver
|
|||
|
||||
/* Function to update the state of a sensor - called as a device poll.
|
||||
* This function shouldn't update the sensor structure directly,
|
||||
* but instead should call SDL_PrivateSensorUpdate() to deliver events
|
||||
* but instead should call SDL_SendSensorUpdate() to deliver events
|
||||
* and update sensor device state.
|
||||
*/
|
||||
void (*Update)(SDL_Sensor *sensor);
|
||||
|
|
|
@ -161,7 +161,7 @@ static void SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor)
|
|||
if (ALooper_pollAll(0, NULL, &events, (void **)&source) == LOOPER_ID_USER) {
|
||||
SDL_zero(event);
|
||||
while (ASensorEventQueue_getEvents(sensor->hwdata->eventqueue, &event, 1) > 0) {
|
||||
SDL_PrivateSensorUpdate(timestamp, sensor, timestamp, event.data, SDL_arraysize(event.data));
|
||||
SDL_SendSensorUpdate(timestamp, sensor, timestamp, event.data, SDL_arraysize(event.data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ static void SDL_COREMOTION_SensorUpdate(SDL_Sensor *sensor)
|
|||
data[1] = -acceleration.y * SDL_STANDARD_GRAVITY;
|
||||
data[2] = -acceleration.z * SDL_STANDARD_GRAVITY;
|
||||
if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) {
|
||||
SDL_PrivateSensorUpdate(timestamp, sensor, timestamp, data, SDL_arraysize(data));
|
||||
SDL_SendSensorUpdate(timestamp, sensor, timestamp, data, SDL_arraysize(data));
|
||||
SDL_memcpy(sensor->hwdata->data, data, sizeof(data));
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ static void SDL_COREMOTION_SensorUpdate(SDL_Sensor *sensor)
|
|||
data[1] = rotationRate.y;
|
||||
data[2] = rotationRate.z;
|
||||
if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) {
|
||||
SDL_PrivateSensorUpdate(timestamp, sensor, timestamp, data, SDL_arraysize(data));
|
||||
SDL_SendSensorUpdate(timestamp, sensor, timestamp, data, SDL_arraysize(data));
|
||||
SDL_memcpy(sensor->hwdata->data, data, sizeof(data));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ UpdateN3DSAccelerometer(SDL_Sensor *sensor)
|
|||
data[0] = (float)current_state.x * SDL_STANDARD_GRAVITY;
|
||||
data[1] = (float)current_state.y * SDL_STANDARD_GRAVITY;
|
||||
data[2] = (float)current_state.z * SDL_STANDARD_GRAVITY;
|
||||
SDL_PrivateSensorUpdate(timestamp, sensor, timestamp, data, sizeof data);
|
||||
SDL_SendSensorUpdate(timestamp, sensor, timestamp, data, sizeof data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ UpdateN3DSGyroscope(SDL_Sensor *sensor)
|
|||
data[0] = (float)current_state.x;
|
||||
data[1] = (float)current_state.y;
|
||||
data[2] = (float)current_state.z;
|
||||
SDL_PrivateSensorUpdate(timestamp, sensor, timestamp, data, sizeof data);
|
||||
SDL_SendSensorUpdate(timestamp, sensor, timestamp, data, sizeof data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ static void SDL_VITA_SensorUpdate(SDL_Sensor *sensor)
|
|||
data[0] = motionState[i].accelerometer.x * SDL_STANDARD_GRAVITY;
|
||||
data[1] = motionState[i].accelerometer.y * SDL_STANDARD_GRAVITY;
|
||||
data[2] = motionState[i].accelerometer.z * SDL_STANDARD_GRAVITY;
|
||||
SDL_PrivateSensorUpdate(timestamp, sensor, sensor->hwdata->sensor_timestamp, data, SDL_arraysize(data));
|
||||
SDL_SendSensorUpdate(timestamp, sensor, sensor->hwdata->sensor_timestamp, data, SDL_arraysize(data));
|
||||
} break;
|
||||
case SDL_SENSOR_GYRO:
|
||||
{
|
||||
|
@ -169,7 +169,7 @@ static void SDL_VITA_SensorUpdate(SDL_Sensor *sensor)
|
|||
data[0] = motionState[i].gyro.x;
|
||||
data[1] = motionState[i].gyro.y;
|
||||
data[2] = motionState[i].gyro.z;
|
||||
SDL_PrivateSensorUpdate(timestamp, sensor, sensor->hwdata->sensor_timestamp, data, SDL_arraysize(data));
|
||||
SDL_SendSensorUpdate(timestamp, sensor, sensor->hwdata->sensor_timestamp, data, SDL_arraysize(data));
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -180,7 +180,7 @@ static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnDataUpdated(ISensorEvents *
|
|||
values[0] = (float)valueX.dblVal * SDL_STANDARD_GRAVITY;
|
||||
values[1] = (float)valueY.dblVal * SDL_STANDARD_GRAVITY;
|
||||
values[2] = (float)valueZ.dblVal * SDL_STANDARD_GRAVITY;
|
||||
SDL_PrivateSensorUpdate(timestamp, SDL_sensors[i].sensor_opened, sensor_timestamp, values, 3);
|
||||
SDL_SendSensorUpdate(timestamp, SDL_sensors[i].sensor_opened, sensor_timestamp, values, 3);
|
||||
}
|
||||
break;
|
||||
case SDL_SENSOR_GYRO:
|
||||
|
@ -195,7 +195,7 @@ static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnDataUpdated(ISensorEvents *
|
|||
values[0] = (float)valueX.dblVal * DEGREES_TO_RADIANS;
|
||||
values[1] = (float)valueY.dblVal * DEGREES_TO_RADIANS;
|
||||
values[2] = (float)valueZ.dblVal * DEGREES_TO_RADIANS;
|
||||
SDL_PrivateSensorUpdate(timestamp, SDL_sensors[i].sensor_opened, sensor_timestamp, values, 3);
|
||||
SDL_SendSensorUpdate(timestamp, SDL_sensors[i].sensor_opened, sensor_timestamp, values, 3);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#define UTF8_IsLeadByte(c) ((c) >= 0xC0 && (c) <= 0xF4)
|
||||
#define UTF8_IsTrailingByte(c) ((c) >= 0x80 && (c) <= 0xBF)
|
||||
|
||||
static unsigned UTF8_TrailingBytes(unsigned char c)
|
||||
static unsigned UTF8_GetTrailingBytes(unsigned char c)
|
||||
{
|
||||
if (c >= 0xC0 && c <= 0xDF) {
|
||||
return 1;
|
||||
|
@ -574,7 +574,7 @@ SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_
|
|||
} else if (UTF8_IsTrailingByte(c)) {
|
||||
for (i = bytes - 1; i != 0; --i) {
|
||||
c = (unsigned char)src[i];
|
||||
trailing_bytes = UTF8_TrailingBytes(c);
|
||||
trailing_bytes = UTF8_GetTrailingBytes(c);
|
||||
if (trailing_bytes) {
|
||||
if (bytes - i != trailing_bytes + 1) {
|
||||
bytes = i;
|
||||
|
|
|
@ -202,7 +202,7 @@ static int SDLCALL SDL_TimerThread(void *_data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SDL_TimerInit(void)
|
||||
int SDL_InitTimers(void)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
|
||||
|
@ -224,7 +224,7 @@ int SDL_TimerInit(void)
|
|||
/* Timer threads use a callback into the app, so we can't set a limited stack size here. */
|
||||
data->thread = SDL_CreateThreadInternal(SDL_TimerThread, name, 0, data);
|
||||
if (!data->thread) {
|
||||
SDL_TimerQuit();
|
||||
SDL_QuitTimers();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ int SDL_TimerInit(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void SDL_TimerQuit(void)
|
||||
void SDL_QuitTimers(void)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
SDL_Timer *timer;
|
||||
|
@ -280,7 +280,7 @@ SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *para
|
|||
|
||||
SDL_AtomicLock(&data->lock);
|
||||
if (!SDL_AtomicGet(&data->active)) {
|
||||
if (SDL_TimerInit() < 0) {
|
||||
if (SDL_InitTimers() < 0) {
|
||||
SDL_AtomicUnlock(&data->lock);
|
||||
return 0;
|
||||
}
|
||||
|
@ -399,12 +399,12 @@ static void SDL_Emscripten_TimerHelper(void *userdata)
|
|||
}
|
||||
}
|
||||
|
||||
int SDL_TimerInit(void)
|
||||
int SDL_InitTimers(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_TimerQuit(void)
|
||||
void SDL_QuitTimers(void)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
SDL_TimerMap *entry;
|
||||
|
@ -524,7 +524,7 @@ static Uint32 CalculateGCD(Uint32 a, Uint32 b)
|
|||
return CalculateGCD(b, (a % b));
|
||||
}
|
||||
|
||||
void SDL_TicksInit(void)
|
||||
void SDL_InitTicks(void)
|
||||
{
|
||||
Uint64 tick_freq;
|
||||
Uint32 gcd;
|
||||
|
@ -555,7 +555,7 @@ void SDL_TicksInit(void)
|
|||
}
|
||||
}
|
||||
|
||||
void SDL_TicksQuit(void)
|
||||
void SDL_QuitTicks(void)
|
||||
{
|
||||
SDL_DelHintCallback(SDL_HINT_TIMER_RESOLUTION,
|
||||
SDL_TimerResolutionChanged, NULL);
|
||||
|
@ -571,7 +571,7 @@ SDL_GetTicksNS(void)
|
|||
Uint64 starting_value, value;
|
||||
|
||||
if (!tick_start) {
|
||||
SDL_TicksInit();
|
||||
SDL_InitTicks();
|
||||
}
|
||||
|
||||
starting_value = (SDL_GetPerformanceCounter() - tick_start);
|
||||
|
@ -586,7 +586,7 @@ Uint64 SDL_GetTicks(void)
|
|||
Uint64 starting_value, value;
|
||||
|
||||
if (!tick_start) {
|
||||
SDL_TicksInit();
|
||||
SDL_InitTicks();
|
||||
}
|
||||
|
||||
starting_value = (SDL_GetPerformanceCounter() - tick_start);
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
#define ROUND_RESOLUTION(X) \
|
||||
(((X + TIMER_RESOLUTION - 1) / TIMER_RESOLUTION) * TIMER_RESOLUTION)
|
||||
|
||||
extern void SDL_TicksInit(void);
|
||||
extern void SDL_TicksQuit(void);
|
||||
extern int SDL_TimerInit(void);
|
||||
extern void SDL_TimerQuit(void);
|
||||
extern void SDL_InitTicks(void);
|
||||
extern void SDL_QuitTicks(void);
|
||||
extern int SDL_InitTimers(void);
|
||||
extern void SDL_QuitTimers(void);
|
||||
|
||||
#endif /* SDL_timer_c_h_ */
|
||||
|
|
|
@ -754,10 +754,10 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect,
|
|||
int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||
SDL_Surface *dst, SDL_Rect *dstrect)
|
||||
{
|
||||
return SDL_PrivateUpperBlitScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest);
|
||||
return SDL_PrivateBlitSurfaceScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest);
|
||||
}
|
||||
|
||||
int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||
int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||
SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
double src_x0, src_y0, src_x1, src_y1;
|
||||
|
@ -912,7 +912,7 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
|||
return 0;
|
||||
}
|
||||
|
||||
return SDL_PrivateLowerBlitScaled(src, &final_src, dst, &final_dst, scaleMode);
|
||||
return SDL_PrivateBlitSurfaceUncheckedScaled(src, &final_src, dst, &final_dst, scaleMode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -922,10 +922,10 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
|||
int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, SDL_Rect *srcrect,
|
||||
SDL_Surface *dst, SDL_Rect *dstrect)
|
||||
{
|
||||
return SDL_PrivateLowerBlitScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest);
|
||||
return SDL_PrivateBlitSurfaceUncheckedScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest);
|
||||
}
|
||||
|
||||
int SDL_PrivateLowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect,
|
||||
int SDL_PrivateBlitSurfaceUncheckedScaled(SDL_Surface *src, SDL_Rect *srcrect,
|
||||
SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
static const Uint32 complex_copy_flags = (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA |
|
||||
|
|
|
@ -415,7 +415,7 @@ int SDL_VideoInit(const char *driver_name)
|
|||
}
|
||||
|
||||
#if !SDL_TIMERS_DISABLED
|
||||
SDL_TicksInit();
|
||||
SDL_InitTicks();
|
||||
#endif
|
||||
|
||||
/* Start the event loop */
|
||||
|
@ -423,15 +423,15 @@ int SDL_VideoInit(const char *driver_name)
|
|||
goto pre_driver_error;
|
||||
}
|
||||
init_events = SDL_TRUE;
|
||||
if (SDL_KeyboardInit() < 0) {
|
||||
if (SDL_InitKeyboard() < 0) {
|
||||
goto pre_driver_error;
|
||||
}
|
||||
init_keyboard = SDL_TRUE;
|
||||
if (SDL_MouseInit() < 0) {
|
||||
if (SDL_InitMouse() < 0) {
|
||||
goto pre_driver_error;
|
||||
}
|
||||
init_mouse = SDL_TRUE;
|
||||
if (SDL_TouchInit() < 0) {
|
||||
if (SDL_InitTouch() < 0) {
|
||||
goto pre_driver_error;
|
||||
}
|
||||
init_touch = SDL_TRUE;
|
||||
|
@ -529,13 +529,13 @@ int SDL_VideoInit(const char *driver_name)
|
|||
pre_driver_error:
|
||||
SDL_assert(_this == NULL);
|
||||
if (init_touch) {
|
||||
SDL_TouchQuit();
|
||||
SDL_QuitTouch();
|
||||
}
|
||||
if (init_mouse) {
|
||||
SDL_MouseQuit();
|
||||
SDL_QuitMouse();
|
||||
}
|
||||
if (init_keyboard) {
|
||||
SDL_KeyboardQuit();
|
||||
SDL_QuitKeyboard();
|
||||
}
|
||||
if (init_events) {
|
||||
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
||||
|
@ -1091,7 +1091,7 @@ static void SDL_GetClosestPointOnRect(const SDL_Rect *rect, SDL_Point *point)
|
|||
}
|
||||
}
|
||||
|
||||
static int GetRectDisplayIndex(int x, int y, int w, int h)
|
||||
static int GetDisplayIndexForRect(int x, int y, int w, int h)
|
||||
{
|
||||
int i, dist;
|
||||
int closest = -1;
|
||||
|
@ -1135,12 +1135,12 @@ static int GetRectDisplayIndex(int x, int y, int w, int h)
|
|||
|
||||
int SDL_GetDisplayIndexForPoint(const SDL_Point *point)
|
||||
{
|
||||
return GetRectDisplayIndex(point->x, point->y, 1, 1);
|
||||
return GetDisplayIndexForRect(point->x, point->y, 1, 1);
|
||||
}
|
||||
|
||||
int SDL_GetDisplayIndexForRect(const SDL_Rect *rect)
|
||||
{
|
||||
return GetRectDisplayIndex(rect->x, rect->y, rect->w, rect->h);
|
||||
return GetDisplayIndexForRect(rect->x, rect->y, rect->w, rect->h);
|
||||
}
|
||||
|
||||
int SDL_GetWindowDisplayIndex(SDL_Window *window)
|
||||
|
@ -1177,7 +1177,7 @@ int SDL_GetWindowDisplayIndex(SDL_Window *window)
|
|||
return displayIndex;
|
||||
}
|
||||
|
||||
displayIndex = GetRectDisplayIndex(window->x, window->y, window->w, window->h);
|
||||
displayIndex = GetDisplayIndexForRect(window->x, window->y, window->w, window->h);
|
||||
|
||||
/* Find the display containing the window if fullscreen */
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
|
@ -2508,7 +2508,7 @@ void SDL_MaximizeWindow(SDL_Window *window)
|
|||
}
|
||||
}
|
||||
|
||||
static SDL_bool CanMinimizeWindow(SDL_Window *window)
|
||||
static SDL_bool SDL_CanMinimizeWindow(SDL_Window *window)
|
||||
{
|
||||
if (!_this->MinimizeWindow) {
|
||||
return SDL_FALSE;
|
||||
|
@ -2524,7 +2524,7 @@ void SDL_MinimizeWindow(SDL_Window *window)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CanMinimizeWindow(window)) {
|
||||
if (!SDL_CanMinimizeWindow(window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3000,7 +3000,7 @@ void SDL_OnWindowFocusGained(SDL_Window *window)
|
|||
SDL_UpdateWindowGrab(window);
|
||||
}
|
||||
|
||||
static SDL_bool ShouldMinimizeOnFocusLoss(SDL_Window *window)
|
||||
static SDL_bool SDL_ShouldMinimizeOnFocusLoss(SDL_Window *window)
|
||||
{
|
||||
const char *hint;
|
||||
|
||||
|
@ -3042,7 +3042,7 @@ void SDL_OnWindowFocusLost(SDL_Window *window)
|
|||
{
|
||||
SDL_UpdateWindowGrab(window);
|
||||
|
||||
if (ShouldMinimizeOnFocusLoss(window)) {
|
||||
if (SDL_ShouldMinimizeOnFocusLoss(window)) {
|
||||
SDL_MinimizeWindow(window);
|
||||
}
|
||||
}
|
||||
|
@ -3194,9 +3194,9 @@ void SDL_VideoQuit(void)
|
|||
}
|
||||
|
||||
/* Halt event processing before doing anything else */
|
||||
SDL_TouchQuit();
|
||||
SDL_MouseQuit();
|
||||
SDL_KeyboardQuit();
|
||||
SDL_QuitTouch();
|
||||
SDL_QuitMouse();
|
||||
SDL_QuitKeyboard();
|
||||
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
||||
|
||||
SDL_EnableScreenSaver();
|
||||
|
@ -4350,7 +4350,7 @@ int SDL_GetMessageBoxCount(void)
|
|||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_WAYLAND || SDL_VIDEO_DRIVER_HAIKU || SDL_VIDEO_DRIVER_RISCOS
|
||||
static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
|
||||
static SDL_bool SDL_IsMessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
|
||||
{
|
||||
SDL_SysWMinfo info;
|
||||
SDL_Window *window = messageboxdata->window;
|
||||
|
@ -4415,56 +4415,56 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
#endif
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||
if (retval == -1 &&
|
||||
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINDOWS) &&
|
||||
SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINDOWS) &&
|
||||
WIN_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_WINRT
|
||||
if (retval == -1 &&
|
||||
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINRT) &&
|
||||
SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINRT) &&
|
||||
WINRT_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
if (retval == -1 &&
|
||||
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_COCOA) &&
|
||||
SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_COCOA) &&
|
||||
Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_UIKIT
|
||||
if (retval == -1 &&
|
||||
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_UIKIT) &&
|
||||
SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_UIKIT) &&
|
||||
UIKit_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_WAYLAND
|
||||
if (retval == -1 &&
|
||||
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WAYLAND) &&
|
||||
SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_WAYLAND) &&
|
||||
Wayland_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11
|
||||
if (retval == -1 &&
|
||||
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_X11) &&
|
||||
SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_X11) &&
|
||||
X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_HAIKU
|
||||
if (retval == -1 &&
|
||||
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_HAIKU) &&
|
||||
SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_HAIKU) &&
|
||||
HAIKU_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_RISCOS
|
||||
if (retval == -1 &&
|
||||
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_RISCOS) &&
|
||||
SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_RISCOS) &&
|
||||
RISCOS_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ SDL_FORCE_INLINE SDL_bool FullscreenModeEmulation(SDL_Window *window)
|
|||
((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
}
|
||||
|
||||
static SDL_bool NeedViewport(SDL_Window *window)
|
||||
static SDL_bool WindowNeedsViewport(SDL_Window *window)
|
||||
{
|
||||
SDL_WindowData *wind = window->driverdata;
|
||||
SDL_VideoData *video = wind->waylandData;
|
||||
|
@ -161,7 +161,7 @@ static void GetBufferSize(SDL_Window *window, int *width, int *height)
|
|||
|
||||
if (FullscreenModeEmulation(window)) {
|
||||
GetFullScreenDimensions(window, NULL, NULL, &buf_width, &buf_height);
|
||||
} else if (NeedViewport(window)) {
|
||||
} else if (WindowNeedsViewport(window)) {
|
||||
/* Round fractional backbuffer sizes halfway away from zero. */
|
||||
buf_width = (int)SDL_lroundf(window->w * data->scale_factor);
|
||||
buf_height = (int)SDL_lroundf(window->h * data->scale_factor);
|
||||
|
@ -233,7 +233,7 @@ static void ConfigureWindowGeometry(SDL_Window *window)
|
|||
0, 0);
|
||||
}
|
||||
|
||||
if (FullscreenModeEmulation(window) && NeedViewport(window)) {
|
||||
if (FullscreenModeEmulation(window) && WindowNeedsViewport(window)) {
|
||||
int fs_width, fs_height;
|
||||
const int output_width = data->fs_output_width ? data->fs_output_width : output->width;
|
||||
const int output_height = data->fs_output_height ? data->fs_output_height : output->height;
|
||||
|
@ -258,7 +258,7 @@ static void ConfigureWindowGeometry(SDL_Window *window)
|
|||
window_size_changed = data->window_width != window->w || data->window_height != window->h;
|
||||
|
||||
if (window_size_changed || drawable_size_changed) {
|
||||
if (NeedViewport(window)) {
|
||||
if (WindowNeedsViewport(window)) {
|
||||
wl_surface_set_buffer_scale(data->surface, 1);
|
||||
SetDrawSurfaceViewport(window, data->drawable_width, data->drawable_height, window->w, window->h);
|
||||
} else {
|
||||
|
|
|
@ -324,7 +324,7 @@ static int X11_ShowCursor(SDL_Cursor *cursor)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void WarpMouseInternal(Window xwindow, const int x, const int y)
|
||||
static void X11_WarpMouseInternal(Window xwindow, const int x, const int y)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)SDL_GetVideoDevice()->driverdata;
|
||||
Display *display = videodata->display;
|
||||
|
@ -354,16 +354,16 @@ static void X11_WarpMouse(SDL_Window *window, int x, int y)
|
|||
#if SDL_VIDEO_DRIVER_X11_XFIXES
|
||||
/* If we have no barrier, we need to warp */
|
||||
if (data->pointer_barrier_active == SDL_FALSE) {
|
||||
WarpMouseInternal(data->xwindow, x, y);
|
||||
X11_WarpMouseInternal(data->xwindow, x, y);
|
||||
}
|
||||
#else
|
||||
WarpMouseInternal(data->xwindow, x, y);
|
||||
X11_WarpMouseInternal(data->xwindow, x, y);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int X11_WarpMouseGlobal(int x, int y)
|
||||
{
|
||||
WarpMouseInternal(DefaultRootWindow(GetDisplay()), x, y);
|
||||
X11_WarpMouseInternal(DefaultRootWindow(GetDisplay()), x, y);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ void X11_InitTouch(_THIS)
|
|||
|
||||
void X11_QuitTouch(_THIS)
|
||||
{
|
||||
SDL_TouchQuit();
|
||||
SDL_QuitTouch();
|
||||
}
|
||||
|
||||
void X11_ResetTouch(_THIS)
|
||||
|
|
|
@ -1183,7 +1183,7 @@ void X11_HideWindow(_THIS, SDL_Window *window)
|
|||
}
|
||||
}
|
||||
|
||||
static void SetWindowActive(_THIS, SDL_Window *window)
|
||||
static void X11_SetWindowActive(_THIS, SDL_Window *window)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
SDL_DisplayData *displaydata =
|
||||
|
@ -1218,11 +1218,11 @@ void X11_RaiseWindow(_THIS, SDL_Window *window)
|
|||
Display *display = data->videodata->display;
|
||||
|
||||
X11_XRaiseWindow(display, data->xwindow);
|
||||
SetWindowActive(_this, window);
|
||||
X11_SetWindowActive(_this, window);
|
||||
X11_XFlush(display);
|
||||
}
|
||||
|
||||
static void SetWindowMaximized(_THIS, SDL_Window *window, SDL_bool maximized)
|
||||
static void X11_SetWindowMaximized(_THIS, SDL_Window *window, SDL_bool maximized)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
SDL_DisplayData *displaydata =
|
||||
|
@ -1270,7 +1270,7 @@ static void SetWindowMaximized(_THIS, SDL_Window *window, SDL_bool maximized)
|
|||
|
||||
void X11_MaximizeWindow(_THIS, SDL_Window *window)
|
||||
{
|
||||
SetWindowMaximized(_this, window, SDL_TRUE);
|
||||
X11_SetWindowMaximized(_this, window, SDL_TRUE);
|
||||
}
|
||||
|
||||
void X11_MinimizeWindow(_THIS, SDL_Window *window)
|
||||
|
@ -1286,9 +1286,9 @@ void X11_MinimizeWindow(_THIS, SDL_Window *window)
|
|||
|
||||
void X11_RestoreWindow(_THIS, SDL_Window *window)
|
||||
{
|
||||
SetWindowMaximized(_this, window, SDL_FALSE);
|
||||
X11_SetWindowMaximized(_this, window, SDL_FALSE);
|
||||
X11_ShowWindow(_this, window);
|
||||
SetWindowActive(_this, window);
|
||||
X11_SetWindowActive(_this, window);
|
||||
}
|
||||
|
||||
/* This asks the Window Manager to handle fullscreen for us. This is the modern way. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue