11use serde:: { Deserialize , Serialize } ;
22
3- use crate :: { Delta , Unity , Zero } ;
3+ use crate :: Direction ;
44
55use super :: { EventSource , KeyModifiers } ;
66
@@ -22,28 +22,28 @@ pub struct KeyEvent {
2222
2323impl KeyEvent {
2424 /// The direction if either the WASD or arrow keys were pressed.
25- pub fn direction < T > ( & self ) -> Option < Delta < T > > where T : Zero + Unity {
25+ pub fn direction ( & self ) -> Option < Direction > {
2626 self . wasd_direction ( ) . or_else ( || self . arrow_direction ( ) )
2727 }
2828
2929 /// The direction if one of the WASD keys was pressed.
30- pub fn wasd_direction < T > ( & self ) -> Option < Delta < T > > where T : Zero + Unity {
30+ pub fn wasd_direction ( & self ) -> Option < Direction > {
3131 match self . code . as_str ( ) {
32- "KeyW" => Some ( Delta :: UP ) ,
33- "KeyA" => Some ( Delta :: LEFT ) ,
34- "KeyS" => Some ( Delta :: DOWN ) ,
35- "KeyD" => Some ( Delta :: RIGHT ) ,
32+ "KeyW" => Some ( Direction :: Up ) ,
33+ "KeyA" => Some ( Direction :: Left ) ,
34+ "KeyS" => Some ( Direction :: Down ) ,
35+ "KeyD" => Some ( Direction :: Right ) ,
3636 _ => None ,
3737 }
3838 }
3939
4040 /// The direction if one of the arrow keys was pressed.
41- pub fn arrow_direction < T > ( & self ) -> Option < Delta < T > > where T : Zero + Unity {
41+ pub fn arrow_direction ( & self ) -> Option < Direction > {
4242 match self . code . as_str ( ) {
43- "ArrowUp" => Some ( Delta :: UP ) ,
44- "ArrowLeft" => Some ( Delta :: LEFT ) ,
45- "ArrowDown" => Some ( Delta :: DOWN ) ,
46- "ArrowRight" => Some ( Delta :: RIGHT ) ,
43+ "ArrowUp" => Some ( Direction :: Up ) ,
44+ "ArrowLeft" => Some ( Direction :: Left ) ,
45+ "ArrowDown" => Some ( Direction :: Down ) ,
46+ "ArrowRight" => Some ( Direction :: Right ) ,
4747 _ => None ,
4848 }
4949 }
0 commit comments