Beispiel #1
0
        public unsafe override void SetRumble(float leftValue, float rightValue)
        {
            if (leftValue > 1)
            {
                leftValue = 1;
            }
            if (leftValue < 0)
            {
                leftValue = 0;
            }
            if (rightValue > 1)
            {
                rightValue = 1;
            }
            if (rightValue < 0)
            {
                rightValue = 0;
            }
            var desc = new XINPUT_VIBRATION()
            {
                wLeftMotorSpeed  = (WORD)(WORD.MaxValue * leftValue),
                wRightMotorSpeed = (WORD)(WORD.MaxValue * rightValue)
            };

            instanceXI.XInputSetState((DWORD)index, &desc);
        }
Beispiel #2
0
        public void Vibrate(UInt16 motorSpeed)
        {
            var inputVibration = new XINPUT_VIBRATION();

            inputVibration.wLeftMotorSpeed  = motorSpeed;
            inputVibration.wRightMotorSpeed = motorSpeed;

            _driver.SetState(_dwUserIndex, ref inputVibration);
        }
        public override bool SetRumbleSpeed(float leftMotor, float rightMotor)
        {
            int controllerIndex = ((WindowsXBoxGamepad)Device).controllerIndex;

            XINPUT_VIBRATION vibration = new XINPUT_VIBRATION();

            vibration.wLeftMotorSpeed  = (ushort)(leftMotor * 65535.0f);
            vibration.wRightMotorSpeed = (ushort)(rightMotor * 65535.0f);

            int hr = XInput.SetState(controllerIndex, ref vibration);

            if (XInputNativeWrapper.Wrapper.FAILED(hr))
            {
                Log.Warning("WindowsXBox360ForceFeedbackController: Cannot " +
                            "set vibration params for \"{0}\".", Device.Name);
                return(false);
            }
            return(true);
        }
Beispiel #4
0
        public unsafe override void SetRumble(float value, int motorIndex)
        {
            if (value > 1)
            {
                value = 1;
            }
            if (value < 0)
            {
                value = 0;
            }
            var desc = new XINPUT_VIBRATION();

            if (motorIndex == 0)
            {
                desc.wLeftMotorSpeed = (WORD)(WORD.MaxValue * value);
            }
            if (motorIndex == 1)
            {
                desc.wRightMotorSpeed = (WORD)(WORD.MaxValue * value);
            }
            instanceXI.XInputSetState((DWORD)index, &desc);
        }
Beispiel #5
0
 public static uint XInputSetState(uint dwUserIndex, ref XINPUT_VIBRATION pVibration)
 {
     return OriginalXInputSetStateFunction.Value(dwUserIndex, ref pVibration);
 }
Beispiel #6
0
 public static uint XInputSetState(uint dwUserIndex, ref XINPUT_VIBRATION pVibration)
 {
     return(OriginalXInputSetStateFunction.Value(dwUserIndex, ref pVibration));
 }
Beispiel #7
0
 /// <summary>
 /// XInputSetState
 /// https://msdn.microsoft.com/ja-jp/library/bb174830(v=vs.85).aspx
 /// <summary>
 public static uint SetState(uint dwUserIndex, ref XINPUT_VIBRATION pVibration)
 {
     return(funcXInputSetState(dwUserIndex, ref pVibration));
 }
Beispiel #8
0
 public static extern uint XInputSetState
 (
     [In] uint dwUserIndex,            // Index of the gamer associated with the device
     [In] XINPUT_VIBRATION pVibration  // The vibration information to send to the controller
 );
Beispiel #9
0
 private static unsafe extern int XInputSetState(int idx, XINPUT_VIBRATION* state);
Beispiel #10
0
        public static bool SetVibration(int nUserIdx, float fLowFreqMotorSpeed, float fHiFreqMotorSpeed)
        {
            XINPUT_VIBRATION state = new XINPUT_VIBRATION();
            state.wLeftMotorSpeed = (ushort)(65535.0f * fLowFreqMotorSpeed);
            state.wRightMotorSpeed = (ushort)(65535.0f * fHiFreqMotorSpeed);

            int res = 0;
            unsafe
            {
                res = XInputSetState(nUserIdx, &state);
            }
            return (res == 0);
        }
Beispiel #11
0
 private static extern UInt32 _GetVibration(UInt32 UserIndex, ref XINPUT_VIBRATION pVib);
Beispiel #12
0
 public UInt32 GetVibration(UInt32 UserIndex, ref XINPUT_VIBRATION pVib)
 {
     return(_GetVibration(UserIndex, ref pVib));
 }