Device detection

This has been sitting around for informal review for a quite while.  With 0.3 out and the issue (#26) that triggered this targeted for 0.4, I hereby request a review/merge.