vibrate method
Activate a gamepad controller's vibration motors.
Either the left or right motor can be activated. The value should be between 0 and 65535.
Implementation
void vibrate({int leftMotorSpeed = 0, int rightMotorSpeed = 0}) {
if (leftMotorSpeed < 0 ||
leftMotorSpeed > 65535 ||
rightMotorSpeed < 0 ||
rightMotorSpeed > 65535) {
throw ArgumentError('Vibration value must be in range 0..65535');
}
using((arena) {
final pVibration = arena<XINPUT_VIBRATION>();
pVibration.ref
..wLeftMotorSpeed = leftMotorSpeed
..wRightMotorSpeed = rightMotorSpeed;
final dwResult = WIN32_ERROR(XInputSetState(controller, pVibration));
if (dwResult == ERROR_DEVICE_NOT_CONNECTED) {
throw DeviceNotConnectedError();
} else if (dwResult != ERROR_SUCCESS) {
throw WindowsException(dwResult.toHRESULT());
}
});
}