|
@@ -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;
|
|
|
- }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
|
|
|
- // Set the joystick to non-blocking read mode
|
|
|
- fcntl(fd, F_SETFL, O_NONBLOCK);
|
|
|
+ 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) {
|
|
|
- fcntl(fd_sensor, F_SETFL, O_NONBLOCK);
|
|
|
+ close(fd_sensor);
|
|
|
}
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- // Get the number of buttons and axes on the joystick
|
|
|
- ConfigJoystick(joystick, fd, fd_sensor);
|
|
|
+ // 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();
|
|
|
}
|
|
|
|
|
|
/*
|