public unsafe static extern int SetProperty_DIPROPRANGE(void * /*IDirectInputDevice8*/ _this, void */*GUID*/ rguidProp, ref DIPROPRANGE pdiph);
unsafe static bool EnumDeviceObjectsHandler(IntPtr /*DIDEVICEOBJECTINSTANCE*/ lpddoi, void *pvRef) { DirectInputJoystickInputDevice device = tempDeviceForEnumerate; DIDEVICEOBJECTINSTANCE *deviceObjectInstance = (DIDEVICEOBJECTINSTANCE *)lpddoi; if ((deviceObjectInstance->dwType & DInput.DIDFT_AXIS) != 0) { int hr; // set range DIPROPRANGE diPropRange = new DIPROPRANGE(); diPropRange.diph.dwSize = (uint)sizeof(DIPROPRANGE); diPropRange.diph.dwHeaderSize = (uint)sizeof(DIPROPHEADER); diPropRange.diph.dwHow = DInput.DIPH_BYID; diPropRange.diph.dwObj = deviceObjectInstance->dwType; diPropRange.lMin = -(int)MaxRange; diPropRange.lMax = +(int)MaxRange; GUID *propRangeGuid = (GUID *)DInput.getDIPROP_RANGE(); hr = IDirectInputDevice8.SetProperty_DIPROPRANGE(device.directInputDevice, propRangeGuid, ref diPropRange); //hr = IDirectInputDevice8.SetProperty( device.directInputDevice, // propRangeGuid, ref diPropRange.diph ); if (Wrapper.FAILED(hr)) { Log.Warning("DirectInputJoystickInputDevice: Cannot set axis range for \"{0}\" ({1}).", device.Name, DInput.GetOutString(DInput.DXGetErrorStringW(hr))); } // set axis type //uint userData = 0xFFFFFFFF; if (deviceObjectInstance->guidType == DInput.GUID_Slider) { device.temporarySliderCount++; } if (deviceObjectInstance->guidType == DInput.GUID_XAxis || deviceObjectInstance->guidType == DInput.GUID_YAxis || deviceObjectInstance->guidType == DInput.GUID_ZAxis || deviceObjectInstance->guidType == DInput.GUID_RxAxis || deviceObjectInstance->guidType == DInput.GUID_RyAxis || deviceObjectInstance->guidType == DInput.GUID_RzAxis) { // set dead zone //DIPROPDWORD deadZone = new DIPROPDWORD(); //deadZone.diph.dwSize = (uint)sizeof( DIPROPDWORD ); //deadZone.diph.dwHeaderSize = (uint)sizeof( DIPROPHEADER ); //deadZone.diph.dwHow = DInput.DIPH_BYID; //deadZone.diph.dwObj = deviceObjectInstance->dwType; // Specify the enumerated axis //deadZone.dwData = 500; // dead zone of 5% //GUID* propDeadZone = (GUID*)DInput.getDIPROP_DEADZONE(); //hr = IDirectInputDevice8.SetProperty( joystickDevice, // propDeadZone, ref deadZone.diph ); //if( Wrapper.FAILED( hr ) ) //{ // Log.Error( "Cannot set axis dead zone for '" + Name + "'" ); //} // type settings //userData = 0x80000000 | (uint)device.temporaryAxisList.Count; JoystickAxes axisName = GetJoystickAxisNameByGUID(deviceObjectInstance->guidType); RangeF range = new RangeF(-1, 1); bool forceFeedbackSupported = (deviceObjectInstance->dwFlags & DInput.DIDOI_FFACTUATOR) != 0; JoystickInputDevice.Axis axis = new JoystickInputDevice.Axis( axisName, range, forceFeedbackSupported); device.temporaryAxisList.Add(axis); } //// set user data //DIPROPPOINTER diptr = new DIPROPPOINTER(); //diptr.diph.dwSize = (uint)sizeof( DIPROPPOINTER ); //diptr.diph.dwHeaderSize = (uint)sizeof( DIPROPHEADER ); //diptr.diph.dwHow = DInput.DIPH_BYID; //diptr.diph.dwObj = deviceObjectInstance->dwType; ////if( IntPtr.Size == 8 ) ////{ //// UInt64 v64 = userData; //// NativeUtils.CopyMemory( (IntPtr)( &diptr.uData ), (IntPtr)( &v64 ), IntPtr.Size ); ////} ////else ////{ //// NativeUtils.CopyMemory( (IntPtr)( &diptr.uData ), (IntPtr)( &userData ), IntPtr.Size ); ////} //diptr.uData = IntPtr.Zero; ////diptr.uData = (IntPtr)userData; //GUID* appDataGuid = (GUID*)DInput.getDIPROP_APPDATA(); //hr = IDirectInputDevice8.SetProperty( device.directInputDevice, // appDataGuid, ref diptr.diph ); //if( Wrapper.FAILED( hr ) ) //{ // Log.InvisibleInfo( "DirectInputJoystickDevice: Cannot set appData for \"{0}\".", // device.Name ); // //Log.Warning( "DirectInputJoystickDevice: Cannot set appData for \"{0}\".", // // device.Name ); //} } return(true); // continue }