Beispiel #1
0
        private unsafe void InputSystem_onEvent(UnityEngine.Experimental.Input.LowLevel.InputEventPtr obj)
        {
            var device = InputSystem.TryGetDeviceById(obj.deviceId);

            if (device is Touchscreen)
            {
                InputRemoting.Message msg;
                msg.participantId = 1;
                msg.type          = InputRemoting.MessageType.NewEvents;

                // Find total size of event buffer we need.
                var totalSize = 0u;
                totalSize += obj.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)
                {
                    IntPtr intP = obj.data;

                    //Marshal.Copy(intPSendTouchInput, data, 0, (int)totalSize);

                    UnsafeUtility.MemCpy(dataPtr, obj.data.ToPointer(), totalSize);
                }

                if (dataSender != null)
                {
                    int   phase = (int)Touchscreen.current.phase.ReadValue();
                    float posX  = Touchscreen.current.position.x.ReadValue();
                    float posY  = Touchscreen.current.position.y.ReadValue();

                    dataSender.SendTouchInput(connectionProvider, phase, posX, posY);
                }
            }
        }