Skip to content

Commit

Permalink
Fix compatibility with SDL versions below 2.0.18 (#273)
Browse files Browse the repository at this point in the history
SDL_GameControllerHasRumble() was introduced in SDL 2.0.18 only (libsdl-org/SDL#4943).

Signed-off-by: Johannes Meyer <[email protected]>
  • Loading branch information
meyerj authored Oct 23, 2023
1 parent f2ffeec commit a5adee5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions joy/src/game_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,14 @@ void GameController::handleControllerDeviceAdded(const SDL_ControllerDeviceEvent
joy_msg_.axes.at(i) = convertRawAxisValueToROS(state);
}

#if SDL_VERSION_ATLEAST(2, 0, 18)
const char * has_rumble_string = "No";
if (SDL_GameControllerHasRumble(game_controller_)) {
has_rumble_string = "Yes";
}
#else
const char * has_rumble_string = "Unknown";
#endif

RCLCPP_INFO(
get_logger(), "Opened game controller: %s, deadzone: %f, rumble: %s",
Expand Down

0 comments on commit a5adee5

Please sign in to comment.