//ForceFeedbackEnvelope envelope; //uint gain = nominalMaxGain; //float samplePeriod; // internal ForceFeedbackEffect(ForceFeedbackController owner, ForceFeedbackEffectTypes effectType, JoystickAxes[] axes) { this.owner = owner; this.effectType = effectType; this.axes = new JoystickAxes[axes.Length]; for (int n = 0; n < axes.Length; n++) { this.axes[n] = axes[n]; } this.axesAsReadOnly = new ReadOnlyCollection <JoystickAxes>(this.axes); //if( axes.Length > 1 ) //{ // direction = new float[ this.axes.Length ]; // directionAsReadOnly = new ReadOnlyCollection<float>( direction ); //} //envelope = new ForceFeedbackEnvelope( this ); }
public ForceFeedbackEffect CreateEffect(ForceFeedbackEffectTypes effectType, JoystickAxes[] axes) { ForceFeedbackEffect effect = OnCreateEffect(effectType, axes); if (effect == null) { return(null); } effects.Add(effect); if (!device.IsDeviceLost()) { if (!effect.CallOnCreateRealEffect()) { effect.Destroy(); return(null); } } return(effect); }
// public unsafe DirectInputForceFeedbackPeriodicEffect(ForceFeedbackController owner, ForceFeedbackEffectTypes effectType, JoystickAxes[] axes) : base(owner, effectType, axes) { }
public unsafe static IDirectInputEffect *CreateEffect(DirectInputJoystickInputDevice device, ForceFeedbackEffectTypes effectType, IList <JoystickAxes> axes) { uint *pAxes = stackalloc uint[axes.Count]; int * pDirections = stackalloc int[axes.Count]; for (int n = 0; n < axes.Count; n++) { pAxes[n] = (uint)GetOffsetByAxisType(axes[n]); pDirections[n] = 0; } // DICONSTANTFORCE diConstantForce = new DICONSTANTFORCE(); //DICUSTOMFORCE diCustomForce = new DICUSTOMFORCE(); DICONDITION diCondition = new DICONDITION(); DIPERIODIC diPeriodic = new DIPERIODIC(); DIRAMPFORCE diRamp = new DIRAMPFORCE(); GUID effectTypeGuid = new GUID(); DIEFFECT diEffect = new DIEFFECT(); switch (effectType) { case ForceFeedbackEffectTypes.Spring: effectTypeGuid = DInput.GUID_Spring; diEffect.cbTypeSpecificParams = (uint)sizeof(DICONDITION); diEffect.lpvTypeSpecificParams = &diCondition; break; case ForceFeedbackEffectTypes.Damper: effectTypeGuid = DInput.GUID_Damper; diEffect.cbTypeSpecificParams = (uint)sizeof(DICONDITION); diEffect.lpvTypeSpecificParams = &diCondition; break; case ForceFeedbackEffectTypes.Friction: effectTypeGuid = DInput.GUID_Friction; diEffect.cbTypeSpecificParams = (uint)sizeof(DICONDITION); diEffect.lpvTypeSpecificParams = &diCondition; break; case ForceFeedbackEffectTypes.Inertia: effectTypeGuid = DInput.GUID_Inertia; diEffect.cbTypeSpecificParams = (uint)sizeof(DICONDITION); diEffect.lpvTypeSpecificParams = &diCondition; break; case ForceFeedbackEffectTypes.ConstantForce: effectTypeGuid = DInput.GUID_ConstantForce; diEffect.cbTypeSpecificParams = (uint)sizeof(DICONSTANTFORCE); diEffect.lpvTypeSpecificParams = &diConstantForce; break; //case ForceFeedbackEffectTypes.CustomForce: // effectTypeGuid = DInput.GUID_CustomForce; // diEffect.cbTypeSpecificParams = (uint)sizeof( DICUSTOMFORCE ); // diEffect.lpvTypeSpecificParams = &diCustomForce; // break; case ForceFeedbackEffectTypes.SawtoothDown: effectTypeGuid = DInput.GUID_SawtoothDown; diEffect.cbTypeSpecificParams = (uint)sizeof(DIPERIODIC); diEffect.lpvTypeSpecificParams = &diPeriodic; break; case ForceFeedbackEffectTypes.SawtoothUp: effectTypeGuid = DInput.GUID_SawtoothUp; diEffect.cbTypeSpecificParams = (uint)sizeof(DIPERIODIC); diEffect.lpvTypeSpecificParams = &diPeriodic; break; case ForceFeedbackEffectTypes.Sine: effectTypeGuid = DInput.GUID_Sine; diEffect.cbTypeSpecificParams = (uint)sizeof(DIPERIODIC); diEffect.lpvTypeSpecificParams = &diPeriodic; break; case ForceFeedbackEffectTypes.Square: effectTypeGuid = DInput.GUID_Square; diEffect.cbTypeSpecificParams = (uint)sizeof(DIPERIODIC); diEffect.lpvTypeSpecificParams = &diPeriodic; break; case ForceFeedbackEffectTypes.Triangle: effectTypeGuid = DInput.GUID_Triangle; diEffect.cbTypeSpecificParams = (uint)sizeof(DIPERIODIC); diEffect.lpvTypeSpecificParams = &diPeriodic; break; case ForceFeedbackEffectTypes.Ramp: effectTypeGuid = DInput.GUID_RampForce; diEffect.cbTypeSpecificParams = (uint)sizeof(DIRAMPFORCE); diEffect.lpvTypeSpecificParams = &diRamp; break; } diEffect.dwSize = (uint)sizeof(DIEFFECT); diEffect.dwFlags = DInput.DIEFF_CARTESIAN | DInput.DIEFF_OBJECTOFFSETS; diEffect.dwDuration = DInput.INFINITE; diEffect.dwSamplePeriod = 0; diEffect.dwGain = DInput.DI_FFNOMINALMAX; diEffect.dwTriggerButton = DInput.DIEB_NOTRIGGER; diEffect.dwTriggerRepeatInterval = 0; diEffect.cAxes = (uint)axes.Count; diEffect.rgdwAxes = pAxes; diEffect.rglDirection = pDirections; diEffect.lpEnvelope = null; diEffect.dwStartDelay = 0; diEffect.dwSamplePeriod = 0; // void */*IDirectInputEffect*/ directInputEffect = null; int hr = IDirectInputDevice8.CreateEffect(device.directInputDevice, ref effectTypeGuid, ref diEffect, out directInputEffect, null); if (Wrapper.FAILED(hr)) { Log.Warning("DirectInputForceFeedbackController: " + "Cannot create ForceFeedbackEffect for \"{0}\" ({1}).", device.Name, DInput.GetOutString(DInput.DXGetErrorStringW(hr))); return(null); } return((IDirectInputEffect *)directInputEffect); }
internal ForceFeedbackPeriodicEffect(ForceFeedbackController owner, ForceFeedbackEffectTypes effectType, JoystickAxes[] axes) : base(owner, effectType, axes) { }
protected virtual ForceFeedbackEffect OnCreateEffect(ForceFeedbackEffectTypes effectType, JoystickAxes[] axes) { return(null); }
public bool IsEffectSupported(ForceFeedbackEffectTypes effectType) { return(supportedEffects[(int)effectType]); }
protected void SetEffectSupported(ForceFeedbackEffectTypes effectType) { supportedEffects[(int)effectType] = true; }
protected override ForceFeedbackEffect OnCreateEffect(ForceFeedbackEffectTypes effectType, JoystickAxes[] axes) { ForceFeedbackEffect effect = null; switch (effectType) { case ForceFeedbackEffectTypes.Spring: effect = new DirectInputForceFeedbackConditionEffect( this, ForceFeedbackEffectTypes.Spring, axes); break; case ForceFeedbackEffectTypes.Damper: effect = new DirectInputForceFeedbackConditionEffect( this, ForceFeedbackEffectTypes.Damper, axes); break; case ForceFeedbackEffectTypes.Friction: effect = new DirectInputForceFeedbackConditionEffect( this, ForceFeedbackEffectTypes.Friction, axes); break; case ForceFeedbackEffectTypes.Inertia: effect = new DirectInputForceFeedbackConditionEffect( this, ForceFeedbackEffectTypes.Inertia, axes); break; case ForceFeedbackEffectTypes.ConstantForce: effect = new DirectInputForceFeedbackConstantForceEffect(this, axes); break; //case ForceFeedbackEffectTypes.CustomForce: // effect = new DirectInputForceFeedbackCustomForceEffect( this, axes ); // break; case ForceFeedbackEffectTypes.SawtoothDown: effect = new DirectInputForceFeedbackPeriodicEffect( this, ForceFeedbackEffectTypes.SawtoothDown, axes); break; case ForceFeedbackEffectTypes.SawtoothUp: effect = new DirectInputForceFeedbackPeriodicEffect( this, ForceFeedbackEffectTypes.SawtoothUp, axes); break; case ForceFeedbackEffectTypes.Sine: effect = new DirectInputForceFeedbackPeriodicEffect( this, ForceFeedbackEffectTypes.Sine, axes); break; case ForceFeedbackEffectTypes.Square: effect = new DirectInputForceFeedbackPeriodicEffect( this, ForceFeedbackEffectTypes.Square, axes); break; case ForceFeedbackEffectTypes.Triangle: effect = new DirectInputForceFeedbackPeriodicEffect( this, ForceFeedbackEffectTypes.Triangle, axes); break; case ForceFeedbackEffectTypes.Ramp: effect = new DirectInputForceFeedbackRampEffect(this, axes); break; default: Log.Fatal("DirectInputForceFeedbackController: OnCreateEffect: not implemented."); break; } return(effect); }