Move copy/paste, add cursor keys

This commit is contained in:
Ada 2025-04-08 01:40:29 +10:00
parent ff46c739a3
commit a736520087
7 changed files with 555 additions and 14 deletions

View file

@ -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",

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -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 != " ") {

View file

@ -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 };