diff --git a/interface/resources/config/keyboard.json b/interface/resources/config/keyboard.json index 6a6cc4d6b7..4528003602 100644 --- a/interface/resources/config/keyboard.json +++ b/interface/resources/config/keyboard.json @@ -820,9 +820,9 @@ "y": 0.04787999764084816 }, "position": { - "x": -0.65333323516845703, + "x": -0.026292800903320312, "y": 0.019300000742077827, - "z": -0.02 + "z": 0.09745675086975098 }, "modelURL": "meshes/keyboard/SM_key.fbx", "texture": { @@ -841,13 +841,13 @@ "type": "cut", "dimensions": { "x": 0.04787999764084816, - "z": 0.020519999787211418, + "z": 0.02051999792456627, "y": 0.04787999764084816 }, "position": { - "x": -0.70333323516845703, + "x": -0.08203601837158203, "y": 0.019300000742077827, - "z": -0.02 + "z": 0.09745675086975098 }, "modelURL": "meshes/keyboard/SM_key.fbx", "texture": { @@ -870,9 +870,9 @@ "y": 0.04787999764084816 }, "position": { - "x": -0.65333323516845703, + "x": -0.47769832611083984, "y": 0.019300000742077827, - "z": -0.07 + "z": 0.09745675086975098 }, "modelURL": "meshes/keyboard/SM_key.fbx", "texture": { @@ -895,9 +895,9 @@ "y": 0.04787999764084816 }, "position": { - "x": -0.70333323516845703, + "x": -0.5332040786743164, "y": 0.019300000742077827, - "z": -0.07 + "z": 0.09745675086975098 }, "modelURL": "meshes/keyboard/SM_key.fbx", "texture": { @@ -911,6 +911,106 @@ "z": 0.707 } }, + { + "key": "Up", + "type": "cursor_up", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.68333323516845703, + "y": 0.019300000742077827, + "z": -0.02282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_up.png", + "file10": "meshes/keyboard/key_up.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Left", + "type": "cursor_left", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.63333323516845703, + "y": 0.019300000742077827, + "z": -0.07282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_left.png", + "file10": "meshes/keyboard/key_left.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Down", + "type": "cursor_down", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.68333323516845703, + "y": 0.019300000742077827, + "z": -0.07282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_down.png", + "file10": "meshes/keyboard/key_down.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Right", + "type": "cursor_right", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.73333323516845703, + "y": 0.019300000742077827, + "z": -0.07282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_right.png", + "file10": "meshes/keyboard/key_right.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, { "key": "numbers", "type": "layer", @@ -1689,6 +1789,206 @@ "z": 0.707 } }, + { + "key": "Select All", + "type": "select_all", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.026292800903320312, + "y": 0.019300000742077827, + "z": 0.09745675086975098 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_select_all.png", + "file10": "meshes/keyboard/key_select_all.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Cut", + "type": "cut", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.02051999792456627, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.08203601837158203, + "y": 0.019300000742077827, + "z": 0.09745675086975098 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_cut.png", + "file10": "meshes/keyboard/key_cut.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Copy", + "type": "copy", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.47769832611083984, + "y": 0.019300000742077827, + "z": 0.09745675086975098 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_copy.png", + "file10": "meshes/keyboard/key_copy.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Paste", + "type": "paste", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.5332040786743164, + "y": 0.019300000742077827, + "z": 0.09745675086975098 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_paste.png", + "file10": "meshes/keyboard/key_paste.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Up", + "type": "cursor_up", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.68333323516845703, + "y": 0.019300000742077827, + "z": -0.02282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_up.png", + "file10": "meshes/keyboard/key_up.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Left", + "type": "cursor_left", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.63333323516845703, + "y": 0.019300000742077827, + "z": -0.07282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_left.png", + "file10": "meshes/keyboard/key_left.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Down", + "type": "cursor_down", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.68333323516845703, + "y": 0.019300000742077827, + "z": -0.07282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_down.png", + "file10": "meshes/keyboard/key_down.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Right", + "type": "cursor_right", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.73333323516845703, + "y": 0.019300000742077827, + "z": -0.07282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_right.png", + "file10": "meshes/keyboard/key_right.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, { "key": "numbers", "type": "layer", @@ -2515,6 +2815,206 @@ "z": 0.707 } }, + { + "key": "Select All", + "type": "select_all", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.026292800903320312, + "y": 0.019300000742077827, + "z": 0.09745675086975098 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_select_all.png", + "file10": "meshes/keyboard/key_select_all.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Cut", + "type": "cut", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.02051999792456627, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.08203601837158203, + "y": 0.019300000742077827, + "z": 0.09745675086975098 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_cut.png", + "file10": "meshes/keyboard/key_cut.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Copy", + "type": "copy", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.47769832611083984, + "y": 0.019300000742077827, + "z": 0.09745675086975098 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_copy.png", + "file10": "meshes/keyboard/key_copy.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Paste", + "type": "paste", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.5332040786743164, + "y": 0.019300000742077827, + "z": 0.09745675086975098 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_paste.png", + "file10": "meshes/keyboard/key_paste.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Up", + "type": "cursor_up", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.68333323516845703, + "y": 0.019300000742077827, + "z": -0.02282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_up.png", + "file10": "meshes/keyboard/key_up.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Left", + "type": "cursor_left", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.63333323516845703, + "y": 0.019300000742077827, + "z": -0.07282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_left.png", + "file10": "meshes/keyboard/key_left.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Down", + "type": "cursor_down", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.68333323516845703, + "y": 0.019300000742077827, + "z": -0.07282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_down.png", + "file10": "meshes/keyboard/key_down.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, + { + "key": "Right", + "type": "cursor_right", + "dimensions": { + "x": 0.04787999764084816, + "z": 0.020519999787211418, + "y": 0.04787999764084816 + }, + "position": { + "x": -0.73333323516845703, + "y": 0.019300000742077827, + "z": -0.07282185554504395 + }, + "modelURL": "meshes/keyboard/SM_key.fbx", + "texture": { + "file9": "meshes/keyboard/key_right.png", + "file10": "meshes/keyboard/key_right.png" + }, + "localOrientation": { + "w": 0.000, + "x": 0.000, + "y": 0.707, + "z": 0.707 + } + }, { "key": "numbers", "type": "layer", diff --git a/interface/resources/meshes/keyboard/key_down.png b/interface/resources/meshes/keyboard/key_down.png new file mode 100644 index 0000000000..fd9cc215e2 Binary files /dev/null and b/interface/resources/meshes/keyboard/key_down.png differ diff --git a/interface/resources/meshes/keyboard/key_left.png b/interface/resources/meshes/keyboard/key_left.png new file mode 100644 index 0000000000..d96515582f Binary files /dev/null and b/interface/resources/meshes/keyboard/key_left.png differ diff --git a/interface/resources/meshes/keyboard/key_right.png b/interface/resources/meshes/keyboard/key_right.png new file mode 100644 index 0000000000..aa082807c3 Binary files /dev/null and b/interface/resources/meshes/keyboard/key_right.png differ diff --git a/interface/resources/meshes/keyboard/key_up.png b/interface/resources/meshes/keyboard/key_up.png new file mode 100644 index 0000000000..65b7e6707c Binary files /dev/null and b/interface/resources/meshes/keyboard/key_up.png differ diff --git a/interface/src/ui/Keyboard.cpp b/interface/src/ui/Keyboard.cpp index 3d7d4bf264..a4d346fd2c 100644 --- a/interface/src/ui/Keyboard.cpp +++ b/interface/src/ui/Keyboard.cpp @@ -88,6 +88,10 @@ static const QString SELECT_ALL_STRING = "select_all"; static const QString COPY_STRING = "copy"; static const QString CUT_STRING = "cut"; static const QString PASTE_STRING = "paste"; +static const QString CURSOR_UP_STRING = "cursor_up"; +static const QString CURSOR_RIGHT_STRING = "cursor_right"; +static const QString CURSOR_DOWN_STRING = "cursor_down"; +static const QString CURSOR_LEFT_STRING = "cursor_left"; static const QString KEY_HOVER_HIGHLIGHT = "keyHoverHiglight"; static const QString KEY_PRESSED_HIGHLIGHT = "keyPressesHighlight"; @@ -216,6 +220,14 @@ Key::Type Key::getKeyTypeFromString(const QString& keyTypeString) { return Type::CUT; } else if (keyTypeString == PASTE_STRING) { return Type::PASTE; + } else if (keyTypeString == CURSOR_UP_STRING) { + return Type::CURSOR_UP; + } else if (keyTypeString == CURSOR_RIGHT_STRING) { + return Type::CURSOR_RIGHT; + } else if (keyTypeString == CURSOR_DOWN_STRING) { + return Type::CURSOR_DOWN; + } else if (keyTypeString == CURSOR_LEFT_STRING) { + return Type::CURSOR_LEFT; } return Type::CHARACTER; @@ -520,7 +532,8 @@ bool Keyboard::shouldProcessPointerEvent(const PointerEvent& event) const { return ((isStylusEvent && preferMalletsOverLasers) || (isLaserEvent && !preferMalletsOverLasers)); } -void Keyboard::handleShortcut(Key::Type keyType) { +void Keyboard::handleSpecialKey(Key::Type keyType) { + Qt::KeyboardModifier keyMod = Qt::ControlModifier; int keyCode; switch (keyType) { case Key::Type::SELECT_ALL: @@ -539,14 +552,34 @@ void Keyboard::handleShortcut(Key::Type keyType) { keyCode = Qt::Key_V; break; + case Key::Type::CURSOR_UP: + keyCode = Qt::Key_Up; + keyMod = Qt::NoModifier; + break; + + case Key::Type::CURSOR_RIGHT: + keyCode = Qt::Key_Right; + keyMod = Qt::NoModifier; + break; + + case Key::Type::CURSOR_DOWN: + keyCode = Qt::Key_Down; + keyMod = Qt::NoModifier; + break; + + case Key::Type::CURSOR_LEFT: + keyCode = Qt::Key_Left; + keyMod = Qt::NoModifier; + break; + // shouldn't reach here default: return; } // Qt automatically remaps ⌘A, ⌘C, etc. to ^A and ^C on macOS - QKeyEvent* pressEvent = new QKeyEvent(QEvent::KeyPress, keyCode, Qt::ControlModifier); - QKeyEvent* releaseEvent = new QKeyEvent(QEvent::KeyRelease, keyCode, Qt::ControlModifier); + QKeyEvent* pressEvent = new QKeyEvent(QEvent::KeyPress, keyCode, keyMod); + QKeyEvent* releaseEvent = new QKeyEvent(QEvent::KeyRelease, keyCode, keyMod); if (_inputToHudUI) { QCoreApplication::postEvent(qApp->getPrimaryWidget(), pressEvent); @@ -629,7 +662,11 @@ void Keyboard::handleTriggerBegin(const QUuid& id, const PointerEvent& event) { case Key::Type::COPY: case Key::Type::CUT: case Key::Type::PASTE: - handleShortcut(key.getKeyType()); + case Key::Type::CURSOR_UP: + case Key::Type::CURSOR_RIGHT: + case Key::Type::CURSOR_DOWN: + case Key::Type::CURSOR_LEFT: + handleSpecialKey(key.getKeyType()); return; case Key::Type::CHARACTER: if (keyString != " ") { diff --git a/interface/src/ui/Keyboard.h b/interface/src/ui/Keyboard.h index 0b0de6110f..81f2e13019 100644 --- a/interface/src/ui/Keyboard.h +++ b/interface/src/ui/Keyboard.h @@ -45,6 +45,10 @@ public: COPY, CUT, PASTE, + CURSOR_UP, + CURSOR_RIGHT, + CURSOR_DOWN, + CURSOR_LEFT, }; static Key::Type getKeyTypeFromString(const QString& keyTypeString); @@ -165,7 +169,7 @@ private: void startLayerSwitchTimer(); bool isLayerSwitchTimerFinished() const; - void handleShortcut(Key::Type keyType); + void handleSpecialKey(Key::Type keyType); bool _raised { false }; bool _resetKeyboardPositionOnRaise { true };