limit mappings to linux hosts

This commit is contained in:
Maki 2025-11-30 12:23:51 -05:00
parent 467707cf7e
commit 28b85302e4
2 changed files with 10 additions and 9 deletions

View file

@ -48,9 +48,6 @@ namespace Ryujinx.Input.SDL3
{GamepadButtonInputId.SingleLeftTrigger1, SDL_GamepadButton.SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1}
};
private const string LeftMapping = "050067007e0500000620000001800000,Nintendo Switch Joy-Con (L),back:b5,dpdown:b8,dpleft:b9,dpright:b10,dpup:b7,leftshoulder:b1,leftstick:b6,lefttrigger:b3,leftx:a1,lefty:a0,misc1:b0,paddle2:b2,paddle4:b4,";
private const string RightMapping = "05006ea07e0500000720000001800000,Nintendo Switch Joy-Con (R),a:b0,b:b1,guide:b9,paddle1:b6,paddle3:b4,rightshoulder:b5,rightstick:b10,righttrigger:b7,leftx:a1,lefty:a0,start:b8,x:b3,y:b2,";
private readonly Dictionary<GamepadButtonInputId, SDL_GamepadButton> _buttonsDriverMapping;
private readonly Lock _userMappingLock = new();
@ -107,18 +104,12 @@ namespace Ryujinx.Input.SDL3
{
_buttonsDriverMapping = _leftButtonsDriverMapping;
_joyConType = JoyConType.Left;
if (SDL_AddGamepadMapping(LeftMapping) == -1) {
Logger.Error?.Print(LogClass.Hid, $"Could not set SDL input map for {Name}");
}
break;
}
case RightName:
{
_buttonsDriverMapping = _rightButtonsDriverMapping;
_joyConType = JoyConType.Right;
if (SDL_AddGamepadMapping(RightMapping) == -1) {
Logger.Error?.Print(LogClass.Hid, $"Could not set SDL input map for {Name}");
}
break;
}
}

View file

@ -28,6 +28,9 @@ namespace Ryujinx.SDL3.Common
private const SDL_InitFlags SdlInitFlags = SDL_InitFlags.SDL_INIT_EVENTS | SDL_InitFlags.SDL_INIT_GAMEPAD | SDL_InitFlags.SDL_INIT_JOYSTICK | SDL_InitFlags.SDL_INIT_AUDIO | SDL_InitFlags.SDL_INIT_VIDEO;
private const string JoyconLeftMappingLinux = "050067007e0500000620000001800000,Nintendo Switch Joy-Con (L),platform:Linux,back:b5,dpdown:b8,dpleft:b9,dpright:b10,dpup:b7,leftshoulder:b1,leftstick:b6,lefttrigger:b3,leftx:a1,lefty:a0,misc1:b0,paddle2:b2,paddle4:b4,";
private const string JoyconRightMappingLinux = "05006ea07e0500000720000001800000,Nintendo Switch Joy-Con (R),platform:Linux,a:b0,b:b1,guide:b9,leftx:a1,lefty:a0,paddle1:b6,paddle3:b4,rightshoulder:b5,rightstick:b10,righttrigger:b7,start:b8,x:b3,y:b2,";
private bool _isRunning;
private uint _refereceCount;
private Thread _worker;
@ -96,6 +99,13 @@ namespace Ryujinx.SDL3.Common
SDL_SetEventEnabled((uint)SDL_EventType.SDL_EVENT_GAMEPAD_SENSOR_UPDATE, false);
if (SDL_AddGamepadMapping(JoyconLeftMappingLinux) == -1) {
Logger.Error?.Print(LogClass.Hid, $"Could not set SDL Joycon (L) mappings");
}
if (SDL_AddGamepadMapping(JoyconRightMappingLinux) == -1) {
Logger.Error?.Print(LogClass.Hid, $"Could not set SDL Joycon (R) mappings");
}
string gamepadDbPath = Path.Combine(AppDataManager.BaseDirPath, "SDL_GameControllerDB.txt");
if (File.Exists(gamepadDbPath))