mirror of https://github.com/stella-emu/stella.git
make controller repeats configurable in UIDialog
This commit is contained in:
parent
ce10108660
commit
1ecf55ffc0
|
@ -108,6 +108,15 @@ void EventHandler::initialize()
|
|||
|
||||
// Set number of lines a mousewheel will scroll
|
||||
ScrollBarWidget::setWheelLines(myOSystem.settings().getInt("mwheel"));
|
||||
|
||||
// Mouse double click
|
||||
DialogContainer::setDoubleClickDelay(myOSystem.settings().getInt("mdouble"));
|
||||
|
||||
// Input delay
|
||||
DialogContainer::setControllerDelay(myOSystem.settings().getInt("inpDelay"));
|
||||
|
||||
// Input rate
|
||||
DialogContainer::setControllerRate(myOSystem.settings().getInt("inpRate"));
|
||||
#endif
|
||||
|
||||
// Integer to string conversions (for HEX) use upper or lower-case
|
||||
|
@ -1157,7 +1166,6 @@ bool EventHandler::addJoyHatMapping(Event::Type event, EventMode mode,
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::eraseMapping(Event::Type event, EventMode mode)
|
||||
{
|
||||
|
|
|
@ -135,6 +135,9 @@ Settings::Settings()
|
|||
setPermanent("hidpi", "false");
|
||||
setPermanent("listdelay", "300");
|
||||
setPermanent("mwheel", "4");
|
||||
setPermanent("mdouble", "500");
|
||||
setPermanent("ctrldelay", "400");
|
||||
setPermanent("ctrlrate", "20");
|
||||
setPermanent("basic_settings", false);
|
||||
setPermanent("dialogpos", 0);
|
||||
|
||||
|
@ -487,6 +490,9 @@ void Settings::usage() const
|
|||
<< " (300-1000)\n"
|
||||
<< " -mwheel <lines> Number of lines the mouse wheel will scroll in\n"
|
||||
<< " UI\n"
|
||||
<< " -mdouble <speed> Mouse double click speed in UI\n"
|
||||
<< " -ctrldelay <delay> Delay before controller input is repeated in UI\n"
|
||||
<< " -ctrlrate <rate> Rate per second of repeated controller input in UI\n"
|
||||
<< " -basic_settings <0|1> Display only a basic settings dialog\n"
|
||||
<< " -romdir <dir> Directory from which to load ROM files\n"
|
||||
<< " -avoxport <name> The name of the serial port where an AtariVox is\n"
|
||||
|
|
|
@ -34,6 +34,9 @@ DialogContainer::DialogContainer(OSystem& osystem)
|
|||
myAxisRepeatTime(0),
|
||||
myHatRepeatTime(0)
|
||||
{
|
||||
_DOUBLE_CLICK_DELAY = osystem.settings().getInt("mdouble");
|
||||
_REPEAT_INITIAL_DELAY = osystem.settings().getInt("ctrldelay");
|
||||
setControllerRate(osystem.settings().getInt("ctrlrate"));
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -55,14 +58,14 @@ void DialogContainer::updateTime(uInt64 time)
|
|||
activeDialog->handleMouseDown(myCurrentMouseDown.x - activeDialog->_x,
|
||||
myCurrentMouseDown.y - activeDialog->_y,
|
||||
myCurrentMouseDown.b, 1);
|
||||
myClickRepeatTime = myTime + kRepeatSustainDelay;
|
||||
myClickRepeatTime = myTime + _REPEAT_SUSTAIN_DELAY;
|
||||
}
|
||||
|
||||
// Joystick button still pressed
|
||||
if(myCurrentButtonDown.stick != -1 && myButtonRepeatTime < myTime)
|
||||
{
|
||||
activeDialog->handleJoyDown(myCurrentButtonDown.stick, myCurrentButtonDown.button);
|
||||
myButtonRepeatTime = myTime + kRepeatSustainDelay;
|
||||
myButtonRepeatTime = myTime + _REPEAT_SUSTAIN_DELAY;
|
||||
}
|
||||
|
||||
// Joystick axis still pressed
|
||||
|
@ -70,7 +73,7 @@ void DialogContainer::updateTime(uInt64 time)
|
|||
{
|
||||
activeDialog->handleJoyAxis(myCurrentAxisDown.stick, myCurrentAxisDown.axis,
|
||||
myCurrentAxisDown.value);
|
||||
myAxisRepeatTime = myTime + kRepeatSustainDelay;
|
||||
myAxisRepeatTime = myTime + _REPEAT_SUSTAIN_DELAY;
|
||||
}
|
||||
|
||||
// Joystick hat still pressed
|
||||
|
@ -78,7 +81,7 @@ void DialogContainer::updateTime(uInt64 time)
|
|||
{
|
||||
activeDialog->handleJoyHat(myCurrentHatDown.stick, myCurrentHatDown.hat,
|
||||
myCurrentHatDown.value);
|
||||
myHatRepeatTime = myTime + kRepeatSustainDelay;
|
||||
myHatRepeatTime = myTime + _REPEAT_SUSTAIN_DELAY;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,7 +222,7 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed,
|
|||
myLastClick.count = 0;
|
||||
}
|
||||
|
||||
if(myLastClick.count && (myTime < myLastClick.time + kDoubleClickDelay)
|
||||
if(myLastClick.count && (myTime < myLastClick.time + _DOUBLE_CLICK_DELAY)
|
||||
&& std::abs(myLastClick.x - x) < 3
|
||||
&& std::abs(myLastClick.y - y) < 3)
|
||||
{
|
||||
|
@ -240,7 +243,7 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed,
|
|||
myCurrentMouseDown.x = x;
|
||||
myCurrentMouseDown.y = y;
|
||||
myCurrentMouseDown.b = b;
|
||||
myClickRepeatTime = myTime + kRepeatInitialDelay;
|
||||
myClickRepeatTime = myTime + _REPEAT_INITIAL_DELAY;
|
||||
}
|
||||
else
|
||||
myCurrentMouseDown.b = MouseButton::NONE;
|
||||
|
@ -284,7 +287,7 @@ void DialogContainer::handleJoyBtnEvent(int stick, int button, bool pressed)
|
|||
{
|
||||
myCurrentButtonDown.stick = stick;
|
||||
myCurrentButtonDown.button = button;
|
||||
myButtonRepeatTime = myTime + (activeDialog->repeatEnabled() ? kRepeatInitialDelay : kRepeatNone);
|
||||
myButtonRepeatTime = myTime + (activeDialog->repeatEnabled() ? _REPEAT_INITIAL_DELAY : kRepeatNone);
|
||||
|
||||
activeDialog->handleJoyDown(stick, button);
|
||||
}
|
||||
|
@ -323,7 +326,7 @@ void DialogContainer::handleJoyAxisEvent(int stick, int axis, int value, int but
|
|||
myCurrentAxisDown.stick = stick;
|
||||
myCurrentAxisDown.axis = axis;
|
||||
myCurrentAxisDown.value = value;
|
||||
myAxisRepeatTime = myTime + (activeDialog->repeatEnabled() ? kRepeatInitialDelay : kRepeatNone);
|
||||
myAxisRepeatTime = myTime + (activeDialog->repeatEnabled() ? _REPEAT_INITIAL_DELAY : kRepeatNone);
|
||||
}
|
||||
activeDialog->handleJoyAxis(stick, axis, value, button);
|
||||
}
|
||||
|
@ -349,8 +352,7 @@ void DialogContainer::handleJoyHatEvent(int stick, int hat, JoyHat value, int bu
|
|||
myCurrentHatDown.stick = stick;
|
||||
myCurrentHatDown.hat = hat;
|
||||
myCurrentHatDown.value = value;
|
||||
myHatRepeatTime = myTime + (activeDialog->repeatEnabled() ? kRepeatInitialDelay : kRepeatNone);
|
||||
//myHatRepeatTime = myTime + kRepeatInitialDelay;
|
||||
myHatRepeatTime = myTime + (activeDialog->repeatEnabled() ? _REPEAT_INITIAL_DELAY : kRepeatNone);
|
||||
}
|
||||
activeDialog->handleJoyHat(stick, hat, value, button);
|
||||
}
|
||||
|
@ -367,3 +369,9 @@ void DialogContainer::reset()
|
|||
myCurrentAxisDown.stick = myCurrentAxisDown.axis = -1;
|
||||
myCurrentHatDown.stick = myCurrentHatDown.hat = -1;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt64 DialogContainer::_DOUBLE_CLICK_DELAY = 500;
|
||||
uInt64 DialogContainer::_REPEAT_INITIAL_DELAY = 400;
|
||||
uInt64 DialogContainer::_REPEAT_SUSTAIN_DELAY = 50;
|
||||
|
||||
|
|
|
@ -155,6 +155,13 @@ class DialogContainer
|
|||
*/
|
||||
virtual Dialog* baseDialog() = 0;
|
||||
|
||||
/**
|
||||
Set input speeds
|
||||
*/
|
||||
static void setDoubleClickDelay(int delay) { _DOUBLE_CLICK_DELAY = delay; }
|
||||
static void setControllerDelay(int delay) { _REPEAT_INITIAL_DELAY = delay; }
|
||||
static void setControllerRate(int rate) { _REPEAT_SUSTAIN_DELAY = 1000 / rate; }
|
||||
|
||||
private:
|
||||
void reset();
|
||||
|
||||
|
@ -174,15 +181,16 @@ class DialogContainer
|
|||
|
||||
private:
|
||||
enum {
|
||||
kDoubleClickDelay = 500,
|
||||
kRepeatInitialDelay = 400,
|
||||
kRepeatSustainDelay = 50,
|
||||
kRepeatNone = 1 << 24 // loooong
|
||||
};
|
||||
|
||||
// Indicates the most current time (in milliseconds) as set by updateTime()
|
||||
uInt64 myTime;
|
||||
|
||||
static uInt64 _DOUBLE_CLICK_DELAY;
|
||||
static uInt64 _REPEAT_INITIAL_DELAY;
|
||||
static uInt64 _REPEAT_SUSTAIN_DELAY;
|
||||
|
||||
// For continuous 'mouse down' events
|
||||
struct {
|
||||
int x;
|
||||
|
|
|
@ -71,7 +71,7 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
// 1) Misc. options
|
||||
wid.clear();
|
||||
tabID = myTab->addTab(" Look & Feel ");
|
||||
lwidth = font.getStringWidth("Mouse wheel scroll ");
|
||||
lwidth = font.getStringWidth("Controller repeat delay ");
|
||||
pwidth = font.getStringWidth("Right bottom");
|
||||
xpos = HBORDER; ypos = VBORDER;
|
||||
|
||||
|
@ -94,7 +94,7 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
VarList::push_back(items, "Right bottom", 3);
|
||||
VarList::push_back(items, "Left bottom", 4);
|
||||
myPositionPopup = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
|
||||
items, "Dialogs position ", lwidth);
|
||||
items, "Dialogs position ", lwidth);
|
||||
wid.push_back(myPositionPopup);
|
||||
ypos += lineHeight + V_GAP;
|
||||
|
||||
|
@ -105,24 +105,57 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
|
||||
// Delay between quick-selecting characters in ListWidget
|
||||
int swidth = myPalettePopup->getWidth() - lwidth;
|
||||
myListDelayPopup = new SliderWidget(myTab, font, xpos, ypos, swidth, lineHeight,
|
||||
"List input delay ", 0, kListDelay,
|
||||
myListDelaySlider = new SliderWidget(myTab, font, xpos, ypos, swidth, lineHeight,
|
||||
"List input delay ", 0, kListDelay,
|
||||
font.getStringWidth("1 second"));
|
||||
myListDelayPopup->setMinValue(0);
|
||||
myListDelayPopup->setMaxValue(1000);
|
||||
myListDelayPopup->setStepValue(50);
|
||||
myListDelayPopup->setTickmarkIntervals(5);
|
||||
wid.push_back(myListDelayPopup);
|
||||
myListDelaySlider->setMinValue(0);
|
||||
myListDelaySlider->setMaxValue(1000);
|
||||
myListDelaySlider->setStepValue(50);
|
||||
myListDelaySlider->setTickmarkIntervals(5);
|
||||
wid.push_back(myListDelaySlider);
|
||||
ypos += lineHeight + V_GAP;
|
||||
|
||||
// Number of lines a mouse wheel will scroll
|
||||
myWheelLinesPopup = new SliderWidget(myTab, font, xpos, ypos, swidth, lineHeight,
|
||||
"Mouse wheel scroll ", 0, kMouseWheel,
|
||||
myWheelLinesSlider = new SliderWidget(myTab, font, xpos, ypos, swidth, lineHeight,
|
||||
"Mouse wheel scroll ", 0, kMouseWheel,
|
||||
font.getStringWidth("10 lines"));
|
||||
myWheelLinesPopup->setMinValue(1);
|
||||
myWheelLinesPopup->setMaxValue(10);
|
||||
myWheelLinesPopup->setTickmarkIntervals(3);
|
||||
wid.push_back(myWheelLinesPopup);
|
||||
myWheelLinesSlider->setMinValue(1);
|
||||
myWheelLinesSlider->setMaxValue(10);
|
||||
myWheelLinesSlider->setTickmarkIntervals(3);
|
||||
wid.push_back(myWheelLinesSlider);
|
||||
ypos += lineHeight + V_GAP;
|
||||
|
||||
// Mouse double click speed
|
||||
myDoubleClickSlider = new SliderWidget(myTab, font, xpos, ypos, swidth, lineHeight,
|
||||
"Double-click speed ", 0, 0,
|
||||
font.getStringWidth("900 ms"), " ms");
|
||||
myDoubleClickSlider->setMinValue(100);
|
||||
myDoubleClickSlider->setMaxValue(900);
|
||||
myDoubleClickSlider->setStepValue(50);
|
||||
myDoubleClickSlider->setTickmarkIntervals(8);
|
||||
wid.push_back(myDoubleClickSlider);
|
||||
ypos += lineHeight + V_GAP;
|
||||
|
||||
// Initial delay before controller input will start repeating
|
||||
myControllerDelaySlider = new SliderWidget(myTab, font, xpos, ypos, swidth, lineHeight,
|
||||
"Controller repeat delay ", 0, kControllerDelay,
|
||||
font.getStringWidth("1 second"));
|
||||
myControllerDelaySlider->setMinValue(200);
|
||||
myControllerDelaySlider->setMaxValue(1000);
|
||||
myControllerDelaySlider->setStepValue(100);
|
||||
myControllerDelaySlider->setTickmarkIntervals(4);
|
||||
wid.push_back(myControllerDelaySlider);
|
||||
ypos += lineHeight + V_GAP;
|
||||
|
||||
// Controller repeat rate
|
||||
myControllerRateSlider = new SliderWidget(myTab, font, xpos, ypos, swidth, lineHeight,
|
||||
"Controller repeat rate ", 0, 0,
|
||||
font.getStringWidth("30 repeats/s"), " repeats/s");
|
||||
myControllerRateSlider->setMinValue(2);
|
||||
myControllerRateSlider->setMaxValue(30);
|
||||
myControllerRateSlider->setStepValue(1);
|
||||
myControllerRateSlider->setTickmarkIntervals(14);
|
||||
wid.push_back(myControllerRateSlider);
|
||||
|
||||
// Add message concerning usage
|
||||
ypos = myTab->getHeight() - 5 - fontHeight - ifont.getFontHeight() - 10;
|
||||
|
@ -300,11 +333,23 @@ void UIDialog::loadConfig()
|
|||
|
||||
// Listwidget quick delay
|
||||
int delay = settings.getInt("listdelay");
|
||||
myListDelayPopup->setValue(delay);
|
||||
myListDelaySlider->setValue(delay);
|
||||
|
||||
// Mouse wheel lines
|
||||
int mw = settings.getInt("mwheel");
|
||||
myWheelLinesPopup->setValue(mw);
|
||||
myWheelLinesSlider->setValue(mw);
|
||||
|
||||
// Mouse double click
|
||||
int md = settings.getInt("mdouble");
|
||||
myDoubleClickSlider->setValue(md);
|
||||
|
||||
// Controller input delay
|
||||
int cs = settings.getInt("ctrldelay");
|
||||
myControllerDelaySlider->setValue(cs);
|
||||
|
||||
// Controller input rate
|
||||
int cr = settings.getInt("ctrlrate");
|
||||
myControllerRateSlider->setValue(cr);
|
||||
|
||||
handleRomViewer();
|
||||
|
||||
|
@ -350,12 +395,24 @@ void UIDialog::saveConfig()
|
|||
settings.setValue("dialogpos", myPositionPopup->getSelectedTag().toString());
|
||||
|
||||
// Listwidget quick delay
|
||||
settings.setValue("listdelay", myListDelayPopup->getValue());
|
||||
ListWidget::setQuickSelectDelay(myListDelayPopup->getValue());
|
||||
settings.setValue("listdelay", myListDelaySlider->getValue());
|
||||
ListWidget::setQuickSelectDelay(myListDelaySlider->getValue());
|
||||
|
||||
// Mouse wheel lines
|
||||
settings.setValue("mwheel", myWheelLinesPopup->getValue());
|
||||
ScrollBarWidget::setWheelLines(myWheelLinesPopup->getValue());
|
||||
settings.setValue("mwheel", myWheelLinesSlider->getValue());
|
||||
ScrollBarWidget::setWheelLines(myWheelLinesSlider->getValue());
|
||||
|
||||
// Mouse double click
|
||||
settings.setValue("mdouble", myDoubleClickSlider->getValue());
|
||||
DialogContainer::setDoubleClickDelay(myDoubleClickSlider->getValue());
|
||||
|
||||
// Controller input delay
|
||||
settings.setValue("ctrldelay", myControllerDelaySlider->getValue());
|
||||
DialogContainer::setControllerDelay(myControllerDelaySlider->getValue());
|
||||
|
||||
// Controller input rate
|
||||
settings.setValue("ctrlrate", myControllerRateSlider->getValue());
|
||||
DialogContainer::setControllerRate(myControllerRateSlider->getValue());
|
||||
|
||||
// Flush changes to disk and inform the OSystem
|
||||
instance().saveConfig();
|
||||
|
@ -371,8 +428,11 @@ void UIDialog::setDefaults()
|
|||
myPalettePopup->setSelected("standard");
|
||||
myHidpiWidget->setState(false);
|
||||
myPositionPopup->setSelected("0");
|
||||
myListDelayPopup->setValue(300);
|
||||
myWheelLinesPopup->setValue(4);
|
||||
myListDelaySlider->setValue(300);
|
||||
myWheelLinesSlider->setValue(4);
|
||||
myDoubleClickSlider->setValue(500);
|
||||
myControllerDelaySlider->setValue(400);
|
||||
myControllerRateSlider->setValue(20);
|
||||
break;
|
||||
case 1: // Launcher options
|
||||
{
|
||||
|
@ -410,26 +470,39 @@ void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
|||
break;
|
||||
|
||||
case kListDelay:
|
||||
if(myListDelayPopup->getValue() == 0)
|
||||
if(myListDelaySlider->getValue() == 0)
|
||||
{
|
||||
myListDelayPopup->setValueLabel("Off");
|
||||
myListDelayPopup->setValueUnit("");
|
||||
myListDelaySlider->setValueLabel("Off");
|
||||
myListDelaySlider->setValueUnit("");
|
||||
}
|
||||
else if(myListDelayPopup->getValue() == 1000)
|
||||
else if(myListDelaySlider->getValue() == 1000)
|
||||
{
|
||||
myListDelayPopup->setValueLabel("1");
|
||||
myListDelayPopup->setValueUnit(" second");
|
||||
myListDelaySlider->setValueLabel("1");
|
||||
myListDelaySlider->setValueUnit(" second");
|
||||
}
|
||||
else
|
||||
{
|
||||
myListDelayPopup->setValueUnit(" ms");
|
||||
myListDelaySlider->setValueUnit(" ms");
|
||||
}
|
||||
break;
|
||||
|
||||
case kMouseWheel:
|
||||
if(myWheelLinesPopup->getValue() == 1)
|
||||
myWheelLinesPopup->setValueUnit(" line");
|
||||
if(myWheelLinesSlider->getValue() == 1)
|
||||
myWheelLinesSlider->setValueUnit(" line");
|
||||
else
|
||||
myWheelLinesPopup->setValueUnit(" lines");
|
||||
myWheelLinesSlider->setValueUnit(" lines");
|
||||
break;
|
||||
|
||||
case kControllerDelay:
|
||||
if(myControllerDelaySlider->getValue() == 1000)
|
||||
{
|
||||
myControllerDelaySlider->setValueLabel("1");
|
||||
myControllerDelaySlider->setValueUnit(" second");
|
||||
}
|
||||
else
|
||||
{
|
||||
myControllerDelaySlider->setValueUnit(" ms");
|
||||
}
|
||||
break;
|
||||
|
||||
case kChooseRomDirCmd:
|
||||
|
|
|
@ -41,6 +41,7 @@ class UIDialog : public Dialog, public CommandSender
|
|||
{
|
||||
kListDelay = 'UILd',
|
||||
kMouseWheel = 'UIMw',
|
||||
kControllerDelay = 'UIcd',
|
||||
kChooseRomDirCmd = 'LOrm', // rom select
|
||||
kLauncherSize = 'UIls',
|
||||
kRomViewer = 'UIRv',
|
||||
|
@ -65,8 +66,11 @@ class UIDialog : public Dialog, public CommandSender
|
|||
PopUpWidget* myPalettePopup;
|
||||
CheckboxWidget* myHidpiWidget;
|
||||
PopUpWidget* myPositionPopup;
|
||||
SliderWidget* myListDelayPopup;
|
||||
SliderWidget* myWheelLinesPopup;
|
||||
SliderWidget* myListDelaySlider;
|
||||
SliderWidget* myWheelLinesSlider;
|
||||
SliderWidget* myControllerRateSlider;
|
||||
SliderWidget* myControllerDelaySlider;
|
||||
SliderWidget* myDoubleClickSlider;
|
||||
|
||||
unique_ptr<BrowserDialog> myBrowser;
|
||||
|
||||
|
|
Loading…
Reference in New Issue