Ejemplo n.º 1
0
        private static DoubleBuffers SetUpDeviceToBufferMappings(int deviceCount, ref byte *bufferPtr, uint sizePerBuffer, uint mappingTableSizePerBuffer)
        {
            var front    = bufferPtr;
            var back     = bufferPtr + sizePerBuffer;
            var mappings = (void **)(bufferPtr + sizePerBuffer * 2);  // Put mapping table at end.

            bufferPtr += sizePerBuffer * 2 + mappingTableSizePerBuffer;

            var buffers = new DoubleBuffers {
                deviceToBufferMapping = mappings
            };

            for (var i = 0; i < deviceCount; ++i)
            {
                var deviceIndex = i;
                buffers.SetFrontBuffer(deviceIndex, front);
                buffers.SetBackBuffer(deviceIndex, back);
            }

            return(buffers);
        }
Ejemplo n.º 2
0
        private unsafe DoubleBuffers SetUpDeviceToBufferMappings(InputDevice[] devices, int deviceCount, ref IntPtr bufferPtr, uint sizePerBuffer, uint mappingTableSizePerBuffer)
        {
            var front    = bufferPtr;
            var back     = new IntPtr(bufferPtr.ToInt64() + sizePerBuffer);
            var mappings = (void **)new IntPtr(bufferPtr.ToInt64() + sizePerBuffer * 2).ToPointer();  // Put mapping table at end.

            bufferPtr = new IntPtr(bufferPtr.ToInt64() + sizePerBuffer * 2 + mappingTableSizePerBuffer);

            var buffers = new DoubleBuffers {
                deviceToBufferMapping = mappings
            };

            for (var i = 0; i < deviceCount; ++i)
            {
                var deviceIndex = devices[i].m_DeviceIndex;

                buffers.SetFrontBuffer(deviceIndex, front);
                buffers.SetBackBuffer(deviceIndex, back);
            }

            return(buffers);
        }