summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmeventtranslator.h
blob: 8f4e9f6d05f0372bb2350e88efbd4c3869077b71 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef QWASMEVENTTRANSLATOR_H
#define QWASMEVENTTRANSLATOR_H

#include <QtCore/qobject.h>
#include <QtCore/qrect.h>
#include <QtCore/qpoint.h>
#include <emscripten/html5.h>
#include "qwasmwindow.h"
#include <QtGui/qinputdevice.h>
#include <QHash>
#include <QCursor>
#include "qwasmevent.h"
#include "qwasmplatform.h"

QT_BEGIN_NAMESPACE

class QWindow;

class QWasmEventTranslator : public QObject
{
    Q_OBJECT

public:
    struct TranslatedEvent
    {
        QEvent::Type type;
        Qt::Key key;
        QString text;
    };
    explicit QWasmEventTranslator();
    ~QWasmEventTranslator();

    static QCursor cursorForMode(QWasmCompositor::ResizeMode mode);

    TranslatedEvent translateKeyEvent(int emEventType, const EmscriptenKeyboardEvent *keyEvent);

private:
    static quint64 getTimestamp();

    Qt::Key m_emDeadKey = Qt::Key_unknown;
    Qt::Key m_keyModifiedByDeadKeyOnPress = Qt::Key_unknown;
};

QT_END_NAMESPACE
#endif // QWASMEVENTTRANSLATOR_H