コード例 #1
0
        static unsafe bool EnumDevicesHandler(IntPtr /*DIDEVICEINSTANCE*/ lpddi, void *pvRef)
        {
            DIDEVICEINSTANCE *deviceInstance = (DIDEVICEINSTANCE *)lpddi.ToPointer();

            //ignore XInput devices
            if (Instance.haveXInput && DInput.IsXInputDevice(ref deviceInstance->guidProduct))
            {
                return(true);                //continue
            }
            if ((deviceInstance->dwDevType & DInput.DI8DEVTYPE_JOYSTICK) != 0)
            {
                string deviceName = new string( deviceInstance->tszInstanceName );

                DirectInputJoystickInputDevice joystick = new DirectInputJoystickInputDevice(
                    deviceName, deviceInstance->guidInstance);

                if (!joystick.Init())
                {
                    joystick.CallOnShutdown();
                    return(true);
                }

                Instance.RegisterDevice(joystick);
            }

            return(true);            //continue
        }
コード例 #2
0
ファイル: DeviceInfo.cs プロジェクト: gregdivis/Aeon
 /// <summary>
 /// Initializes a new instance of the <see cref="DeviceInfo"/> class.
 /// </summary>
 /// <param name="info">The native device info.</param>
 internal unsafe DeviceInfo(DIDEVICEINSTANCE *info)
 {
     this.Name       = new string(info->wszInstanceName);
     this.Product    = new string(info->wszProductName);
     this.InstanceId = info->guidInstance;
     this.ProductId  = info->guidProduct;
 }