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
This commit is contained in:
Thomas Jentzsch 2022-10-01 11:07:02 +02:00
parent 129ec5886a
commit 65115cc3a1
4 changed files with 40 additions and 15 deletions

View File

@ -4068,10 +4068,10 @@
<p>Stella supports viewing images and ROM properties of the currently <p>Stella supports viewing images and ROM properties of the currently
selected ROM in the ROM launcher. Image support is automatic, as long as your selected ROM in the ROM launcher. Image support is automatic, as long as your
image directory contains snapshots in the appropriate format. The label image directory contains any images in the appropriate format. The label (if
(if existing) and the number of matching snapshots are displayed under the existing) and the number of matching images are displayed under the
current one. The mouse or the ROM Launcher hotkeys can be used to browse current image. The mouse, the ROM Launcher hotkeys or the controller can be
multiple images or a ROM.</p> used to browse multiple images of a ROM.</p>
Notes: Notes:
<li>The images can have PNG or JPG format.</li> <li>The images can have PNG or JPG format.</li>

View File

@ -160,6 +160,16 @@
Button 2 or 6 close the menu without any action. Button 2 or 6 close the menu without any action.
</td> </td>
</tr> </tr>
<tr>
<td>Button 1 + Left</td>
<td>-</td>
<td>Display previous image</td>
</tr>
<tr>
<td>Button 1 + Right</td>
<td>-</td>
<td>Display next image</td>
</tr>
<tr> <tr>
<td>Button 2</td> <td>Button 2</td>
<td>SKILL P2</td> <td>SKILL P2</td>

View File

@ -75,8 +75,12 @@ void DialogContainer::updateTime(uInt64 time)
// Joystick axis still pressed // Joystick axis still pressed
if(myCurrentAxisDown.stick != -1 && myAxisRepeatTime < myTime) if(myCurrentAxisDown.stick != -1 && myAxisRepeatTime < myTime)
{ {
activeDialog->handleJoyAxis(myCurrentAxisDown.stick, myCurrentAxisDown.axis, if(myCurrentButtonDown.stick == myCurrentAxisDown.stick)
myCurrentAxisDown.adir); activeDialog->handleJoyAxis(myCurrentAxisDown.stick, myCurrentAxisDown.axis,
myCurrentAxisDown.adir, myCurrentButtonDown.button);
else
activeDialog->handleJoyAxis(myCurrentAxisDown.stick, myCurrentAxisDown.axis,
myCurrentAxisDown.adir);
myAxisRepeatTime = myTime + _REPEAT_SUSTAIN_DELAY; 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 // Send the event to the dialog box on the top of the stack
Dialog* activeDialog = myDialogStack.top(); Dialog* activeDialog = myDialogStack.top();
if(pressed && myButtonRepeatTime < myTime) // prevent pending repeats after enabling repeat again if(pressed)
{ {
myCurrentButtonDown.stick = stick; if(myButtonRepeatTime < myTime || // prevent pending repeats after enabling repeat again
myCurrentButtonDown.button = button; myButtonRepeatTime + _REPEAT_INITIAL_DELAY > myTime) // ignore blocking delays
myButtonRepeatTime = myTime + (activeDialog->repeatEnabled() ? _REPEAT_INITIAL_DELAY : _REPEAT_NONE); {
myButtonLongPressTime = myTime + _LONG_PRESS_DELAY; 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 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 // Send the event to the dialog box on the top of the stack
Dialog* activeDialog = myDialogStack.top(); 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; myButtonLongPressTime = myTime + _REPEAT_NONE;
// Only stop firing events if it's the current stick // 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 // Send the event to the dialog box on the top of the stack
Dialog* activeDialog = myDialogStack.top(); 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; myButtonLongPressTime = myTime + _REPEAT_NONE;
// Only stop firing events if it's the current stick // Only stop firing events if it's the current stick

View File

@ -952,12 +952,13 @@ Event::Type LauncherDialog::getJoyAxisEvent(int stick, JoyAxis axis, JoyDir adir
break; break;
case Event::UITabPrev: case Event::UITabPrev:
// TODO: check with controller, then update doc (R77 too)
myRomImageWidget->changeImage(-1); myRomImageWidget->changeImage(-1);
myEventHandled = true;
break; break;
case Event::UITabNext: case Event::UITabNext:
myRomImageWidget->changeImage(1); myRomImageWidget->changeImage(1);
myEventHandled = true;
break; break;
default: default:
@ -1136,11 +1137,13 @@ void LauncherDialog::openContextMenu(int x, int y)
{ {
// Dynamically create context menu for ROM list options // Dynamically create context menu for ROM list options
bool addCancel = false;
if(x < 0 || y < 0) if(x < 0 || y < 0)
{ {
// Long pressed button, determine position from currently selected list item // Long pressed button, determine position from currently selected list item
x = myList->getLeft() + myList->getWidth() / 2; x = myList->getLeft() + myList->getWidth() / 2;
y = myList->getTop() + (myList->getSelected() - myList->currentPos() + 1) * _font.getLineHeight(); y = myList->getTop() + (myList->getSelected() - myList->currentPos() + 1) * _font.getLineHeight();
addCancel = true;
} }
struct ContextItem { struct ContextItem {
@ -1219,6 +1222,8 @@ void LauncherDialog::openContextMenu(int x, int y)
// items.push_back(ContextItem("Options" + ELLIPSIS, "Ctrl+O", "options")); // 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 // Format items for menu
VariantList varItems; VariantList varItems;