Beispiel #1
0
        public List <double> GetForce(JOYSTICK_INPUT joystickInput, Dictionary <string, object> structDictonary, double elapsedTime)
        {
            SET_EFFECT eff = (SET_EFFECT)structDictonary["SET_EFFECT"];
            RAMP       rmp = (RAMP)structDictonary["RAMP"];
            ENVELOPE   env = (ENVELOPE)structDictonary["ENVELOPE"];

            List <double> forces = new List <double>();

            double end      = rmp.end;
            double start    = rmp.start;
            double duration = eff.duration;

            double slope     = (end - start) / duration;
            double magnitude = start + slope * elapsedTime;

            magnitude = _calculationProvider.ApplyGain(magnitude, eff.gain);

            double envelope = _calculationProvider.ApplyGain(_calculationProvider.GetEnvelope(env, elapsedTime, eff.duration), eff.gain);

            List <double> directions = _calculationProvider.GetDirection(eff);

            foreach (var direction in directions)
            {
                forces.Add(magnitude * envelope * direction);
            }

            return(forces);
        }
Beispiel #2
0
        public List <double> GetForce(JOYSTICK_INPUT joystickInput, Dictionary <string, object> structDictonary, double elapsedTime)
        {
            SET_EFFECT eff      = (SET_EFFECT)structDictonary["SET_EFFECT"];
            PERIOD     periodic = (PERIOD)structDictonary["PERIOD"];
            ENVELOPE   env      = (ENVELOPE)structDictonary["ENVELOPE"];

            List <double> forces    = new List <double>();
            double        offset    = periodic.offset;
            double        magnitude = periodic.magnitude;
            double        phase     = periodic.phase;
            double        period    = periodic.period;

            magnitude = _calculationProvider.ApplyGain(magnitude, eff.gain);

            double angle     = ((elapsedTime / period) + (phase / _reportDescriptorProperties.MAX_PHASE) * period) * 2 * Math.PI;
            double sine      = Math.Sin(angle);
            double tempforce = sine * magnitude;

            tempforce += offset;

            double envelope = _calculationProvider.ApplyGain(_calculationProvider.GetEnvelope(env, elapsedTime, eff.duration), eff.gain);

            List <double> directions = _calculationProvider.GetDirection(eff);

            foreach (var direction in directions)
            {
                forces.Add(tempforce * envelope * direction);
            }
            return(forces);
        }
        public List <double> GetForce(JOYSTICK_INPUT joystickInput, Dictionary <string, object> structDictonary, double elapsedTime)
        {
            SET_EFFECT eff      = (SET_EFFECT)structDictonary["SET_EFFECT"];
            PERIOD     periodic = (PERIOD)structDictonary["PERIOD"];
            ENVELOPE   env      = (ENVELOPE)structDictonary["ENVELOPE"];

            List <double> forces    = new List <double>();
            double        offset    = periodic.offset;
            double        magnitude = periodic.magnitude;
            double        phase     = periodic.phase;
            double        period    = periodic.period;

            magnitude = _calculationProvider.ApplyGain(magnitude, eff.gain);

            double max       = offset + magnitude;
            double min       = offset - magnitude;
            double phasetime = (phase * period) / _reportDescriptorProperties.MAX_PHASE;
            double time      = elapsedTime + phasetime;
            double reminder  = time % period;
            double slope     = (max - min) / period;
            double tempforce = 0;

            tempforce  = slope * reminder;
            tempforce += min;

            double envelope = _calculationProvider.ApplyGain(_calculationProvider.GetEnvelope(env, elapsedTime, eff.duration), eff.gain);

            List <double> directions = _calculationProvider.GetDirection(eff);

            foreach (var direction in directions)
            {
                forces.Add(tempforce * envelope * direction);
            }
            return(forces);
        }
Beispiel #4
0
        public List <double> GetForce(JOYSTICK_INPUT joystickInput, Dictionary <string, object> structDictonary, double elapsedTime)
        {
            SET_EFFECT               eff                   = (SET_EFFECT)structDictonary["SET_EFFECT"];
            PERIOD                   periodic              = (PERIOD)structDictonary["PERIOD"];
            CUSTOM_FORCE_PARAMETER   customForceParameter  = (CUSTOM_FORCE_PARAMETER)structDictonary["CUSTOM_FORCE_PARAMETER"];
            CUSTOM_FORCE_DATA_REPORT customForceDataReport = (CUSTOM_FORCE_DATA_REPORT)structDictonary["CUSTOM_FORCE_DATA_REPORT"];

            List <double> forces      = new List <double>();
            List <int>    samples     = customForceDataReport.samples;
            double        sampleCount = customForceParameter.sampleCount;
            double        period      = periodic.period;
            List <double> directions  = _calculationProvider.GetDirection(eff);

            int sampleIndex = (int)Math.Round((elapsedTime / period) * sampleCount);

            if (sampleIndex > samples.Count)
            {
                sampleIndex %= samples.Count;
            }

            foreach (var direction in directions)
            {
                forces.Add(samples[sampleIndex] * direction);
            }
            return(forces);
        }
Beispiel #5
0
        public List <double> GetForce(JOYSTICK_INPUT joystickInput, Dictionary <string, object> structDictonary, double elapsedTime)
        {
            SET_EFFECT       eff  = (SET_EFFECT)structDictonary["SET_EFFECT"];
            List <CONDITION> cond = (List <CONDITION>)structDictonary["CONDITION"];
            ENVELOPE         env  = (ENVELOPE)structDictonary["ENVELOPE"];

            List <double> forces = joystickInput.axesPositions.Select(x => 0d).ToList();

            if (previousAxesPositions != null)
            {
                var axesSpeeds = joystickInput.axesPositions.Zip(previousAxesPositions, (u, v) => u - v).ToList();

                if (previousAxesSpeeds != null)
                {
                    var axesAccelerations = axesSpeeds.Zip(previousAxesSpeeds, (u, v) => u - v).ToList();

                    forces = _calculationProvider.GetCondition(cond, axesAccelerations);
                }

                previousAxesSpeeds = axesSpeeds;
            }

            previousAxesPositions = joystickInput.axesPositions;

            return(forces);
        }
Beispiel #6
0
        public List <double> GetForce(JOYSTICK_INPUT joystickInput, Dictionary <string, object> structDictonary, double elapsedTime)
        {
            SET_EFFECT       eff  = (SET_EFFECT)structDictonary["SET_EFFECT"];
            List <CONDITION> cond = (List <CONDITION>)structDictonary["CONDITION"];

            List <double> forces = _calculationProvider.GetCondition(cond, joystickInput.axesPositions);

            return(forces);
        }
        public void SetDuration(int effectBlockIndex, long loopCount)
        {
            IEffect    effect    = _effects.GetEffect(effectBlockIndex);
            SET_EFFECT setEffect = (SET_EFFECT)effect.GetParameter("SET_EFFECT");

            if (loopCount == _reportDescriptorProperties.MAX_LOOP)
            {
                ENVELOPE envelope = (ENVELOPE)effect.GetParameter("ENVELOPE");

                setEffect.duration = _reportDescriptorProperties.DURATION_INFINITE;
                envelope.fadeTime  = 0d;
            }
            else
            {
                setEffect.duration *= loopCount;
            }
        }
Beispiel #8
0
        public List <double> GetForce(JOYSTICK_INPUT joystickInput)
        {
            List <double> forces = joystickInput.axesPositions.Select(x => 0d).ToList();

            if (!paused)
            {
                long elapsedTime = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - ticksStart;
                lastUpdate = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - lastUpdate;
                SET_EFFECT setEffect = (SET_EFFECT)_structDictonary["SET_EFFECT"];

                long duration     = setEffect.duration;
                long samplePeriod = setEffect.samplePeriod;

                if (((elapsedTime < duration) && (elapsedTime > 0) && (lastUpdate > samplePeriod)) || (duration == _reportDescriptorProperties.DURATION_INFINITE))
                {
                    forces = _effect.GetForce(joystickInput, _structDictonary, elapsedTime);
                }
            }
            return(forces);
        }
Beispiel #9
0
        public List <double> GetForce(JOYSTICK_INPUT joystickInput, Dictionary <string, object> structDictonary, double elapsedTime)
        {
            ENVELOPE   env      = (ENVELOPE)structDictonary["ENVELOPE"];
            SET_EFFECT eff      = (SET_EFFECT)structDictonary["SET_EFFECT"];
            CONSTANT   constant = (CONSTANT)structDictonary["CONSTANT"];

            List <double> forces = new List <double>();

            double magnitude = _calculationProvider.ApplyGain(constant.magnitude, eff.gain);

            double envelope = _calculationProvider.ApplyGain(_calculationProvider.GetEnvelope(env, elapsedTime, eff.duration), eff.gain);

            List <double> directions = _calculationProvider.GetDirection(eff);

            foreach (var direction in directions)
            {
                forces.Add(magnitude * envelope * direction);
            }
            return(forces);
        }
Beispiel #10
0
        public void TriggerButtonPressed()
        {
            if (paused)
            {
                Start();
                buttonReleased = false;
                return;
            }

            if (!buttonReleased)
            {
                long       elapsedTime  = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - ticksStart;
                SET_EFFECT setEffect    = (SET_EFFECT)_structDictonary["SET_EFFECT"];
                long       duration     = setEffect.duration;
                long       trigerRepeat = setEffect.trigerRepeat;
                if ((duration + trigerRepeat) > elapsedTime)
                {
                    Start();
                }
            }
        }
Beispiel #11
0
        public List <double> GetDirection(SET_EFFECT dirParms)
        {
            double directionX     = dirParms.directionX;
            double directionY     = dirParms.directionY;
            double polarDirection = dirParms.direction;

            double        angle;
            List <double> axes = new List <double>();

            if (dirParms.polar)
            {
                angle = polarDirection * TO_RAD;
            }
            else
            {
                double x = directionX / _reportDescriptorProperties.DIRECTION_MAX;
                double y = directionY / _reportDescriptorProperties.DIRECTION_MAX;
                angle = Math.Atan2(y, x) + HALF_PI;
            }

            axes.Add(Math.Cos(angle));
            axes.Add(Math.Sin(angle));
            return(axes);
        }