updateState method
- @override
- GamepadState state
override
Any logic to run before checking parseInputs.
Implementation
@override
void updateState(GamepadState state) {
// Update only ONE camera. Go left to right.
final newFrontSwivel = state.normalLeftX;
final newFrontTilt = state.normalLeftY;
final newRearSwivel = state.normalRightX;
final newRearTilt = -1 * state.normalRightY;
if (newFrontSwivel.abs() >= 0.05 || newFrontTilt.abs() >= 0.05) {
// Update the front camera. Now, choose which axis
if (newFrontSwivel.abs() > newFrontTilt.abs()) {
frontSwivel += newFrontSwivel * cameraSwivelIncrement;
} else {
frontTilt += newFrontTilt * cameraTiltIncrement;
}
} else if (newRearSwivel.abs() >= 0.05 || newRearTilt.abs() >= 0.05) {
if (newRearSwivel.abs() > newRearTilt.abs()) {
rearSwivel += newRearSwivel * cameraSwivelIncrement;
} else {
rearTilt += newRearTilt * cameraTiltIncrement * -1;
}
}
armTilt += -1 * state.normalDpadY * cameraTiltIncrement;
armTilt = armTilt.clamp(0, 180);
frontSwivel = frontSwivel.clamp(0, 180);
frontTilt = frontTilt.clamp(0, 60);
rearSwivel = rearSwivel.clamp(0, 180);
rearTilt = rearTilt.clamp(0, 180);
}