DeviceConfigurationEvent.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Runtime.InteropServices;
  2. using UnityEngine.InputSystem.Utilities;
  3. ////REVIEW: should this have optional data that identifies *what* has changed?
  4. namespace UnityEngine.InputSystem.LowLevel
  5. {
  6. /// <summary>
  7. /// Indicates that the configuration of a device has changed.
  8. /// </summary>
  9. /// <seealso cref="InputSystem.QueueConfigChangeEvent"/>
  10. /// <seealso cref="InputDevice.OnConfigurationChanged"/>
  11. [StructLayout(LayoutKind.Explicit, Size = InputEvent.kBaseEventSize)]
  12. public struct DeviceConfigurationEvent : IInputEventTypeInfo
  13. {
  14. public const int Type = 0x44434647;
  15. [FieldOffset(0)]
  16. public InputEvent baseEvent;
  17. ////REVIEW: have some kind of payload that allows indicating what changed in the config?
  18. public FourCC typeStatic => Type;
  19. public unsafe InputEventPtr ToEventPtr()
  20. {
  21. fixed(DeviceConfigurationEvent * ptr = &this)
  22. {
  23. return new InputEventPtr((InputEvent*)ptr);
  24. }
  25. }
  26. public static DeviceConfigurationEvent Create(int deviceId, double time)
  27. {
  28. var inputEvent = new DeviceConfigurationEvent();
  29. inputEvent.baseEvent = new InputEvent(Type, InputEvent.kBaseEventSize, deviceId, time);
  30. return inputEvent;
  31. }
  32. }
  33. }