////TODO: add support for Windows.Gaming.Input.Gamepad (including the trigger motors) using UnityEngine.InputSystem.Layouts; namespace UnityEngine.InputSystem.XInput { /// /// Adds support for XInput controllers. /// #if UNITY_DISABLE_DEFAULT_INPUT_PLUGIN_INITIALIZATION public #else internal #endif static class XInputSupport { public static void Initialize() { // Base layout for Xbox-style gamepad. InputSystem.RegisterLayout(); ////FIXME: layouts should always be available in the editor (mac/win/linux) #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN || UNITY_WSA InputSystem.RegisterLayout( matches: new InputDeviceMatcher().WithInterface("XInput")); #endif #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX InputSystem.RegisterLayout( matches: new InputDeviceMatcher().WithInterface("HID") .WithProduct("Xbox.*Wired Controller")); // Matching older Xbox One controllers that have different View and Share buttons than the newer Xbox Series // controllers. // Reported inhttps://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1264 // Based on devices from this list // https://github.com/mdqinc/SDL_GameControllerDB/blob/a453871de2e0e2484544514c6c080e1e916d620c/gamecontrollerdb.txt#L798C1-L806C1 RegisterXboxOneWirelessFromProductAndVendorID(0x045E, 0x02B0); RegisterXboxOneWirelessFromProductAndVendorID(0x045E, 0x02D1); RegisterXboxOneWirelessFromProductAndVendorID(0x045E, 0x02DD); RegisterXboxOneWirelessFromProductAndVendorID(0x045E, 0x02E0); RegisterXboxOneWirelessFromProductAndVendorID(0x045E, 0x02E3); RegisterXboxOneWirelessFromProductAndVendorID(0x045E, 0x02EA); RegisterXboxOneWirelessFromProductAndVendorID(0x045E, 0x02FD); RegisterXboxOneWirelessFromProductAndVendorID(0x045E, 0x02FF); // This layout is for all the other Xbox One or Series controllers that have the same View and Share buttons. // Reported in https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-385 InputSystem.RegisterLayout( matches: new InputDeviceMatcher().WithInterface("HID") .WithProduct("Xbox.*Wireless Controller")); void RegisterXboxOneWirelessFromProductAndVendorID(int vendorId, int productId) { InputSystem.RegisterLayout( matches: new InputDeviceMatcher().WithInterface("HID") .WithProduct("Xbox.*Wireless Controller") .WithCapability("vendorId", vendorId) .WithCapability("productId", productId)); } #endif } } }