// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
namespace SharpDX.DirectInput
{
public partial class DirectInput
{
///
/// Initializes a new instance of the class.
///
public DirectInput() : base(IntPtr.Zero)
{
IntPtr temp;
DInput.DirectInput8Create(Win32Native.GetModuleHandle(null), DInput.SdkVersion, Utilities.GetGuidFromType(typeof(DirectInput)), out temp, null);
NativePointer = temp;
}
///
/// Gets all devices.
///
/// A collection of
public IList GetDevices()
{
return GetDevices(DeviceClass.All, DeviceEnumerationFlags.AllDevices);
}
///
/// Gets the devices for a particular and .
///
/// Class of the device.
/// The device enum flags.
/// A collection of
public IList GetDevices(DeviceClass deviceClass, DeviceEnumerationFlags deviceEnumFlags)
{
var enumDevicesCallback = new EnumDevicesCallback();
EnumDevices((int)deviceClass, enumDevicesCallback.NativePointer, IntPtr.Zero, deviceEnumFlags);
return enumDevicesCallback.DeviceInstances;
}
///
/// Gets the devices for a particular and .
///
/// Type of the device.
/// The device enum flags.
/// A collection of
public IList GetDevices(DeviceType deviceType, DeviceEnumerationFlags deviceEnumFlags)
{
var enumDevicesCallback = new EnumDevicesCallback();
EnumDevices((int)deviceType, enumDevicesCallback.NativePointer, IntPtr.Zero, deviceEnumFlags);
return enumDevicesCallback.DeviceInstances;
}
///
/// Determines whether a device with the specified Guid is attached.
///
/// The device Guid.
///
/// true if the device with the specified device Guid is attached ; otherwise, false.
///
public bool IsDeviceAttached(Guid deviceGuid)
{
return GetDeviceStatus(deviceGuid).Code == 0;
}
///
/// Runs Control Panel to enable the user to install a new input device or modify configurations.
///
public void RunControlPanel()
{
RunControlPanel(IntPtr.Zero);
}
///
/// Runs Control Panel to enable the user to install a new input device or modify configurations.
///
/// Handle of the window to be used as the parent window for the subsequent user interface. If this parameter is NULL, no parent window is used.
public void RunControlPanel(IntPtr handle)
{
RunControlPanel(handle, 0);
}
}
}