From 0707b85cda9e621df26b49cddf08f82b28a3f907 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Mon, 1 Jun 2020 17:46:30 +1000 Subject: wasm: search emscripten key first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes key lookups with different keyboard layouts Pick-to: 5.15 Fixes: QTBUG-84494 Change-Id: I18f1643331961d9bfc1ac6977181f8959e76449d Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmeventtranslator.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index 77decc970d..8eb30c0ecd 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -433,20 +433,21 @@ Qt::Key QWasmEventTranslator::translateEmscriptKey(const EmscriptenKeyboardEvent { Qt::Key qtKey = Qt::Key_unknown; - if (qstrncmp(emscriptKey->code, "Key", 3) == 0 || qstrncmp(emscriptKey->code, "Numpad", 6) == 0 || - qstrncmp(emscriptKey->code, "Digit", 5) == 0) { + if (qstrncmp(emscriptKey->key, "Dead", 4) == 0 ) { + emkb2qt_t searchKey1{emscriptKey->code, 0}; + for (auto it1 = KeyTbl.cbegin(); it1 != KeyTbl.end(); ++it1) + if (it1 != KeyTbl.end() && (qstrcmp(searchKey1.em, it1->em) == 0)) { + qtKey = static_cast(it1->qt); + } + + } else if (qstrncmp(emscriptKey->code, "Key", 3) == 0 || qstrncmp(emscriptKey->code, "Numpad", 6) == 0 || + qstrncmp(emscriptKey->code, "Digit", 5) == 0) { emkb2qt_t searchKey{emscriptKey->code, 0}; // search emcsripten code auto it1 = std::lower_bound(KeyTbl.cbegin(), KeyTbl.cend(), searchKey); if (it1 != KeyTbl.end() && !(searchKey < *it1)) { qtKey = static_cast(it1->qt); } - } else if (qstrncmp(emscriptKey->key, "Dead", 4) == 0 ) { - emkb2qt_t searchKey1{emscriptKey->code, 0}; - for (auto it1 = KeyTbl.cbegin(); it1 != KeyTbl.end(); ++it1) - if (it1 != KeyTbl.end() && (qstrcmp(searchKey1.em, it1->em) == 0)) { - qtKey = static_cast(it1->qt); - } } if (qtKey == Qt::Key_unknown) { -- cgit v1.2.3