diff --git a/src/window.cpp b/src/window.cpp index 550a02ca72..0a1e223f9c 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -3636,8 +3636,13 @@ void HandleGamepadScrolling(int stick_x, int stick_y, int max_axis_value) /* Apply scrolling to the target viewport */ if (target_window != nullptr && target_window->viewport != nullptr) { - /* Cancel vehicle following when gamepad scrolling */ - target_window->viewport->CancelFollow(*target_window); + /* Check if the viewport is following a vehicle (similar to mouse scroll behavior) */ + if (target_window == GetMainWindow() && target_window->viewport->follow_vehicle != VehicleID::Invalid()) { + /* If following a vehicle, center on it and stop following (like mouse scroll) */ + const Vehicle *veh = Vehicle::Get(target_window->viewport->follow_vehicle); + ScrollMainWindowTo(veh->x_pos, veh->y_pos, veh->z_pos, true); // This also resets follow_vehicle + return; // Don't apply gamepad scroll, just like mouse scroll returns ES_NOT_HANDLED + } /* Apply the scroll using the same method as keyboard scrolling */ target_window->viewport->dest_scrollpos_x += ScaleByZoom(delta_x, target_window->viewport->zoom);