defon_gamepad_event(self,event:carb.input.GamepadEvent):# D-pad Up for acceleratingifevent.input==GamepadInput.DPAD_UP:ifevent.value>0.5:self.throttle=1else:self.throttle=0# D-pad Down for brakingelifevent.input==GamepadInput.DPAD_DOWN:ifevent.value>0.5:self.brakes=1else:self.brakes=0cur_val=event.valueabsval=abs(event.value)# Ignore 0 since it signifies the movement of the stick has stopped,# but doesn't mean it's at center...could be being held steadyifabsval==0:returnifabsval<0.001:cur_val=0# Use right stick for steeringifevent.input==GamepadInput.RIGHT_STICK_RIGHT:self.steering=cur_valelifevent.input==GamepadInput.RIGHT_STICK_LEFT:self.steering=-1*cur_val