Skip to content

Commit

Permalink
fix autorepeat not being triggered when inside deadzone
Browse files Browse the repository at this point in the history
when the joystick is moved there is an SDL_Event, but when inside the deadzone the position of the joystick will not be updated. In this case should_publish remains false. However, before this commit we would not trigger the autorepeat functionality in this case.

Now we trigger the autorepeat functionality everytime where we didnt update the joystick (due to deadzone) or when there was no SDL_Event.
  • Loading branch information
Marco Boneberger authored and clalancette committed Sep 14, 2023
1 parent 1bc08a5 commit 0ee3548
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions joy/src/joy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,16 @@ void Joy::eventThread()
} else {
RCLCPP_INFO(get_logger(), "Unknown event type %d", e.type);
}
} else {
// We didn't succeed, either because of a failure or because of a timeout.
}

if (!should_publish) {
// So far, nothing has indicated that we should publish. However we need to
// do additional checking since there are several possible reasons:
// 1. SDL_WaitEventTimeout failed
// 2. SDL_WaitEventTimeout timed out
// 3. SDL_WaitEventTimeout succeeded, but the event that happened didn't cause
// a publish to happen.
//
// If we are autorepeating and enough time has passed, set should_publish.
rclcpp::Time now = this->now();
rclcpp::Duration diff_since_last_publish = now - last_publish;
Expand Down

0 comments on commit 0ee3548

Please sign in to comment.