Merge pull request #1412 from ada-tv/feature/vr_keyboard_shortcuts
Some checks are pending
Master API-docs CI Build and Deploy / Build and deploy API-docs (push) Waiting to run
Master Doxygen CI Build and Deploy / Build and deploy Doxygen documentation (push) Waiting to run

VR Keyboard Shortcuts
This commit is contained in:
ksuprynowicz 2025-04-10 19:30:10 +02:00 committed by GitHub
commit e7817b55df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 705 additions and 1 deletions

View file

@ -811,6 +811,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",
@ -1589,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",
@ -2415,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",

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -84,6 +84,14 @@ static const QString LAYER_STRING = "layer";
static const QString BACKSPACE_STRING = "backspace";
static const QString SPACE_STRING = "space";
static const QString ENTER_STRING = "enter";
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";
@ -204,6 +212,22 @@ Key::Type Key::getKeyTypeFromString(const QString& keyTypeString) {
return Type::CLOSE;
} else if (keyTypeString == ENTER_STRING) {
return Type::ENTER;
} else if (keyTypeString == SELECT_ALL_STRING) {
return Type::SELECT_ALL;
} else if (keyTypeString == COPY_STRING) {
return Type::COPY;
} else if (keyTypeString == CUT_STRING) {
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;
@ -508,6 +532,67 @@ bool Keyboard::shouldProcessPointerEvent(const PointerEvent& event) const {
return ((isStylusEvent && preferMalletsOverLasers) || (isLaserEvent && !preferMalletsOverLasers));
}
void Keyboard::handleSpecialKey(Key::Type keyType) {
Qt::KeyboardModifier keyMod = Qt::ControlModifier;
int keyCode;
switch (keyType) {
case Key::Type::SELECT_ALL:
keyCode = Qt::Key_A;
break;
case Key::Type::COPY:
keyCode = Qt::Key_C;
break;
case Key::Type::CUT:
keyCode = Qt::Key_X;
break;
case Key::Type::PASTE:
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, keyMod);
QKeyEvent* releaseEvent = new QKeyEvent(QEvent::KeyRelease, keyCode, keyMod);
if (_inputToHudUI) {
QCoreApplication::postEvent(qApp->getPrimaryWidget(), pressEvent);
QCoreApplication::postEvent(qApp->getPrimaryWidget(), releaseEvent);
} else {
QCoreApplication::postEvent(QCoreApplication::instance(), pressEvent);
QCoreApplication::postEvent(QCoreApplication::instance(), releaseEvent);
}
_typedCharacters.clear();
updateTextDisplay();
}
void Keyboard::handleTriggerBegin(const QUuid& id, const PointerEvent& event) {
auto buttonType = event.getButton();
if (!shouldProcessEntityAndPointerEvent(event) || buttonType != PointerEvent::PrimaryButton) {
@ -573,6 +658,16 @@ void Keyboard::handleTriggerBegin(const QUuid& id, const PointerEvent& event) {
_typedCharacters.clear();
updateTextDisplay();
break;
case Key::Type::SELECT_ALL:
case Key::Type::COPY:
case Key::Type::CUT:
case Key::Type::PASTE:
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 != " ") {
_typedCharacters.push_back((_password ? "*" : keyString));

View file

@ -40,7 +40,15 @@ public:
LAYER,
BACKSPACE,
SPACE,
ENTER
ENTER,
SELECT_ALL,
COPY,
CUT,
PASTE,
CURSOR_UP,
CURSOR_RIGHT,
CURSOR_DOWN,
CURSOR_LEFT,
};
static Key::Type getKeyTypeFromString(const QString& keyTypeString);
@ -161,6 +169,7 @@ private:
void startLayerSwitchTimer();
bool isLayerSwitchTimerFinished() const;
void handleSpecialKey(Key::Type keyType);
bool _raised { false };
bool _resetKeyboardPositionOnRaise { true };