Removed Linux Steam Controller support

The HIDAPI driver has all the functionality we need on Linux
This commit is contained in:
Sam Lantinga 2024-11-14 21:09:17 -08:00
parent b43b333d25
commit b54f6044a5
5 changed files with 33 additions and 221 deletions

View File

@ -1295,7 +1295,6 @@ if(ANDROID)
set(SDL_JOYSTICK_ANDROID 1) set(SDL_JOYSTICK_ANDROID 1)
sdl_glob_sources( sdl_glob_sources(
"${SDL3_SOURCE_DIR}/src/joystick/android/*.c" "${SDL3_SOURCE_DIR}/src/joystick/android/*.c"
"${SDL3_SOURCE_DIR}/src/joystick/steam/*.c"
) )
set(HAVE_SDL_JOYSTICK TRUE) set(HAVE_SDL_JOYSTICK TRUE)
endif() endif()
@ -1741,7 +1740,6 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
set(SDL_JOYSTICK_LINUX 1) set(SDL_JOYSTICK_LINUX 1)
sdl_glob_sources( sdl_glob_sources(
"${SDL3_SOURCE_DIR}/src/joystick/linux/*.c" "${SDL3_SOURCE_DIR}/src/joystick/linux/*.c"
"${SDL3_SOURCE_DIR}/src/joystick/steam/*.c"
) )
set(HAVE_SDL_JOYSTICK TRUE) set(HAVE_SDL_JOYSTICK TRUE)
endif() endif()
@ -2146,7 +2144,6 @@ elseif(APPLE)
if(SDL_JOYSTICK) if(SDL_JOYSTICK)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/joystick/apple/*.m") sdl_glob_sources("${SDL3_SOURCE_DIR}/src/joystick/apple/*.m")
if(IOS OR TVOS OR VISIONOS OR WATCHOS) if(IOS OR TVOS OR VISIONOS OR WATCHOS)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/joystick/steam/*.c")
set(SDL_JOYSTICK_MFI 1) set(SDL_JOYSTICK_MFI 1)
if(IOS OR VISIONOS OR WATCHOS) if(IOS OR VISIONOS OR WATCHOS)
set(SDL_FRAMEWORK_COREMOTION 1) set(SDL_FRAMEWORK_COREMOTION 1)

View File

@ -346,8 +346,6 @@
A7D8BBA523E2514500DCD162 /* SDL_events_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A94223E2514000DCD162 /* SDL_events_c.h */; }; A7D8BBA523E2514500DCD162 /* SDL_events_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A94223E2514000DCD162 /* SDL_events_c.h */; };
A7D8BBAB23E2514500DCD162 /* SDL_windowevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A94323E2514000DCD162 /* SDL_windowevents_c.h */; }; A7D8BBAB23E2514500DCD162 /* SDL_windowevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A94323E2514000DCD162 /* SDL_windowevents_c.h */; };
A7D8BBB123E2514500DCD162 /* SDL_assert.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A94423E2514000DCD162 /* SDL_assert.c */; }; A7D8BBB123E2514500DCD162 /* SDL_assert.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A94423E2514000DCD162 /* SDL_assert.c */; };
A7D8BBC523E2561500DCD162 /* SDL_steamcontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A7A723E2513E00DCD162 /* SDL_steamcontroller.c */; };
A7D8BBC723E2561500DCD162 /* SDL_steamcontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A7A523E2513E00DCD162 /* SDL_steamcontroller.h */; };
A7D8BBD223E2574800DCD162 /* SDL_uikitappdelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62F23E2513D00DCD162 /* SDL_uikitappdelegate.h */; }; A7D8BBD223E2574800DCD162 /* SDL_uikitappdelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62F23E2513D00DCD162 /* SDL_uikitappdelegate.h */; };
A7D8BBD323E2574800DCD162 /* SDL_uikitappdelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A61E23E2513D00DCD162 /* SDL_uikitappdelegate.m */; }; A7D8BBD323E2574800DCD162 /* SDL_uikitappdelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A61E23E2513D00DCD162 /* SDL_uikitappdelegate.m */; };
A7D8BBD423E2574800DCD162 /* SDL_uikitclipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62123E2513D00DCD162 /* SDL_uikitclipboard.h */; }; A7D8BBD423E2574800DCD162 /* SDL_uikitclipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62123E2513D00DCD162 /* SDL_uikitclipboard.h */; };
@ -798,8 +796,6 @@
A7D8A78823E2513E00DCD162 /* SDL_sysmutex_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysmutex_c.h; sourceTree = "<group>"; }; A7D8A78823E2513E00DCD162 /* SDL_sysmutex_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysmutex_c.h; sourceTree = "<group>"; };
A7D8A79E23E2513E00DCD162 /* SDL_gamepad_db.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamepad_db.h; sourceTree = "<group>"; }; A7D8A79E23E2513E00DCD162 /* SDL_gamepad_db.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamepad_db.h; sourceTree = "<group>"; };
A7D8A7A023E2513E00DCD162 /* SDL_sysjoystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_sysjoystick.c; sourceTree = "<group>"; }; A7D8A7A023E2513E00DCD162 /* SDL_sysjoystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_sysjoystick.c; sourceTree = "<group>"; };
A7D8A7A523E2513E00DCD162 /* SDL_steamcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_steamcontroller.h; sourceTree = "<group>"; };
A7D8A7A723E2513E00DCD162 /* SDL_steamcontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_steamcontroller.c; sourceTree = "<group>"; };
A7D8A7A923E2513E00DCD162 /* SDL_joystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_joystick.c; sourceTree = "<group>"; }; A7D8A7A923E2513E00DCD162 /* SDL_joystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_joystick.c; sourceTree = "<group>"; };
A7D8A7AD23E2513E00DCD162 /* SDL_gamepad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_gamepad.c; sourceTree = "<group>"; }; A7D8A7AD23E2513E00DCD162 /* SDL_gamepad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_gamepad.c; sourceTree = "<group>"; };
A7D8A7C223E2513E00DCD162 /* SDL_hidapi_xbox360.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_xbox360.c; sourceTree = "<group>"; }; A7D8A7C223E2513E00DCD162 /* SDL_hidapi_xbox360.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_xbox360.c; sourceTree = "<group>"; };
@ -1857,7 +1853,6 @@
A7D8A7CC23E2513E00DCD162 /* darwin */, A7D8A7CC23E2513E00DCD162 /* darwin */,
A7D8A79F23E2513E00DCD162 /* dummy */, A7D8A79F23E2513E00DCD162 /* dummy */,
A7D8A7BE23E2513E00DCD162 /* hidapi */, A7D8A7BE23E2513E00DCD162 /* hidapi */,
A7D8A7A123E2513E00DCD162 /* steam */,
75E09157241EA924004729E1 /* virtual */, 75E09157241EA924004729E1 /* virtual */,
F362B9152B3349E200D30B94 /* controller_list.h */, F362B9152B3349E200D30B94 /* controller_list.h */,
F3820712284F3609004DD584 /* controller_type.c */, F3820712284F3609004DD584 /* controller_type.c */,
@ -1883,15 +1878,6 @@
path = dummy; path = dummy;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
A7D8A7A123E2513E00DCD162 /* steam */ = {
isa = PBXGroup;
children = (
A7D8A7A723E2513E00DCD162 /* SDL_steamcontroller.c */,
A7D8A7A523E2513E00DCD162 /* SDL_steamcontroller.h */,
);
path = steam;
sourceTree = "<group>";
};
A7D8A7AA23E2513E00DCD162 /* apple */ = { A7D8A7AA23E2513E00DCD162 /* apple */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -2601,7 +2587,6 @@
F310138F2C1F2CB700FBE946 /* SDL_sysstdlib.h in Headers */, F310138F2C1F2CB700FBE946 /* SDL_sysstdlib.h in Headers */,
F3F7D8F52933074E00816151 /* SDL_stdinc.h in Headers */, F3F7D8F52933074E00816151 /* SDL_stdinc.h in Headers */,
F362B91B2B3349E200D30B94 /* SDL_steam_virtual_gamepad.h in Headers */, F362B91B2B3349E200D30B94 /* SDL_steam_virtual_gamepad.h in Headers */,
A7D8BBC723E2561500DCD162 /* SDL_steamcontroller.h in Headers */,
F3F7D9312933074E00816151 /* SDL_surface.h in Headers */, F3F7D9312933074E00816151 /* SDL_surface.h in Headers */,
A7D8B85A23E2514400DCD162 /* SDL_sysaudio.h in Headers */, A7D8B85A23E2514400DCD162 /* SDL_sysaudio.h in Headers */,
A7D8AAD423E2514100DCD162 /* SDL_syshaptic.h in Headers */, A7D8AAD423E2514100DCD162 /* SDL_syshaptic.h in Headers */,
@ -2905,7 +2890,6 @@
E4F257922C81903800FCEAFC /* Metal_Blit.metal in Sources */, E4F257922C81903800FCEAFC /* Metal_Blit.metal in Sources */,
A7D8AF2423E2514100DCD162 /* SDL_cocoametalview.m in Sources */, A7D8AF2423E2514100DCD162 /* SDL_cocoametalview.m in Sources */,
A7D8B86023E2514400DCD162 /* SDL_audiotypecvt.c in Sources */, A7D8B86023E2514400DCD162 /* SDL_audiotypecvt.c in Sources */,
A7D8BBC523E2561500DCD162 /* SDL_steamcontroller.c in Sources */,
A7D8AD3223E2514100DCD162 /* SDL_blit_N.c in Sources */, A7D8AD3223E2514100DCD162 /* SDL_blit_N.c in Sources */,
A7D8BB7B23E2514500DCD162 /* SDL_dropevents.c in Sources */, A7D8BB7B23E2514500DCD162 /* SDL_dropevents.c in Sources */,
A7D8BACD23E2514500DCD162 /* e_atan2.c in Sources */, A7D8BACD23E2514500DCD162 /* e_atan2.c in Sources */,

View File

@ -46,7 +46,6 @@
#include "../SDL_sysjoystick.h" #include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h" #include "../SDL_joystick_c.h"
#include "../usb_ids.h" #include "../usb_ids.h"
#include "../steam/SDL_steamcontroller.h"
#include "SDL_sysjoystick_c.h" #include "SDL_sysjoystick_c.h"
#include "../hidapi/SDL_hidapijoystick_c.h" #include "../hidapi/SDL_hidapijoystick_c.h"
@ -158,9 +157,6 @@ typedef struct SDL_joylist_item
struct joystick_hwdata *hwdata; struct joystick_hwdata *hwdata;
struct SDL_joylist_item *next; struct SDL_joylist_item *next;
// Steam Controller support
bool m_bSteamController;
bool checked_mapping; bool checked_mapping;
SDL_GamepadMapping *mapping; SDL_GamepadMapping *mapping;
} SDL_joylist_item; } 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) static bool StrIsInteger(const char *string)
{ {
const char *p; const char *p;
@ -1023,8 +961,6 @@ static void LINUX_JoystickDetect(void)
} }
HandlePendingRemovals(); HandlePendingRemovals();
SDL_UpdateSteamControllers();
} }
static bool LINUX_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) 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_free(envcopy);
} }
SDL_InitSteamControllers(SteamControllerConnectedCallback,
SteamControllerDisconnectedCallback);
// Force immediate joystick detection if using fallback // Force immediate joystick detection if using fallback
last_joy_detect_time = 0; last_joy_detect_time = 0;
last_input_dir_mtime = 0; last_input_dir_mtime = 0;
@ -1523,17 +1456,9 @@ static bool PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item
joystick->hwdata->item_sensor = item_sensor; joystick->hwdata->item_sensor = item_sensor;
joystick->hwdata->guid = item->guid; joystick->hwdata->guid = item->guid;
joystick->hwdata->effect.id = -1; 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->key_map, 0xFF, sizeof(joystick->hwdata->key_map));
SDL_memset(joystick->hwdata->abs_map, 0xFF, sizeof(joystick->hwdata->abs_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; int fd = -1, fd_sensor = -1;
// Try read-write first, so we can do rumble // Try read-write first, so we can do rumble
fd = open(item->path, O_RDWR | O_CLOEXEC, 0); fd = open(item->path, O_RDWR | O_CLOEXEC, 0);
@ -1568,7 +1493,6 @@ static bool PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item
// Get the number of buttons and axes on the joystick // Get the number of buttons and axes on the joystick
ConfigJoystick(joystick, fd, fd_sensor); ConfigJoystick(joystick, fd, fd_sensor);
}
return true; return true;
} }
@ -2207,11 +2131,6 @@ static void LINUX_JoystickUpdate(SDL_Joystick *joystick)
SDL_AssertJoysticksLocked(); SDL_AssertJoysticksLocked();
if (joystick->hwdata->m_bSteamController) {
SDL_UpdateSteamController(joystick);
return;
}
if (joystick->hwdata->classic) { if (joystick->hwdata->classic) {
HandleClassicEvents(joystick); HandleClassicEvents(joystick);
} else { } else {
@ -2298,8 +2217,6 @@ static void LINUX_JoystickQuit(void)
SDL_UDEV_Quit(); SDL_UDEV_Quit();
} }
#endif #endif
SDL_QuitSteamControllers();
} }
/* /*

View File

@ -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)
{
}

View File

@ -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_