# SDL: Use the automatic mapping instead of a hardcoded one for Xbox controllers on Linux (35c78)

**URL:** <https://discourse.libsdl.org/t/sdl-use-the-automatic-mapping-instead-of-a-hardcoded-one-for-xbox-controllers-on-linux-35c78/44244>\
**Category:** SDL Commits\
**Created:** [June 14, 2023, 12:08am UTC](https://discourse.libsdl.org/t/sdl-use-the-automatic-mapping-instead-of-a-hardcoded-one-for-xbox-controllers-on-linux-35c78/44244 "2023-06-14T00:08:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [June 14, 2023, 12:08am UTC](https://discourse.libsdl.org/t/sdl-use-the-automatic-mapping-instead-of-a-hardcoded-one-for-xbox-controllers-on-linux-35c78/44244/1 "2023-06-14T00:08:15Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/35c7884929abfb338028bb9dc67a5a03f8cff32d>
>
> This is much more robust and able to dynamically create a mapping for Xbox One S…, Xbox Series X, and Xbox Elite 2 controllers.
> 
> (cherry picked from commit 9567989eb3ce9c858f0fe76806c5ccad69da89ba)

```diff
From 35c7884929abfb338028bb9dc67a5a03f8cff32d Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 13 Jun 2023 16:41:52 -0700
Subject: [PATCH] Use the automatic mapping instead of a hardcoded one for Xbox
 controllers on Linux

This is much more robust and able to dynamically create a mapping for Xbox One S, Xbox Series X, and Xbox Elite 2 controllers.

(cherry picked from commit 9567989eb3ce9c858f0fe76806c5ccad69da89ba)
---
 src/joystick/SDL_gamecontroller.c | 2 --
 src/joystick/SDL_gamecontrollerdb.h | 1 -
 2 files changed, 3 deletions(-)

diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c
index 5583f768f432..2f4235cba6b6 100644
--- a/src/joystick/SDL_gamecontroller.c
+++ b/src/joystick/SDL_gamecontroller.c
@@ -1350,8 +1350,6 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const
             mapping = SDL_PrivateAddMappingForGUID(guid,
                                                    "none,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
                                                    &existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
- } else if (SDL_strstr(name, "Xbox") || SDL_strstr(name, "X-Box") || SDL_strstr(name, "XBOX")) {
- mapping = s_pXInputMapping;
         }
     }
 #endif /* __LINUX__ */
diff --git a/src/joystick/SDL_gamecontrollerdb.h b/src/joystick/SDL_gamecontrollerdb.h
index 716132b7eedf..ecd1672b344a 100644
--- a/src/joystick/SDL_gamecontrollerdb.h
+++ b/src/joystick/SDL_gamecontrollerdb.h
@@ -525,7 +525,6 @@ static const char *s_ControllerMappings[] = {
     "03000000830500006020000000000000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,",
 #endif
 #if defined(SDL_JOYSTICK_LINUX) || defined( __OpenBSD__ )
- "xinput,*,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
     "03000000c82d00000090000011010000,8BitDo FC30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
     "03000000c82d00000090000011010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
     "05000000c82d00001038000000010000,8BitDo FC30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",

```
