Skip to content

Commit a5adee5

Browse files
authored
Fix compatibility with SDL versions below 2.0.18 (#273)
SDL_GameControllerHasRumble() was introduced in SDL 2.0.18 only (libsdl-org/SDL#4943). Signed-off-by: Johannes Meyer <[email protected]>
1 parent f2ffeec commit a5adee5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

joy/src/game_controller.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,14 @@ void GameController::handleControllerDeviceAdded(const SDL_ControllerDeviceEvent
315315
joy_msg_.axes.at(i) = convertRawAxisValueToROS(state);
316316
}
317317

318+
#if SDL_VERSION_ATLEAST(2, 0, 18)
318319
const char * has_rumble_string = "No";
319320
if (SDL_GameControllerHasRumble(game_controller_)) {
320321
has_rumble_string = "Yes";
321322
}
323+
#else
324+
const char * has_rumble_string = "Unknown";
325+
#endif
322326

323327
RCLCPP_INFO(
324328
get_logger(), "Opened game controller: %s, deadzone: %f, rumble: %s",

0 commit comments

Comments
 (0)