Skip to content

Commit 3b96223

Browse files
author
Gin
committed
fix keyboard on 0 native key
1 parent d8f9af8 commit 3b96223

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

SerialPrograms/Source/CommonFramework/Windows/MainWindow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ MainWindow::MainWindow(QWidget* parent)
192192
keyboard, &QPushButton::clicked,
193193
this, [button = m_button_diagram.get()](bool){
194194
button->show();
195+
button->raise(); // bring the window to front on macOS
196+
button->activateWindow(); // bring the window to front on Windows
195197
}
196198
);
197199
}

SerialPrograms/Source/Controllers/KeyboardInput/GlobalQtKeyMap.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ namespace PokemonAutomation{
1313

1414

1515
void QtKeyMap::record(const QKeyEvent& event){
16+
int qt_key = event.key();
1617
uint32_t native_key = event.nativeVirtualKey();
17-
if (native_key == 0){
18+
if (native_key == 0 && (qt_key == 0 || qt_key == Qt::Key_unknown)){
19+
// both native key and Qt key event is 0 or unknown, meaning we really don't know
20+
// what key event it is. Skip
1821
return;
1922
}
20-
Qt::Key qkey = (Qt::Key)event.key();
23+
24+
Qt::Key qkey = (Qt::Key)qt_key;
2125
WriteSpinLock lg(m_lock);
2226
m_map[native_key].insert(qkey);
2327
}

0 commit comments

Comments
 (0)