Пример #1
0
            public static unsafe void Process(InputRemoting receiver, Message msg)
            {
                var manager = receiver.m_LocalManager;

                fixed(byte *dataPtr = msg.data)
                {
                    var dataEndPtr  = new IntPtr(dataPtr + msg.data.Length);
                    var eventCount  = 0;
                    var eventPtr    = new InputEventPtr((InputEvent *)dataPtr);
                    var senderIndex = receiver.FindOrCreateSenderRecord(msg.participantId);

                    while (eventPtr.data.ToInt64() < dataEndPtr.ToInt64())
                    {
                        // Patch up device ID to refer to local device and send event.
                        var remoteDeviceId = eventPtr.deviceId;
                        var localDeviceId  = receiver.FindLocalDeviceId(remoteDeviceId, senderIndex);
                        eventPtr.deviceId = localDeviceId;

                        if (localDeviceId != InputDevice.kInvalidDeviceId)
                        {
                            ////TODO: add API to send events in bulk rather than one by one
                            manager.QueueEvent(eventPtr);
                        }

                        ++eventCount;
                        eventPtr = eventPtr.Next();
                    }
                }
            }
Пример #2
0
            public static unsafe Message Create(InputRemoting sender, IntPtr events, int eventCount)
            {
                // Find total size of event buffer we need.
                var totalSize = 0u;
                var eventPtr  = new InputEventPtr(events);

                for (var i = 0; i < eventCount; ++i, eventPtr = eventPtr.Next())
                {
                    totalSize += eventPtr.sizeInBytes;
                }

                // Copy event data to buffer. Would be nice if we didn't have to do that
                // but unfortunately we need a byte[] and can't just pass the 'events' IntPtr
                // directly.
                var data = new byte[totalSize];

                fixed(byte *dataPtr = data)
                {
                    UnsafeUtility.MemCpy(dataPtr, events.ToPointer(), totalSize);
                }

                // Done.
                return(new Message
                {
                    type = MessageType.NewEvents,
                    data = data
                });
            }
        public static unsafe void Process(InputRemoting.Message msg, int deviceId, FourCC type)
        {
            fixed(byte *dataPtr = msg.data)
            {
                var dataEndPtr = new IntPtr(dataPtr + msg.data.Length);
                var eventCount = 0;
                var eventPtr   = new InputEventPtr((InputEvent *)dataPtr);

                while (eventPtr.data.ToInt64() < dataEndPtr.ToInt64())
                {
                    eventPtr.deviceId = deviceId;

                    InputSystem.QueueEvent(eventPtr);

                    ++eventCount;
                    eventPtr = eventPtr.Next();
                }

                InputSystem.Update();
            }
        }
Пример #4
0
            public static unsafe void Process(InputRemoting receiver, Message msg)
            {
                // This isn't the best solution but should do for now. NativeInputSystem isn't
                // designed for having multiple InputManagers and we only have that scenario
                // for tests ATM. So, to make InputManagers that aren't really properly connected
                // still work for testing, we directly feed them the events we get here.
                var isConnectedToNative = NativeInputSystem.onUpdate == receiver.m_LocalManager.OnNativeUpdate;

                fixed(byte *dataPtr = msg.data)
                {
                    var dataEndPtr  = new IntPtr(dataPtr + msg.data.Length);
                    var eventCount  = 0;
                    var eventPtr    = new InputEventPtr((InputEvent *)dataPtr);
                    var senderIndex = receiver.FindOrCreateSenderRecord(msg.participantId);

                    while (eventPtr.data.ToInt64() < dataEndPtr.ToInt64())
                    {
                        // Patch up device ID to refer to local device and send event.
                        var remoteDeviceId = eventPtr.deviceId;
                        var localDeviceId  = receiver.FindLocalDeviceId(remoteDeviceId, senderIndex);
                        eventPtr.deviceId = localDeviceId;

                        if (localDeviceId != InputDevice.kInvalidDeviceId && isConnectedToNative)
                        {
                            ////TODO: add API to send events in bulk rather than one by one
                            InputSystem.QueueEvent(eventPtr);
                        }

                        ++eventCount;
                        eventPtr = eventPtr.Next();
                    }

                    if (!isConnectedToNative)
                    {
                        receiver.m_LocalManager.OnNativeUpdate(NativeInputUpdateType.Dynamic, eventCount, new IntPtr(dataPtr));
                    }
                }
            }