Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion engine/includes/editor/editorplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

class Engine;
class Camera;
class QKeyEvent;

class ENGINE_EXPORT EditorPlatform : public PlatformAdaptor {
public:
Expand All @@ -29,7 +30,7 @@ class ENGINE_EXPORT EditorPlatform : public PlatformAdaptor {
void setMouseScrollDelta(float delta);
void setMouseButtons(int button, int state);

void setKeys(int key, const QString &text, bool release, bool repeat);
void setKeys(QKeyEvent *ev, bool release);

void update() override;

Expand Down
13 changes: 9 additions & 4 deletions engine/src/editor/editorplatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,15 @@ void EditorPlatform::setMouseButtons(int button, int state) {
m_mouseButtons[btn] = state;
}

void EditorPlatform::setKeys(int key, const QString &text, bool release, bool repeat) {
Input::KeyCode code = mapToInput(key);
m_keys[code] = release ? RELEASE : (repeat ? REPEAT : PRESS);
m_inputString += text.toStdString();
void EditorPlatform::setKeys(QKeyEvent *ev, bool release) {
Input::KeyCode code = mapToInput(ev->key());
if(code == Input::KEY_UNKNOWN) {
code = mapToInput(ev->nativeVirtualKey());
}
m_keys[code] = release ? RELEASE : (ev->isAutoRepeat() ? REPEAT : PRESS);
if(!release) {
m_inputString += ev->text().toStdString();
}
}

bool EditorPlatform::isMouseLocked() const {
Expand Down
6 changes: 2 additions & 4 deletions engine/src/editor/viewport/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,11 @@ bool Viewport::processEvent(QEvent *event) {
return true;
}
case QEvent::KeyPress: {
QKeyEvent *ev = static_cast<QKeyEvent *>(event);
EditorPlatform::instance().setKeys(ev->nativeVirtualKey(), ev->text(), false, ev->isAutoRepeat());
EditorPlatform::instance().setKeys(static_cast<QKeyEvent *>(event), false);
return true;
}
case QEvent::KeyRelease: {
QKeyEvent *ev = static_cast<QKeyEvent *>(event);
EditorPlatform::instance().setKeys(ev->nativeVirtualKey(), "", true, ev->isAutoRepeat());
EditorPlatform::instance().setKeys(static_cast<QKeyEvent *>(event), true);
return true;
}
case QEvent::Wheel: {
Expand Down
Loading