Ejemplo n.º 1
0
        public static bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor)
        {
            IntPtr     haptic = INTERNAL_haptics[(int)playerIndex];
            HapticType type   = INTERNAL_hapticTypes[(int)playerIndex];

            if (haptic == IntPtr.Zero)
            {
                return(false);
            }

            if (leftMotor <= 0.0f && rightMotor <= 0.0f)
            {
                SDL.SDL_HapticStopAll(haptic);
            }
            else if (type == HapticType.LeftRight)
            {
                INTERNAL_leftRightEffect.leftright.large_magnitude = (ushort)(65535.0f * leftMotor);
                INTERNAL_leftRightEffect.leftright.small_magnitude = (ushort)(65535.0f * rightMotor);
                SDL.SDL_HapticUpdateEffect(
                    haptic,
                    0,
                    ref INTERNAL_leftRightEffect
                    );
                SDL.SDL_HapticRunEffect(
                    haptic,
                    0,
                    1
                    );
            }
            else if (type == HapticType.LeftRightMacHack)
            {
#if !JSIL
                leftRightMacHackData[0] = (ushort)(65535.0f * leftMotor);
                leftRightMacHackData[1] = (ushort)(65535.0f * rightMotor);
                SDL.SDL_HapticUpdateEffect(
                    haptic,
                    0,
                    ref INTERNAL_leftRightMacHackEffect
                    );
                SDL.SDL_HapticRunEffect(
                    haptic,
                    0,
                    1
                    );
#endif
            }
            else
            {
                SDL.SDL_HapticRumblePlay(
                    haptic,
                    Math.Max(leftMotor, rightMotor),
                    SDL.SDL_HAPTIC_INFINITY                     // Oh dear...
                    );
            }
            return(true);
        }
Ejemplo n.º 2
0
    public void SetHaptic(HapticType type)
    {
        ushort length = 0;

        if (type == HapticType.grapple)
        {
            length = grappleHaptic;
        }
        else if (type == HapticType.grab)
        {
            length = grabHaptic;
        }
        else if (type == HapticType.detach)
        {
            length = detachHaptic;
        }
        else if (type == HapticType.retractDone)
        {
            length = retractDoneHaptic;
        }
        TriggerHapticPulse(length);
    }
Ejemplo n.º 3
0
 // todo custom drawer (or window?)
 public HapticPattern(float amplitude = 1, float duration = 0.1f, HapticType curveType = HapticType.SINGLE)
 {
     this.hapticType = curveType;
     this.amplitude  = amplitude;
     this.duration   = duration;
 }