Lionel has had DCC compatibility in Legacy O scale locomotives since 2013. It was introduced in American Flyer Legacy SD70's in 2012. The DCC feature is automatic with no switches to set.
However, verify before purchasing a used Legacy locomotive as it may have been built before 2013.
Rusty