BufferedRumble.cs 864 B

12345678910111213141516171819202122232425262728
  1. #if UNITY_INPUT_SYSTEM_ENABLE_XR || PACKAGE_DOCS_GENERATION
  2. namespace UnityEngine.InputSystem.XR.Haptics
  3. {
  4. public struct BufferedRumble
  5. {
  6. public HapticCapabilities capabilities { get; private set; }
  7. InputDevice device { get; set; }
  8. public BufferedRumble(InputDevice device)
  9. {
  10. if (device == null)
  11. throw new System.ArgumentNullException(nameof(device));
  12. this.device = device;
  13. var command = GetHapticCapabilitiesCommand.Create();
  14. device.ExecuteCommand(ref command);
  15. capabilities = command.capabilities;
  16. }
  17. public void EnqueueRumble(byte[] samples)
  18. {
  19. var command = SendBufferedHapticCommand.Create(samples);
  20. device.ExecuteCommand(ref command);
  21. }
  22. }
  23. }
  24. #endif // UNITY_INPUT_SYSTEM_ENABLE_XR