From aebc097e9512b867aaf8339fb21e3c1a117b6b83 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sat, 1 Oct 2022 11:07:02 +0200 Subject: [PATCH] enhanced UI navigation with a controller added "Cancel" option to LauncherDialog context menu if opened with a controller updated docs for image navigation in LauncherDialog --- docs/index.html | 8 ++++---- docs/index_r77.html | 10 ++++++++++ src/gui/DialogContainer.cxx | 30 ++++++++++++++++++++---------- src/gui/LauncherDialog.cxx | 7 ++++++- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/docs/index.html b/docs/index.html index daab10049..df6d923cd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4068,10 +4068,10 @@

Stella supports viewing images and ROM properties of the currently selected ROM in the ROM launcher. Image support is automatic, as long as your - image directory contains snapshots in the appropriate format. The label - (if existing) and the number of matching snapshots are displayed under the - current one. The mouse or the ROM Launcher hotkeys can be used to browse - multiple images or a ROM.

+ image directory contains any images in the appropriate format. The label (if + existing) and the number of matching images are displayed under the + current image. The mouse, the ROM Launcher hotkeys or the controller can be + used to browse multiple images of a ROM.

Notes:
  • The images can have PNG or JPG format.
  • diff --git a/docs/index_r77.html b/docs/index_r77.html index bf3a3a8a2..982c281c8 100644 --- a/docs/index_r77.html +++ b/docs/index_r77.html @@ -160,6 +160,16 @@ Button 2 or 6 close the menu without any action. + + Button 1 + Left + - + Display previous image + + + Button 1 + Right + - + Display next image + Button 2 SKILL P2 diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 35e5cf601..f39a022e8 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -75,8 +75,12 @@ void DialogContainer::updateTime(uInt64 time) // Joystick axis still pressed if(myCurrentAxisDown.stick != -1 && myAxisRepeatTime < myTime) { - activeDialog->handleJoyAxis(myCurrentAxisDown.stick, myCurrentAxisDown.axis, - myCurrentAxisDown.adir); + if(myCurrentButtonDown.stick == myCurrentAxisDown.stick) + activeDialog->handleJoyAxis(myCurrentAxisDown.stick, myCurrentAxisDown.axis, + myCurrentAxisDown.adir, myCurrentButtonDown.button); + else + activeDialog->handleJoyAxis(myCurrentAxisDown.stick, myCurrentAxisDown.axis, + myCurrentAxisDown.adir); myAxisRepeatTime = myTime + _REPEAT_SUSTAIN_DELAY; } @@ -323,14 +327,18 @@ void DialogContainer::handleJoyBtnEvent(int stick, int button, bool pressed) // Send the event to the dialog box on the top of the stack Dialog* activeDialog = myDialogStack.top(); - if(pressed && myButtonRepeatTime < myTime) // prevent pending repeats after enabling repeat again + if(pressed) { - myCurrentButtonDown.stick = stick; - myCurrentButtonDown.button = button; - myButtonRepeatTime = myTime + (activeDialog->repeatEnabled() ? _REPEAT_INITIAL_DELAY : _REPEAT_NONE); - myButtonLongPressTime = myTime + _LONG_PRESS_DELAY; + if(myButtonRepeatTime < myTime || // prevent pending repeats after enabling repeat again + myButtonRepeatTime + _REPEAT_INITIAL_DELAY > myTime) // ignore blocking delays + { + myCurrentButtonDown.stick = stick; + myCurrentButtonDown.button = button; + myButtonRepeatTime = myTime + (activeDialog->repeatEnabled() ? _REPEAT_INITIAL_DELAY : _REPEAT_NONE); + myButtonLongPressTime = myTime + _LONG_PRESS_DELAY; - activeDialog->handleJoyDown(stick, button); + activeDialog->handleJoyDown(stick, button); + } } else { @@ -356,7 +364,8 @@ void DialogContainer::handleJoyAxisEvent(int stick, JoyAxis axis, JoyDir adir, i // Send the event to the dialog box on the top of the stack Dialog* activeDialog = myDialogStack.top(); - // Prevent long button press in button/axis combinations + // Prevent button repeats and long button press in button/axis combinations + myButtonRepeatTime = myTime + _REPEAT_NONE; myButtonLongPressTime = myTime + _REPEAT_NONE; // Only stop firing events if it's the current stick @@ -386,7 +395,8 @@ void DialogContainer::handleJoyHatEvent(int stick, int hat, JoyHatDir hdir, int // Send the event to the dialog box on the top of the stack Dialog* activeDialog = myDialogStack.top(); - // Prevent long button press in button/hat combinations + // Prevent button repeats and long button press in button/hat combinations + myButtonRepeatTime = myTime + _REPEAT_NONE; myButtonLongPressTime = myTime + _REPEAT_NONE; // Only stop firing events if it's the current stick diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 37f8c6b53..5ddcc8bd9 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -952,12 +952,13 @@ Event::Type LauncherDialog::getJoyAxisEvent(int stick, JoyAxis axis, JoyDir adir break; case Event::UITabPrev: - // TODO: check with controller, then update doc (R77 too) myRomImageWidget->changeImage(-1); + myEventHandled = true; break; case Event::UITabNext: myRomImageWidget->changeImage(1); + myEventHandled = true; break; default: @@ -1136,11 +1137,13 @@ void LauncherDialog::openContextMenu(int x, int y) { // Dynamically create context menu for ROM list options + bool addCancel = false; if(x < 0 || y < 0) { // Long pressed button, determine position from currently selected list item x = myList->getLeft() + myList->getWidth() / 2; y = myList->getTop() + (myList->getSelected() - myList->currentPos() + 1) * _font.getLineHeight(); + addCancel = true; } struct ContextItem { @@ -1219,6 +1222,8 @@ void LauncherDialog::openContextMenu(int x, int y) // items.push_back(ContextItem("Options" + ELLIPSIS, "Ctrl+O", "options")); //} } + if(addCancel) + items.push_back(ContextItem("Cancel", "")); // closes the context menu and does nothing // Format items for menu VariantList varItems;