1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! Identifiers and storage for [`Binding::Custom`] values.
use ;
use ;
use crate*;
/// Identifier for a custom input, used in [`Binding::Custom`].
///
/// Obtainable from [`CustomInputs::register_input`].
;
/// Stores values for [`Binding::Custom`] entries.
///
/// Write to this resource from any system to make custom input values available to actions.
///
/// To register a custom input, use [`Self::register_input`].
///
/// Missing entries are read as [`ActionValue::Bool`] `false`.
///
/// # Examples
///
/// Feeding trackpad pinch events:
///
/// ```
/// use bevy::{input::gestures::PinchGesture, prelude::*};
/// use bevy_enhanced_input::prelude::*;
///
/// let mut app = App::new();
/// app.add_plugins((MinimalPlugins, EnhancedInputPlugin));
/// let pinch = app
/// .world_mut()
/// .resource_mut::<CustomInputs>()
/// .register_input();
/// app.insert_resource(PinchId(pinch)).add_systems(
/// PreUpdate,
/// stage_pinch
/// .after(bevy::input::InputSystems)
/// .before(EnhancedInputSystems::Update),
/// );
///
/// fn stage_pinch(
/// mut events: MessageReader<PinchGesture>,
/// mut custom_inputs: ResMut<CustomInputs>,
/// id: Res<PinchId>,
/// ) {
/// let delta: f32 = events.read().map(|e| e.0).sum();
/// custom_inputs.insert(id.0, ActionValue::Axis1D(delta));
/// }
///
/// #[derive(Resource)]
/// struct PinchId(CustomInput);
/// ```