@@ -19,6 +19,8 @@ pub struct TrackballInput {
19
19
/// the focus operation in favor of the orbit operation.
20
20
pub focus : bool ,
21
21
22
+ /// Key used to toggle `esdf`/`wasd` mapping. Default is [`KeyCode::M`].
23
+ pub gamer_key : Option < KeyCode > ,
22
24
/// Key used to toggle projection mode. Default is [`KeyCode::P`].
23
25
pub ortho_key : Option < KeyCode > ,
24
26
@@ -74,6 +76,51 @@ pub struct TrackballInput {
74
76
pub scale_out_key : Option < KeyCode > ,
75
77
}
76
78
79
+ impl TrackballInput {
80
+ /// Maps `esdf`/`gv` to slide operations.
81
+ ///
82
+ /// Key | Operation
83
+ /// --- | ---------------------------
84
+ /// `e` | Slides up.
85
+ /// `s` | Slides left.
86
+ /// `d` | Slides down.
87
+ /// `f` | Slides right.
88
+ /// `g` | Slides far (in/forward).
89
+ /// `v` | Slides near (out/backward).
90
+ ///
91
+ /// This mapping is symmetric to the `ijkl`/`hn` orbit mapping but less intuitive to gamers
92
+ /// compared with [`Self::map_wasd`].
93
+ pub fn map_esdf ( & mut self ) {
94
+ self . slide_up_key = Some ( KeyCode :: E ) ;
95
+ self . slide_down_key = Some ( KeyCode :: D ) ;
96
+ self . slide_left_key = Some ( KeyCode :: S ) ;
97
+ self . slide_right_key = Some ( KeyCode :: F ) ;
98
+ self . slide_far_key = Some ( KeyCode :: G ) ;
99
+ self . slide_near_key = Some ( KeyCode :: V ) ;
100
+ }
101
+ /// Maps `wasd`/`Space`/`ControlLeft` to slide operations.
102
+ ///
103
+ /// Key | Operation
104
+ /// ------------- | ---------------------------
105
+ /// `w` | Slides far (in/forward).
106
+ /// `a` | Slides left.
107
+ /// `s` | Slides near (out/backward).
108
+ /// `d` | Slides right.
109
+ /// `Space` | Slides up (jump).
110
+ /// `ControlLeft` | Slides down (crouch).
111
+ ///
112
+ /// This mapping isn't symmetric to the `ijkl`/`hn` orbit mapping but more intuitive to gamers
113
+ /// compared with [`Self::map_esdf`].
114
+ pub fn map_wasd ( & mut self ) {
115
+ self . slide_up_key = Some ( KeyCode :: Space ) ;
116
+ self . slide_down_key = Some ( KeyCode :: ControlLeft ) ;
117
+ self . slide_left_key = Some ( KeyCode :: A ) ;
118
+ self . slide_right_key = Some ( KeyCode :: D ) ;
119
+ self . slide_far_key = Some ( KeyCode :: W ) ;
120
+ self . slide_near_key = Some ( KeyCode :: S ) ;
121
+ }
122
+ }
123
+
77
124
impl Default for TrackballInput {
78
125
fn default ( ) -> Self {
79
126
Self {
@@ -82,6 +129,8 @@ impl Default for TrackballInput {
82
129
83
130
focus : true ,
84
131
132
+ gamer_key : Some ( KeyCode :: M ) ,
133
+
85
134
ortho_key : Some ( KeyCode :: P ) ,
86
135
87
136
reset_key : Some ( KeyCode :: Return ) ,
0 commit comments