From b90b0854e08b0ecf432e351e9594e48a894834bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Miko=C5=82ajczyk?= Date: Sat, 16 Feb 2013 13:51:31 +0100 Subject: [PATCH] Fix input responsiveness --- Qt/EmuThread.cpp | 13 ------------- Qt/QtHost.cpp | 3 ++- Qt/mainwindow.cpp | 24 ++++++++++++------------ Qt/mainwindow.h | 2 ++ 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/Qt/EmuThread.cpp b/Qt/EmuThread.cpp index 44c3fc6366..3c41af0359 100644 --- a/Qt/EmuThread.cpp +++ b/Qt/EmuThread.cpp @@ -219,19 +219,6 @@ void EmuThread::run() host->BootDone(); needInitGame = false; } - UpdateInputState(input_state); - - for (int i = 0; i < controllistCount; i++) { - if (input_state->pad_buttons_down & controllist[i].emu_id) { - __CtrlButtonDown(controllist[i].psp_id); - } - if (input_state->pad_buttons_up & controllist[i].emu_id) { - __CtrlButtonUp(controllist[i].psp_id); - } - } - __CtrlSetAnalog(input_state->pad_lstick_x, input_state->pad_lstick_y); - - EndInputState(input_state); glstate.Restore(); glViewport(0, 0, pixel_xres, pixel_yres); diff --git a/Qt/QtHost.cpp b/Qt/QtHost.cpp index 78cc696698..5a8989ead8 100644 --- a/Qt/QtHost.cpp +++ b/Qt/QtHost.cpp @@ -48,7 +48,6 @@ void QtHost::SetWindowTitle(const char *message) void QtHost::UpdateUI() { - mainWindow->Update(); mainWindow->UpdateMenus(); } @@ -77,7 +76,9 @@ void QtHost::SetDebugMode(bool mode) void QtHost::BeginFrame() { + mainWindow->Update(); } + void QtHost::EndFrame() { } diff --git a/Qt/mainwindow.cpp b/Qt/mainwindow.cpp index c951d70f53..af4cf7776a 100644 --- a/Qt/mainwindow.cpp +++ b/Qt/mainwindow.cpp @@ -697,22 +697,12 @@ void MainWindow::keyPressEvent(QKeyEvent *e) return; } - for (int b = 0; b < controllistCount; b++) { - if (e->key() == controllist[b].key) - { - input_state.pad_buttons |= (controllist[b].emu_id); - } - } + pressedKeys.insert(e->key()); } void MainWindow::keyReleaseEvent(QKeyEvent *e) { - for (int b = 0; b < controllistCount; b++) { - if (e->key() == controllist[b].key) - { - input_state.pad_buttons &= ~(controllist[b].emu_id); - } - } + pressedKeys.remove(e->key()); } void MainWindow::on_MainWindow_destroyed() @@ -928,7 +918,17 @@ void MainWindow::ShowMemory(u32 addr) void MainWindow::Update() { + UpdateInputState(&input_state); + for (int i = 0; i < controllistCount; i++) + { + if (pressedKeys.contains(controllist[i].key) || + input_state.pad_buttons_down & controllist[i].emu_id) + __CtrlButtonDown(controllist[i].psp_id); + else + __CtrlButtonUp(controllist[i].psp_id); + } + __CtrlSetAnalog(input_state.pad_lstick_x, input_state.pad_lstick_y); } void MainWindow::on_action_EmulationReset_triggered() diff --git a/Qt/mainwindow.h b/Qt/mainwindow.h index 9b83c867ae..14a1b8af75 100644 --- a/Qt/mainwindow.h +++ b/Qt/mainwindow.h @@ -192,6 +192,8 @@ private: Debugger_Memory *memoryWindow; Controls* controls; GamePadDialog* gamePadDlg; + + QSet pressedKeys; }; #endif // MAINWINDOW_H