File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,7 @@ void Joy::handleJoyDeviceAdded(const SDL_Event & e)
308
308
RCLCPP_WARN (get_logger (), " Failed to get the number of joysticks: %s" , SDL_GetError ());
309
309
return ;
310
310
}
311
+ bool matching_device_found = false ;
311
312
for (int i = 0 ; i < num_joysticks; ++i) {
312
313
const char * name = SDL_JoystickNameForIndex (i);
313
314
if (name == nullptr ) {
@@ -316,10 +317,17 @@ void Joy::handleJoyDeviceAdded(const SDL_Event & e)
316
317
}
317
318
if (std::string (name) == dev_name_) {
318
319
// We found it!
320
+ matching_device_found = true ;
319
321
dev_id_ = i;
320
322
break ;
321
323
}
322
324
}
325
+ if (!matching_device_found) {
326
+ RCLCPP_WARN (
327
+ get_logger (), " Could not get joystick with name %s: %s" ,
328
+ dev_name_.c_str (), SDL_GetError ());
329
+ return ;
330
+ }
323
331
}
324
332
325
333
if (e.jdevice .which != dev_id_) {
You can’t perform that action at this time.
0 commit comments