make user aware of grab mouse limitations

This commit is contained in:
thrust26 2019-12-30 09:46:46 +01:00
parent 767f952e4e
commit bfb5bee208
4 changed files with 61 additions and 25 deletions

View File

@ -566,9 +566,12 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
case Event::ToggleGrabMouse: case Event::ToggleGrabMouse:
if (pressed && !repeated && !myOSystem.frameBuffer().fullScreen()) if (pressed && !repeated && !myOSystem.frameBuffer().fullScreen())
{ {
bool oldState = myOSystem.frameBuffer().grabMouseEnabled();
myOSystem.frameBuffer().toggleGrabMouse(); myOSystem.frameBuffer().toggleGrabMouse();
myOSystem.frameBuffer().showMessage(myOSystem.frameBuffer().grabMouseEnabled() bool newState = myOSystem.frameBuffer().grabMouseEnabled();
? "Grab mouse enabled" : "Grab mouse disabled"); myOSystem.frameBuffer().showMessage(oldState != newState ? myOSystem.frameBuffer().grabMouseEnabled()
? "Grab mouse enabled" : "Grab mouse disabled"
: "Grab mouse not allowed while cursor shown");
} }
return; return;

View File

@ -843,16 +843,27 @@ void FrameBuffer::setCursorState()
myOSystem.console().rightController().isAnalog()) : false; myOSystem.console().rightController().isAnalog()) : false;
bool alwaysUseMouse = BSPF::equalsIgnoreCase("always", myOSystem.settings().getString("usemouse")); bool alwaysUseMouse = BSPF::equalsIgnoreCase("always", myOSystem.settings().getString("usemouse"));
grabMouse(emulation && (analog || alwaysUseMouse) && myGrabMouse);
// Show/hide cursor in UI/emulation mode based on 'cursor' setting // Show/hide cursor in UI/emulation mode based on 'cursor' setting
switch(myOSystem.settings().getInt("cursor")) int cursor = myOSystem.settings().getInt("cursor");
switch(cursor)
{ {
case 0: showCursor(false); break; case 0:
case 1: showCursor(emulation); break; showCursor(false);
case 2: showCursor(!emulation); break; break;
case 3: showCursor(true); break; case 1:
showCursor(emulation);
myGrabMouse = false; // disable grab while cursor is shown in emulation
break;
case 2:
showCursor(!emulation);
break;
case 3:
showCursor(true);
myGrabMouse = false; // disable grab while cursor is shown in emulation
break;
} }
grabMouse(emulation && (analog || alwaysUseMouse) && myGrabMouse);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -129,7 +129,7 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
VarList::push_back(items, "+UI, -Emulation", "2"); VarList::push_back(items, "+UI, -Emulation", "2");
VarList::push_back(items, "+UI, +Emulation", "3"); VarList::push_back(items, "+UI, +Emulation", "3");
myCursorState = new PopUpWidget(myTab, font, HBORDER, ypos, pwidth, lineHeight, items, myCursorState = new PopUpWidget(myTab, font, HBORDER, ypos, pwidth, lineHeight, items,
"Mouse cursor visibility ", lwidth); "Mouse cursor visibility ", lwidth, kCursorStateChanged);
wid.push_back(myCursorState); wid.push_back(myCursorState);
#ifndef WINDOWED_SUPPORT #ifndef WINDOWED_SUPPORT
myCursorState->clearFlags(Widget::FLAG_ENABLED); myCursorState->clearFlags(Widget::FLAG_ENABLED);
@ -272,6 +272,7 @@ void InputDialog::loadConfig()
// Mouse cursor state // Mouse cursor state
myCursorState->setSelected(instance().settings().getString("cursor"), "2"); myCursorState->setSelected(instance().settings().getString("cursor"), "2");
handleCursorState();
// Joystick deadzone // Joystick deadzone
myDeadzone->setValue(instance().settings().getInt("joydeadzone")); myDeadzone->setValue(instance().settings().getInt("joydeadzone"));
@ -280,7 +281,7 @@ void InputDialog::loadConfig()
// Paddle speed (digital and mouse) // Paddle speed (digital and mouse)
myDejitterBase->setValue(instance().settings().getInt("dejitter.base")); myDejitterBase->setValue(instance().settings().getInt("dejitter.base"));
myDejitterDiff->setValue(instance().settings().getInt("dejitter.diff")); myDejitterDiff->setValue(instance().settings().getInt("dejitter.diff"));
UpdateDejitter(); updateDejitter();
myDPaddleSpeed->setValue(instance().settings().getInt("dsense")); myDPaddleSpeed->setValue(instance().settings().getInt("dsense"));
myDPaddleLabel->setLabel(instance().settings().getString("dsense")); myDPaddleLabel->setLabel(instance().settings().getString("dsense"));
myMPaddleSpeed->setValue(instance().settings().getInt("msense")); myMPaddleSpeed->setValue(instance().settings().getInt("msense"));
@ -365,8 +366,12 @@ void InputDialog::saveConfig()
// Grab mouse and hide cursor // Grab mouse and hide cursor
const string& cursor = myCursorState->getSelectedTag().toString(); const string& cursor = myCursorState->getSelectedTag().toString();
instance().settings().setValue("cursor", cursor); instance().settings().setValue("cursor", cursor);
instance().settings().setValue("grabmouse", myGrabMouse->getState()); // only allow grab mouse if cursor is hidden in emulation
instance().frameBuffer().enableGrabMouse(myGrabMouse->getState()); int state = myCursorState->getSelected();
bool enableGrab = state != 1 && state != 3;
bool grab = enableGrab ? myGrabMouse->getState() : false;
instance().settings().setValue("grabmouse", grab);
instance().frameBuffer().enableGrabMouse(grab);
// Enable/disable modifier key-combos // Enable/disable modifier key-combos
instance().settings().setValue("modcombo", myModCombo->getState()); instance().settings().setValue("modcombo", myModCombo->getState());
@ -416,7 +421,7 @@ void InputDialog::setDefaults()
myDejitterBase->setValue(0); myDejitterBase->setValue(0);
myDejitterDiff->setValue(0); myDejitterDiff->setValue(0);
#endif #endif
UpdateDejitter(); updateDejitter();
myTrackBallSpeed->setValue(10); myTrackBallSpeed->setValue(10);
myTrackBallLabel->setLabel("10"); myTrackBallLabel->setLabel("10");
@ -432,6 +437,8 @@ void InputDialog::setDefaults()
// Enable/disable modifier key-combos // Enable/disable modifier key-combos
myModCombo->setState(true); myModCombo->setState(true);
handleCursorState();
break; break;
} }
@ -559,6 +566,10 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
setDefaults(); setDefaults();
break; break;
case kCursorStateChanged:
handleCursorState();
break;
case kDeadzoneChanged: case kDeadzoneChanged:
myDeadzoneLabel->setValue(3200 + 1000*myDeadzone->getValue()); myDeadzoneLabel->setValue(3200 + 1000*myDeadzone->getValue());
break; break;
@ -572,7 +583,7 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
break; break;
case kDejitterChanged: case kDejitterChanged:
UpdateDejitter(); updateDejitter();
break; break;
case kTBSpeedChanged: case kTBSpeedChanged:
@ -618,7 +629,16 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::UpdateDejitter() void InputDialog::handleCursorState()
{
int state = myCursorState->getSelected();
bool enableGrab = state != 1 && state != 3;
myGrabMouse->setEnabled(enableGrab);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::updateDejitter()
{ {
int strength = myDejitterBase->getValue(); int strength = myDejitterBase->getValue();
stringstream label; stringstream label;

View File

@ -61,11 +61,13 @@ class InputDialog : public Dialog
void addDevicePortTab(const GUI::Font& font); void addDevicePortTab(const GUI::Font& font);
void handleCursorState();
void updateDejitter();
void eraseEEPROM(); void eraseEEPROM();
void UpdateDejitter();
private: private:
enum { enum {
kCursorStateChanged = 'CSch',
kDeadzoneChanged = 'DZch', kDeadzoneChanged = 'DZch',
kDejitterChanged = 'Pjch', kDejitterChanged = 'Pjch',
kDPSpeedChanged = 'PDch', kDPSpeedChanged = 'PDch',