Restore Serialized Input Events

Hi everyone!
I’v necessity to replay serialized input events, kind of replay system. I took byte[ ] with State.From() and then serialize it. After that i have tried restore it, created separate devices from and then try add events with QueueEvent() for they.

        public unsafe void Emit(InputDevice device, InputClipFrame frame)
        {
            InputEventPtr ptr = RestoreEventPtr(frame.EventData);
            ptr.time = frame.Timestamp;
            InputSystem.QueueEvent();
        }
       
        private unsafe InputEventPtr RestoreEventPtr(byte[] eventData)
        {
            NativeArray<byte> nativeDataBuffer = new NativeArray<byte>(eventData, Allocator.Persistent);
            InputEvent* eventPtr = (InputEvent*)NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks(nativeDataBuffer);
            InputEventPtr managedPtr = InputEventPtr.From(eventPtr);
            nativeDataBuffer.Dispose();
            return managedPtr;
        }

But have’t any effect. Maybe you can show me right way for this.

There’s greatly enhanced API for this in the landing pattern. If all goes well, should be in the upcoming package.

Oh… Looks perfect. Very grateful for this!