mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-30 09:42:48 +01:00
While a calibration run is on, the rider never has to touch the screen: - hold shift down: too heavy - hold shift up: too light - press both shifters together: about right / next grade - buttons mapped to navigate left / select / navigate right answer directly on controllers that have them Short presses still shift, so the rider can pick a gear on each grade. The run installs a ControllerInputInterceptor on BaseDevice; the device layer offers it every press (with the button's single-click action), claims the long press of the shift buttons, and catches the shifter chord before the front-shift combo. Consumed presses are not forwarded to a trainer app, keyboard or touch output. Two controller halves pressed together within 150 ms count as the chord and undo the first shift; a held button cannot answer twice within 700 ms. Every way a run ends (finish, stop, leaving the page, a trainer app connecting) removes the interceptor. An answer gives the shift haptic/sound feedback, outlines its button briefly and is announced for screen readers. With a controller connected, each answer shows its controller gesture underneath, in all six locales. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.3 KiB
Dart
30 lines
1.3 KiB
Dart
import 'package:bike_control/utils/actions/base_actions.dart';
|
|
import 'package:bike_control/utils/keymap/buttons.dart';
|
|
import 'package:bike_control/utils/keymap/keymap.dart';
|
|
|
|
/// Lets a screen take over some controller presses for as long as it is
|
|
/// installed in `BaseDevice.inputInterceptor`, before they become actions.
|
|
///
|
|
/// Every press is offered with the action the rider's keymap gives the button
|
|
/// on a single click ([mappedAction]), so a scheme can be written in terms of
|
|
/// "the shift up button" rather than hardware button names. A non-null result
|
|
/// consumes the press: it is not forwarded to the trainer app, keyboard or
|
|
/// touch output. Null lets it through unchanged.
|
|
abstract interface class ControllerInputInterceptor {
|
|
/// True when a long press of a button mapped to [mappedAction] should be
|
|
/// detected (and offered to [intercept]) even though the keymap gives it no
|
|
/// long-press action. Its short press then fires on release, as for any
|
|
/// button with a long-press action.
|
|
bool claimsLongPress(InGameAction? mappedAction);
|
|
|
|
ActionResult? intercept(
|
|
ControllerButton button,
|
|
InGameAction? mappedAction,
|
|
ButtonTrigger trigger, {
|
|
required bool isKeyDown,
|
|
});
|
|
|
|
/// Several buttons pressed in the same frame.
|
|
ActionResult? interceptChord(List<ControllerButton> buttons, List<InGameAction?> mappedActions);
|
|
}
|