mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-14 05:46:00 +00:00
Removed Linux Steam Controller support
The HIDAPI driver has all the functionality we need on Linux
This commit is contained in:
@@ -46,7 +46,6 @@
|
||||
#include "../SDL_sysjoystick.h"
|
||||
#include "../SDL_joystick_c.h"
|
||||
#include "../usb_ids.h"
|
||||
#include "../steam/SDL_steamcontroller.h"
|
||||
#include "SDL_sysjoystick_c.h"
|
||||
#include "../hidapi/SDL_hidapijoystick_c.h"
|
||||
|
||||
@@ -158,9 +157,6 @@ typedef struct SDL_joylist_item
|
||||
struct joystick_hwdata *hwdata;
|
||||
struct SDL_joylist_item *next;
|
||||
|
||||
// Steam Controller support
|
||||
bool m_bSteamController;
|
||||
|
||||
bool checked_mapping;
|
||||
SDL_GamepadMapping *mapping;
|
||||
} SDL_joylist_item;
|
||||
@@ -664,64 +660,6 @@ static void HandlePendingRemovals(void)
|
||||
}
|
||||
}
|
||||
|
||||
static bool SteamControllerConnectedCallback(const char *name, SDL_GUID guid, SDL_JoystickID *device_instance)
|
||||
{
|
||||
Uint16 vendor, product, version;
|
||||
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version, NULL);
|
||||
if (SDL_JoystickHandledByAnotherDriver(&SDL_LINUX_JoystickDriver, vendor, product, version, name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_joylist_item *item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item));
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
item->path = SDL_strdup("");
|
||||
item->name = SDL_strdup(name);
|
||||
item->guid = guid;
|
||||
item->m_bSteamController = true;
|
||||
|
||||
if ((!item->path) || (!item->name)) {
|
||||
FreeJoylistItem(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
*device_instance = item->device_instance = SDL_GetNextObjectID();
|
||||
SDL_LockJoysticks();
|
||||
if (!SDL_joylist_tail) {
|
||||
SDL_joylist = SDL_joylist_tail = item;
|
||||
} else {
|
||||
SDL_joylist_tail->next = item;
|
||||
SDL_joylist_tail = item;
|
||||
}
|
||||
|
||||
// Need to increment the joystick count before we post the event
|
||||
++numjoysticks;
|
||||
|
||||
SDL_PrivateJoystickAdded(item->device_instance);
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void SteamControllerDisconnectedCallback(SDL_JoystickID device_instance)
|
||||
{
|
||||
SDL_joylist_item *item;
|
||||
SDL_joylist_item *prev = NULL;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
for (item = SDL_joylist; item; item = item->next) {
|
||||
// found it, remove it.
|
||||
if (item->device_instance == device_instance) {
|
||||
RemoveJoylistItem(item, prev);
|
||||
break;
|
||||
}
|
||||
prev = item;
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
static bool StrIsInteger(const char *string)
|
||||
{
|
||||
const char *p;
|
||||
@@ -1023,8 +961,6 @@ static void LINUX_JoystickDetect(void)
|
||||
}
|
||||
|
||||
HandlePendingRemovals();
|
||||
|
||||
SDL_UpdateSteamControllers();
|
||||
}
|
||||
|
||||
static bool LINUX_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
|
||||
@@ -1060,9 +996,6 @@ static bool LINUX_JoystickInit(void)
|
||||
SDL_free(envcopy);
|
||||
}
|
||||
|
||||
SDL_InitSteamControllers(SteamControllerConnectedCallback,
|
||||
SteamControllerDisconnectedCallback);
|
||||
|
||||
// Force immediate joystick detection if using fallback
|
||||
last_joy_detect_time = 0;
|
||||
last_input_dir_mtime = 0;
|
||||
@@ -1523,52 +1456,43 @@ static bool PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item
|
||||
joystick->hwdata->item_sensor = item_sensor;
|
||||
joystick->hwdata->guid = item->guid;
|
||||
joystick->hwdata->effect.id = -1;
|
||||
joystick->hwdata->m_bSteamController = item->m_bSteamController;
|
||||
SDL_memset(joystick->hwdata->key_map, 0xFF, sizeof(joystick->hwdata->key_map));
|
||||
SDL_memset(joystick->hwdata->abs_map, 0xFF, sizeof(joystick->hwdata->abs_map));
|
||||
|
||||
if (item->m_bSteamController) {
|
||||
joystick->hwdata->fd = -1;
|
||||
joystick->hwdata->fd_sensor = -1;
|
||||
SDL_GetSteamControllerInputs(&joystick->nbuttons,
|
||||
&joystick->naxes,
|
||||
&joystick->nhats);
|
||||
} else {
|
||||
int fd = -1, fd_sensor = -1;
|
||||
// Try read-write first, so we can do rumble
|
||||
fd = open(item->path, O_RDWR | O_CLOEXEC, 0);
|
||||
if (fd < 0) {
|
||||
// Try read-only again, at least we'll get events in this case
|
||||
fd = open(item->path, O_RDONLY | O_CLOEXEC, 0);
|
||||
}
|
||||
if (fd < 0) {
|
||||
return SDL_SetError("Unable to open %s", item->path);
|
||||
}
|
||||
// If opening sensor fail, continue with buttons and axes only
|
||||
if (item_sensor) {
|
||||
fd_sensor = open(item_sensor->path, O_RDONLY | O_CLOEXEC, 0);
|
||||
}
|
||||
|
||||
joystick->hwdata->fd = fd;
|
||||
joystick->hwdata->fd_sensor = fd_sensor;
|
||||
joystick->hwdata->fname = SDL_strdup(item->path);
|
||||
if (!joystick->hwdata->fname) {
|
||||
close(fd);
|
||||
if (fd_sensor >= 0) {
|
||||
close(fd_sensor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the joystick to non-blocking read mode
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
if (fd_sensor >= 0) {
|
||||
fcntl(fd_sensor, F_SETFL, O_NONBLOCK);
|
||||
}
|
||||
|
||||
// Get the number of buttons and axes on the joystick
|
||||
ConfigJoystick(joystick, fd, fd_sensor);
|
||||
int fd = -1, fd_sensor = -1;
|
||||
// Try read-write first, so we can do rumble
|
||||
fd = open(item->path, O_RDWR | O_CLOEXEC, 0);
|
||||
if (fd < 0) {
|
||||
// Try read-only again, at least we'll get events in this case
|
||||
fd = open(item->path, O_RDONLY | O_CLOEXEC, 0);
|
||||
}
|
||||
if (fd < 0) {
|
||||
return SDL_SetError("Unable to open %s", item->path);
|
||||
}
|
||||
// If opening sensor fail, continue with buttons and axes only
|
||||
if (item_sensor) {
|
||||
fd_sensor = open(item_sensor->path, O_RDONLY | O_CLOEXEC, 0);
|
||||
}
|
||||
|
||||
joystick->hwdata->fd = fd;
|
||||
joystick->hwdata->fd_sensor = fd_sensor;
|
||||
joystick->hwdata->fname = SDL_strdup(item->path);
|
||||
if (!joystick->hwdata->fname) {
|
||||
close(fd);
|
||||
if (fd_sensor >= 0) {
|
||||
close(fd_sensor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the joystick to non-blocking read mode
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
if (fd_sensor >= 0) {
|
||||
fcntl(fd_sensor, F_SETFL, O_NONBLOCK);
|
||||
}
|
||||
|
||||
// Get the number of buttons and axes on the joystick
|
||||
ConfigJoystick(joystick, fd, fd_sensor);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2207,11 +2131,6 @@ static void LINUX_JoystickUpdate(SDL_Joystick *joystick)
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (joystick->hwdata->m_bSteamController) {
|
||||
SDL_UpdateSteamController(joystick);
|
||||
return;
|
||||
}
|
||||
|
||||
if (joystick->hwdata->classic) {
|
||||
HandleClassicEvents(joystick);
|
||||
} else {
|
||||
@@ -2298,8 +2217,6 @@ static void LINUX_JoystickQuit(void)
|
||||
SDL_UDEV_Quit();
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_QuitSteamControllers();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#include "../SDL_sysjoystick.h"
|
||||
#include "../SDL_joystick_c.h"
|
||||
#include "SDL_steamcontroller.h"
|
||||
|
||||
void SDL_InitSteamControllers(SteamControllerConnectedCallback_t connectedCallback,
|
||||
SteamControllerDisconnectedCallback_t disconnectedCallback)
|
||||
{
|
||||
}
|
||||
|
||||
void SDL_GetSteamControllerInputs(int *nbuttons, int *naxes, int *nhats)
|
||||
{
|
||||
*nbuttons = 0;
|
||||
*naxes = 0;
|
||||
*nhats = 0;
|
||||
}
|
||||
|
||||
void SDL_UpdateSteamControllers(void)
|
||||
{
|
||||
}
|
||||
|
||||
void SDL_UpdateSteamController(SDL_Joystick *joystick)
|
||||
{
|
||||
}
|
||||
|
||||
void SDL_QuitSteamControllers(void)
|
||||
{
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_steamcontroller_h_
|
||||
#define SDL_steamcontroller_h_
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
typedef bool (*SteamControllerConnectedCallback_t)(const char *name, SDL_GUID guid, SDL_JoystickID *device_instance);
|
||||
typedef void (*SteamControllerDisconnectedCallback_t)(SDL_JoystickID device_instance);
|
||||
|
||||
void SDL_InitSteamControllers(SteamControllerConnectedCallback_t connectedCallback,
|
||||
SteamControllerDisconnectedCallback_t disconnectedCallback);
|
||||
void SDL_GetSteamControllerInputs(int *nbuttons, int *naxes, int *nhats);
|
||||
void SDL_UpdateSteamControllers(void);
|
||||
void SDL_UpdateSteamController(SDL_Joystick *joystick);
|
||||
void SDL_QuitSteamControllers(void);
|
||||
|
||||
#endif // SDL_steamcontroller_h_
|
Reference in New Issue
Block a user