1717
1818class Keyboard :
1919 def __init__ (self ):
20+ managed_processes ['ui' ].w .customWindow .accelDown .connect (self .GUI_ACCEL )
21+ managed_processes ['ui' ].w .customWindow .accelRelease .connect (self .GUI_ACCEL )
2022 self .kb = KBHit ()
2123 self .axis_increment = 0.05 # 5% of full actuation each key press
22- self .axes_map = {'b ' : 'gb' , 's' : 'gb' ,
24+ self .axes_map = {'GUI_ACCEL ' : 'gb' , 's' : 'gb' ,
2325 'a' : 'steer' , 'd' : 'steer' }
2426 self .axes_values = {'gb' : 0. , 'steer' : 0. }
2527 self .axes_order = ['gb' , 'steer' ]
@@ -34,7 +36,7 @@ def update(self):
3436 self .cancel = True
3537 elif key in self .axes_map :
3638 axis = self .axes_map [key ]
37- incr = self .axis_increment if key in ['b ' , 'a' ] else - self .axis_increment
39+ incr = self .axis_increment if key in ['GUI_ACCEL ' , 'a' ] else - self .axis_increment
3840 self .axes_values [axis ] = float (np .clip (self .axes_values [axis ] + incr , - 1 , 1 ))
3941 else :
4042 return False
@@ -46,7 +48,7 @@ def __init__(self, steer_slider):
4648 managed_processes ['ui' ].w .customWindow .accelDown .connect (self .GUI_ACCEL )
4749 managed_processes ['ui' ].w .customWindow .accelRelease .connect (self .GUI_ACCEL )
4850 # Refers to the acceleration and steering inputs
49- self .accel_axis = 'GUI_ACCEL '
51+ self .accel_axis = 'b '
5052 self .steer_axis = 'GUI_STEER'
5153
5254 # Acceleration and steering both range from -1.0 to 1.0
@@ -196,7 +198,7 @@ def main():
196198 if args .gui :
197199 print ('Using GUI for control (slider + throttle inputs).' )
198200 elif args .keyboard :
199- print ('Gas/brake control: `B ` and `S` keys' )
201+ print ('Gas/brake control: `GUI_ACCEL ` and `S` keys' )
200202 print ('Steering control: `A` and `D` keys' )
201203 print ('Buttons' )
202204 print ('- `R`: Resets axes' )
0 commit comments