Skip to content

Commit 48e35e9

Browse files
authored
Merge pull request 86Box#5257 from Cacodemon345/keyboard-alt-tab
All held-down keys are now released when Alt-Tab'ing out
2 parents 26074e9 + 168910b commit 48e35e9

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/device/keyboard.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,20 @@ keyboard_input(int down, uint16_t scan)
332332
}
333333
}
334334

335+
void
336+
keyboard_all_up(void)
337+
{
338+
for (unsigned short i = 0; i < 0x200; i++) {
339+
if (recv_key_ui[i]) {
340+
recv_key_ui[i] = 0;
341+
}
342+
if (recv_key[i]) {
343+
recv_key[i] = 0;
344+
key_process(i, 0);
345+
}
346+
}
347+
}
348+
335349
static uint8_t
336350
keyboard_do_break(uint16_t scan)
337351
{

src/include/86box/keyboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ extern void keyboard_poll_host(void);
269269
extern void keyboard_process(void);
270270
extern uint16_t keyboard_convert(int ch);
271271
extern void keyboard_input(int down, uint16_t scan);
272+
extern void keyboard_all_up(void);
272273
extern void keyboard_update_states(uint8_t cl, uint8_t nl, uint8_t sl);
273274
extern uint8_t keyboard_get_shift(void);
274275
extern void keyboard_get_states(uint8_t *cl, uint8_t *nl, uint8_t *sl);

src/qt/qt_mainwindow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ MainWindow::MainWindow(QWidget *parent)
277277
if (mouse_capture)
278278
emit setMouseCapture(false);
279279

280+
keyboard_all_up();
281+
280282
if (do_auto_pause && !dopause) {
281283
auto_paused = 1;
282284
plat_pause(1);

0 commit comments

Comments
 (0)