GetHapticCapabilitiesCommand.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #if UNITY_INPUT_SYSTEM_ENABLE_XR || PACKAGE_DOCS_GENERATION
  2. using System.Runtime.InteropServices;
  3. using UnityEngine.InputSystem.Utilities;
  4. using UnityEngine.InputSystem.LowLevel;
  5. namespace UnityEngine.InputSystem.XR.Haptics
  6. {
  7. public struct HapticCapabilities
  8. {
  9. public HapticCapabilities(uint numChannels, uint frequencyHz, uint maxBufferSize)
  10. {
  11. this.numChannels = numChannels;
  12. this.frequencyHz = frequencyHz;
  13. this.maxBufferSize = maxBufferSize;
  14. }
  15. public uint numChannels { get; private set; }
  16. public uint frequencyHz { get; private set; }
  17. public uint maxBufferSize { get; private set; }
  18. }
  19. [StructLayout(LayoutKind.Explicit, Size = kSize)]
  20. public struct GetHapticCapabilitiesCommand : IInputDeviceCommandInfo
  21. {
  22. static FourCC Type => new FourCC('X', 'H', 'C', '0');
  23. const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(uint) * 3;
  24. public FourCC typeStatic => Type;
  25. [FieldOffset(0)]
  26. InputDeviceCommand baseCommand;
  27. [FieldOffset(InputDeviceCommand.kBaseCommandSize)]
  28. public uint numChannels;
  29. [FieldOffset(InputDeviceCommand.kBaseCommandSize + sizeof(uint))]
  30. public uint frequencyHz;
  31. [FieldOffset(InputDeviceCommand.kBaseCommandSize + (sizeof(uint) * 2))]
  32. public uint maxBufferSize;
  33. public HapticCapabilities capabilities => new HapticCapabilities(numChannels, frequencyHz, maxBufferSize);
  34. public static GetHapticCapabilitiesCommand Create()
  35. {
  36. return new GetHapticCapabilitiesCommand
  37. {
  38. baseCommand = new InputDeviceCommand(Type, kSize),
  39. };
  40. }
  41. }
  42. }
  43. #endif // UNITY_INPUT_SYSTEM_ENABLE_XR