diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py index d4911375e744ea..f4881dd3638272 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -94,6 +94,7 @@ def _update(self, c): 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.extend(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 +109,7 @@ def _update(self, c): 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 18dd7b4fa31ab9..b0a1c15f34d1b6 100644 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -75,6 +75,7 @@ def _update(self, c): 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.extend(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 +86,7 @@ def _update(self, c): 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 0e428bc13b1f33..4a1e45972269bd 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -218,6 +218,8 @@ def _update(self, c): ] distance_button = self.CS.distance_button + self.CS.button_events.extend(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 +233,7 @@ def _update(self, c): 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 72ab68647fc9d0..af294a63a7f1ad 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -282,7 +282,7 @@ def _update(self, c): 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 dbe0b62895c328..72a12b0ba8ae81 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -205,7 +205,9 @@ def _update(self, c): 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.extend(create_button_events(self.CS.cruise_buttons[-1], self.CS.prev_cruise_buttons, BUTTONS_DICT)) + self.CS.button_events.extend(create_button_events(self.CS.lfa_enabled, self.CS.prev_lfa_enabled, {1: ButtonType.altButton1})) + self.CS.button_events.extend(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 +216,12 @@ def _update(self, c): 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 9447803ae69797..2bd4f71c787e3f 100755 --- a/selfdrive/car/mazda/interface.py +++ b/selfdrive/car/mazda/interface.py @@ -40,10 +40,8 @@ def _update(self, c): self.sp_update_params() # 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}) - ] + self.CS.button_events.extend(create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})) + self.CS.button_events.extend(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 +52,7 @@ def _update(self, c): 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: