From a75925d1e358da1043e201c53de2757cd3c8549a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 13 Oct 2016 14:18:21 +1300 Subject: [PATCH] Add numeric shift --- .../resources/qml/controls-uit/Keyboard.qml | 40 +++++++++++-------- libraries/gl/src/gl/OffscreenQmlSurface.cpp | 22 +++++----- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/interface/resources/qml/controls-uit/Keyboard.qml b/interface/resources/qml/controls-uit/Keyboard.qml index 4c617420b6..94ba34b93e 100644 --- a/interface/resources/qml/controls-uit/Keyboard.qml +++ b/interface/resources/qml/controls-uit/Keyboard.qml @@ -22,6 +22,7 @@ Item { visible: enabled && raised property bool shiftMode: false + property bool numericShiftMode: false function resetShiftMode(mode) { shiftMode = mode; @@ -159,7 +160,6 @@ Item { } Row { - id: row3 width: 480 height: 50 anchors.left: parent.left @@ -180,8 +180,8 @@ Item { Key { width: 43; glyph: "n"; } Key { width: 43; glyph: "m"; } Key { width: 43; glyph: "_"; } - Key { width: 43; glyph: "?"; } Key { width: 43; glyph: "/"; } + Key { width: 43; glyph: "?"; } } Row { @@ -198,8 +198,8 @@ Item { Key { width: 43; glyph: ","; } Key { width: 215; glyph: " "; } Key { width: 43; glyph: "."; } - Key { width: 43; glyph: "⇦"; } - Key { width: 43; glyph: "⇨"; } + Key { width: 43; glyph: "\u276C"; } + Key { width: 43; glyph: "\u276D"; } } } @@ -253,17 +253,23 @@ Item { anchors.left: parent.left anchors.leftMargin: 4 - Key { width: 43; glyph: "="; } - Key { width: 43; glyph: "+"; } - Key { width: 43; glyph: "-"; } - Key { width: 43; glyph: ","; } - Key { width: 43; glyph: "."; } - Key { width: 43; glyph: ";"; } - Key { width: 43; glyph: ":"; } - Key { width: 43; glyph: "'"; } - Key { width: 43; glyph: "\""; } - Key { width: 43; glyph: "<"; } - Key { width: 43; glyph: ">"; } + Key { + id: numericShiftKey + width: 43 + glyph: "\u21E8" + toggle: true + onToggledChanged: numericShiftMode = toggled + } + Key { width: 43; glyph: numericShiftMode ? "`" : "+"; } + Key { width: 43; glyph: numericShiftMode ? "~" : "-"; } + Key { width: 43; glyph: numericShiftMode ? "\u00A3" : "="; } + Key { width: 43; glyph: numericShiftMode ? "\u20AC" : ";"; } + Key { width: 43; glyph: numericShiftMode ? "\u00A5" : ":"; } + Key { width: 43; glyph: numericShiftMode ? "<" : "'"; } + Key { width: 43; glyph: numericShiftMode ? ">" : "\""; } + Key { width: 43; glyph: numericShiftMode ? "[" : "{"; } + Key { width: 43; glyph: numericShiftMode ? "]" : "}"; } + Key { width: 43; glyph: numericShiftMode ? "\\" : "|"; } } Row { @@ -280,8 +286,8 @@ Item { Key { width: 43; glyph: ","; } Key { width: 215; glyph: " "; } Key { width: 43; glyph: "."; } - Key { width: 43; glyph: "⇦"; } - Key { width: 43; glyph: "⇨"; } + Key { width: 43; glyph: "\u276C"; } + Key { width: 43; glyph: "\u276D"; } } } } diff --git a/libraries/gl/src/gl/OffscreenQmlSurface.cpp b/libraries/gl/src/gl/OffscreenQmlSurface.cpp index 9644852f83..f9a7ef09e7 100644 --- a/libraries/gl/src/gl/OffscreenQmlSurface.cpp +++ b/libraries/gl/src/gl/OffscreenQmlSurface.cpp @@ -726,13 +726,13 @@ void OffscreenQmlSurface::setFocusText(bool newFocusText) { } // UTF-8 encoded symbols -static const uint8_t UPWARDS_WHITE_ARROW_FROM_BAR[] = { 0xE2, 0x87, 0xAA, 0x00 }; // shift -static const uint8_t LEFT_ARROW[] = { 0xE2, 0x86, 0x90, 0x00 }; // backspace -static const uint8_t LEFTWARD_WHITE_ARROW[] = { 0xE2, 0x87, 0xA6, 0x00 }; // left arrow -static const uint8_t RIGHTWARD_WHITE_ARROW[] = { 0xE2, 0x87, 0xA8, 0x00 }; // right arrow -static const uint8_t ASTERISIM[] = { 0xE2, 0x81, 0x82, 0x00 }; // symbols -static const uint8_t RETURN_SYMBOL[] = { 0xE2, 0x8F, 0x8E, 0x00 }; // return -static const char PUNCTUATION_STRING[] = "&123"; +static const uint8_t SHIFT_ARROW[] = { 0xE2, 0x87, 0xAA, 0x00 }; +static const uint8_t NUMERIC_SHIFT_ARROW[] = { 0xE2, 0x87, 0xA8, 0x00 }; +static const uint8_t BACKSPACE_SYMBOL[] = { 0xE2, 0x86, 0x90, 0x00 }; +static const uint8_t LEFT_ARROW[] = { 0xE2, 0x9D, 0xAC, 0x00 }; +static const uint8_t RIGHT_ARROW[] = { 0xE2, 0x9D, 0xAD, 0x00 }; +static const uint8_t RETURN_SYMBOL[] = { 0xE2, 0x8F, 0x8E, 0x00 }; +static const char PUNCTUATION_STRING[] = "123"; static const char ALPHABET_STRING[] = "abc"; static bool equals(const QByteArray& byteArray, const uint8_t* ptr) { @@ -752,19 +752,19 @@ void OffscreenQmlSurface::synthesizeKeyPress(QString key) { int scanCode = (int)utf8Key[0]; QString keyString = key; - if (equals(utf8Key, UPWARDS_WHITE_ARROW_FROM_BAR) || equals(utf8Key, ASTERISIM) || + if (equals(utf8Key, SHIFT_ARROW) || equals(utf8Key, NUMERIC_SHIFT_ARROW) || equals(utf8Key, (uint8_t*)PUNCTUATION_STRING) || equals(utf8Key, (uint8_t*)ALPHABET_STRING)) { return; // ignore - } else if (equals(utf8Key, LEFT_ARROW)) { + } else if (equals(utf8Key, BACKSPACE_SYMBOL)) { scanCode = Qt::Key_Backspace; keyString = "\x08"; } else if (equals(utf8Key, RETURN_SYMBOL)) { scanCode = Qt::Key_Return; keyString = "\x0d"; - } else if (equals(utf8Key, LEFTWARD_WHITE_ARROW)) { + } else if (equals(utf8Key, LEFT_ARROW)) { scanCode = Qt::Key_Left; keyString = ""; - } else if (equals(utf8Key, RIGHTWARD_WHITE_ARROW)) { + } else if (equals(utf8Key, RIGHT_ARROW)) { scanCode = Qt::Key_Right; keyString = ""; }