@@ -72,6 +72,13 @@ impl DBusDevice {
7272 let include_event = if matches ! ( & source_cap, Capability :: Gamepad ( Gamepad :: Axis ( _) ) ) {
7373 match event. action {
7474 Action :: Left => {
75+ // If the opposite axis is pressed, emit a "release" event
76+ // for it.
77+ if self . state . pressed_right {
78+ let other_event = DBusEvent :: new ( Action :: Right , InputValue :: Float ( 0.0 ) ) ;
79+ translated. push ( other_event) ;
80+ self . state . pressed_right = false ;
81+ }
7582 if self . state . pressed_left && event. as_f64 ( ) < AXIS_THRESHOLD {
7683 event. value = InputValue :: Float ( 0.0 ) ;
7784 self . state . pressed_left = false ;
@@ -85,6 +92,13 @@ impl DBusDevice {
8592 }
8693 }
8794 Action :: Right => {
95+ // If the opposite axis is pressed, emit a "release" event
96+ // for it.
97+ if self . state . pressed_left {
98+ let other_event = DBusEvent :: new ( Action :: Left , InputValue :: Float ( 0.0 ) ) ;
99+ translated. push ( other_event) ;
100+ self . state . pressed_left = false ;
101+ }
88102 if self . state . pressed_right && event. as_f64 ( ) < AXIS_THRESHOLD {
89103 event. value = InputValue :: Float ( 0.0 ) ;
90104 self . state . pressed_right = false ;
@@ -98,6 +112,13 @@ impl DBusDevice {
98112 }
99113 }
100114 Action :: Up => {
115+ // If the opposite axis is pressed, emit a "release" event
116+ // for it.
117+ if self . state . pressed_down {
118+ let other_event = DBusEvent :: new ( Action :: Down , InputValue :: Float ( 0.0 ) ) ;
119+ translated. push ( other_event) ;
120+ self . state . pressed_down = false ;
121+ }
101122 if self . state . pressed_up && event. as_f64 ( ) < AXIS_THRESHOLD {
102123 event. value = InputValue :: Float ( 0.0 ) ;
103124 self . state . pressed_up = false ;
@@ -111,6 +132,13 @@ impl DBusDevice {
111132 }
112133 }
113134 Action :: Down => {
135+ // If the opposite axis is pressed, emit a "release" event
136+ // for it.
137+ if self . state . pressed_up {
138+ let other_event = DBusEvent :: new ( Action :: Up , InputValue :: Float ( 0.0 ) ) ;
139+ translated. push ( other_event) ;
140+ self . state . pressed_up = false ;
141+ }
114142 if self . state . pressed_down && event. as_f64 ( ) < AXIS_THRESHOLD {
115143 event. value = InputValue :: Float ( 0.0 ) ;
116144 self . state . pressed_down = false ;
0 commit comments