diff options
Diffstat (limited to 'web/src/deviceDetect.js')
| -rw-r--r-- | web/src/deviceDetect.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/web/src/deviceDetect.js b/web/src/deviceDetect.js new file mode 100644 index 0000000..bef49dc --- /dev/null +++ b/web/src/deviceDetect.js @@ -0,0 +1,10 @@ +// Coarse touch/mobile detection for the "match/rank against desktop only" +// preference - not trying to be a precise device fingerprint, just enough +// to separate "typed on a physical keyboard" from "typed on a touchscreen" +// for fairness purposes (see anticheat.rs's comment on why this is opt-in +// tagging, not a default exclusion). +export function detectDeviceType() { + const coarsePointer = typeof window.matchMedia === 'function' && window.matchMedia('(pointer: coarse)').matches; + const touchPoints = navigator.maxTouchPoints > 0; + return coarsePointer && touchPoints ? 'mobile' : 'desktop'; +} |