Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hardcoded SDL controller mapping from UWP build #6965

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

StephenCWills
Copy link
Member

@StephenCWills StephenCWills commented Feb 15, 2024

See #6930 (comment)

I remember now that the Xbox One/Xbox Series build had some custom startup code that attempted to swap the A/B and X/Y buttons using SDL controller mappings.

std::string controllerMapping = ",*,a:b1,b:b0,x:b3,y:b2,back:b6,start:b7,leftstick:b8,rightstick:b9,leftshoulder:b4,rightshoulder:b5,dpup:b10,dpdown:b12,dpleft:b13,dpright:b11,leftx:a1,lefty:a0~,rightx:a3,righty:a2~,lefttrigger:a4,righttrigger:a5,platform:WinRT";
for(int i = 0; i < SDL_NumJoysticks(); ++i)
{
SDL_JoystickType type = SDL_JoystickGetDeviceType(i);
if(type == SDL_JOYSTICK_POWER_UNKNOWN)
continue;
SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(i);
if(!guid.data)
continue;
char guidString[33];
SDL_JoystickGetGUIDString(guid, guidString, 33);
SDL_GameControllerAddMapping((guidString + controllerMapping).c_str());
}

Now that we are able to detect controller type, this code should be unnecessary. But it's worse than that because I've found that it's subject to a race condition. Sometimes this code runs before the SDL event that adds the game controller. Discord user Tree reported it on Discord back in August 2022, and I think there was another report even before that so I think that confirms it happens on Xbox hardware. I have never run the build on anything but Windows, but I was also able to reproduce the issue there.

@AJenbo AJenbo enabled auto-merge (rebase) February 15, 2024 04:45
@AJenbo AJenbo merged commit 55a5337 into diasurgical:master Feb 15, 2024
22 checks passed
@StephenCWills StephenCWills deleted the uwp-button-swap branch February 15, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants