Device autodetection