added option for toggling autofire (resolves #843)

This commit is contained in:
Thomas Jentzsch 2021-11-23 09:37:40 +01:00
parent f619b4e5cb
commit 7052f15b56
15 changed files with 117 additions and 34 deletions

View File

@ -12,6 +12,13 @@
Release History Release History
=========================================================================== ===========================================================================
6.6 to 6.?
* Added option to toggle autofire mode.
-Have fun!
6.5.3 to 6.6 (November 16, 2021) 6.5.3 to 6.6 (November 16, 2021)
* Added preliminary PlusROM support for saving high scores. * Added preliminary PlusROM support for saving high scores.
@ -43,9 +50,6 @@
* Debugger: added Thumb cycle counting. * Debugger: added Thumb cycle counting.
-Have fun!
6.5.2 to 6.5.3 (April 20, 2021) 6.5.2 to 6.5.3 (April 20, 2021)
* Added context-sensitive help. * Added context-sensitive help.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -1660,6 +1660,11 @@
<td>Control + F5</td> <td>Control + F5</td>
</tr> </tr>
<tr>
<td>Toggle autofire</td>
<td>Alt + A</td>
<td>Cmd + A</td>
</tr>
<tr> <tr>
<td><i>Decrease</i> autofire rate</td> <td><i>Decrease</i> autofire rate</td>
<td>Shift-Control + A</td> <td>Shift-Control + A</td>
@ -3048,6 +3053,11 @@
faster movement.</td> faster movement.</td>
</tr> </tr>
<tr>
<td><pre>-autofire &lt;1|0&gt;</pre></td>
<td>Set auto fire mode on or off.</td>
</tr>
<tr> <tr>
<td><pre>-autofirerate &lt;0 - 30&gt;</pre></td> <td><pre>-autofirerate &lt;0 - 30&gt;</pre></td>
<td>Automatic trigger rate of the fire buttons in Hz (0 = disabled)</td> <td>Automatic trigger rate of the fire buttons in Hz (0 = disabled)</td>
@ -4079,7 +4089,8 @@
</td><td>-dejitter.base</td></tr> </td><td>-dejitter.base</td></tr>
<tr><td>(Analog paddle) Dejitter reaction</td><td>Strength of paddle reaction to fast paddle movements, suppresses paddle jitter</td><td>-dejitter.diff</td></tr> <tr><td>(Analog paddle) Dejitter reaction</td><td>Strength of paddle reaction to fast paddle movements, suppresses paddle jitter</td><td>-dejitter.diff</td></tr>
<tr><td>Digital paddle sensitivity</td><td>Sensitivity used when emulating a paddle using a digital device</td><td>-dsense</td></tr> <tr><td>Digital paddle sensitivity</td><td>Sensitivity used when emulating a paddle using a digital device</td><td>-dsense</td></tr>
<tr><td>Autofire rate</td><td>Automatic trigger rate of the fire buttons in Hz</td><td>-autofirerate</td></tr> <tr><td>Autofire</td><td>Set auto fire mode on or off</td><td>-autofire</td></tr>
<tr><td>(Autofire) Rate</td><td>Automatic trigger rate of the fire buttons in Hz</td><td>-autofirerate</td></tr>
<tr><td>Allow all 4 directions ...</td><td>Allow all 4 joystick directions to be pressed simultaneously</td><td>-joyallow4</td></tr> <tr><td>Allow all 4 directions ...</td><td>Allow all 4 joystick directions to be pressed simultaneously</td><td>-joyallow4</td></tr>
<tr><td>Use modifier key combos</td><td>Enable using modifier keys in keyboard actions</td><td>-modcombo</td></tr> <tr><td>Use modifier key combos</td><td>Enable using modifier keys in keyboard actions</td><td>-modcombo</td></tr>
<tr><td>Swap Stelladaptor ports</td><td>Swap the order of the detected Stelladaptors/2600-daptors (see <b>Advanced Configuration - <a href="#Adaptor">Stelladaptor/2600-daptor Support</a></b>)</td><td>-saport</td></tr> <tr><td>Swap Stelladaptor ports</td><td>Swap the order of the detected Stelladaptors/2600-daptors (see <b>Advanced Configuration - <a href="#Adaptor">Stelladaptor/2600-daptor Support</a></b>)</td><td>-saport</td></tr>

View File

@ -700,6 +700,7 @@ PhysicalKeyboardHandler::DefaultCommonMapping = {
{ Event::IncDejtterReaction, KBDK_F4, KBDM_CTRL }, { Event::IncDejtterReaction, KBDK_F4, KBDM_CTRL },
{ Event::DecDigitalSense, KBDK_F5, KBDM_CTRL | KBDM_SHIFT }, { Event::DecDigitalSense, KBDK_F5, KBDM_CTRL | KBDM_SHIFT },
{ Event::IncDigitalSense, KBDK_F5, KBDM_CTRL }, { Event::IncDigitalSense, KBDK_F5, KBDM_CTRL },
{ Event::ToggleAutoFire, KBDK_A, MOD3 },
{ Event::DecreaseAutoFire, KBDK_A, KBDM_CTRL | KBDM_SHIFT }, { Event::DecreaseAutoFire, KBDK_A, KBDM_CTRL | KBDM_SHIFT },
{ Event::IncreaseAutoFire, KBDK_A, KBDM_CTRL }, { Event::IncreaseAutoFire, KBDK_A, KBDM_CTRL },
{ Event::ToggleFourDirections, KBDK_F6, KBDM_CTRL }, { Event::ToggleFourDirections, KBDK_F6, KBDM_CTRL },

View File

@ -211,8 +211,6 @@ NLOHMANN_JSON_SERIALIZE_ENUM(Event::Type, {
{Event::IncDejtterReaction, "IncDejtterReaction"}, {Event::IncDejtterReaction, "IncDejtterReaction"},
{Event::DecDigitalSense, "DecDigitalSense"}, {Event::DecDigitalSense, "DecDigitalSense"},
{Event::IncDigitalSense, "IncDigitalSense"}, {Event::IncDigitalSense, "IncDigitalSense"},
{Event::DecreaseAutoFire, "DecreaseAutoFire"},
{Event::IncreaseAutoFire, "IncreaseAutoFire"},
{Event::ToggleFourDirections, "ToggleFourDirections"}, {Event::ToggleFourDirections, "ToggleFourDirections"},
{Event::ToggleKeyCombos, "ToggleKeyCombos"}, {Event::ToggleKeyCombos, "ToggleKeyCombos"},
{Event::ToggleSAPortOrder, "ToggleSAPortOrder"}, {Event::ToggleSAPortOrder, "ToggleSAPortOrder"},
@ -386,6 +384,7 @@ NLOHMANN_JSON_SERIALIZE_ENUM(Event::Type, {
{Event::PreviousSettingGroup, "PreviousSettingGroup"}, {Event::PreviousSettingGroup, "PreviousSettingGroup"},
{Event::NextSettingGroup, "NextSettingGroup"}, {Event::NextSettingGroup, "NextSettingGroup"},
{Event::TogglePlayBackMode, "TogglePlayBackMode"}, {Event::TogglePlayBackMode, "TogglePlayBackMode"},
{Event::ToggleAutoFire, "ToggleAutoFire"},
{Event::DecreaseAutoFire, "DecreaseAutoFire"}, {Event::DecreaseAutoFire, "DecreaseAutoFire"},
{Event::IncreaseAutoFire, "IncreaseAutoFire"}, {Event::IncreaseAutoFire, "IncreaseAutoFire"},
{Event::DecreaseSpeed, "DecreaseSpeed"}, {Event::DecreaseSpeed, "DecreaseSpeed"},

View File

@ -1110,6 +1110,22 @@ void Console::changePaddleAxesRange(int direction)
myOSystem.frameBuffer().showGaugeMessage("Mouse axes range", val.str(), range); myOSystem.frameBuffer().showGaugeMessage("Mouse axes range", val.str(), range);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleAutoFire(bool toggle)
{
bool enabled = myOSystem.settings().getBool("autofire");
if(toggle)
{
myOSystem.settings().setValue("autofire", !enabled);
Controller::setAutoFire(!enabled);
}
ostringstream ss;
ss << "Autofire " << (!enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showTextMessage(ss.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changeAutoFireRate(int direction) void Console::changeAutoFireRate(int direction)
{ {
@ -1126,7 +1142,11 @@ void Console::changeAutoFireRate(int direction)
ostringstream val; ostringstream val;
if(rate) if(rate)
{
myOSystem.settings().setValue("autofire", true);
Controller::setAutoFire(true);
val << rate << " Hz"; val << rate << " Hz";
}
else else
val << "Off"; val << "Off";

View File

@ -187,11 +187,6 @@ class Console : public Serializable, public ConsoleIO
*/ */
EmulationTiming& emulationTiming() { return myEmulationTiming; } EmulationTiming& emulationTiming() { return myEmulationTiming; }
/**
Retrieve the current game's refresh rate, or 0 if no game.
*/
int refreshRate() const;
/** /**
Toggle left and right controller ports swapping Toggle left and right controller ports swapping
*/ */
@ -378,6 +373,11 @@ class Console : public Serializable, public ConsoleIO
*/ */
void setTIAProperties(); void setTIAProperties();
/**
Toggle autofire for all controllers
*/
void toggleAutoFire(bool toggle = true);
/** /**
Change the autofire speed for all controllers Change the autofire speed for all controllers
*/ */

View File

@ -184,6 +184,12 @@ void Controller::setMouseSensitivity(int sensitivity)
MOUSE_SENSITIVITY = BSPF::clamp(sensitivity, MIN_MOUSE_SENSE, MAX_MOUSE_SENSE); MOUSE_SENSITIVITY = BSPF::clamp(sensitivity, MIN_MOUSE_SENSE, MAX_MOUSE_SENSE);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Controller::setAutoFire(bool enable)
{
AUTO_FIRE = enable;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Controller::setAutoFireRate(int rate, bool isNTSC) void Controller::setAutoFireRate(int rate, bool isNTSC)
{ {
@ -195,4 +201,5 @@ void Controller::setAutoFireRate(int rate, bool isNTSC)
int Controller::DIGITAL_DEAD_ZONE = 3200; int Controller::DIGITAL_DEAD_ZONE = 3200;
int Controller::ANALOG_DEAD_ZONE = 0; int Controller::ANALOG_DEAD_ZONE = 0;
int Controller::MOUSE_SENSITIVITY = -1; int Controller::MOUSE_SENSITIVITY = -1;
bool Controller::AUTO_FIRE = false;
int Controller::AUTO_FIRE_RATE = 0; int Controller::AUTO_FIRE_RATE = 0;

View File

@ -317,6 +317,13 @@ class Controller : public Serializable
*/ */
static void setMouseSensitivity(int sensitivity); static void setMouseSensitivity(int sensitivity);
/**
Set auto fire state.
@param enable The new autofire state
*/
static void setAutoFire(bool enable);
/** /**
Sets the auto fire rate. 0 disables auto fire. Sets the auto fire rate. 0 disables auto fire.
@ -359,12 +366,12 @@ class Controller : public Serializable
/** /**
Checks for the next auto fire event. Checks for the next auto fire event.
@param pressed True if the fire button is current pressed @param pressed True if the fire button is currently pressed
@return The result of the auto fire event check @return The result of the auto fire event check
*/ */
inline bool getAutoFireState(bool pressed) inline bool getAutoFireState(bool pressed)
{ {
if(AUTO_FIRE_RATE && pressed) if(AUTO_FIRE && AUTO_FIRE_RATE && pressed)
{ {
myFireDelay -= AUTO_FIRE_RATE; myFireDelay -= AUTO_FIRE_RATE;
if(myFireDelay <= 0) if(myFireDelay <= 0)
@ -383,7 +390,7 @@ class Controller : public Serializable
*/ */
inline bool getAutoFireStateP1(bool pressed) inline bool getAutoFireStateP1(bool pressed)
{ {
if(AUTO_FIRE_RATE && pressed) if(AUTO_FIRE && AUTO_FIRE_RATE && pressed)
{ {
myFireDelayP1 -= AUTO_FIRE_RATE; myFireDelayP1 -= AUTO_FIRE_RATE;
if(myFireDelayP1 <= 0) if(myFireDelayP1 <= 0)
@ -418,7 +425,10 @@ class Controller : public Serializable
static int MOUSE_SENSITIVITY; static int MOUSE_SENSITIVITY;
/// Defines the speed of the auto fire /// Defines the state of auto fire
static bool AUTO_FIRE;
/// Defines the speed of auto fire
static int AUTO_FIRE_RATE; static int AUTO_FIRE_RATE;
/// Delay[frames] until the next fire event /// Delay[frames] until the next fire event

View File

@ -128,7 +128,7 @@ class Event
// add new (after Version 4) events from here to avoid that user remapped events get overwritten // add new (after Version 4) events from here to avoid that user remapped events get overwritten
PreviousSettingGroup, NextSettingGroup, PreviousSettingGroup, NextSettingGroup,
TogglePlayBackMode, TogglePlayBackMode,
DecreaseAutoFire, IncreaseAutoFire, ToggleAutoFire, DecreaseAutoFire, IncreaseAutoFire,
DecreaseSpeed, IncreaseSpeed, DecreaseSpeed, IncreaseSpeed,
QTJoystickThreeUp, QTJoystickThreeDown, QTJoystickThreeLeft, QTJoystickThreeRight, QTJoystickThreeUp, QTJoystickThreeDown, QTJoystickThreeLeft, QTJoystickThreeRight,

View File

@ -113,6 +113,7 @@ void EventHandler::initialize()
Controller::setMouseSensitivity(myOSystem.settings().getInt("msense")); Controller::setMouseSensitivity(myOSystem.settings().getInt("msense"));
PointingDevice::setSensitivity(myOSystem.settings().getInt("tsense")); PointingDevice::setSensitivity(myOSystem.settings().getInt("tsense"));
Driving::setSensitivity(myOSystem.settings().getInt("dcsense")); Driving::setSensitivity(myOSystem.settings().getInt("dcsense"));
Controller::setAutoFire(myOSystem.settings().getBool("autofire"));
Controller::setAutoFireRate(myOSystem.settings().getInt("autofirerate")); Controller::setAutoFireRate(myOSystem.settings().getInt("autofirerate"));
#ifdef GUI_SUPPORT #ifdef GUI_SUPPORT
@ -1100,6 +1101,14 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
} }
return; return;
case Event::ToggleAutoFire:
if(pressed && !repeated)
{
myOSystem.console().toggleAutoFire();
myGlobalKeyHandler->setSetting(GlobalKeyHandler::Setting::AUTO_FIRE);
}
return;
case Event::DecreaseAutoFire: case Event::DecreaseAutoFire:
if(pressed) if(pressed)
{ {
@ -2929,6 +2938,7 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { {
{ Event::IncDejtterReaction, "Increase paddle dejitter reaction", "" }, { Event::IncDejtterReaction, "Increase paddle dejitter reaction", "" },
{ Event::DecDigitalSense, "Decrease digital paddle sensitivity", "" }, { Event::DecDigitalSense, "Decrease digital paddle sensitivity", "" },
{ Event::IncDigitalSense, "Increase digital paddle sensitivity", "" }, { Event::IncDigitalSense, "Increase digital paddle sensitivity", "" },
{ Event::ToggleAutoFire, "Toggle auto fire", "" },
{ Event::DecreaseAutoFire, "Decrease auto fire speed", "" }, { Event::DecreaseAutoFire, "Decrease auto fire speed", "" },
{ Event::IncreaseAutoFire, "Increase auto fire speed", "" }, { Event::IncreaseAutoFire, "Increase auto fire speed", "" },
{ Event::ToggleFourDirections, "Toggle allow four joystick directions", "" }, { Event::ToggleFourDirections, "Toggle allow four joystick directions", "" },
@ -3142,7 +3152,7 @@ const Event::EventSet EventHandler::DevicesEvents = {
Event::DecDejtterAveraging, Event::IncDejtterAveraging, Event::DecDejtterAveraging, Event::IncDejtterAveraging,
Event::DecDejtterReaction, Event::IncDejtterReaction, Event::DecDejtterReaction, Event::IncDejtterReaction,
Event::DecDigitalSense, Event::IncDigitalSense, Event::DecDigitalSense, Event::IncDigitalSense,
Event::DecreaseAutoFire, Event::IncreaseAutoFire, Event::ToggleAutoFire, Event::DecreaseAutoFire, Event::IncreaseAutoFire,
Event::ToggleFourDirections, Event::ToggleKeyCombos, Event::ToggleSAPortOrder, Event::ToggleFourDirections, Event::ToggleKeyCombos, Event::ToggleSAPortOrder,
Event::PrevMouseAsController, Event::NextMouseAsController, Event::PrevMouseAsController, Event::NextMouseAsController,
Event::DecMousePaddleSense, Event::IncMousePaddleSense, Event::DecMousePaddleSense, Event::IncMousePaddleSense,

View File

@ -522,7 +522,7 @@ class EventHandler
#else #else
REFRESH_SIZE = 0, REFRESH_SIZE = 0,
#endif #endif
EMUL_ACTIONLIST_SIZE = 221 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE, EMUL_ACTIONLIST_SIZE = 222 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE,
MENU_ACTIONLIST_SIZE = 19 MENU_ACTIONLIST_SIZE = 19
; ;

View File

@ -113,6 +113,7 @@ Settings::Settings()
setPermanent("combomap", ""); setPermanent("combomap", "");
setPermanent("joydeadzone", "13"); setPermanent("joydeadzone", "13");
setPermanent("joyallow4", "false"); setPermanent("joyallow4", "false");
setPermanent("autofire", "0");
setPermanent("autofirerate", "0"); setPermanent("autofirerate", "0");
setPermanent("usemouse", "analog"); setPermanent("usemouse", "analog");
setPermanent("grabmouse", "true"); setPermanent("grabmouse", "true");
@ -549,6 +550,7 @@ void Settings::usage() const
<< " -tsense <1-20> Sensitivity of mouse emulated trackball movement\n" << " -tsense <1-20> Sensitivity of mouse emulated trackball movement\n"
<< " -dcsense <1-20> Sensitivity of digital emulated driving controller\n" << " -dcsense <1-20> Sensitivity of digital emulated driving controller\n"
<< " movement\n" << " movement\n"
<< " -autofire <1|0> Enable fire button autofire\n"
<< " -autofirerate <0-30> Set fire button's autofire rate (0 means off)\n" << " -autofirerate <0-30> Set fire button's autofire rate (0 means off)\n"
<< " -saport <lr|rl> How to assign virtual ports to multiple\n" << " -saport <lr|rl> How to assign virtual ports to multiple\n"
<< " Stelladaptor/2600-daptors\n" << " Stelladaptor/2600-daptors\n"

View File

@ -106,6 +106,7 @@ void InputDialog::addDevicePortTab()
VBORDER = Dialog::vBorder(), VBORDER = Dialog::vBorder(),
HBORDER = Dialog::hBorder(), HBORDER = Dialog::hBorder(),
VGAP = Dialog::vGap(); VGAP = Dialog::vGap();
const int swidth = 13 * fontWidth;
int xpos, ypos, lwidth, tabID; int xpos, ypos, lwidth, tabID;
WidgetArray wid; WidgetArray wid;
@ -116,7 +117,7 @@ void InputDialog::addDevicePortTab()
lwidth = _font.getStringWidth("Digital paddle sensitivity "); lwidth = _font.getStringWidth("Digital paddle sensitivity ");
// Add digital dead zone setting // Add digital dead zone setting
myDigitalDeadzone = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, myDigitalDeadzone = new SliderWidget(myTab, _font, xpos, ypos - 1, swidth, lineHeight,
"Digital dead zone size ", "Digital dead zone size ",
lwidth, kDDeadzoneChanged, 3 * fontWidth, "%"); lwidth, kDDeadzoneChanged, 3 * fontWidth, "%");
myDigitalDeadzone->setMinValue(Controller::MIN_DIGITAL_DEADZONE); myDigitalDeadzone->setMinValue(Controller::MIN_DIGITAL_DEADZONE);
@ -127,7 +128,7 @@ void InputDialog::addDevicePortTab()
// Add analog dead zone // Add analog dead zone
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
myAnalogDeadzone = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, myAnalogDeadzone = new SliderWidget(myTab, _font, xpos, ypos - 1, swidth, lineHeight,
"Analog dead zone size", "Analog dead zone size",
lwidth, kADeadzoneChanged, 3 * fontWidth, "%"); lwidth, kADeadzoneChanged, 3 * fontWidth, "%");
myAnalogDeadzone->setMinValue(Controller::MIN_ANALOG_DEADZONE); myAnalogDeadzone->setMinValue(Controller::MIN_ANALOG_DEADZONE);
@ -142,7 +143,7 @@ void InputDialog::addDevicePortTab()
// Add analog paddle sensitivity // Add analog paddle sensitivity
ypos += lineHeight; ypos += lineHeight;
myPaddleSpeed = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, myPaddleSpeed = new SliderWidget(myTab, _font, xpos, ypos - 1, swidth, lineHeight,
"Sensitivity", "Sensitivity",
lwidth - fontWidth * 2, kPSpeedChanged, 4 * fontWidth, "%"); lwidth - fontWidth * 2, kPSpeedChanged, 4 * fontWidth, "%");
myPaddleSpeed->setMinValue(0); myPaddleSpeed->setMinValue(0);
@ -152,7 +153,7 @@ void InputDialog::addDevicePortTab()
// Add analog paddle linearity // Add analog paddle linearity
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
myPaddleLinearity = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, myPaddleLinearity = new SliderWidget(myTab, _font, xpos, ypos - 1, swidth, lineHeight,
"Linearity", lwidth - fontWidth * 2, 0, 4 * fontWidth, "%"); "Linearity", lwidth - fontWidth * 2, 0, 4 * fontWidth, "%");
myPaddleLinearity->setMinValue(Paddles::MIN_ANALOG_LINEARITY); myPaddleLinearity->setMinValue(Paddles::MIN_ANALOG_LINEARITY);
myPaddleLinearity->setMaxValue(Paddles::MAX_ANALOG_LINEARITY); myPaddleLinearity->setMaxValue(Paddles::MAX_ANALOG_LINEARITY);
@ -163,7 +164,7 @@ void InputDialog::addDevicePortTab()
// Add dejitter (analog paddles) // Add dejitter (analog paddles)
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
myDejitterBase = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, myDejitterBase = new SliderWidget(myTab, _font, xpos, ypos - 1, swidth, lineHeight,
"Dejitter averaging", lwidth - fontWidth * 2, "Dejitter averaging", lwidth - fontWidth * 2,
kDejitterAvChanged, 3 * fontWidth); kDejitterAvChanged, 3 * fontWidth);
myDejitterBase->setMinValue(Paddles::MIN_DEJITTER); myDejitterBase->setMinValue(Paddles::MIN_DEJITTER);
@ -175,7 +176,7 @@ void InputDialog::addDevicePortTab()
wid.push_back(myDejitterBase); wid.push_back(myDejitterBase);
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
myDejitterDiff = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, myDejitterDiff = new SliderWidget(myTab, _font, xpos, ypos - 1, swidth, lineHeight,
"Dejitter reaction", lwidth - fontWidth * 2, "Dejitter reaction", lwidth - fontWidth * 2,
kDejitterReChanged, 3 * fontWidth); kDejitterReChanged, 3 * fontWidth);
myDejitterDiff->setMinValue(Paddles::MIN_DEJITTER); myDejitterDiff->setMinValue(Paddles::MIN_DEJITTER);
@ -186,7 +187,7 @@ void InputDialog::addDevicePortTab()
// Add paddle speed (digital emulation) // Add paddle speed (digital emulation)
ypos += lineHeight + VGAP * (3 - 2); ypos += lineHeight + VGAP * (3 - 2);
myDPaddleSpeed = new SliderWidget(myTab, _font, HBORDER, ypos - 1, 13 * fontWidth, lineHeight, myDPaddleSpeed = new SliderWidget(myTab, _font, HBORDER, ypos - 1, swidth, lineHeight,
"Digital paddle sensitivity", "Digital paddle sensitivity",
lwidth, kDPSpeedChanged, 4 * fontWidth, "%"); lwidth, kDPSpeedChanged, 4 * fontWidth, "%");
myDPaddleSpeed->setMinValue(1); myDPaddleSpeed->setMaxValue(20); myDPaddleSpeed->setMinValue(1); myDPaddleSpeed->setMaxValue(20);
@ -194,9 +195,11 @@ void InputDialog::addDevicePortTab()
wid.push_back(myDPaddleSpeed); wid.push_back(myDPaddleSpeed);
ypos += lineHeight + VGAP * (3 - 2); ypos += lineHeight + VGAP * (3 - 2);
myAutoFireRate = new SliderWidget(myTab, _font, HBORDER, ypos - 1, 13 * fontWidth, lineHeight, myAutoFire = new CheckboxWidget(myTab, _font, HBORDER, ypos + 1, "Autofire", kAutoFireChanged);
"Autofire rate", wid.push_back(myAutoFire);
lwidth, kAutoFireChanged, 5 * fontWidth, "Hz");
myAutoFireRate = new SliderWidget(myTab, _font, HBORDER + lwidth - fontWidth * 5,
ypos - 1, swidth, lineHeight, "Rate ", 0, kAutoFireRate, 5 * fontWidth, "Hz");
myAutoFireRate->setMinValue(0); myAutoFireRate->setMaxValue(30); myAutoFireRate->setMinValue(0); myAutoFireRate->setMaxValue(30);
myAutoFireRate->setTickmarkIntervals(6); myAutoFireRate->setTickmarkIntervals(6);
wid.push_back(myAutoFireRate); wid.push_back(myAutoFireRate);
@ -204,13 +207,13 @@ void InputDialog::addDevicePortTab()
// Add 'allow all 4 directions' for joystick // Add 'allow all 4 directions' for joystick
ypos += lineHeight + VGAP * (4 - 2); ypos += lineHeight + VGAP * (4 - 2);
myAllowAll4 = new CheckboxWidget(myTab, _font, HBORDER, ypos, myAllowAll4 = new CheckboxWidget(myTab, _font, HBORDER, ypos,
"Allow all 4 directions on joystick"); "Allow all 4 directions on joystick");
wid.push_back(myAllowAll4); wid.push_back(myAllowAll4);
// Enable/disable modifier key-combos // Enable/disable modifier key-combos
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
myModCombo = new CheckboxWidget(myTab, _font, HBORDER, ypos, myModCombo = new CheckboxWidget(myTab, _font, HBORDER, ypos,
"Use modifier key combos"); "Use modifier key combos");
wid.push_back(myModCombo); wid.push_back(myModCombo);
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
@ -264,6 +267,7 @@ void InputDialog::addMouseTab()
HBORDER = Dialog::hBorder(), HBORDER = Dialog::hBorder(),
VGAP = Dialog::vGap(), VGAP = Dialog::vGap(),
INDENT = Dialog::indent(); INDENT = Dialog::indent();
const int swidth = 13 * fontWidth;
int xpos = HBORDER, ypos, lwidth, pwidth, tabID; int xpos = HBORDER, ypos, lwidth, pwidth, tabID;
WidgetArray wid; WidgetArray wid;
VariantList items; VariantList items;
@ -289,7 +293,7 @@ void InputDialog::addMouseTab()
// Add paddle speed (mouse emulation) // Add paddle speed (mouse emulation)
xpos += INDENT; ypos += lineHeight + VGAP; xpos += INDENT; ypos += lineHeight + VGAP;
lwidth -= INDENT; lwidth -= INDENT;
myMPaddleSpeed = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, myMPaddleSpeed = new SliderWidget(myTab, _font, xpos, ypos - 1, swidth, lineHeight,
"Paddle", "Paddle",
lwidth, kMPSpeedChanged, 4 * fontWidth, "%"); lwidth, kMPSpeedChanged, 4 * fontWidth, "%");
myMPaddleSpeed->setMinValue(1); myMPaddleSpeed->setMaxValue(20); myMPaddleSpeed->setMinValue(1); myMPaddleSpeed->setMaxValue(20);
@ -298,7 +302,7 @@ void InputDialog::addMouseTab()
// Add trackball speed // Add trackball speed
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
myTrackBallSpeed = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, myTrackBallSpeed = new SliderWidget(myTab, _font, xpos, ypos - 1, swidth, lineHeight,
"Trackball", "Trackball",
lwidth, kTBSpeedChanged, 4 * fontWidth, "%"); lwidth, kTBSpeedChanged, 4 * fontWidth, "%");
myTrackBallSpeed->setMinValue(1); myTrackBallSpeed->setMaxValue(20); myTrackBallSpeed->setMinValue(1); myTrackBallSpeed->setMaxValue(20);
@ -307,7 +311,7 @@ void InputDialog::addMouseTab()
// Add driving controller speed // Add driving controller speed
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
myDrivingSpeed = new SliderWidget(myTab, _font, xpos, ypos - 1, 13 * fontWidth, lineHeight, myDrivingSpeed = new SliderWidget(myTab, _font, xpos, ypos - 1, swidth, lineHeight,
"Driving controller", "Driving controller",
lwidth, kDCSpeedChanged, 4 * fontWidth, "%"); lwidth, kDCSpeedChanged, 4 * fontWidth, "%");
myDrivingSpeed->setMinValue(1); myDrivingSpeed->setMaxValue(20); myDrivingSpeed->setMinValue(1); myDrivingSpeed->setMaxValue(20);
@ -384,6 +388,9 @@ void InputDialog::loadConfig()
// Driving controller speed // Driving controller speed
myDrivingSpeed->setValue(settings.getInt("dcsense")); myDrivingSpeed->setValue(settings.getInt("dcsense"));
// Autofire
myAutoFire->setState(settings.getBool("autofire"));
// Autofire rate // Autofire rate
myAutoFireRate->setValue(settings.getInt("autofirerate")); myAutoFireRate->setValue(settings.getInt("autofirerate"));
@ -462,7 +469,11 @@ void InputDialog::saveConfig()
settings.setValue("dsense", sensitivity); settings.setValue("dsense", sensitivity);
Paddles::setDigitalSensitivity(sensitivity); Paddles::setDigitalSensitivity(sensitivity);
// Autofire rate // Autofire mode & rate
bool enabled = myAutoFire->getState();
settings.setValue("autofire", enabled);
Controller::setAutoFire(enabled);
int rate = myAutoFireRate->getValue(); int rate = myAutoFireRate->getValue();
settings.setValue("autofirerate", rate); settings.setValue("autofirerate", rate);
Controller::setAutoFireRate(rate); Controller::setAutoFireRate(rate);
@ -550,6 +561,9 @@ void InputDialog::setDefaults()
// Paddle speed (digital) // Paddle speed (digital)
myDPaddleSpeed->setValue(10); myDPaddleSpeed->setValue(10);
// Autofire
myAutoFire->setState(false);
// Autofire rate // Autofire rate
myAutoFireRate->setValue(0); myAutoFireRate->setValue(0);
@ -733,6 +747,7 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
break; break;
case kAutoFireChanged: case kAutoFireChanged:
case kAutoFireRate:
updateAutoFireRate(); updateAutoFireRate();
break; break;
@ -806,8 +821,10 @@ void InputDialog::updateDejitterReaction()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::updateAutoFireRate() void InputDialog::updateAutoFireRate()
{ {
bool enable = myAutoFire->getState();
int rate = myAutoFireRate->getValue(); int rate = myAutoFireRate->getValue();
myAutoFireRate->setEnabled(enable);
myAutoFireRate->setValueLabel(rate ? std::to_string(rate) : "Off"); myAutoFireRate->setValueLabel(rate ? std::to_string(rate) : "Off");
myAutoFireRate->setValueUnit(rate ? " Hz" : ""); myAutoFireRate->setValueUnit(rate ? " Hz" : "");
} }

View File

@ -78,6 +78,7 @@ class InputDialog : public Dialog
kDejitterReChanged = 'JRch', kDejitterReChanged = 'JRch',
kDPSpeedChanged = 'DSch', kDPSpeedChanged = 'DSch',
kAutoFireChanged = 'AFch', kAutoFireChanged = 'AFch',
kAutoFireRate = 'AFra',
kTBSpeedChanged = 'TBch', kTBSpeedChanged = 'TBch',
kDCSpeedChanged = 'DCch', kDCSpeedChanged = 'DCch',
kDBButtonPressed = 'DBbp', kDBButtonPressed = 'DBbp',
@ -104,6 +105,7 @@ class InputDialog : public Dialog
SliderWidget* myDejitterBase{nullptr}; SliderWidget* myDejitterBase{nullptr};
SliderWidget* myDejitterDiff{nullptr}; SliderWidget* myDejitterDiff{nullptr};
SliderWidget* myDPaddleSpeed{nullptr}; SliderWidget* myDPaddleSpeed{nullptr};
CheckboxWidget* myAutoFire{nullptr};
SliderWidget* myAutoFireRate{nullptr}; SliderWidget* myAutoFireRate{nullptr};
CheckboxWidget* myAllowAll4{nullptr}; CheckboxWidget* myAllowAll4{nullptr};
CheckboxWidget* myModCombo{nullptr}; CheckboxWidget* myModCombo{nullptr};