add notes about checking gamepads and vibration
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
4ae140c7c3
commit
18c02a5173
|
@ -66,10 +66,30 @@ Inputs.Mouse.RelativeMode = true;
|
||||||
|
|
||||||
## Gamepad Input
|
## Gamepad Input
|
||||||
|
|
||||||
|
Checking if a gamepad is connected is easy! Gamepads can be connected to slots 0-3.
|
||||||
|
|
||||||
|
```cs
|
||||||
|
if (Inputs.GamepadExists(0))
|
||||||
|
{
|
||||||
|
var gamepad = Inputs.GetGamepad(0);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`GetGamepad` will throw if a gamepad is not connected so you should make sure to check `GamepadExists` before using it.
|
||||||
|
|
||||||
MoonWorks assumes your gamepad has a left stick, a right stick, and two triggers. The stick axes are represented in the range [-1f, 1f] and the trigger axes in the range [0f, 1f];
|
MoonWorks assumes your gamepad has a left stick, a right stick, and two triggers. The stick axes are represented in the range [-1f, 1f] and the trigger axes in the range [0f, 1f];
|
||||||
|
|
||||||
```cs
|
```cs
|
||||||
var leftStickHorizontal= Inputs.GetGamepad(0).LeftX;
|
var leftStickHorizontal = gamepad.LeftX;
|
||||||
var rightStickVertical = Inputs.GetGamepad(0).RightY;
|
var rightStickVertical = gamepad.RightY;
|
||||||
var leftTrigger = Inputs.GetGamepad(0).LeftTrigger;
|
var leftTrigger = gamepad.LeftTrigger;
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also set controller vibration by providing left and right motor amounts and a duration in milliseconds.
|
||||||
|
|
||||||
|
```cs
|
||||||
|
var leftMotorAmount = 0.2;
|
||||||
|
var rightMotorAmount = 0.5;
|
||||||
|
var durationInMilliseconds = 10;
|
||||||
|
gamepad.SetVibration(leftMotorAmount, rightMotorAmount, durationInMilliseconds)
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue