예제 #1
0
        protected override unsafe void OnUpdateEffectTypeSpecificParameters()
        {
            base.OnUpdateEffectTypeSpecificParameters();

            if (directInputEffect != null)
            {
                DIRAMPFORCE diRamp = new DIRAMPFORCE();
                diRamp.lStart = (int)(StartForce * DInput.DI_FFNOMINALMAX);
                diRamp.lEnd   = (int)(EndForce * DInput.DI_FFNOMINALMAX);

                DIEFFECT diEffect = new DIEFFECT();
                diEffect.dwSize  = (uint)sizeof(DIEFFECT);
                diEffect.dwFlags = DInput.DIEFF_CARTESIAN | DInput.DIEFF_OBJECTOFFSETS;
                diEffect.cbTypeSpecificParams  = (uint)sizeof(DIRAMPFORCE);
                diEffect.lpvTypeSpecificParams = &diRamp;

                int hr = IDirectInputEffect.SetParameters(directInputEffect, ref diEffect,
                                                          DInput.DIEP_TYPESPECIFICPARAMS);
                if (Wrapper.FAILED(hr))
                {
                    Log.Warning("DirectInputForceFeedbackRampEffect: " +
                                "Cannot update Ramp effect parameters ({0}).",
                                DInput.GetOutString(DInput.DXGetErrorStringW(hr)));
                    return;
                }
            }
        }
예제 #2
0
        protected override unsafe void OnUpdateEffectTypeSpecificParameters()
        {
            base.OnUpdateEffectTypeSpecificParameters();

            if (directInputEffect != null)
            {
                DIPERIODIC diPeriodic = new DIPERIODIC();
                diPeriodic.dwMagnitude = (uint)(10000.0f * Magnitude);
                diPeriodic.lOffset     = (int)((float)diPeriodic.dwMagnitude * Offset);
                diPeriodic.dwPhase     = (uint)(36000.0f * Phase);
                diPeriodic.dwPeriod    = (uint)(Period * DInput.DI_SECONDS);

                DIEFFECT diEffect = new DIEFFECT();
                diEffect.dwSize  = (uint)sizeof(DIEFFECT);
                diEffect.dwFlags = DInput.DIEFF_CARTESIAN | DInput.DIEFF_OBJECTOFFSETS;
                diEffect.cbTypeSpecificParams  = (uint)sizeof(DIPERIODIC);
                diEffect.lpvTypeSpecificParams = &diPeriodic;

                int hr = IDirectInputEffect.SetParameters(directInputEffect, ref diEffect,
                                                          DInput.DIEP_TYPESPECIFICPARAMS);
                if (Wrapper.FAILED(hr))
                {
                    Log.Warning("DirectInputForceFeedbackPeriodicEffect: " +
                                "Cannot update Periodic effect parameters ({0}).",
                                DInput.GetOutString(DInput.DXGetErrorStringW(hr)));
                    return;
                }
            }
        }
예제 #3
0
        protected override unsafe void OnUpdateEffectTypeSpecificParameters()
        {
            base.OnUpdateEffectTypeSpecificParameters();

            if (directInputEffect != null)
            {
                DICONDITION diCondition = new DICONDITION();
                diCondition.lOffset = (int)(Offset * DInput.DI_FFNOMINALMAX);
                diCondition.lNegativeCoefficient = (int)(NegativeCoefficient * DInput.DI_FFNOMINALMAX);
                diCondition.lPositiveCoefficient = (int)(PositiveCoefficient * DInput.DI_FFNOMINALMAX);
                diCondition.dwNegativeSaturation = (uint)(NegativeSaturation * DInput.DI_FFNOMINALMAX);
                diCondition.dwPositiveSaturation = (uint)(PositiveSaturation * DInput.DI_FFNOMINALMAX);
                diCondition.lDeadBand            = (int)(DeadBand * DInput.DI_FFNOMINALMAX);

                DIEFFECT diEffect = new DIEFFECT();
                diEffect.dwSize  = (uint)sizeof(DIEFFECT);
                diEffect.dwFlags = DInput.DIEFF_CARTESIAN | DInput.DIEFF_OBJECTOFFSETS;
                diEffect.cbTypeSpecificParams  = (uint)sizeof(DICONDITION);
                diEffect.lpvTypeSpecificParams = &diCondition;

                int hr = IDirectInputEffect.SetParameters(directInputEffect, ref diEffect,
                                                          DInput.DIEP_TYPESPECIFICPARAMS);
                if (Wrapper.FAILED(hr))
                {
                    Log.Warning("DirectInputForceFeedbackConditionEffect: " +
                                "Cannot update Condition effect parameters ({0}).",
                                DInput.GetOutString(DInput.DXGetErrorStringW(hr)));
                    return;
                }
            }
        }
예제 #4
0
        public static unsafe void UpdateEffectDirection(ForceFeedbackEffect effect,
                                                        IDirectInputEffect *directInputEffect)
        {
            if (effect.Direction != null)
            {
                int *pDirections = stackalloc int[effect.Direction.Count];
                for (int n = 0; n < effect.Direction.Count; n++)
                {
                    pDirections[n] = (int)(effect.Direction[n] * DInput.DI_FFNOMINALMAX);
                }

                uint dwFlags = DInput.DIEP_DIRECTION;

                DIEFFECT diEffect = new DIEFFECT();
                diEffect.dwSize       = (uint)sizeof(DIEFFECT);
                diEffect.dwFlags      = DInput.DIEFF_CARTESIAN | DInput.DIEFF_OBJECTOFFSETS;
                diEffect.cAxes        = (uint)effect.Axes.Count;
                diEffect.rglDirection = pDirections;

                int hr = IDirectInputEffect.SetParameters(directInputEffect, ref diEffect, dwFlags);

                if (Wrapper.FAILED(hr))
                {
                    Log.Warning("DirectInputForceFeedbackEffect: " +
                                "Cannot update direction ({0}).",
                                DInput.GetOutString(DInput.DXGetErrorStringW(hr)));
                    return;
                }
            }
        }
예제 #5
0
        protected override unsafe void OnDestroyRealEffect()
        {
            if (directInputEffect != null)
            {
                IDirectInputEffect.Unload(directInputEffect);
                IDirectInputEffect.Release(directInputEffect);
                directInputEffect = null;
            }

            base.OnDestroyRealEffect();
        }
예제 #6
0
        protected override unsafe void OnStart()
        {
            base.OnStart();

            OnUpdateDirection();
            OnUpdateEffectTypeSpecificParameters();

            int hr = IDirectInputEffect.Start(directInputEffect, 1, 0);

            if (Wrapper.FAILED(hr))
            {
                Log.Warning("DirectInputForceFeedbackRampEffect: " +
                            "Cannot start Ramp force feedback effect ({0}).",
                            DInput.GetOutString(DInput.DXGetErrorStringW(hr)));
                return;
            }
        }