Nissan: Use modern button events

This commit is contained in:
Jason Wen
2024-07-11 23:20:19 -04:00
parent 29bc69be5b
commit a3e2661ca5
+5 -5
View File
@@ -34,7 +34,7 @@ class CarInterface(CarInterfaceBase):
ret = self.CS.update(self.cp, self.cp_adas, self.cp_cam)
self.sp_update_params()
buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})
self.CS.button_events = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})
self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS)
@@ -58,19 +58,19 @@ class CarInterface(CarInterfaceBase):
be = car.CarState.ButtonEvent.new_message()
be.pressed = True
be.type = ButtonType.cancel
buttonEvents.append(be)
self.CS.button_events.append(be)
# MADS BUTTON
if self.CS.out.madsEnabled != self.CS.madsEnabled:
if self.mads_event_lock:
buttonEvents.append(create_mads_event(self.mads_event_lock))
self.CS.button_events.append(create_mads_event(self.mads_event_lock))
self.mads_event_lock = False
else:
if not self.mads_event_lock:
buttonEvents.append(create_mads_event(self.mads_event_lock))
self.CS.button_events.append(create_mads_event(self.mads_event_lock))
self.mads_event_lock = True
ret.buttonEvents = buttonEvents
ret.buttonEvents = self.CS.button_events
events = self.create_common_events(ret, c, extra_gears=[GearShifter.sport, GearShifter.low, GearShifter.brake],
pcm_enable=False)