diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py index d4911375e7..38d7cf0828 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -93,7 +93,11 @@ class CarInterface(CarInterfaceBase): ret = self.CS.update(self.cp, self.cp_cam) self.sp_update_params() - self.CS.button_events.extend(create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})) + self.CS.button_events = [ + *self.CS.button_events, + *create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}), + *create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}), + ] self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS) @@ -108,7 +112,7 @@ class CarInterface(CarInterfaceBase): if self.enable_mads: if not self.CS.prev_mads_enabled and self.CS.mads_enabled: self.CS.madsEnabled = True - if self.CS.prev_lkas_enabled != 1 and self.CS.lkas_enabled == 1: + if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events): self.CS.madsEnabled = not self.CS.madsEnabled self.CS.lkas_disabled = not self.CS.lkas_disabled self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled) diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index 18dd7b4fa3..080663c9cf 100644 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -74,7 +74,11 @@ class CarInterface(CarInterfaceBase): ret = self.CS.update(self.cp, self.cp_cam) self.sp_update_params() - self.CS.button_events.extend(create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})) + self.CS.button_events = [ + *self.CS.button_events, + *create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}), + *create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}), + ] self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS) @@ -85,7 +89,7 @@ class CarInterface(CarInterfaceBase): if self.enable_mads: if not self.CS.prev_mads_enabled and self.CS.mads_enabled: self.CS.madsEnabled = True - if not self.CS.prev_lkas_enabled and self.CS.lkas_enabled: + if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events): self.CS.madsEnabled = not self.CS.madsEnabled self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled) else: diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 0e428bc13b..726af2afac 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -218,6 +218,11 @@ class CarInterface(CarInterfaceBase): ] distance_button = self.CS.distance_button + self.CS.button_events = [ + *self.CS.button_events, + *create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}), + ] + self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS) if not self.CP.pcmCruise: @@ -231,7 +236,7 @@ class CarInterface(CarInterfaceBase): if self.enable_mads: if not self.CS.prev_mads_enabled and self.CS.mads_enabled: self.CS.madsEnabled = True - if self.CS.prev_lkas_enabled != 1 and self.CS.lkas_enabled == 1: + if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events): self.CS.madsEnabled = not self.CS.madsEnabled self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled) else: diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index 72ab68647f..af294a63a7 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -282,7 +282,7 @@ class CarInterface(CarInterfaceBase): if self.enable_mads: if not self.CS.prev_mads_enabled and self.CS.mads_enabled: self.CS.madsEnabled = True - if self.CS.prev_cruise_setting != 1 and self.CS.cruise_setting == 1: + if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events): self.CS.madsEnabled = not self.CS.madsEnabled self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled) else: diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index dbe0b62895..e2ad23a7b6 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -205,7 +205,11 @@ class CarInterface(CarInterfaceBase): ret = self.CS.update(self.cp, self.cp_cam) self.sp_update_params() - self.CS.button_events = create_button_events(self.CS.cruise_buttons[-1], self.CS.prev_cruise_buttons, BUTTONS_DICT) + self.CS.button_events = [ + *create_button_events(self.CS.cruise_buttons[-1], self.CS.prev_cruise_buttons, BUTTONS_DICT), + *create_button_events(self.CS.lfa_enabled, self.CS.prev_lfa_enabled, {1: ButtonType.altButton1}), + *create_button_events(self.CS.main_buttons[-1], self.CS.prev_main_buttons, {1: ButtonType.altButton3}), + ] self.CS.accEnabled = self.get_sp_v_cruise_non_pcm_state(ret, self.CS.accEnabled, self.CS.button_events, c.vCruise) @@ -214,16 +218,12 @@ class CarInterface(CarInterfaceBase): if ret.cruiseState.available: if not self.CP.pcmCruiseSpeed: - if self.CS.prev_main_buttons == 1: - if self.CS.main_buttons[-1] != 1: - self.CS.accEnabled = True - elif self.CS.prev_cruise_buttons == 4: - if self.CS.cruise_buttons[-1] != 4: - self.accEnabled = True + if any(b.type in (ButtonType.altButton3, ButtonType.cancel) and not b.pressed for b in self.CS.button_events): + self.CS.accEnabled = True if self.enable_mads: if not self.CS.prev_mads_enabled and self.CS.mads_enabled: self.CS.madsEnabled = True - if self.CS.prev_lfa_enabled != 1 and self.CS.lfa_enabled == 1: + if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events): self.CS.madsEnabled = not self.CS.madsEnabled self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled) else: diff --git a/selfdrive/car/mazda/interface.py b/selfdrive/car/mazda/interface.py index 9447803ae6..8b113cf4db 100755 --- a/selfdrive/car/mazda/interface.py +++ b/selfdrive/car/mazda/interface.py @@ -42,7 +42,8 @@ class CarInterface(CarInterfaceBase): # TODO: add button types for inc and dec self.CS.button_events = [ *self.CS.button_events, - *create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}) + *create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}), + *create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}), ] self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS) @@ -54,7 +55,7 @@ class CarInterface(CarInterfaceBase): if self.enable_mads: if not self.CS.prev_mads_enabled and self.CS.mads_enabled: self.CS.madsEnabled = True - if self.CS.prev_lkas_enabled != self.CS.lkas_enabled: + if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events): self.CS.madsEnabled = not self.CS.madsEnabled self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled) else: