@@ -19,6 +19,8 @@ pub struct TrackballInput {
1919 /// the focus operation in favor of the orbit operation.
2020 pub focus : bool ,
2121
22+ /// Key used to toggle `esdf`/`wasd` mapping. Default is [`KeyCode::M`].
23+ pub gamer_key : Option < KeyCode > ,
2224 /// Key used to toggle projection mode. Default is [`KeyCode::P`].
2325 pub ortho_key : Option < KeyCode > ,
2426
@@ -74,6 +76,51 @@ pub struct TrackballInput {
7476 pub scale_out_key : Option < KeyCode > ,
7577}
7678
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+
77124impl Default for TrackballInput {
78125 fn default ( ) -> Self {
79126 Self {
@@ -82,6 +129,8 @@ impl Default for TrackballInput {
82129
83130 focus : true ,
84131
132+ gamer_key : Some ( KeyCode :: M ) ,
133+
85134 ortho_key : Some ( KeyCode :: P ) ,
86135
87136 reset_key : Some ( KeyCode :: Return ) ,
0 commit comments