added hotkeys for Input Devices & Ports settings

added hotkeys for Game Properties/Controller settings
added new global hotkey group for new hotkeys
add a few more tooltips
updated doc
This commit is contained in:
thrust26 2020-12-17 16:37:51 +01:00
parent e7715aea9d
commit d7bb07fc55
34 changed files with 1547 additions and 225 deletions

View File

@ -30,6 +30,8 @@
* Added sound to Time Machine playback.
* Extended global hotkeys for input devices & ports settings.
* Increased sample size for CDFJ+.
* Fixed autofire bug for trackball controllers.

View File

@ -1561,6 +1561,253 @@
</tr>
</table>
<p><b>Input Devices & Ports Keys (can be remapped)</b></p>
<table BORDER=2 cellpadding=4>
<tr>
<th>Function</th>
<th>Key (Standard)</th>
<th>Key (macOS)</th>
</tr>
<tr>
<td><i>Decrease</i> joystick deadzone</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Increase</i> joystick deadzone</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Decrease</i> analog paddle sensitivity</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Increase</i> analog paddle sensitivity</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Decrease</i> analog paddle dejitter averaging</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Increase</i> analog paddle dejitter averaging</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Decrease</i> analog paddle dejitter reaction</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Increase</i> analog paddle dejitter reaction</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Decrease</i> digital paddle sensitivity</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Increase</i> digital paddle sensitivity</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Decrease</i> digital and mouse driving controller sensitivity</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Increase</i> digital and mouse driving controller sensitivity</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Decrease</i> autofire rate</td>
<td>Shift-Control + a</td>
<td>Shift-Control + a</td>
</tr>
<tr>
<td><i>Increase</i> autofire rate</td>
<td>Control + a</td>
<td>Control + a</td>
</tr>
<tr>
<td>Toggle allowing all four directions on joystick</br>
to be pressed simultaneously</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Toggle use of modifier key combos</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Swap Stelladaptor/2600-daptor port ordering</td>
<td>Control + 1</td>
<td>Control + 1</td>
</tr>
<tr>
<td>Select <i>previous</i> controllers emulated by the mouse
</br>(all, analog, none)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Select <i>next</i> controllers emulated by the mouse
</br>(all, analog, none)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Decrease</i> mouse paddle sensitivity</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Increase</i> mouse paddle sensitivity</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Decrease</i> mouse trackball sensitivity</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Increase</i> mouse trackball sensitivity</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Select <i>previous</i> mouse cursor visiblity option
(-UI, -Emulation/</br>-UI, +Emulation/+UI, -Emulation/+UI, +Emulation)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Select <i>next</i> mouse cursor visiblity option
(-UI, -Emulation/</br>-UI, +Emulation/+UI, -Emulation/+UI, +Emulation)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Toggle grab mouse</td>
<td>Control + g</td>
<td>Control + g</td>
</tr>
<tr>
<td>Select <i>previous</i> left port controller type</td>
<td>Shift-Control-Alt + L</td>
<td>Shift-Control-Cmd + L</td>
</tr>
<tr>
<td>Select <i>next</i> left port controller type</td>
<td>Control-Alt + L</td>
<td>Control-Cmd + L</td>
</tr>
<tr>
<td>Select <i>previous</i> right port controller type</td>
<td>Shift-Control-Alt + r</td>
<td>Shift-Control-Cmd + r</td>
</tr>
<tr>
<td>Select <i>next</i> right port controller type</td>
<td>Control-Alt + r</td>
<td>Control-Cmd + r</td>
</tr>
<tr>
<td>Toggle swap left and right controller ports</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Toggle swap paddles</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Decrease</i> horizontal center of paddles </td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Increase</i> horizontal center of paddles </td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Decrease</i> vertical center of paddles </td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Increase</i> vertical center of paddles </td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Switch mouse to <i>previous</i> controller emulation mode</br>(see <b><a href="#Controller">Controller Properties</a></b>)</td>
<td>Shift-Control + 0</td>
<td>Shift-Control + 0</td>
</tr>
<tr>
<td>Switch mouse to <i>next</i> controller emulation modes</br>(see <b><a href="#Controller">Controller Properties</a></b>)</td>
<td>Control + 0</td>
<td>Control + 0</td>
</tr>
<tr>
<td><i>Decrease</i> mouse paddle axes range</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><i>Increase</i> mouse paddle axes range</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td colspan="3"><center><font size="-1">
These settings can also be changed using <a href="#GlobalKeys"><b>Global Keys</a></font></center>
</td>
</tr>
</table>
<a name="DeveloperKeys"></a>
<p><b>Developer Keys (can be remapped)</b></p>
@ -1687,7 +1934,7 @@
<p><b><a name="GlobalKeys">Global Keys</a> (can be remapped)</b></p>
<p>These keys allow selecting and changing settings without having to remember the
dedicated keys. They keys are grouped by Audio & Video and Debug settings.</p>
dedicated keys. They keys are grouped by 'Audio & Video', 'Input Device & Ports' and 'Debug' settings.</p>
<table BORDER=2 cellpadding=4>
<tr>
<th>Function</th>
@ -1729,7 +1976,7 @@
<ul>
<li>Only available if UI messages are enabled.</li>
<li>Currently not available settings are automatically skipped.</li>
<li>If a setting was selected via dedicated key, its value can also be changed with the
<li>If a setting was previously selected via a dedicated key, its value can also be changed with the
global keys.</li>
</ul>
</p>
@ -1778,33 +2025,7 @@
<td>Control + t</td>
<td>Control + t</td>
</tr>
<tr>
<td><i>Decrease</i> autofire rate</td>
<td>Shift-Control + a</td>
<td>Shift-Control + a</td>
</tr>
<tr>
<td><i>Increase</i> autofire rate</td>
<td>Control + a</td>
<td>Control + a</td>
</tr>
<tr>
<td>Switch mouse between controller emulation modes</br>(see <b><a href="#Controller">Controller Properties</a></b>)</td>
<td>Control + 0</td>
<td>Control + 0</td>
</tr>
<tr>
<td>Toggle grab mouse</td>
<td>Control + g</td>
<td>Control + g</td>
</tr>
<tr>
<td>Swap Stelladaptor/2600-daptor port ordering</td>
<td>Control + 1</td>
<td>Control + 1</td>
</tr>
<tr>
<td>Save continuous PNG snapshots</br>(per interval defined in <a href="#Snapshots"><b>Snapshot Settings</b></a>)</td>
<td>Control-Alt + s</td>
@ -3684,8 +3905,10 @@
<tr><th>Item</th><th>Brief description</th><th>For more information,<br>see <a href="#CommandLine">Command Line</a></th></tr>
<tr><td>Joystick deadzone size</td><td>Deadzone area for axes on joysticks/gamepads</td><td>-joydeadzone</td></tr>
<tr><td>(Analog paddle) Sensitivity</td><td>Sensitivity of an analog paddle</td><td>-psense</td></tr>
<tr><td>Analog paddle) Dejitter averaging</td><td>Strength of paddle input averaging, suppresses mouse jitter</td><td>-dejitter.base</td></tr>
<tr><td>(Analog paddle) Dejitter reaction</td><td>Strength of paddle reaction to fast paddle movements, suppresses mouse jitter</td><td>-dejitter.diff</td></tr>
<tr><td>(Analog paddle) Dejitter averaging</td><td>Strength of paddle input averaging, suppresses paddle jitter.<br>
Note: The 2600-daptor has built-in dejitter, so there should be no need to use Stella's dejitter.
</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>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>Allow all 4 directions ...</td><td>Allow all 4 joystick directions to be pressed simultaneously</td><td>-joyallow4</td></tr>
@ -3820,7 +4043,9 @@
</tr>
</table>
</li>
<br><li><b>High scores</b>: This option displays the <a href="#HighScores">High Scores</a> dialog for the selected ROM.</li>
<br><li><b>High scores</b>: This option displays the <a href="#HighScores">
High Scores</a> dialog for the selected ROM. Only available if high score
properties have been setup for the ROM.</li>
</li>
<br><li><b>Reload listing</b>: Selecting this performs a reload of the
current listing. It is an alternative to pressing the 'Control + r'

View File

@ -137,14 +137,18 @@ MouseControl::MouseControl(Console& console, const string& mode)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& MouseControl::next()
const string& MouseControl::change(int direction)
{
myCurrentModeNum = BSPF::clampw(myCurrentModeNum + direction, 0, int(myModeList.size() - 1));
const MouseMode& mode = myModeList[myCurrentModeNum];
myCurrentModeNum = (myCurrentModeNum + 1) % myModeList.size();
bool leftControl =
myLeftController.setMouseControl(mode.xtype, mode.xid, mode.ytype, mode.yid);
bool rightControl =
myRightController.setMouseControl(mode.xtype, mode.xid, mode.ytype, mode.yid);
myHasMouseControl = leftControl || rightControl;
return mode.message;
}

View File

@ -62,7 +62,12 @@ class MouseControl
@return A message explaining the current mouse mode
*/
const string& next();
const string& change(int direction = +1);
/**
Get whether any current controller supports mouse control
*/
bool hasMouseControl() const { return myHasMouseControl; }
private:
void addLeftControllerModes(bool noswap);
@ -101,6 +106,7 @@ class MouseControl
int myCurrentModeNum{0};
vector<MouseMode> myModeList;
bool myHasMouseControl{false};
private:
// Following constructors and assignment operators not supported

View File

@ -19,6 +19,9 @@
#include "OSystem.hxx"
#include "Console.hxx"
#include "Joystick.hxx"
#include "Paddles.hxx"
#include "PointingDevice.hxx"
#include "Driving.hxx"
#include "Settings.hxx"
#include "EventHandler.hxx"
#include "PJoystickHandler.hxx"
@ -850,6 +853,147 @@ ostream& operator<<(ostream& os, const PhysicalJoystickHandler& jh)
return os;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::changeDeadzone(int direction)
{
int deadzone = BSPF::clamp(myOSystem.settings().getInt("joydeadzone") + direction,
Joystick::DEAD_ZONE_MIN, Joystick::DEAD_ZONE_MAX);
myOSystem.settings().setValue("joydeadzone", deadzone);
Joystick::setDeadZone(deadzone);
int value = Joystick::deadZoneValue(deadzone);
myOSystem.frameBuffer().showGaugeMessage("Joystick deadzone", std::to_string(value),
value, 3200, 32200);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::changeAnalogPaddleSensitivity(int direction)
{
int sense = BSPF::clamp(myOSystem.settings().getInt("psense") + direction,
Paddles::MIN_ANALOG_SENSE, Paddles::MAX_ANALOG_SENSE);
myOSystem.settings().setValue("psense", sense);
Paddles::setAnalogSensitivity(sense);
ostringstream ss;
ss << std::round(Paddles::analogSensitivityValue(sense) * 100.F) << "%";
myOSystem.frameBuffer().showGaugeMessage("Analog paddle sensitivity", ss.str(), sense,
Paddles::MIN_ANALOG_SENSE, Paddles::MAX_ANALOG_SENSE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::changePaddleDejitterAveraging(int direction)
{
int dejitter = BSPF::clamp(myOSystem.settings().getInt("dejitter.base") + direction,
Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER);
myOSystem.settings().setValue("dejitter.base", dejitter);
Paddles::setDejitterBase(dejitter);
ostringstream ss;
if(dejitter)
ss << dejitter;
else
ss << "Off";
myOSystem.frameBuffer().showGaugeMessage("Analog paddle dejitter averaging",
ss.str(), dejitter,
Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::changePaddleDejitterReaction(int direction)
{
int dejitter = BSPF::clamp(myOSystem.settings().getInt("dejitter.diff") + direction,
Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER);
myOSystem.settings().setValue("dejitter.diff", dejitter);
Paddles::setDejitterDiff(dejitter);
ostringstream ss;
if(dejitter)
ss << dejitter;
else
ss << "Off";
myOSystem.frameBuffer().showGaugeMessage("Analog paddle dejitter reaction",
ss.str(), dejitter,
Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::changeDigitalPaddleSensitivity(int direction)
{
int sense = BSPF::clamp(myOSystem.settings().getInt("dsense") + direction,
Paddles::MIN_DIGITAL_SENSE, Paddles::MAX_DIGITAL_SENSE);
myOSystem.settings().setValue("dsense", sense);
Paddles::setDigitalSensitivity(sense);
ostringstream ss;
if(sense)
ss << sense * 10 << "%";
else
ss << "Off";
myOSystem.frameBuffer().showGaugeMessage("Digital sensitivity",
ss.str(), sense,
Paddles::MIN_DIGITAL_SENSE, Paddles::MAX_DIGITAL_SENSE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::changeMousePaddleSensitivity(int direction)
{
int sense = BSPF::clamp(myOSystem.settings().getInt("msense") + direction,
Paddles::MIN_MOUSE_SENSE, Paddles::MAX_MOUSE_SENSE);
myOSystem.settings().setValue("msense", sense);
Paddles::setMouseSensitivity(sense);
ostringstream ss;
ss << sense * 10 << "%";
myOSystem.frameBuffer().showGaugeMessage("Mouse paddle sensitivity",
ss.str(), sense,
Paddles::MIN_MOUSE_SENSE, Paddles::MAX_MOUSE_SENSE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::changeMouseTrackballSensitivity(int direction)
{
int sense = BSPF::clamp(myOSystem.settings().getInt("tsense") + direction,
PointingDevice::MIN_SENSE, PointingDevice::MAX_SENSE);
myOSystem.settings().setValue("tsense", sense);
PointingDevice::setSensitivity(sense);
ostringstream ss;
ss << sense * 10 << "%";
myOSystem.frameBuffer().showGaugeMessage("Mouse trackball sensitivity",
ss.str(), sense,
PointingDevice::MIN_SENSE, PointingDevice::MAX_SENSE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::changeDrivingSensitivity(int direction)
{
int sense = BSPF::clamp(myOSystem.settings().getInt("dcsense") + direction,
Driving::MIN_SENSE, Driving::MAX_SENSE);
myOSystem.settings().setValue("dcsense", sense);
Driving::setSensitivity(sense);
ostringstream ss;
ss << sense * 10 << "%";
myOSystem.frameBuffer().showGaugeMessage("Mouse driving controller sensitivity",
ss.str(), sense,
Driving::MIN_SENSE, Driving::MAX_SENSE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PhysicalJoystickHandler::EventMappingArray PhysicalJoystickHandler::DefaultLeftJoystickMapping = {
// Left joystick (assume buttons zero..two)

View File

@ -109,6 +109,15 @@ class PhysicalJoystickHandler
/** Returns a list of pairs consisting of joystick name and associated ID. */
VariantList database() const;
void changeDeadzone(int direction = +1);
void changeAnalogPaddleSensitivity(int direction = +1);
void changePaddleDejitterAveraging(int direction = +1);
void changePaddleDejitterReaction(int direction = +1);
void changeDigitalPaddleSensitivity(int direction = +1);
void changeMousePaddleSensitivity(int direction = +1);
void changeMouseTrackballSensitivity(int direction = +1);
void changeDrivingSensitivity(int direction = +1);
private:
using StickDatabase = std::map<string,StickInfo>;
using StickList = std::map<int, PhysicalJoystickPtr>;

View File

@ -1,4 +1,5 @@
//============================================================================
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
@ -480,6 +481,24 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod,
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalKeyboardHandler::toggleModKeys(bool toggle)
{
bool modCombo = myOSystem.settings().getBool("modcombo");
if(toggle)
{
modCombo = !modCombo;
myKeyMap.enableMod() = modCombo;
myOSystem.settings().setValue("modcombo", modCombo);
}
ostringstream ss;
ss << "Modifier key combos ";
ss << (modCombo ? "enabled" : "disabled");
myOSystem.frameBuffer().showTextMessage(ss.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PhysicalKeyboardHandler::EventMappingArray
PhysicalKeyboardHandler::DefaultCommonMapping = {
@ -554,7 +573,6 @@ PhysicalKeyboardHandler::DefaultCommonMapping = {
{Event::ToggleColorLoss, KBDK_L, KBDM_CTRL},
{Event::PaletteDecrease, KBDK_P, KBDM_SHIFT | KBDM_CTRL},
{Event::PaletteIncrease, KBDK_P, KBDM_CTRL},
#ifndef BSPF_MACOS
{Event::PreviousSetting, KBDK_END},
{Event::NextSetting, KBDK_HOME},
@ -589,11 +607,18 @@ PhysicalKeyboardHandler::DefaultCommonMapping = {
{Event::ToggleContSnapshotsFrame, KBDK_S, KBDM_SHIFT | MOD3 | KBDM_CTRL},
#endif
{Event::DecreaseAutoFire, KBDK_A, KBDM_SHIFT | KBDM_CTRL},
{Event::DecreaseAutoFire, KBDK_A, KBDM_CTRL | KBDM_SHIFT},
{Event::IncreaseAutoFire, KBDK_A, KBDM_CTRL},
{Event::HandleMouseControl, KBDK_0, KBDM_CTRL},
{Event::ToggleGrabMouse, KBDK_G, KBDM_CTRL},
{Event::ToggleSAPortOrder, KBDK_1, KBDM_CTRL},
{Event::ToggleGrabMouse, KBDK_G, KBDM_CTRL},
{Event::PreviousLeftPort, KBDK_L, KBDM_CTRL | MOD3 | KBDM_SHIFT},
{Event::NextLeftPort, KBDK_L, KBDM_CTRL | MOD3},
{Event::PreviousRightPort, KBDK_R, KBDM_CTRL | MOD3 | KBDM_SHIFT},
{Event::NextRightPort, KBDK_R, KBDM_CTRL | MOD3},
{Event::PreviousMouseControl, KBDK_0, KBDM_CTRL | KBDM_SHIFT},
{Event::NextMouseControl, KBDK_0, KBDM_CTRL},
{Event::FormatDecrease, KBDK_F, KBDM_SHIFT | KBDM_CTRL},
{Event::FormatIncrease, KBDK_F, KBDM_CTRL},

View File

@ -79,6 +79,8 @@ class PhysicalKeyboardHandler
/** See comments on KeyMap.myModEnabled for more information. */
bool& useModKeys() { return myKeyMap.enableMod(); }
void toggleModKeys(bool toggle = true);
private:
// Structure used for action menu items

View File

@ -69,6 +69,16 @@ NLOHMANN_JSON_SERIALIZE_ENUM(Event::Type, {
{Event::JoystickOneFire, "JoystickOneFire"},
{Event::JoystickOneFire5, "JoystickOneFire5"},
{Event::JoystickOneFire9, "JoystickOneFire9"},
{Event::JoystickTwoUp, "JoystickTwoUp"},
{Event::JoystickTwoDown, "JoystickTwoDown"},
{Event::JoystickTwoLeft, "JoystickTwoLeft"},
{Event::JoystickTwoRight, "JoystickTwoRight"},
{Event::JoystickTwoFire, "JoystickTwoFire"},
{Event::JoystickThreeUp, "JoystickThreeUp"},
{Event::JoystickThreeDown, "JoystickThreeDown"},
{Event::JoystickThreeLeft, "JoystickThreeLeft"},
{Event::JoystickThreeRight, "JoystickThreeRight"},
{Event::JoystickThreeFire, "JoystickThreeFire"},
{Event::PaddleZeroDecrease, "PaddleZeroDecrease"},
{Event::PaddleZeroIncrease, "PaddleZeroIncrease"},
{Event::PaddleZeroAnalog, "PaddleZeroAnalog"},
@ -160,6 +170,50 @@ NLOHMANN_JSON_SERIALIZE_ENUM(Event::Type, {
{Event::CompuMateEquals, "CompuMateEquals"},
{Event::CompuMatePlus, "CompuMatePlus"},
{Event::CompuMateSlash, "CompuMateSlash"},
{Event::DecreaseDeadzone, "DecreaseDeadzone"},
{Event::IncreaseDeadzone, "IncreaseDeadzone"},
{Event::DecAnalogSense, "DecAnalogSense"},
{Event::IncAnalogSense, "IncAnalogSense"},
{Event::DecDejtterAveraging, "DecDejtterAveraging"},
{Event::IncDejtterAveraging, "IncDejtterAveraging"},
{Event::DecDejtterReaction, "DecDejtterReaction"},
{Event::IncDejtterReaction, "IncDejtterReaction"},
{Event::DecDigitalSense, "DecDigitalSense"},
{Event::IncDigitalSense, "IncDigitalSense"},
{Event::DecreaseAutoFire, "DecreaseAutoFire"},
{Event::IncreaseAutoFire, "IncreaseAutoFire"},
{Event::ToggleFourDirections, "ToggleFourDirections"},
{Event::ToggleKeyCombos, "ToggleKeyCombos"},
{Event::ToggleSAPortOrder, "ToggleSAPortOrder"},
{Event::PrevMouseAsController, "PrevMouseAsController"},
{Event::NextMouseAsController, "NextMouseAsController"},
{Event::DecMousePaddleSense, "DecMousePaddleSense"},
{Event::IncMousePaddleSense, "IncMousePaddleSense"},
{Event::DecMouseTrackballSense, "DecMouseTrackballSense"},
{Event::IncMouseTrackballSense, "IncMouseTrackballSense"},
{Event::DecreaseDrivingSense, "DecreaseDrivingSense"},
{Event::IncreaseDrivingSense, "IncreaseDrivingSense"},
{Event::PreviousCursorVisbility, "PreviousCursorVisbility"},
{Event::NextCursorVisbility, "NextCursorVisbility"},
{Event::ToggleGrabMouse, "ToggleGrabMouse"},
{Event::PreviousLeftPort, "PreviousLeftPort"},
{Event::NextLeftPort, "NextLeftPort"},
{Event::PreviousRightPort, "PreviousRightPort"},
{Event::NextRightPort, "NextRightPort"},
{Event::ToggleSwapPorts, "ToggleSwapPorts"},
{Event::ToggleSwapPaddles,"ToggleSwapPaddles"},
{Event::DecreasePaddleCenterX, "DecreasePaddleCenterX"},
{Event::IncreasePaddleCenterX, "IncreasePaddleCenterX"},
{Event::DecreasePaddleCenterY, "DecreasePaddleCenterY"},
{Event::IncreasePaddleCenterY, "IncreasePaddleCenterY"},
{Event::PreviousMouseControl, "PreviousMouseControl"},
{Event::NextMouseControl, "NextMouseControl"},
{Event::DecreaseMouseAxesRange, "DecreaseMouseAxesRange"},
{Event::IncreaseMouseAxesRange, "IncreaseMouseAxesRange"},
{Event::Combo1, "Combo1"},
{Event::Combo2, "Combo2"},
{Event::Combo3, "Combo3"},
@ -192,8 +246,6 @@ NLOHMANN_JSON_SERIALIZE_ENUM(Event::Type, {
{Event::UIPrevDir, "UIPrevDir"},
{Event::UITabPrev, "UITabPrev"},
{Event::UITabNext, "UITabNext"},
{Event::HandleMouseControl, "HandleMouseControl"},
{Event::ToggleGrabMouse, "ToggleGrabMouse"},
{Event::MouseAxisXMove, "MouseAxisXMove"},
{Event::MouseAxisYMove, "MouseAxisYMove"},
{Event::MouseAxisXValue, "MouseAxisXValue"},
@ -287,7 +339,6 @@ NLOHMANN_JSON_SERIALIZE_ENUM(Event::Type, {
{Event::ToggleBits, "ToggleBits"},
{Event::ToggleFixedColors, "ToggleFixedColors"},
{Event::ToggleFrameStats, "ToggleFrameStats"},
{Event::ToggleSAPortOrder, "ToggleSAPortOrder"},
{Event::ExitGame, "ExitGame"},
{Event::SettingDecrease, "SettingDecrease"},
{Event::SettingIncrease, "SettingIncrease"},
@ -302,16 +353,6 @@ NLOHMANN_JSON_SERIALIZE_ENUM(Event::Type, {
{Event::IncreaseAutoFire, "IncreaseAutoFire"},
{Event::DecreaseSpeed, "DecreaseSpeed"},
{Event::IncreaseSpeed, "IncreaseSpeed"},
{Event::JoystickTwoUp, "JoystickTwoUp"},
{Event::JoystickTwoDown, "JoystickTwoDown"},
{Event::JoystickTwoLeft, "JoystickTwoLeft"},
{Event::JoystickTwoRight, "JoystickTwoRight"},
{Event::JoystickTwoFire, "JoystickTwoFire"},
{Event::JoystickThreeUp, "JoystickThreeUp"},
{Event::JoystickThreeDown, "JoystickThreeDown"},
{Event::JoystickThreeLeft, "JoystickThreeLeft"},
{Event::JoystickThreeRight, "JoystickThreeRight"},
{Event::JoystickThreeFire, "JoystickThreeFire"},
{Event::ToggleCorrectAspectRatio, "ToggleCorrectAspectRatio"},
{Event::MoveLeftChar, "MoveLeftChar"},
{Event::MoveRightChar, "MoveRightChar"},

View File

@ -858,6 +858,40 @@ void Console::setControllers(const string& romMd5)
myOSystem.eventHandler().setMouseControllerMode(myOSystem.settings().getString("usemouse"));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changeLeftController(int direction)
{
int type = int(Controller::getType(myProperties.get(PropType::Controller_Left)));
if(!type)
type = int(Controller::getType(leftController().name()));
type = BSPF::clampw(type + direction,
1, int(Controller::Type::LastType) - 1);
myProperties.set(PropType::Controller_Left, Controller::getPropName(Controller::Type(type)));
setControllers(myProperties.get(PropType::Cart_MD5));
ostringstream msg;
msg << "Left controller " << Controller::getName(Controller::Type(type));
myOSystem.frameBuffer().showTextMessage(msg.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changeRightController(int direction)
{
int type = int(Controller::getType(myProperties.get(PropType::Controller_Right)));
if(!type)
type = int(Controller::getType(rightController().name()));
type = BSPF::clampw(type + direction,
1, int(Controller::Type::LastType) - 1);
myProperties.set(PropType::Controller_Right, Controller::getPropName(Controller::Type(type)));
setControllers(myProperties.get(PropType::Cart_MD5));
ostringstream msg;
msg << "Right controller " << Controller::getName(Controller::Type(type));
myOSystem.frameBuffer().showTextMessage(msg.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
const Controller::Jack port, const string& romMd5)
@ -967,6 +1001,99 @@ unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
return controller;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleSwapPorts(bool toggle)
{
bool swapped = myProperties.get(PropType::Console_SwapPorts) == "YES";
if(toggle)
{
swapped = !swapped;
myProperties.set(PropType::Console_SwapPorts, (swapped ? "YES" : "NO"));
//myOSystem.propSet().insert(myProperties);
setControllers(myProperties.get(PropType::Cart_MD5));
}
ostringstream msg;
msg << "Swap ports " << (swapped ? "enabled" : "disabled");
myOSystem.frameBuffer().showTextMessage(msg.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleSwapPaddles(bool toggle)
{
bool swapped = myProperties.get(PropType::Controller_SwapPaddles) == "YES";
if(toggle)
{
swapped = !swapped;
myProperties.set(PropType::Controller_SwapPaddles, (swapped ? "YES" : "NO"));
//myOSystem.propSet().insert(myProperties);
setControllers(myProperties.get(PropType::Cart_MD5));
}
ostringstream msg;
msg << "Swap paddles " << (swapped ? "enabled" : "disabled");
myOSystem.frameBuffer().showTextMessage(msg.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changePaddleCenterX(int direction)
{
int center =
BSPF::clamp(BSPF::stringToInt(myProperties.get(PropType::Controller_PaddlesXCenter)) + direction,
Paddles::MIN_ANALOG_CENTER, Paddles::MAX_ANALOG_CENTER);
myProperties.set(PropType::Controller_PaddlesXCenter, std::to_string(center));
Paddles::setAnalogXCenter(center);
ostringstream val;
val << (center ? center > 0 ? "+" : "" : " ") << center * 5 << "px";
myOSystem.frameBuffer().showGaugeMessage("Paddles x-center ", val.str(), center,
Paddles::MIN_ANALOG_CENTER, Paddles::MAX_ANALOG_CENTER);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changePaddleCenterY(int direction)
{
int center =
BSPF::clamp(BSPF::stringToInt(myProperties.get(PropType::Controller_PaddlesYCenter)) + direction,
Paddles::MIN_ANALOG_CENTER, Paddles::MAX_ANALOG_CENTER);
myProperties.set(PropType::Controller_PaddlesYCenter, std::to_string(center));
Paddles::setAnalogYCenter(center);
ostringstream val;
val << (center ? center > 0 ? "+" : "" : " ") << center * 5 << "px";
myOSystem.frameBuffer().showGaugeMessage("Paddles y-center ", val.str(), center,
Paddles::MIN_ANALOG_CENTER, Paddles::MAX_ANALOG_CENTER);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changePaddleAxesRange(int direction)
{
istringstream m_axis(myProperties.get(PropType::Controller_MouseAxis));
string mode = "AUTO";
int range;
m_axis >> mode;
if(!(m_axis >> range))
range = Paddles::MAX_MOUSE_RANGE;
range = BSPF::clamp(range + direction,
Paddles::MIN_MOUSE_RANGE, Paddles::MAX_MOUSE_RANGE);
ostringstream control;
control << mode;
if(range != 100)
control << " " << std::to_string(range);
myProperties.set(PropType::Controller_MouseAxis, control.str());
Paddles::setDigitalPaddleRange(range);
ostringstream val;
val << range << "%";
myOSystem.frameBuffer().showGaugeMessage("Mouse axes range", val.str(), range);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changeAutoFireRate(int direction)
{

View File

@ -85,7 +85,7 @@ class Console : public Serializable, public ConsoleIO
/**
Sets the left and right controllers for the console.
*/
void setControllers(const string& roMd5);
void setControllers(const string& romMd5);
/**
Get the controller plugged into the specified jack
@ -95,6 +95,12 @@ class Console : public Serializable, public ConsoleIO
Controller& leftController() const override { return *myLeftControl; }
Controller& rightController() const override { return *myRightControl; }
/**
Change to next or previous controller type
*/
void changeLeftController(int direction = +1);
void changeRightController(int direction = +1);
/**
Get the TIA for this console
@ -190,6 +196,31 @@ class Console : public Serializable, public ConsoleIO
*/
int refreshRate() const;
/**
Toggle left and right controller ports swapping
*/
void toggleSwapPorts(bool toggle = true);
/**
Toggle paddle controllers swapping
*/
void toggleSwapPaddles(bool toggle = true);
/**
Change x-center of paddles
*/
void changePaddleCenterX(int direction = +1);
/**
Change y-center of paddles
*/
void changePaddleCenterY(int direction = +1);
/**
Change paddle range for digital/mouse emulation
*/
void changePaddleAxesRange(int direction = +1);
public:
/**
Toggle between NTSC/PAL/SECAM (and variants) display format.

View File

@ -177,7 +177,7 @@ bool Driving::setMouseControl(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Driving::setSensitivity(int sensitivity)
{
BSPF::clamp(sensitivity, 1, 20, 10);
BSPF::clamp(sensitivity, MIN_SENSE, MAX_SENSE, (MIN_SENSE + MAX_SENSE) / 2);
SENSITIVITY = sensitivity / 10.0F;
}

View File

@ -41,6 +41,10 @@ class Driving : public Controller
Driving(Jack jack, const Event& event, const System& system, bool altmap = false);
~Driving() override = default;
public:
static constexpr int MIN_SENSE = 1;
static constexpr int MAX_SENSE = 20;
public:
/**
Update the entire digital and analog pin state according to the

View File

@ -83,7 +83,7 @@ class Event
UISelect, UINavPrev, UINavNext, UIOK, UICancel, UIPrevDir,
UITabPrev, UITabNext,
HandleMouseControl, ToggleGrabMouse,
NextMouseControl, ToggleGrabMouse,
MouseAxisXMove, MouseAxisYMove, MouseAxisXValue, MouseAxisYValue,
MouseButtonLeftValue, MouseButtonRightValue,
@ -145,6 +145,26 @@ class Event
AbortEdit, EndEdit,
HighScoresMenuMode,
// Input settings
DecreaseDeadzone, IncreaseDeadzone,
DecAnalogSense, IncAnalogSense,
DecDejtterAveraging, IncDejtterAveraging,
DecDejtterReaction, IncDejtterReaction,
DecDigitalSense, IncDigitalSense,
ToggleFourDirections, ToggleKeyCombos,
PrevMouseAsController, NextMouseAsController,
DecMousePaddleSense, IncMousePaddleSense,
DecMouseTrackballSense, IncMouseTrackballSense,
DecreaseDrivingSense, IncreaseDrivingSense,
PreviousCursorVisbility, NextCursorVisbility,
// GameInfoDialog/Controllers
PreviousLeftPort, NextLeftPort,
PreviousRightPort, NextRightPort,
ToggleSwapPorts, ToggleSwapPaddles,
DecreasePaddleCenterX, IncreasePaddleCenterX,
DecreasePaddleCenterY, IncreasePaddleCenterY,
PreviousMouseControl,
DecreaseMouseAxesRange, IncreaseMouseAxesRange,
LastType
};
@ -153,6 +173,7 @@ class Event
{
Menu, Emulation,
Misc, AudioVideo, States, Console, Joystick, Paddles, Keyboard,
Devices,
Debug, Combo,
LastGroup
};

View File

@ -188,20 +188,42 @@ void EventHandler::mapStelladaptors(const string& saport)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::toggleSAPortOrder()
void EventHandler::toggleAllow4JoyDirections(bool toggle)
{
bool joyAllow4 = myOSystem.settings().getBool("joyallow4");
if(toggle)
{
joyAllow4 = !joyAllow4;
allowAllDirections(joyAllow4);
myOSystem.settings().setValue("joyallow4", joyAllow4);
}
ostringstream ss;
ss << "Allow all 4 joystick directions ";
ss << (joyAllow4 ? "enabled" : "disabled");
myOSystem.frameBuffer().showTextMessage(ss.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::toggleSAPortOrder(bool toggle)
{
#ifdef JOYSTICK_SUPPORT
const string& saport = myOSystem.settings().getString("saport");
string saport = myOSystem.settings().getString("saport");
if(toggle)
{
if(saport == "lr")
{
mapStelladaptors("rl");
myOSystem.frameBuffer().showTextMessage("Stelladaptor ports right/left");
}
saport = "rl";
else
{
mapStelladaptors("lr");
myOSystem.frameBuffer().showTextMessage("Stelladaptor ports left/right");
saport = "lr";
mapStelladaptors(saport);
}
if(saport == "lr")
myOSystem.frameBuffer().showTextMessage("Stelladaptor ports left/right");
else
myOSystem.frameBuffer().showTextMessage("Stelladaptor ports right/left");
#endif
}
@ -215,10 +237,18 @@ void EventHandler::set7800Mode()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::handleMouseControl()
void EventHandler::changeMouseControl(int direction)
{
if(myMouseControl)
myOSystem.frameBuffer().showTextMessage(myMouseControl->next());
myOSystem.frameBuffer().showTextMessage(myMouseControl->change(direction));
else
myOSystem.frameBuffer().showTextMessage("Mouse input is disabled");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::hasMouseControl()
{
return myMouseControl && myMouseControl->hasMouseControl();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -355,18 +385,39 @@ EventHandler::AdjustGroup EventHandler::getAdjustGroup()
{
if (myAdjustSetting >= AdjustSetting::START_DEBUG_ADJ && myAdjustSetting <= AdjustSetting::END_DEBUG_ADJ)
return AdjustGroup::DEBUG;
if(myAdjustSetting >= AdjustSetting::START_INPUT_ADJ && myAdjustSetting <= AdjustSetting::END_INPUT_ADJ)
return AdjustGroup::INPUT;
return AdjustGroup::AV;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::isJoystick(const Controller& controller) const
{
return controller.type() == Controller::Type::Joystick
|| controller.type() == Controller::Type::BoosterGrip
|| controller.type() == Controller::Type::Genesis;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::isPaddle(const Controller& controller) const
{
return controller.type() == Controller::Type::Paddles
|| controller.type() == Controller::Type::PaddlesIAxDr
|| controller.type() == Controller::Type::PaddlesIAxis;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::isTrackball(const Controller& controller) const
{
return controller.type() == Controller::Type::AmigaMouse
|| controller.type() == Controller::Type::AtariMouse
|| controller.type() == Controller::Type::TrakBall;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AdjustFunction EventHandler::cycleAdjustSetting(int direction)
{
const bool isFullScreen = myOSystem.frameBuffer().fullScreen();
const bool isCustomPalette =
myOSystem.settings().getString("palette") == PaletteHandler::SETTING_CUSTOM;
const bool isCustomFilter =
myOSystem.settings().getInt("tv.filter") == int(NTSCFilter::Preset::CUSTOM);
const bool isPAL = myOSystem.console().timing() == ConsoleTiming::pal;
bool repeat = false;
@ -375,6 +426,13 @@ AdjustFunction EventHandler::cycleAdjustSetting(int direction)
switch (getAdjustGroup())
{
case AdjustGroup::AV:
{
const bool isFullScreen = myOSystem.frameBuffer().fullScreen();
const bool isCustomPalette =
myOSystem.settings().getString("palette") == PaletteHandler::SETTING_CUSTOM;
const bool isCustomFilter =
myOSystem.settings().getInt("tv.filter") == int(NTSCFilter::Preset::CUSTOM);
myAdjustSetting =
AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction,
int(AdjustSetting::START_AV_ADJ), int(AdjustSetting::END_AV_ADJ)));
@ -390,11 +448,58 @@ AdjustFunction EventHandler::cycleAdjustSetting(int direction)
&& myAdjustSetting <= AdjustSetting::NTSC_BLEEDING
&& !isCustomFilter);
break;
}
case AdjustGroup::INPUT:
{
const bool grabMouseAllowed = myOSystem.frameBuffer().grabMouseAllowed();
const bool analog = myOSystem.console().leftController().isAnalog()
|| myOSystem.console().rightController().isAnalog();
const bool joystick = isJoystick(myOSystem.console().leftController())
|| isJoystick(myOSystem.console().rightController());
const bool paddle = isPaddle(myOSystem.console().leftController())
|| isPaddle(myOSystem.console().rightController());
const bool trackball = isTrackball(myOSystem.console().leftController())
|| isTrackball(myOSystem.console().rightController());
const bool driving = myOSystem.console().leftController().type() == Controller::Type::Driving
|| myOSystem.console().rightController().type() == Controller::Type::Driving;
const bool useMouse = myOSystem.settings().getString("usemouse") != "never";
myAdjustSetting =
AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction,
int(AdjustSetting::START_INPUT_ADJ), int(AdjustSetting::END_INPUT_ADJ)));
// skip currently non-relevant adjustments
repeat = (!grabMouseAllowed && myAdjustSetting == AdjustSetting::GRAB_MOUSE)
|| (!joystick
&& (myAdjustSetting == AdjustSetting::DEADZONE
|| myAdjustSetting == AdjustSetting::FOUR_DIRECTIONS)
|| (!paddle
&& (myAdjustSetting == AdjustSetting::ANALOG_SENSITIVITY
|| myAdjustSetting == AdjustSetting::DEJITTER_AVERAGING
|| myAdjustSetting == AdjustSetting::DEJITTER_REACTION
|| myAdjustSetting == AdjustSetting::DIGITAL_SENSITIVITY
|| myAdjustSetting == AdjustSetting::SWAP_PADDLES
|| myAdjustSetting == AdjustSetting::PADDLE_CENTER_X
|| myAdjustSetting == AdjustSetting::PADDLE_CENTER_Y))
|| ((!paddle || !useMouse)
&& myAdjustSetting == AdjustSetting::PADDLE_SENSITIVITY)
|| ((!trackball || !useMouse)
&& myAdjustSetting == AdjustSetting::TRACKBALL_SENSITIVITY)
|| (!driving
&& myAdjustSetting == AdjustSetting::DRIVING_SENSITIVITY) // also affects keyboard input sensitivity
|| ((!hasMouseControl() || !useMouse)
&& myAdjustSetting == AdjustSetting::MOUSE_CONTROL)
|| ((!paddle || !useMouse)
&& myAdjustSetting == AdjustSetting::MOUSE_RANGE)
);
break;
}
case AdjustGroup::DEBUG:
myAdjustSetting =
AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction,
int(AdjustSetting::START_DEBUG_ADJ), int(AdjustSetting::END_DEBUG_ADJ)));
// skip currently non-relevant adjustments
repeat = (myAdjustSetting == AdjustSetting::COLOR_LOSS && !isPAL);
break;
@ -417,7 +522,7 @@ AdjustFunction EventHandler::getAdjustSetting(AdjustSetting setting)
// - This array MUST have the same order as AdjustSetting
const AdjustFunction ADJUST_FUNCTIONS[int(AdjustSetting::NUM_ADJ)] =
{
// Audio & Video settings
// *** Audio & Video settings ***
std::bind(&Sound::adjustVolume, &myOSystem.sound(), _1),
std::bind(&FrameBuffer::switchVideoMode, &myOSystem.frameBuffer(), _1),
std::bind(&FrameBuffer::toggleFullscreen, &myOSystem.frameBuffer(), _1),
@ -470,7 +575,38 @@ AdjustFunction EventHandler::getAdjustSetting(AdjustSetting setting)
std::bind(&Console::changePhosphor, &myOSystem.console(), _1),
std::bind(&TIASurface::setScanlineIntensity, &myOSystem.frameBuffer().tiaSurface(), _1),
std::bind(&Console::toggleInter, &myOSystem.console(), _1),
// Debug settings
// *** Input settings ***
#ifdef JOYSTICK_SUPPORT
std::bind(&PhysicalJoystickHandler::changeDeadzone, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changeAnalogPaddleSensitivity, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changePaddleDejitterAveraging, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changePaddleDejitterReaction, &joyHandler(), _1),
#endif
std::bind(&PhysicalJoystickHandler::changeDigitalPaddleSensitivity, &joyHandler(), _1),
std::bind(&Console::changeAutoFireRate, &myOSystem.console(), _1),
std::bind(&EventHandler::toggleAllow4JoyDirections, this, _1),
std::bind(&PhysicalKeyboardHandler::toggleModKeys, &keyHandler(), _1),
#ifdef JOYSTICK_SUPPORT
std::bind(&EventHandler::toggleSAPortOrder, this, _1),
#endif
std::bind(&EventHandler::changeMouseControllerMode, this, _1),
std::bind(&PhysicalJoystickHandler::changeMousePaddleSensitivity, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changeMouseTrackballSensitivity, &joyHandler(), _1),
std::bind(&PhysicalJoystickHandler::changeDrivingSensitivity, &joyHandler(), _1),
std::bind(&EventHandler::changeMouseCursor, this, _1),
std::bind(&FrameBuffer::toggleGrabMouse, &myOSystem.frameBuffer(), _1),
// Game properties/Controllers
std::bind(&Console::changeLeftController, &myOSystem.console(), _1),
std::bind(&Console::changeRightController, &myOSystem.console(), _1),
std::bind(&Console::toggleSwapPorts, &myOSystem.console(), _1),
std::bind(&Console::toggleSwapPaddles, &myOSystem.console(), _1),
std::bind(&Console::changePaddleCenterX, &myOSystem.console(), _1),
std::bind(&Console::changePaddleCenterY, &myOSystem.console(), _1),
std::bind(&EventHandler::changeMouseControl, this, _1),
std::bind(&Console::changePaddleAxesRange, &myOSystem.console(), _1),
// *** Debug settings ***
std::bind(&FrameBuffer::toggleFrameStats, &myOSystem.frameBuffer(), _1),
std::bind(&Console::toggleP0Bit, &myOSystem.console(), _1),
std::bind(&Console::toggleP1Bit, &myOSystem.console(), _1),
@ -489,7 +625,8 @@ AdjustFunction EventHandler::getAdjustSetting(AdjustSetting setting)
std::bind(&Console::toggleFixedColors, &myOSystem.console(), _1),
std::bind(&Console::toggleColorLoss, &myOSystem.console(), _1),
std::bind(&Console::toggleJitter, &myOSystem.console(), _1),
// Following functions are not used when cycling settings but for "direct only" hotkeys
// *** Following functions are not used when cycling settings but for "direct only" hotkeys ***
std::bind(&StateManager::changeState, &myOSystem.state(), _1),
std::bind(&PaletteHandler::changeCurrentAdjustable, &myOSystem.frameBuffer().tiaSurface().paletteHandler(), _1),
std::bind(&TIASurface::changeCurrentNTSCAdjustable, &myOSystem.frameBuffer().tiaSurface(), _1),
@ -530,7 +667,6 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{
////////////////////////////////////////////////////////////////////////
// Allow adjusting several (mostly repeated) settings using the same six hotkeys
case Event::PreviousSettingGroup:
case Event::NextSettingGroup:
if(pressed && !repeated)
@ -547,6 +683,11 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
myAdjustSetting = AdjustSetting::START_AV_ADJ;
break;
case AdjustGroup::INPUT:
msg = "Input Devices & Ports";
myAdjustSetting = AdjustSetting::START_INPUT_ADJ;
break;
case AdjustGroup::DEBUG:
msg = "Debug";
myAdjustSetting = AdjustSetting::START_DEBUG_ADJ;
@ -1039,7 +1180,6 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
///////////////////////////////////////////////////////////////////////////
// Debug events (with global hotkeys)
case Event::ToggleFrameStats:
if(pressed && !repeated)
{
@ -1203,8 +1343,344 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return;
///////////////////////////////////////////////////////////////////////////
// State events
// Input events
case Event::DecreaseDeadzone:
if(pressed)
{
myPJoyHandler->changeDeadzone(-1);
myAdjustSetting = AdjustSetting::DEADZONE;
myAdjustActive = true;
}
return;
case Event::IncreaseDeadzone:
if(pressed)
{
myPJoyHandler->changeDeadzone(+1);
myAdjustSetting = AdjustSetting::DEADZONE;
myAdjustActive = true;
}
return;
case Event::DecAnalogSense:
if(pressed)
{
myPJoyHandler->changeAnalogPaddleSensitivity(-1);
myAdjustSetting = AdjustSetting::PADDLE_SENSITIVITY;
myAdjustActive = true;
}
return;
case Event::IncAnalogSense:
if(pressed)
{
myPJoyHandler->changeAnalogPaddleSensitivity(+1);
myAdjustSetting = AdjustSetting::PADDLE_SENSITIVITY;
myAdjustActive = true;
}
return;
case Event::DecDejtterAveraging:
if(pressed)
{
myPJoyHandler->changePaddleDejitterAveraging(-1);
myAdjustSetting = AdjustSetting::DEJITTER_AVERAGING;
myAdjustActive = true;
}
return;
case Event::IncDejtterAveraging:
if(pressed)
{
myPJoyHandler->changePaddleDejitterAveraging(+1);
myAdjustSetting = AdjustSetting::DEJITTER_AVERAGING;
myAdjustActive = true;
}
return;
case Event::DecDejtterReaction:
if(pressed)
{
myPJoyHandler->changePaddleDejitterReaction(-1);
myAdjustSetting = AdjustSetting::DEJITTER_REACTION;
myAdjustActive = true;
}
return;
case Event::IncDejtterReaction:
if(pressed)
{
myPJoyHandler->changePaddleDejitterReaction(+1);
myAdjustSetting = AdjustSetting::DEJITTER_REACTION;
myAdjustActive = true;
}
return;
case Event::DecDigitalSense:
if(pressed)
{
myPJoyHandler->changeDigitalPaddleSensitivity(-1);
myAdjustSetting = AdjustSetting::DIGITAL_SENSITIVITY;
myAdjustActive = true;
}
return;
case Event::IncDigitalSense:
if(pressed)
{
myPJoyHandler->changeDigitalPaddleSensitivity(+1);
myAdjustSetting = AdjustSetting::DIGITAL_SENSITIVITY;
myAdjustActive = true;
}
return;
case Event::DecreaseAutoFire:
if(pressed)
{
myOSystem.console().changeAutoFireRate(-1);
myAdjustSetting = AdjustSetting::AUTO_FIRE;
myAdjustActive = true;
}
return;
case Event::IncreaseAutoFire:
if(pressed)
{
myOSystem.console().changeAutoFireRate(+1);
myAdjustSetting = AdjustSetting::AUTO_FIRE;
myAdjustActive = true;
}
return;
case Event::ToggleFourDirections:
if(pressed && !repeated)
{
toggleAllow4JoyDirections();
myAdjustSetting = AdjustSetting::FOUR_DIRECTIONS;
myAdjustActive = true;
}
return;
case Event::ToggleKeyCombos:
if(pressed && !repeated)
{
myPKeyHandler->toggleModKeys();
myAdjustSetting = AdjustSetting::MOD_KEY_COMBOS;
myAdjustActive = true;
}
return;
case Event::ToggleSAPortOrder:
if(pressed && !repeated)
{
toggleSAPortOrder();
myAdjustSetting = AdjustSetting::SA_PORT_ORDER;
myAdjustActive = true;
}
return;
case Event::PrevMouseAsController:
if(pressed && !repeated)
{
changeMouseControllerMode(-1);
myAdjustSetting = AdjustSetting::USE_MOUSE;
myAdjustActive = true;
}
return;
case Event::NextMouseAsController:
if(pressed && !repeated)
{
changeMouseControllerMode(+1);
myAdjustSetting = AdjustSetting::USE_MOUSE;
myAdjustActive = true;
}
return;
case Event::DecMousePaddleSense:
if(pressed)
{
myPJoyHandler->changeMousePaddleSensitivity(-1);
myAdjustSetting = AdjustSetting::PADDLE_SENSITIVITY;
myAdjustActive = true;
}
return;
case Event::IncMousePaddleSense:
if(pressed)
{
myPJoyHandler->changeMousePaddleSensitivity(+1);
myAdjustSetting = AdjustSetting::PADDLE_SENSITIVITY;
myAdjustActive = true;
}
return;
case Event::DecMouseTrackballSense:
if(pressed)
{
myPJoyHandler->changeMouseTrackballSensitivity(-1);
myAdjustSetting = AdjustSetting::TRACKBALL_SENSITIVITY;
myAdjustActive = true;
}
return;
case Event::IncMouseTrackballSense:
if(pressed)
{
myPJoyHandler->changeMouseTrackballSensitivity(+1);
myAdjustSetting = AdjustSetting::TRACKBALL_SENSITIVITY;
myAdjustActive = true;
}
return;
case Event::DecreaseDrivingSense:
if(pressed)
{
myPJoyHandler->changeDrivingSensitivity(-1);
myAdjustSetting = AdjustSetting::DRIVING_SENSITIVITY;
myAdjustActive = true;
}
return;
case Event::IncreaseDrivingSense:
if(pressed)
{
myPJoyHandler->changeDrivingSensitivity(+1);
myAdjustSetting = AdjustSetting::DRIVING_SENSITIVITY;
myAdjustActive = true;
}
return;
case Event::PreviousCursorVisbility:
if(pressed && !repeated)
{
changeMouseCursor(-1);
myAdjustSetting = AdjustSetting::MOUSE_CURSOR;
myAdjustActive = true;
}
return;
case Event::NextCursorVisbility:
if(pressed && !repeated)
{
changeMouseCursor(+1);
myAdjustSetting = AdjustSetting::MOUSE_CURSOR;
myAdjustActive = true;
}
return;
case Event::ToggleGrabMouse:
if(pressed && !repeated && !myOSystem.frameBuffer().fullScreen())
{
myOSystem.frameBuffer().toggleGrabMouse();
myAdjustSetting = AdjustSetting::GRAB_MOUSE;
myAdjustActive = true;
}
return;
case Event::PreviousLeftPort:
if(pressed && !repeated)
{
myOSystem.console().changeLeftController(-1);
myAdjustSetting = AdjustSetting::LEFT_PORT;
myAdjustActive = true;
}
return;
case Event::NextLeftPort:
if(pressed && !repeated)
{
myOSystem.console().changeLeftController(+1);
myAdjustSetting = AdjustSetting::LEFT_PORT;
myAdjustActive = true;
}
return;
case Event::PreviousRightPort:
if(pressed && !repeated)
{
myOSystem.console().changeRightController(-1);
myAdjustSetting = AdjustSetting::RIGHT_PORT;
myAdjustActive = true;
}
return;
case Event::NextRightPort:
if(pressed && !repeated)
{
myOSystem.console().changeRightController(+1);
myAdjustSetting = AdjustSetting::RIGHT_PORT;
myAdjustActive = true;
}
return;
case Event::ToggleSwapPorts:
if(pressed && !repeated)
{
myOSystem.console().toggleSwapPorts();
myAdjustSetting = AdjustSetting::SWAP_PORTS;
myAdjustActive = true;
}
return;
case Event::ToggleSwapPaddles:
if(pressed && !repeated)
{
myOSystem.console().toggleSwapPaddles();
myAdjustSetting = AdjustSetting::SWAP_PADDLES;
myAdjustActive = true;
}
return;
case Event::DecreasePaddleCenterX:
if(pressed)
{
myOSystem.console().changePaddleCenterX(-1);
myAdjustSetting = AdjustSetting::PADDLE_CENTER_X;
myAdjustActive = true;
}
return;
case Event::IncreasePaddleCenterX:
if(pressed)
{
myOSystem.console().changePaddleCenterX(+1);
myAdjustSetting = AdjustSetting::PADDLE_CENTER_X;
myAdjustActive = true;
}
return;
case Event::DecreasePaddleCenterY:
if(pressed)
{
myOSystem.console().changePaddleCenterY(-1);
myAdjustSetting = AdjustSetting::PADDLE_CENTER_Y;
myAdjustActive = true;
}
return;
case Event::IncreasePaddleCenterY:
if(pressed)
{
myOSystem.console().changePaddleCenterY(+1);
myAdjustSetting = AdjustSetting::PADDLE_CENTER_Y;
myAdjustActive = true;
}
return;
case Event::PreviousMouseControl:
if(pressed && !repeated) changeMouseControl(-1);
return;
case Event::NextMouseControl:
if(pressed && !repeated) changeMouseControl(+1);
return;
///////////////////////////////////////////////////////////////////////////
// State events
case Event::SaveState:
if (pressed && !repeated)
{
@ -1289,7 +1765,6 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
///////////////////////////////////////////////////////////////////////////
// Misc events
case Event::DecreaseSpeed:
if(pressed)
{
@ -1336,27 +1811,6 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return;
#endif
case Event::DecreaseAutoFire:
if(pressed) myOSystem.console().changeAutoFireRate(-1);
return;
case Event::IncreaseAutoFire:
if(pressed) myOSystem.console().changeAutoFireRate(+1);
return;
case Event::HandleMouseControl:
if (pressed && !repeated) handleMouseControl();
return;
case Event::ToggleSAPortOrder:
if (pressed && !repeated) toggleSAPortOrder();
return;
case Event::ToggleGrabMouse:
if (pressed && !repeated && !myOSystem.frameBuffer().fullScreen())
myOSystem.frameBuffer().toggleGrabMouse();
return;
case Event::TakeSnapshot:
if(pressed && !repeated) myOSystem.frameBuffer().tiaSurface().saveSnapShot();
return;
@ -1599,7 +2053,6 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return;
////////////////////////////////////////////////////////////////////////
case Event::NoType: // Ignore unmapped events
return;
@ -2028,6 +2481,9 @@ StringList EventHandler::getActionList(Event::Group group) const
case Event::Group::Keyboard:
return getActionList(KeyboardEvents);
case Event::Group::Devices:
return getActionList(DevicesEvents);
case Event::Group::Debug:
return getActionList(DebugEvents);
@ -2197,6 +2653,9 @@ int EventHandler::getActionListIndex(int idx, Event::Group group) const
case Event::Group::Keyboard:
return getEmulActionListIndex(idx, KeyboardEvents);
case Event::Group::Devices:
return getEmulActionListIndex(idx, DevicesEvents);
case Event::Group::Debug:
return getEmulActionListIndex(idx, DebugEvents);
@ -2291,10 +2750,53 @@ void EventHandler::setMouseControllerMode(const string& enable)
myOSystem.console().properties().get(PropType::Controller_MouseAxis) : "none";
myMouseControl = make_unique<MouseControl>(myOSystem.console(), control);
myMouseControl->next(); // set first available mode
myMouseControl->change(0); // set first available mode
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::changeMouseControllerMode(int direction)
{
const int NUM_MODES = 3;
const string MODES[NUM_MODES] = {"always", "analog", "never"};
const string MSG[NUM_MODES] = {"all", "analog", "no"};
string usemouse = myOSystem.settings().getString("usemouse");
int i = 0;
for(auto& mode : MODES)
{
if(mode == usemouse)
{
i = BSPF::clampw(i + direction, 0, NUM_MODES - 1);
usemouse = MODES[i];
break;
}
++i;
}
myOSystem.settings().setValue("usemouse", usemouse);
setMouseControllerMode(usemouse);
myOSystem.frameBuffer().setCursorState(); // if necessary change grab mouse
ostringstream ss;
ss << "Mouse controls " << MSG[i] << " devices";
myOSystem.frameBuffer().showTextMessage(ss.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::changeMouseCursor(int direction)
{
int cursor = BSPF::clampw(myOSystem.settings().getInt("cursor") + direction, 0, 3);
myOSystem.settings().setValue("cursor", cursor);
myOSystem.frameBuffer().setCursorState();
ostringstream ss;
ss << "Mouse cursor visibilility: "
<< ((cursor & 2) ? "+" : "-") << "UI, "
<< ((cursor & 1) ? "+" : "-") << "Emulation";
myOSystem.frameBuffer().showTextMessage(ss.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::enterMenuMode(EventHandlerState state)
{
@ -2692,11 +3194,43 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { {
{ Event::VolumeDecrease, "Decrease volume", "" },
{ Event::VolumeIncrease, "Increase volume", "" },
{ Event::DecreaseDeadzone, "Decrease joystick deadzone", "" },
{ Event::IncreaseDeadzone, "Increase joystick deadzone", "" },
{ Event::DecAnalogSense, "Decrease analog paddle sensitivity", "" },
{ Event::IncAnalogSense, "Increase analog paddle sensitivity", "" },
{ Event::DecDejtterAveraging, "Decrease paddle dejitter averaging", "" },
{ Event::IncDejtterAveraging, "Increase paddle dejitter averaging", "" },
{ Event::DecDejtterReaction, "Decrease paddle dejitter reaction", "" },
{ Event::IncDejtterReaction, "Increase paddle dejitter reaction", "" },
{ Event::DecDigitalSense, "Decrease digital paddle sensitivity", "" },
{ Event::IncDigitalSense, "Increase digital paddle sensitivity", "" },
{ Event::DecreaseAutoFire, "Decrease auto fire speed", "" },
{ Event::IncreaseAutoFire, "Increase auto fire speed", "" },
{ Event::HandleMouseControl, "Switch mouse emulation modes", "" },
{ Event::ToggleGrabMouse, "Toggle grab mouse", "" },
{ Event::ToggleFourDirections, "Toggle allow four joystick directions", "" },
{ Event::ToggleKeyCombos, "Toggle use of modifier key combos", "" },
{ Event::ToggleSAPortOrder, "Swap Stelladaptor port ordering", "" },
{ Event::PrevMouseAsController, "Select previous mouse controls", "" },
{ Event::NextMouseAsController, "Select next mouse controls", "" },
{ Event::DecMousePaddleSense, "Decrease mouse paddle sensitivity", "" },
{ Event::IncMousePaddleSense, "Increase mouse paddle sensitivity", "" },
{ Event::DecMouseTrackballSense, "Decrease mouse trackball sensitivity", "" },
{ Event::IncMouseTrackballSense, "Increase mouse trackball sensitivity", "" },
{ Event::DecreaseDrivingSense, "Decrease driving sensitivity", "" },
{ Event::IncreaseDrivingSense, "Increase driving sensitivity", "" },
{ Event::PreviousCursorVisbility, "Select prev. cursor visibility mode", "" },
{ Event::NextCursorVisbility, "Select next cursor visibility mode" ,"" },
{ Event::ToggleGrabMouse, "Toggle grab mouse", "" },
{ Event::PreviousLeftPort, "Select previous left controller", "" },
{ Event::NextLeftPort, "Select next left controller", "" },
{ Event::PreviousRightPort, "Select previous right controller", "" },
{ Event::NextRightPort, "Select next right controller", "" },
{ Event::ToggleSwapPorts, "Toggle swap ports", "" },
{ Event::ToggleSwapPaddles, "Toggle swap paddles", "" },
{ Event::PreviousMouseControl, "Select previous mouse emulation mode", "" },
{ Event::NextMouseControl, "Select next mouse emulation mode", "" },
{ Event::DecreaseMouseAxesRange, "Decrease mouse axes range", "" },
{ Event::IncreaseMouseAxesRange, "Increase mouse axes range", "" },
{ Event::ToggleTimeMachine, "Toggle 'Time Machine' mode", "" },
{ Event::TimeMachineMode, "Toggle 'Time Machine' UI", "" },
@ -2763,10 +3297,8 @@ const Event::EventSet EventHandler::MiscEvents = {
Event::TakeSnapshot, Event::ToggleContSnapshots, Event::ToggleContSnapshotsFrame,
// Event::MouseAxisXMove, Event::MouseAxisYMove,
// Event::MouseButtonLeftValue, Event::MouseButtonRightValue,
Event::DecreaseAutoFire, Event::IncreaseAutoFire,
Event::HandleMouseControl, Event::ToggleGrabMouse,
Event::HighScoresMenuMode,
Event::ToggleSAPortOrder, Event::PreviousMultiCartRom,
Event::PreviousMultiCartRom,
Event::PreviousSettingGroup, Event::NextSettingGroup,
Event::PreviousSetting, Event::NextSetting,
Event::SettingDecrease, Event::SettingIncrease,
@ -2844,10 +3376,35 @@ const Event::EventSet EventHandler::KeyboardEvents = {
Event::KeyboardOneStar, Event::KeyboardOne0, Event::KeyboardOnePound,
};
const Event::EventSet EventHandler::DevicesEvents = {
Event::DecreaseDeadzone, Event::IncreaseDeadzone,
Event::DecAnalogSense, Event::IncAnalogSense,
Event::DecDejtterAveraging, Event::IncDejtterAveraging,
Event::DecDejtterReaction, Event::IncDejtterReaction,
Event::DecDigitalSense, Event::IncDigitalSense,
Event::DecreaseAutoFire, Event::IncreaseAutoFire,
Event::ToggleFourDirections, Event::ToggleKeyCombos, Event::ToggleSAPortOrder,
Event::PrevMouseAsController, Event::NextMouseAsController,
Event::DecMousePaddleSense, Event::IncMousePaddleSense,
Event::DecMouseTrackballSense, Event::IncMouseTrackballSense,
Event::DecreaseDrivingSense, Event::IncreaseDrivingSense,
Event::PreviousCursorVisbility, Event::NextCursorVisbility,
Event::ToggleGrabMouse,
Event::PreviousLeftPort, Event::NextLeftPort,
Event::PreviousRightPort, Event::NextRightPort,
Event::ToggleSwapPorts, Event::ToggleSwapPaddles,
Event::DecreasePaddleCenterX, Event::IncreasePaddleCenterX,
Event::DecreasePaddleCenterY, Event::IncreasePaddleCenterY,
Event::PreviousMouseControl, Event::NextMouseControl,
Event::DecreaseMouseAxesRange, Event::IncreaseMouseAxesRange,
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Event::EventSet EventHandler::ComboEvents = {
Event::Combo1, Event::Combo2, Event::Combo3, Event::Combo4, Event::Combo5, Event::Combo6, Event::Combo7, Event::Combo8,
Event::Combo9, Event::Combo10, Event::Combo11, Event::Combo12, Event::Combo13, Event::Combo14, Event::Combo15, Event::Combo16,
Event::Combo1, Event::Combo2, Event::Combo3, Event::Combo4,
Event::Combo5, Event::Combo6, Event::Combo7, Event::Combo8,
Event::Combo9, Event::Combo10, Event::Combo11, Event::Combo12,
Event::Combo13, Event::Combo14, Event::Combo15, Event::Combo16,
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -81,10 +81,15 @@ class EventHandler
*/
void mapStelladaptors(const string& saport);
/**
Toggles if all four joystick directions are allowed at once
*/
void toggleAllow4JoyDirections(bool toggle = true);
/**
Swaps the ordering of Stelladaptor/2600-daptor(s) devices.
*/
void toggleSAPortOrder();
void toggleSAPortOrder(bool toggle = true);
/**
Toggle whether the console is in 2600 or 7800 mode.
@ -141,6 +146,8 @@ class EventHandler
'always', 'analog', 'never'
*/
void setMouseControllerMode(const string& enable);
void changeMouseControllerMode(int direction = +1);
void changeMouseCursor(int direction = +1);
void enterMenuMode(EventHandlerState state);
void leaveMenuMode();
@ -353,7 +360,8 @@ class EventHandler
/**
Handle changing mouse modes.
*/
void handleMouseControl();
void changeMouseControl(int direction = +1);
bool hasMouseControl();
void saveKeyMapping();
void saveJoyMapping();
@ -462,6 +470,34 @@ class EventHandler
PHOSPHOR,
SCANLINES,
INTERPOLATION,
// *** Input group ***
#ifdef JOYSTICK_SUPPORT
DEADZONE,
ANALOG_SENSITIVITY,
DEJITTER_AVERAGING,
DEJITTER_REACTION,
#endif
DIGITAL_SENSITIVITY,
AUTO_FIRE,
FOUR_DIRECTIONS,
MOD_KEY_COMBOS,
#ifdef JOYSTICK_SUPPORT
SA_PORT_ORDER,
#endif
USE_MOUSE,
PADDLE_SENSITIVITY,
TRACKBALL_SENSITIVITY,
DRIVING_SENSITIVITY,
MOUSE_CURSOR,
GRAB_MOUSE,
LEFT_PORT,
RIGHT_PORT,
SWAP_PORTS,
SWAP_PADDLES,
PADDLE_CENTER_X,
PADDLE_CENTER_Y,
MOUSE_CONTROL,
MOUSE_RANGE,
// *** Debug group ***
STATS,
P0_ENAM,
@ -490,12 +526,15 @@ class EventHandler
NUM_ADJ,
START_AV_ADJ = VOLUME,
END_AV_ADJ = INTERPOLATION,
START_INPUT_ADJ = DEADZONE,
END_INPUT_ADJ = MOUSE_RANGE,
START_DEBUG_ADJ = STATS,
END_DEBUG_ADJ = JITTER,
};
enum class AdjustGroup
{
AV,
INPUT,
DEBUG,
NUM_GROUPS
};
@ -509,6 +548,7 @@ class EventHandler
static const Event::EventSet JoystickEvents;
static const Event::EventSet PaddlesEvents;
static const Event::EventSet KeyboardEvents;
static const Event::EventSet DevicesEvents;
static const Event::EventSet ComboEvents;
static const Event::EventSet DebugEvents;
static const Event::EventSet EditEvents;
@ -533,6 +573,13 @@ class EventHandler
AdjustFunction cycleAdjustSetting(int direction);
AdjustFunction getAdjustSetting(AdjustSetting setting);
PhysicalJoystickHandler& joyHandler() { return *myPJoyHandler; }
PhysicalKeyboardHandler& keyHandler() { return *myPKeyHandler; }
bool isJoystick(const Controller& controller) const;
bool isPaddle(const Controller& controller) const;
bool isTrackball(const Controller& controller) const;
private:
// Structure used for action menu items
struct ActionList {
@ -596,7 +643,7 @@ class EventHandler
#else
REFRESH_SIZE = 0,
#endif
EMUL_ACTIONLIST_SIZE = 176 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE,
EMUL_ACTIONLIST_SIZE = 207 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE,
MENU_ACTIONLIST_SIZE = 18
;

View File

@ -1254,8 +1254,46 @@ float FrameBuffer::maxWindowZoom(uInt32 baseWidth, uInt32 baseHeight) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::setCursorState()
{
myGrabMouse = myOSystem.settings().getBool("grabmouse");
// Always grab mouse in emulation (if enabled) and emulating a controller
// that always uses the mouse
const bool emulation =
myOSystem.eventHandler().state() == EventHandlerState::EMULATION;
const bool usesLightgun = emulation && myOSystem.hasConsole() ?
myOSystem.console().leftController().type() == Controller::Type::Lightgun ||
myOSystem.console().rightController().type() == Controller::Type::Lightgun : false;
// Show/hide cursor in UI/emulation mode based on 'cursor' setting
int cursor = myOSystem.settings().getInt("cursor");
// Always enable cursor in lightgun games
if (usesLightgun && !myGrabMouse)
cursor |= 1; // +Emulation
switch(cursor)
{
case 0: // -UI, -Emulation
showCursor(false);
break;
case 1:
showCursor(emulation); // -UI, +Emulation
break;
case 2: // +UI, -Emulation
showCursor(!emulation);
break;
case 3:
showCursor(true); // +UI, +Emulation
break;
}
myGrabMouse &= grabMouseAllowed();
myBackend->grabMouse(myGrabMouse);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameBuffer::grabMouseAllowed()
{
// Allow grabbing mouse in emulation (if enabled) and emulating a controller
// that always uses the mouse
bool emulation =
myOSystem.eventHandler().state() == EventHandlerState::EMULATION;
bool analog = myOSystem.hasConsole() ?
@ -1266,31 +1304,10 @@ void FrameBuffer::setCursorState()
myOSystem.console().rightController().type() == Controller::Type::Lightgun : false;
bool alwaysUseMouse = BSPF::equalsIgnoreCase("always", myOSystem.settings().getString("usemouse"));
// Show/hide cursor in UI/emulation mode based on 'cursor' setting
int cursor = myOSystem.settings().getInt("cursor");
// always enable cursor in lightgun games
if (usesLightgun && !myGrabMouse)
cursor |= 1; // +Emulation
// Disable grab while cursor is shown in emulation
bool cursorHidden = !(myOSystem.settings().getInt("cursor") & 1);
switch(cursor)
{
case 0: // -UI, -Emulation
showCursor(false);
break;
case 1:
showCursor(emulation); //-UI, +Emulation
myGrabMouse = false; // disable grab while cursor is shown in emulation
break;
case 2: // +UI, -Emulation
showCursor(!emulation);
break;
case 3:
showCursor(true); // +UI, +Emulation
myGrabMouse = false; // disable grab while cursor is shown in emulation
break;
}
myBackend->grabMouse(emulation && (analog || alwaysUseMouse) && myGrabMouse);
return emulation && (analog || usesLightgun || alwaysUseMouse) && cursorHidden;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1301,16 +1318,25 @@ void FrameBuffer::enableGrabMouse(bool enable)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::toggleGrabMouse()
void FrameBuffer::toggleGrabMouse(bool toggle)
{
const bool oldState = myGrabMouse;
bool oldState = myGrabMouse = myOSystem.settings().getBool("grabmouse");
if(toggle)
{
if(grabMouseAllowed())
{
myGrabMouse = !myGrabMouse;
setCursorState();
myOSystem.settings().setValue("grabmouse", myGrabMouse);
setCursorState();
}
}
else
oldState = !myGrabMouse; // display current state
myOSystem.frameBuffer().showTextMessage(oldState != myGrabMouse ? myGrabMouse
? "Grab mouse enabled" : "Grab mouse disabled"
: "Grab mouse not allowed while cursor shown");
: "Grab mouse not allowed");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -252,6 +252,11 @@ class FrameBuffer
*/
void setCursorState();
/**
Checks if mouse grabbing is allowed.
*/
bool grabMouseAllowed();
/**
Sets the use of grabmouse.
*/
@ -260,7 +265,7 @@ class FrameBuffer
/**
Toggles the use of grabmouse (only has effect in emulation mode).
*/
void toggleGrabMouse();
void toggleGrabMouse(bool toggle = true);
/**
Query whether grabmouse is enabled.

View File

@ -153,9 +153,15 @@ bool Joystick::setMouseControl(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Joystick::setDeadZone(int deadzone)
{
deadzone = BSPF::clamp(deadzone, 0, 29);
_DEAD_ZONE = deadZoneValue(deadzone);
}
_DEAD_ZONE = 3200 + deadzone * 1000;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Joystick::deadZoneValue(int deadzone)
{
deadzone = BSPF::clamp(deadzone, DEAD_ZONE_MIN, DEAD_ZONE_MAX);
return 3200 + deadzone * 1000;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -30,6 +30,9 @@
class Joystick : public Controller
{
public:
static constexpr int DEAD_ZONE_MIN = 0;
static constexpr int DEAD_ZONE_MAX = 29;
/**
Create a new joystick controller plugged into the specified jack
@ -78,6 +81,11 @@ class Joystick : public Controller
but it seemed like the best place to put it.
*/
static void setDeadZone(int deadzone);
/**
Retrieves the effective deadzone value
*/
static int deadZoneValue(int deadzone);
inline static int deadzone() { return _DEAD_ZONE; }
private:

View File

@ -416,11 +416,15 @@ void Paddles::setAnalogYCenter(int ycenter)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float Paddles::setAnalogSensitivity(int sensitivity)
{
// BASE_ANALOG_SENSE * (1.1 ^ 20) = 1.0
SENSITIVITY = BASE_ANALOG_SENSE * std::pow(1.1F,
static_cast<float>(BSPF::clamp(sensitivity, 0, MAX_ANALOG_SENSE)));
return SENSITIVITY = analogSensitivityValue(sensitivity);
}
return SENSITIVITY;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float Paddles::analogSensitivityValue(int sensitivity)
{
// BASE_ANALOG_SENSE * (1.1 ^ 20) = 1.0
return BASE_ANALOG_SENSE * std::pow(1.1F,
static_cast<float>(BSPF::clamp(sensitivity, MIN_ANALOG_SENSE, MAX_ANALOG_SENSE)));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -438,20 +442,20 @@ void Paddles::setDejitterDiff(int strength)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Paddles::setDigitalSensitivity(int sensitivity)
{
DIGITAL_SENSITIVITY = BSPF::clamp(sensitivity, 1, MAX_DIGITAL_SENSE);
DIGITAL_SENSITIVITY = BSPF::clamp(sensitivity, MIN_DIGITAL_SENSE, MAX_DIGITAL_SENSE);
DIGITAL_DISTANCE = 20 + (DIGITAL_SENSITIVITY << 3);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Paddles::setMouseSensitivity(int sensitivity)
{
MOUSE_SENSITIVITY = BSPF::clamp(sensitivity, 1, MAX_MOUSE_SENSE);
MOUSE_SENSITIVITY = BSPF::clamp(sensitivity, MIN_MOUSE_SENSE, MAX_MOUSE_SENSE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Paddles::setDigitalPaddleRange(int range)
{
range = BSPF::clamp(range, 1, 100);
range = BSPF::clamp(range, MIN_MOUSE_RANGE, MAX_MOUSE_RANGE);
TRIGRANGE = int(TRIGMAX * (range / 100.0));
}

View File

@ -49,13 +49,19 @@ class Paddles : public Controller
public:
static constexpr float BASE_ANALOG_SENSE = 0.148643628F;
static constexpr int MIN_ANALOG_SENSE = 0;
static constexpr int MAX_ANALOG_SENSE = 30;
static constexpr int MIN_ANALOG_CENTER = -10;
static constexpr int MAX_ANALOG_CENTER = 30;
static constexpr int MIN_DIGITAL_SENSE = 1;
static constexpr int MAX_DIGITAL_SENSE = 20;
static constexpr int MIN_MOUSE_SENSE = 1;
static constexpr int MAX_MOUSE_SENSE = 20;
static constexpr int MIN_DEJITTER = 0;
static constexpr int MAX_DEJITTER = 10;
static constexpr int MIN_MOUSE_RANGE = 1;
static constexpr int MAX_MOUSE_RANGE = 100;
/**
Update the entire digital and analog pin state according to the
@ -114,6 +120,8 @@ class Paddles : public Controller
*/
static float setAnalogSensitivity(int sensitivity);
static float analogSensitivityValue(int sensitivity);
/**
@param strength Value from 0 to 10
*/

View File

@ -110,7 +110,7 @@ bool PointingDevice::setMouseControl(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PointingDevice::setSensitivity(int sensitivity)
{
BSPF::clamp(sensitivity, 1, 20, 10);
BSPF::clamp(sensitivity, MIN_SENSE, MAX_SENSE, (MIN_SENSE + MAX_SENSE) / 2);
TB_SENSITIVITY = sensitivity / 10.0F;
}

View File

@ -39,6 +39,10 @@ class PointingDevice : public Controller
float sensitivity);
~PointingDevice() override = default;
public:
static constexpr int MIN_SENSE = 1;
static constexpr int MAX_SENSE = 20;
public:
using Controller::read;

View File

@ -351,11 +351,11 @@ void Settings::validate()
setValue("cursor", "2");
i = getInt("psense");
if(i < 0|| i > Paddles::MAX_ANALOG_SENSE)
if(i < Paddles::MIN_ANALOG_SENSE || i > Paddles::MAX_ANALOG_SENSE)
setValue("psense", "20");
i = getInt("dsense");
if(i < 1 || i > 20)
if(i < Paddles::MIN_DIGITAL_SENSE || i > Paddles::MAX_DIGITAL_SENSE)
setValue("dsense", "10");
i = getInt("msense");

View File

@ -68,6 +68,7 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
VarList::push_back(items, "Joystick", Event::Group::Joystick);
VarList::push_back(items, "Paddles", Event::Group::Paddles);
VarList::push_back(items, "Keyboard", Event::Group::Keyboard);
VarList::push_back(items, "Input Devices & Ports", Event::Group::Devices);
VarList::push_back(items, "Combo", Event::Group::Combo);
VarList::push_back(items, "Debug", Event::Group::Debug);

View File

@ -394,6 +394,7 @@ void GameInfoDialog::addControllersTab()
"Mouse axes range ", 0, 0, fontWidth * 4, "%");
myMouseRange->setMinValue(1); myMouseRange->setMaxValue(100);
myMouseRange->setTickmarkIntervals(4);
myMouseRange->setToolTip("Adjust paddle range emulated by the mouse.");
wid.push_back(myMouseRange);
// Add items for tab 2
@ -989,6 +990,7 @@ void GameInfoDialog::saveConfig()
Paddles::setAnalogXCenter(myPaddleXCenter->getValue());
Paddles::setAnalogYCenter(myPaddleYCenter->getValue());
Paddles::setDigitalPaddleRange(myMouseRange->getValue());
}
}
@ -1194,9 +1196,10 @@ void GameInfoDialog::updateControllerStates()
BSPF::startsWithIgnoreCase(contrRight, "MindLink");
myMouseControl->setEnabled(enableMouse);
myMouseX->setEnabled(enableMouse);
myMouseY->setEnabled(enableMouse);
myMouseRange->setEnabled(enableMouse);
myMouseX->setEnabled(enableMouse && myMouseControl->getState());
myMouseY->setEnabled(enableMouse && myMouseControl->getState());
myMouseRange->setEnabled(enablePaddles);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -125,7 +125,7 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
ADD_EVENT(Event::TogglePhosphor, "Toggle 'phosphor' effect");
ADD_LINE();
ADD_EVENT(Event::ToggleGrabMouse, "Grab mouse (keep in window)");
ADD_EVENT(Event::HandleMouseControl, "Toggle controller for mouse");
ADD_EVENT(Event::NextMouseControl, "Toggle controller for mouse");
ADD_EVENT(Event::ToggleSAPortOrder, "Toggle Stelladaptor left/right");
ADD_LINE();
ADD_EVENT(Event::VolumeIncrease, "Increase volume by 2%");

View File

@ -126,7 +126,8 @@ void InputDialog::addDevicePortTab()
// Add joystick deadzone setting
myDeadzone = new SliderWidget(myTab, _font, HBORDER, ypos - 1, 13 * fontWidth, lineHeight,
"Joystick deadzone size", lwidth, kDeadzoneChanged, 5 * fontWidth);
myDeadzone->setMinValue(0); myDeadzone->setMaxValue(29);
myDeadzone->setMinValue(Joystick::DEAD_ZONE_MIN);
myDeadzone->setMaxValue(Joystick::DEAD_ZONE_MAX);
myDeadzone->setTickmarkIntervals(4);
wid.push_back(myDeadzone);
@ -152,6 +153,8 @@ void InputDialog::addDevicePortTab()
myDejitterBase->setMinValue(Paddles::MIN_DEJITTER);
myDejitterBase->setMaxValue(Paddles::MAX_DEJITTER);
myDejitterBase->setTickmarkIntervals(5);
myDejitterBase->setToolTip("Adjust paddle input averaging.\n"
"Note: Already implemented in 2600-daptor");
//xpos += myDejitterBase->getWidth() + fontWidth - 4;
wid.push_back(myDejitterBase);
@ -162,6 +165,7 @@ void InputDialog::addDevicePortTab()
myDejitterDiff->setMinValue(Paddles::MIN_DEJITTER);
myDejitterDiff->setMaxValue(Paddles::MAX_DEJITTER);
myDejitterDiff->setTickmarkIntervals(5);
myDejitterDiff->setToolTip("Adjust paddle reaction to fast movements.");
wid.push_back(myDejitterDiff);
// Add paddle speed (digital emulation)
@ -403,14 +407,7 @@ void InputDialog::saveConfig()
{
Settings& settings = instance().settings();
// Left & right ports
instance().eventHandler().mapStelladaptors(mySAPort->getState() ? "rl": "lr");
// Use mouse as a controller
const string& usemouse = myMouseControl->getSelectedTag().toString();
settings.setValue("usemouse", usemouse);
instance().eventHandler().setMouseControllerMode(usemouse);
// *** Device & Ports ***
// Joystick deadzone
int deadzone = myDeadzone->getValue();
settings.setValue("joydeadzone", deadzone);
@ -433,6 +430,31 @@ void InputDialog::saveConfig()
settings.setValue("dsense", sensitivity);
Paddles::setDigitalSensitivity(sensitivity);
// Autofire rate
int rate = myAutoFireRate->getValue();
settings.setValue("autofirerate", rate);
Controller::setAutoFireRate(rate);
// Allow all 4 joystick directions
bool allowall4 = myAllowAll4->getState();
settings.setValue("joyallow4", allowall4);
instance().eventHandler().allowAllDirections(allowall4);
// Enable/disable modifier key-combos
settings.setValue("modcombo", myModCombo->getState());
// Left & right ports
instance().eventHandler().mapStelladaptors(mySAPort->getState() ? "rl" : "lr");
// AtariVox serial port
settings.setValue("avoxport", myAVoxPort->getText());
// *** Mouse ***
// Use mouse as a controller
const string& usemouse = myMouseControl->getSelectedTag().toString();
settings.setValue("usemouse", usemouse);
instance().eventHandler().setMouseControllerMode(usemouse);
sensitivity = myMPaddleSpeed->getValue();
settings.setValue("msense", sensitivity);
Paddles::setMouseSensitivity(sensitivity);
@ -447,22 +469,10 @@ void InputDialog::saveConfig()
settings.setValue("dcsense", sensitivity);
Driving::setSensitivity(sensitivity);
// Autofire rate
int rate = myAutoFireRate->getValue();
settings.setValue("autofirerate", rate);
Controller::setAutoFireRate(rate);
// AtariVox serial port
settings.setValue("avoxport", myAVoxPort->getText());
// Allow all 4 joystick directions
bool allowall4 = myAllowAll4->getState();
settings.setValue("joyallow4", allowall4);
instance().eventHandler().allowAllDirections(allowall4);
// Grab mouse and hide cursor
const string& cursor = myCursorState->getSelectedTag().toString();
settings.setValue("cursor", cursor);
// only allow grab mouse if cursor is hidden in emulation
int state = myCursorState->getSelected();
bool enableGrab = state != 1 && state != 3;
@ -470,9 +480,6 @@ void InputDialog::saveConfig()
settings.setValue("grabmouse", grab);
instance().frameBuffer().enableGrabMouse(grab);
// Enable/disable modifier key-combos
settings.setValue("modcombo", myModCombo->getState());
instance().eventHandler().saveKeyMapping();
instance().eventHandler().saveJoyMapping();
// instance().saveConfig();
@ -668,7 +675,7 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
break;
case kDeadzoneChanged:
myDeadzone->setValueLabel(3200 + 1000 * myDeadzone->getValue());
myDeadzone->setValueLabel(Joystick::deadZoneValue(myDeadzone->getValue()));
break;
case kPSpeedChanged:

View File

@ -219,6 +219,7 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
xpos = _w - HBORDER - font.getStringWidth("Follow Launcher path") - CheckboxWidget::prefixSize(font) - 1;
ypos += lineHeight + VGAP * 2;
myFollowLauncherWidget = new CheckboxWidget(myTab, font, xpos, ypos, "Follow Launcher path");
myFollowLauncherWidget->setToolTip("The ROM path is updated during Launcher navigation.");
wid.push_back(myFollowLauncherWidget);
xpos = HBORDER;
@ -272,6 +273,7 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
bwidth = font.getStringWidth("Image path" + ELLIPSIS) + fontWidth * 2 + 1;
myOpenBrowserButton = new ButtonWidget(myTab, font, xpos, ypos, bwidth, buttonHeight,
"Image path" + ELLIPSIS, kChooseSnapLoadDirCmd);
myOpenBrowserButton->setToolTip("Select path for snapshot images used in Launcher.");
wid.push_back(myOpenBrowserButton);
mySnapLoadPath = new EditTextWidget(myTab, font, HBORDER + lwidth,

View File

@ -48,8 +48,7 @@ WhatsNewDialog::WhatsNewDialog(OSystem& osystem, DialogContainer& parent, const
add(ypos, "fixed autofire bug for trackball controllers");
#else
add(ypos, "added high scores saving");
add(ypos, "enhanced cut/copy/paste for text editing");
add(ypos, "added undo and redo to text editing");
add(ypos, "enhanced cut/copy/paste and undo/redo for text editing");
add(ypos, "added wildcard support to launcher dialog filter");
add(ypos, "added option to search subdirectories in launcher");
add(ypos, "added tooltips to many UI items");

View File

@ -1521,6 +1521,7 @@
<ClInclude Include="..\common\FSNodeZIP.hxx" />
<ClInclude Include="..\common\HighScoresManager.hxx" />
<ClInclude Include="..\common\JoyMap.hxx" />
<ClInclude Include="..\common\jsonDefinitions.hxx" />
<ClInclude Include="..\common\KeyMap.hxx" />
<ClInclude Include="..\common\LinkedObjectPool.hxx" />
<ClInclude Include="..\common\Logger.hxx" />

View File

@ -2162,6 +2162,9 @@
<ClInclude Include="..\json\json_lib.hxx">
<Filter>Header Files\json</Filter>
</ClInclude>
<ClInclude Include="..\common\jsonDefinitions.hxx">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="stella.ico">