Skip to content

Commit

Permalink
Use Scancode instead of Virtual Key
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihaylov93 committed Apr 19, 2020
1 parent 8df55fd commit d14620c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ void MainWindow::onKeyReceived(const QString &iKey)
const int mKeyValue = QMetaEnum::fromType<Qt::Key>().keyToValue(mLabel->text().toStdString().c_str());

#if defined(Q_OS_WIN)
if (mKeyValue != -1) _keySender->sendKeyPress(_setDialog->keyToNative(Qt::Key(mKeyValue)), mKey.at(1));
if (mKeyValue != -1) _keySender->sendKeyPress(_setDialog->keyToNative(Qt::Key(mKeyValue)), mKey.at(1).trimmed());
#endif

#if defined(Q_OS_LINUX)
if (mKeyValue != -1) _keySender->sendKeyPress(Qt::Key(mKeyValue), mKey.at(1));
if (mKeyValue != -1) _keySender->sendKeyPress(Qt::Key(mKeyValue), mKey.at(1).trimmed());
#endif
}

Expand Down
7 changes: 5 additions & 2 deletions x11sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ X11Sender::~X11Sender()

void X11Sender::keyDown(const unsigned int &iKey)
{
XTestFakeKeyEvent(_display, iKey, True, 0);
const unsigned char mKeycode = XKeysymToKeycode(_display, iKey);
XTestFakeKeyEvent(_display, mKeycode, True, 0);
XFlush(_display);

}

void X11Sender::keyUp(const unsigned int &iKey)
{
XTestFakeKeyEvent(_display, iKey, False, 0);
const unsigned char mKeycode = XKeysymToKeycode(_display, iKey);
XTestFakeKeyEvent(_display, mKeycode, False, 0);
XFlush(_display);
}

0 comments on commit d14620c

Please sign in to comment.