diff --git a/src/drivers/Qt/TasEditor/bookmarks.cpp b/src/drivers/Qt/TasEditor/bookmarks.cpp index 949660b8..7ee16364 100644 --- a/src/drivers/Qt/TasEditor/bookmarks.cpp +++ b/src/drivers/Qt/TasEditor/bookmarks.cpp @@ -925,6 +925,10 @@ void BOOKMARKS::mousePressEvent(QMouseEvent * event) bookmarksArray[bookmarkRightclicked].flashType = FLASH_TYPE_SET; } + if ( event->button() & Qt::MiddleButton ) + { + playback->handleMiddleButtonClick(); + } //printf("Mouse Button Pressed: 0x%x (%i,%i)\n", event->button(), c.x(), c.y() ); } diff --git a/src/drivers/Qt/TasEditor/branches.cpp b/src/drivers/Qt/TasEditor/branches.cpp index 3a452b31..17576394 100644 --- a/src/drivers/Qt/TasEditor/branches.cpp +++ b/src/drivers/Qt/TasEditor/branches.cpp @@ -596,6 +596,10 @@ void BRANCHES::mousePressEvent(QMouseEvent * event) //if (branches.branchRightclicked >= 0 && branches.branchRightclicked < TOTAL_BOOKMARKS) } + else if (event->button() & Qt::MiddleButton) + { + playback->handleMiddleButtonClick(); + } } void BRANCHES::mouseReleaseEvent(QMouseEvent * event) diff --git a/src/drivers/Qt/TasEditor/playback.cpp b/src/drivers/Qt/TasEditor/playback.cpp index 7577ad90..37b71ad8 100644 --- a/src/drivers/Qt/TasEditor/playback.cpp +++ b/src/drivers/Qt/TasEditor/playback.cpp @@ -20,6 +20,8 @@ Playback - Player of emulation states * stores resources: upper text field prefix, timings of target frame animation, response times of GUI buttons, progressbar scale ------------------------------------------------------------------------------------ */ +#include + #include "fceu.h" #include "driver.h" #include "Qt/TasEditor/taseditor_project.h" @@ -287,48 +289,60 @@ void PLAYBACK::restoreLastPosition() } void PLAYBACK::handleMiddleButtonClick() { -// if (emuPausedState) -// { -// // Unpause or start seeking -// // works only when right mouse button is released -// if (GetAsyncKeyState(GetSystemMetrics(SM_SWAPBUTTON) ? VK_LBUTTON : VK_RBUTTON) >= 0) -// { -// if (GetAsyncKeyState(VK_SHIFT) < 0) -// { -// // if Shift is held, seek to nearest Marker -// int last_frame = markersManager.getMarkersArraySize() - 1; // the end of movie Markers -// int target_frame = currFrameCounter + 1; -// for (; target_frame <= last_frame; ++target_frame) -// if (markersManager.getMarkerAtFrame(target_frame)) break; -// if (target_frame <= last_frame) -// startSeekingToFrame(target_frame); -// } else if (GetAsyncKeyState(VK_CONTROL) < 0) -// { -// // if Ctrl is held, seek to Selection cursor or replay from Selection cursor -// int selection_beginning = selection.getCurrentRowsSelectionBeginning(); -// if (selection_beginning > currFrameCounter) -// { -// startSeekingToFrame(selection_beginning); -// } else if (selection_beginning < currFrameCounter) -// { -// int saved_currFrameCounter = currFrameCounter; -// if (selection_beginning < 0) -// selection_beginning = 0; -// jump(selection_beginning); -// startSeekingToFrame(saved_currFrameCounter); -// } -// } else if (getPauseFrame() < 0 && getLastPosition() >= greenzone.getSize()) -// { -// restoreLastPosition(); -// } else -// { -// unpauseEmulation(); -// } -// } -// } else -// { -// pauseEmulation(); -// } + if (emuPausedState) + { + int msState = QApplication::mouseButtons(); + int kbModifiers = QApplication::keyboardModifiers(); + //bool alt_down = (kbModifiers & Qt::AltModifier ) ? 1 : 0; + bool shift_down = (kbModifiers & Qt::ShiftModifier ) ? 1 : 0; + bool ctrl_down = (kbModifiers & Qt::ControlModifier) ? 1 : 0; + bool rgtMsBtnDown = (msState & Qt::RightButton) ? 1 : 0; + + // Unpause or start seeking + // works only when right mouse button is released + if (!rgtMsBtnDown) + { + if (shift_down) + { + // if Shift is held, seek to nearest Marker + int last_frame = markersManager->getMarkersArraySize() - 1; // the end of movie Markers + int target_frame = currFrameCounter + 1; + for (; target_frame <= last_frame; ++target_frame) + if (markersManager->getMarkerAtFrame(target_frame)) break; + if (target_frame <= last_frame) + startSeekingToFrame(target_frame); + } + else if (ctrl_down) + { + // if Ctrl is held, seek to Selection cursor or replay from Selection cursor + int selection_beginning = selection->getCurrentRowsSelectionBeginning(); + if (selection_beginning > currFrameCounter) + { + startSeekingToFrame(selection_beginning); + } + else if (selection_beginning < currFrameCounter) + { + int saved_currFrameCounter = currFrameCounter; + if (selection_beginning < 0) + selection_beginning = 0; + jump(selection_beginning); + startSeekingToFrame(saved_currFrameCounter); + } + } + else if (getPauseFrame() < 0 && getLastPosition() >= greenzone->getSize()) + { + restoreLastPosition(); + } + else + { + unpauseEmulation(); + } + } + } + else + { + pauseEmulation(); + } } void PLAYBACK::startSeekingToFrame(int frame)