There are several utility functions in A-Frame we can use to detect compatibility: https://aframe.io/docs/master/core/utils.html
The mobile-related utils look at navigator.userAgent. The VR-related utils check to see if the pose data returned from the headset/polyfill is not 0,0,0.
Given the current API:
- Desktop: 
!AFRAME.utils.checkHeadsetConnected() 
- Mobile: 
AFRAME.utils.isMobile() 
- GearVR: 
AFRAME.utils.isGearVR() 
- Oculus Rift: 
!AFRAME.utils.isMobile() && AFRAME.utils.checkHeadsetConnected() 
- HTC Vive: 
!AFRAME.utils.isMobile() && AFRAME.utils.checkHeadsetConnected() 
To differentiate Rift vs. Vive, try using WebVR API Stage Parameters https://w3c.github.io/webvr/#interface-vrstageparameters