Ejemplo n.º 1
0
        public IList <DIDEVICEINSTANCE> EnumDevices(DI8DEVTYPE deviceType, DIEDFL deviceEnumFlags)
        {
            var callback = new EnumDevicesCallback();

            this.EnumDevices((int)deviceType, callback.NativePointer, IntPtr.Zero, deviceEnumFlags);
            return(callback.DeviceInstances);
        }
 public List<DIDEVICEINSTANCEW> EnumDevices(DI8DEVTYPE deviceType, DIEDFL flags)
 {
     List<DIDEVICEINSTANCEW> result = new List<DIDEVICEINSTANCEW>();
     //
     LPDIENUMDEVICESCALLBACK callback = new LPDIENUMDEVICESCALLBACK(DirectInput.EnumDevicesCallback);
     GCHandle hCallback = GCHandle.Alloc(callback);
     GCHandle hResult   = GCHandle.Alloc(result);
     try {
         IntPtr pfn = Marshal.GetFunctionPointerForDelegate(callback);
         this.pDirectInput8.EnumDevices(deviceType, pfn, GCHandle.ToIntPtr(hResult), flags);
         }
     finally
         {
         hCallback.Free();
         hResult.Free();
         }
     //
     return result;
 }