예제 #1
0
 static extern private int ohmd_device_getf(IntPtr device, ohmd_float_value val, IntPtr out_value);
예제 #2
0
파일: OpenHMD.cs 프로젝트: sjb8100/C3DE
 public static extern int ohmd_device_setf(IntPtr device, ohmd_float_value val, IntPtr in_value);
예제 #3
0
        /// <summary>
        /// Gets float information from a device.
        /// </summary>
        /// <param name="device">The opened device you want information from.</param>
        /// <param name="arrayLength">Length of the array information you want.</param>
        /// <param name="informationType">Enum value for what kind of information is needed.</param>
        /// <returns>Returns an array of floats where the length is defined by arrayLength which is requested.</returns>
        public float[] getFloatInformation(Device device, int arrayLength, ohmd_float_value informationType)
        {

            if (!openedDevices.ContainsKey(device.Index))
            {
                throw new DeviceNotOpenedException(String.Format("Device with index {0} and name {1} is not yet openend. Please open first.", device.Index, device.Product));
            }
            IntPtr hmd = openedDevices[device.Index];

            float[] result = new float[arrayLength];
            
            //Allocate the result memory, otherwise memory gets corrupted on read / write.
            var gch = GCHandle.Alloc(result, GCHandleType.Pinned);
            IntPtr f = gch.AddrOfPinnedObject();

            //Get the actual value.
            ohmd_device_getf(hmd, informationType, f);

            //Copy the returned IntPtr to the result array.
            Marshal.Copy(f, result, 0, arrayLength);

            //Free the memory.
            gch.Free();
            return result;
        }