blob: c641e345e45712ccb545218094c3b2e4f0f28307 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwasmplatform.h"
QT_BEGIN_NAMESPACE
Platform platform()
{
static const Platform qtDetectedPlatform = ([]() {
// The Platform Detect: expand coverage as needed
emscripten::val rawPlatform = emscripten::val::global("navigator")["platform"];
if (rawPlatform.call<bool>("includes", emscripten::val("Mac")))
return Platform::MacOS;
if (rawPlatform.call<bool>("includes", emscripten::val("iPhone")))
return Platform::iPhone;
if (rawPlatform.call<bool>("includes", emscripten::val("Win32")))
return Platform::Windows;
if (rawPlatform.call<bool>("includes", emscripten::val("Linux"))) {
emscripten::val uAgent = emscripten::val::global("navigator")["userAgent"];
if (uAgent.call<bool>("includes", emscripten::val("Android")))
return Platform::Android;
return Platform::Linux;
}
return Platform::Generic;
})();
return qtDetectedPlatform;
}
QT_END_NAMESPACE
|