DeviceLayouts.cs 919 B

123456789101112131415161718192021222324252627282930
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Scripting;
  5. using UnityEngine.InputSystem;
  6. using UnityEngine.InputSystem.XR;
  7. using UnityEngine.InputSystem.Controls;
  8. using UnityEngine.InputSystem.Layouts;
  9. using UnityEditor;
  10. namespace Ximmerse.XR.InputSystems
  11. {
  12. #if UNITY_EDITOR
  13. [InitializeOnLoad]
  14. #endif
  15. public static class InputLayout
  16. {
  17. static InputLayout()
  18. {
  19. RegisterInputLayouts();
  20. }
  21. public static void RegisterInputLayouts()
  22. {
  23. InputSystem.RegisterLayout<XRHMD>(matches: new InputDeviceMatcher().WithInterface(XRUtilities.InterfaceMatchAnyVersion).WithProduct(@"^(Xim_HMD)|^(Xim)|^(HMD)"));
  24. InputSystem.RegisterLayout<XRController>(matches: new InputDeviceMatcher().WithInterface(XRUtilities.InterfaceMatchAnyVersion).WithProduct(@"^(LeftHand)|^(RightHand)"));
  25. }
  26. }
  27. }