Implemented playback mouse middle button functionality for Qt Tas editor.

This commit is contained in:
mjbudd77 2021-11-28 20:12:18 -05:00
parent a7244cf343
commit 27fb529830
3 changed files with 64 additions and 42 deletions

View File

@ -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() );
}

View File

@ -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)

View File

@ -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 <QApplication>
#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)