Added global hot keys for debug options

This commit is contained in:
thrust26 2020-07-02 23:33:13 +02:00
parent 29cbdb09cf
commit 8c2c9ebb60
12 changed files with 393 additions and 141 deletions

View File

@ -16,6 +16,7 @@
* Added new interface palette 'Dark'. (TODO: DOC) * Added new interface palette 'Dark'. (TODO: DOC)
* Extended global hotkeys for debug options.
6.2 to 6.2.1: (June 20, 2020) 6.2 to 6.2.1: (June 20, 2020)

View File

@ -1430,7 +1430,7 @@
</tr> </tr>
<tr> <tr>
<td colspan="3"><center><font size="-1"> <td colspan="3"><center><font size="-1">
These settings can also be changed using <a href="#GlobalKeys"><b>Global Audio & Video Keys</a></font></center> These settings can also be changed using <a href="#GlobalKeys"><b>Global Keys</a></font></center>
</td> </td>
</tr> </tr>
</table> </table>
@ -1480,7 +1480,7 @@
</tr> </tr>
<tr> <tr>
<td colspan="3"><center><font size="-1"> <td colspan="3"><center><font size="-1">
These settings can also be changed using <a href="#GlobalKeys"><b>Global Audio & Video Keys</a></font></center> These settings can also be changed using <a href="#GlobalKeys"><b>Global Keys</a></font></center>
</td> </td>
</tr> </tr>
</table> </table>
@ -1550,7 +1550,7 @@
</tr> </tr>
<tr> <tr>
<td colspan="3"><center><font size="-1"> <td colspan="3"><center><font size="-1">
These settings can also be changed using <a href="#GlobalKeys"><b>Global Audio & Video Keys</a></font></center> These settings can also be changed using <a href="#GlobalKeys"><b>Global Keys</a></font></center>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -1559,45 +1559,6 @@
</tr> </tr>
</table> </table>
<p><b><a name="GlobalKeys">Global Audio & Video Keys</a> (can be remapped)</b></p>
<p>These keys allow selecting and changing audio & video settings without having to remember the
dedicated keys.</p>
<table BORDER=2 cellpadding=4>
<tr>
<th>Function</th>
<th>Key (Standard)</th>
<th>Key (macOS)</th>
</tr>
<tr>
<td>Select <i>previous</i> AV setting</td>
<td>End</td>
<td>Fn + Left arrow</td>
</tr>
<tr>
<td>Select <i>next</i> AV setting</td>
<td>Home</td>
<td>Fn + Right arrow</td>
</tr>
<tr>
<td><i>Decrease</i> current AV setting</td>
<td>PageDown</td>
<td>Fn + Down arrow</td>
</tr>
<tr>
<td><i>Increase</i> current AV setting
<td>PageUp</td>
<td>Fn + Up arrow</td>
</tr>
</table>
<p>Notes:
<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
global keys.</li>
</ul>
</p></br>
<a name="DeveloperKeys"></a> <a name="DeveloperKeys"></a>
<p><b>Developer Keys (can be remapped)</b></p> <p><b>Developer Keys (can be remapped)</b></p>
@ -1715,8 +1676,62 @@
<td>Alt + j</td> <td>Alt + j</td>
<td>Cmd + j</td> <td>Cmd + j</td>
</tr> </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> </table>
<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>
<table BORDER=2 cellpadding=4>
<tr>
<th>Function</th>
<th>Key (Standard)</th>
<th>Key (macOS)</th>
</tr>
<tr>
<td>Select <i>previous</i> setting group</td>
<td>Control + End</td>
<td>Control-Fn + Left arrow</td>
</tr>
<tr>
<td>Select <i>next</i> setting group</td>
<td>Control + Home</td>
<td>Control-Fn + Right arrow</td>
</tr>
<tr>
<td>Select <i>previous</i> setting</td>
<td>End</td>
<td>Fn + Left arrow</td>
</tr>
<tr>
<td>Select <i>next</i> setting</td>
<td>Home</td>
<td>Fn + Right arrow</td>
</tr>
<tr>
<td><i>Decrease</i> current setting</td>
<td>PageDown</td>
<td>Fn + Down arrow</td>
</tr>
<tr>
<td><i>Increase</i> current setting
<td>PageUp</td>
<td>Fn + Up arrow</td>
</tr>
</table>
<p>Notes:
<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
global keys.</li>
</ul>
</p>
<p><b>Other Emulation Keys (can be remapped)</b></p> <p><b>Other Emulation Keys (can be remapped)</b></p>
<table BORDER=2 cellpadding=4> <table BORDER=2 cellpadding=4>

View File

@ -505,9 +505,13 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo
#ifndef BSPF_MACOS #ifndef BSPF_MACOS
{Event::PreviousSetting, KBDK_END}, {Event::PreviousSetting, KBDK_END},
{Event::NextSetting, KBDK_HOME}, {Event::NextSetting, KBDK_HOME},
{Event::PreviousSettingGroup, KBDK_END, KBDM_CTRL},
{Event::NextSettingGroup, KBDK_HOME, KBDM_CTRL},
#else #else
{Event::PreviousSetting, KBDK_HOME}, {Event::PreviousSetting, KBDK_HOME},
{Event::NextSetting, KBDK_END}, {Event::NextSetting, KBDK_END},
{Event::PreviousSettingGroup, KBDK_HOME, KBDM_CTRL},
{Event::NextSettingGroup, KBDK_END, KBDM_CTRL},
#endif #endif
{Event::SettingDecrease, KBDK_PAGEDOWN}, {Event::SettingDecrease, KBDK_PAGEDOWN},
{Event::SettingIncrease, KBDK_PAGEUP}, {Event::SettingIncrease, KBDK_PAGEUP},

View File

@ -444,7 +444,7 @@ void Console::setFormat(uInt32 format, bool force)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleColorLoss() void Console::toggleColorLoss(bool toggle)
{ {
bool colorloss = !myTIA->colorLossEnabled(); bool colorloss = !myTIA->colorLossEnabled();
if(myTIA->enableColorLoss(colorloss)) if(myTIA->enableColorLoss(colorloss))
@ -876,51 +876,56 @@ float Console::getFramerate() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleTIABit(TIABit bit, const string& bitname, bool show) const void Console::toggleTIABit(TIABit bit, const string& bitname, bool show, bool toggle) const
{ {
bool result = myTIA->toggleBit(bit); bool result = myTIA->toggleBit(bit, toggle ? 2 : 3);
string message = bitname + (result ? " enabled" : " disabled"); const string message = bitname + (result ? " enabled" : " disabled");
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleBits() const void Console::toggleBits(bool toggle) const
{ {
bool enabled = myTIA->toggleBits(); bool enabled = myTIA->toggleBits(toggle);
string message = string("TIA bits") + (enabled ? " enabled" : " disabled"); const string message = string("TIA bits ") + (enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleTIACollision(TIABit bit, const string& bitname, bool show) const void Console::toggleTIACollision(TIABit bit, const string& bitname, bool show, bool toggle) const
{ {
bool result = myTIA->toggleCollision(bit); bool result = myTIA->toggleCollision(bit, toggle ? 2 : 3);
string message = bitname + (result ? " collision enabled" : " collision disabled"); const string message = bitname + (result ? " collision enabled" : " collision disabled");
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleCollisions() const void Console::toggleCollisions(bool toggle) const
{ {
bool enabled = myTIA->toggleCollisions(); bool enabled = myTIA->toggleCollisions(toggle);
string message = string("TIA collisions") + (enabled ? " enabled" : " disabled"); const string message = string("TIA collisions ") + (enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleFixedColors() const void Console::toggleFixedColors(bool toggle) const
{ {
if(myTIA->toggleFixedColors()) bool enabled = toggle ? myTIA->toggleFixedColors() : myTIA->usingFixedColors();
myOSystem.frameBuffer().showMessage("Fixed debug colors enabled"); const string message = string("Fixed debug colors ") + (enabled ? "enabled" : "disabled");
else
myOSystem.frameBuffer().showMessage("Fixed debug colors disabled"); myOSystem.frameBuffer().showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleJitter() const void Console::toggleJitter(bool toggle) const
{ {
bool enabled = myTIA->toggleJitter(); bool enabled = myTIA->toggleJitter(toggle ? 2 : 3);
string message = string("TV scanline jitter") + (enabled ? " enabled" : " disabled"); const string message = string("TV scanline jitter ") + (enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showMessage(message);
} }

View File

@ -229,7 +229,7 @@ class Console : public Serializable, public ConsoleIO
/** /**
Toggles the PAL color-loss effect. Toggles the PAL color-loss effect.
*/ */
void toggleColorLoss(); void toggleColorLoss(bool toggle = true);
void enableColorLoss(bool state); void enableColorLoss(bool state);
/** /**
@ -278,34 +278,34 @@ class Console : public Serializable, public ConsoleIO
/** /**
Toggles the TIA bit specified in the method name. Toggles the TIA bit specified in the method name.
*/ */
void toggleP0Bit() const { toggleTIABit(P0Bit, "P0"); } void toggleP0Bit(bool toggle = true) const { toggleTIABit(P0Bit, "P0", true, toggle); }
void toggleP1Bit() const { toggleTIABit(P1Bit, "P1"); } void toggleP1Bit(bool toggle = true) const { toggleTIABit(P1Bit, "P1", true, toggle); }
void toggleM0Bit() const { toggleTIABit(M0Bit, "M0"); } void toggleM0Bit(bool toggle = true) const { toggleTIABit(M0Bit, "M0", true, toggle); }
void toggleM1Bit() const { toggleTIABit(M1Bit, "M1"); } void toggleM1Bit(bool toggle = true) const { toggleTIABit(M1Bit, "M1", true, toggle); }
void toggleBLBit() const { toggleTIABit(BLBit, "BL"); } void toggleBLBit(bool toggle = true) const { toggleTIABit(BLBit, "BL", true, toggle); }
void togglePFBit() const { toggleTIABit(PFBit, "PF"); } void togglePFBit(bool toggle = true) const { toggleTIABit(PFBit, "PF", true, toggle); }
void toggleBits() const; void toggleBits(bool toggle = true) const;
/** /**
Toggles the TIA collisions specified in the method name. Toggles the TIA collisions specified in the method name.
*/ */
void toggleP0Collision() const { toggleTIACollision(P0Bit, "P0"); } void toggleP0Collision(bool toggle = true) const { toggleTIACollision(P0Bit, "P0", true, toggle); }
void toggleP1Collision() const { toggleTIACollision(P1Bit, "P1"); } void toggleP1Collision(bool toggle = true) const { toggleTIACollision(P1Bit, "P1", true, toggle); }
void toggleM0Collision() const { toggleTIACollision(M0Bit, "M0"); } void toggleM0Collision(bool toggle = true) const { toggleTIACollision(M0Bit, "M0", true, toggle); }
void toggleM1Collision() const { toggleTIACollision(M1Bit, "M1"); } void toggleM1Collision(bool toggle = true) const { toggleTIACollision(M1Bit, "M1", true, toggle); }
void toggleBLCollision() const { toggleTIACollision(BLBit, "BL"); } void toggleBLCollision(bool toggle = true) const { toggleTIACollision(BLBit, "BL", true, toggle); }
void togglePFCollision() const { toggleTIACollision(PFBit, "PF"); } void togglePFCollision(bool toggle = true) const { toggleTIACollision(PFBit, "PF", true, toggle); }
void toggleCollisions() const; void toggleCollisions(bool toggle = true) const;
/** /**
Toggles the TIA 'fixed debug colors' mode. Toggles the TIA 'fixed debug colors' mode.
*/ */
void toggleFixedColors() const; void toggleFixedColors(bool toggle = true) const;
/** /**
Toggles the TIA 'scanline jitter' mode. Toggles the TIA 'scanline jitter' mode.
*/ */
void toggleJitter() const; void toggleJitter(bool toggle = true) const;
/** /**
* Update vcenter * Update vcenter
@ -351,8 +351,10 @@ class Console : public Serializable, public ConsoleIO
unique_ptr<Controller> getControllerPort(const Controller::Type type, unique_ptr<Controller> getControllerPort(const Controller::Type type,
const Controller::Jack port, const string& romMd5); const Controller::Jack port, const string& romMd5);
void toggleTIABit(TIABit bit, const string& bitname, bool show = true) const; void toggleTIABit(TIABit bit, const string& bitname,
void toggleTIACollision(TIABit bit, const string& bitname, bool show = true) const; bool show = true, bool toggle = true) const;
void toggleTIACollision(TIABit bit, const string& bitname,
bool show = true, bool toggle = true) const;
private: private:
// Reference to the osystem object // Reference to the osystem object

View File

@ -121,9 +121,10 @@ class Event
ToggleCollisions, ToggleBits, ToggleFixedColors, ToggleCollisions, ToggleBits, ToggleFixedColors,
ToggleFrameStats, ToggleSAPortOrder, ExitGame, ToggleFrameStats, ToggleSAPortOrder, ExitGame,
// add new events from here to avoid that user remapped events get overwritten
SettingDecrease, SettingIncrease, PreviousSetting, NextSetting, SettingDecrease, SettingIncrease, PreviousSetting, NextSetting,
ToggleAdaptRefresh, PreviousMultiCartRom, ToggleAdaptRefresh, PreviousMultiCartRom,
// add new events from here to avoid that user remapped events get overwritten
PreviousSettingGroup, NextSettingGroup,
LastType LastType
}; };

View File

@ -342,6 +342,16 @@ void EventHandler::handleSystemEvent(SystemEvent e, int, int)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandler::AdjustGroup EventHandler::getAdjustGroup()
{
if (myAdjustSetting >= AdjustSetting::START_DEBUG_ADJ && myAdjustSetting <= AdjustSetting::END_DEBUG_ADJ)
return AdjustGroup::DEBUG;
return AdjustGroup::AV;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AdjustFunction EventHandler::cycleAdjustSetting(int direction) AdjustFunction EventHandler::cycleAdjustSetting(int direction)
{ {
@ -350,21 +360,38 @@ AdjustFunction EventHandler::cycleAdjustSetting(int direction)
myOSystem.settings().getString("palette") == PaletteHandler::SETTING_CUSTOM; myOSystem.settings().getString("palette") == PaletteHandler::SETTING_CUSTOM;
const bool isCustomFilter = const bool isCustomFilter =
myOSystem.settings().getInt("tv.filter") == int(NTSCFilter::Preset::CUSTOM); myOSystem.settings().getInt("tv.filter") == int(NTSCFilter::Preset::CUSTOM);
bool repeat; const bool isPAL = myOSystem.console().timing() == ConsoleTiming::pal;
bool repeat = false;
do do
{ {
myAdjustSetting = switch (getAdjustGroup())
AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction, 0, int(AdjustSetting::MAX_ADJ))); {
// skip currently non-relevant adjustments case AdjustGroup::AV:
repeat = (myAdjustSetting == AdjustSetting::OVERSCAN && !isFullScreen) myAdjustSetting =
#ifdef ADAPTABLE_REFRESH_SUPPORT AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction,
|| (myAdjustSetting == AdjustSetting::ADAPT_REFRESH && !isFullScreen) int(AdjustSetting::START_AV_ADJ), int(AdjustSetting::END_AV_ADJ)));
#endif // skip currently non-relevant adjustments
|| (myAdjustSetting == AdjustSetting::PALETTE_PHASE && !isCustomPalette) repeat = (myAdjustSetting == AdjustSetting::OVERSCAN && !isFullScreen)
|| (myAdjustSetting >= AdjustSetting::NTSC_SHARPNESS #ifdef ADAPTABLE_REFRESH_SUPPORT
&& myAdjustSetting <= AdjustSetting::NTSC_BLEEDING || (myAdjustSetting == AdjustSetting::ADAPT_REFRESH && !isFullScreen)
&& !isCustomFilter); #endif
|| (myAdjustSetting == AdjustSetting::PALETTE_PHASE && !isCustomPalette)
|| (myAdjustSetting >= AdjustSetting::NTSC_SHARPNESS
&& myAdjustSetting <= AdjustSetting::NTSC_BLEEDING
&& !isCustomFilter);
break;
case AdjustGroup::DEBUG:
myAdjustSetting =
AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction,
int(AdjustSetting::START_DEBUG_ADJ), int(AdjustSetting::END_DEBUG_ADJ)));
repeat = (myAdjustSetting == AdjustSetting::COLOR_LOSS && !isPAL);
break;
default:
break;
}
// avoid endless loop // avoid endless loop
if(repeat && !direction) if(repeat && !direction)
direction = 1; direction = 1;
@ -381,6 +408,7 @@ AdjustFunction EventHandler::getAdjustSetting(AdjustSetting setting)
// - This array MUST have the same order as AdjustSetting // - This array MUST have the same order as AdjustSetting
const AdjustFunction ADJUST_FUNCTIONS[int(AdjustSetting::NUM_ADJ)] = const AdjustFunction ADJUST_FUNCTIONS[int(AdjustSetting::NUM_ADJ)] =
{ {
// Audio & Video settings
std::bind(&Sound::adjustVolume, &myOSystem.sound(), _1), std::bind(&Sound::adjustVolume, &myOSystem.sound(), _1),
std::bind(&FrameBuffer::selectVidMode, &myOSystem.frameBuffer(), _1), std::bind(&FrameBuffer::selectVidMode, &myOSystem.frameBuffer(), _1),
std::bind(&FrameBuffer::toggleFullscreen, &myOSystem.frameBuffer(), _1), std::bind(&FrameBuffer::toggleFullscreen, &myOSystem.frameBuffer(), _1),
@ -424,6 +452,25 @@ AdjustFunction EventHandler::getAdjustSetting(AdjustSetting setting)
std::bind(&StateManager::changeState, &myOSystem.state(), _1), std::bind(&StateManager::changeState, &myOSystem.state(), _1),
std::bind(&PaletteHandler::changeCurrentAdjustable, &myOSystem.frameBuffer().tiaSurface().paletteHandler(), _1), std::bind(&PaletteHandler::changeCurrentAdjustable, &myOSystem.frameBuffer().tiaSurface().paletteHandler(), _1),
std::bind(&TIASurface::changeCurrentNTSCAdjustable, &myOSystem.frameBuffer().tiaSurface(), _1), std::bind(&TIASurface::changeCurrentNTSCAdjustable, &myOSystem.frameBuffer().tiaSurface(), _1),
// Debug settings
std::bind(&FrameBuffer::toggleFrameStats, &myOSystem.frameBuffer(), _1),
std::bind(&Console::toggleP0Bit, &myOSystem.console(), _1),
std::bind(&Console::toggleP1Bit, &myOSystem.console(), _1),
std::bind(&Console::toggleM0Bit, &myOSystem.console(), _1),
std::bind(&Console::toggleM1Bit, &myOSystem.console(), _1),
std::bind(&Console::toggleBLBit, &myOSystem.console(), _1),
std::bind(&Console::togglePFBit, &myOSystem.console(), _1),
std::bind(&Console::toggleBits, &myOSystem.console(), _1),
std::bind(&Console::toggleP0Collision, &myOSystem.console(), _1),
std::bind(&Console::toggleP1Collision, &myOSystem.console(), _1),
std::bind(&Console::toggleM0Collision, &myOSystem.console(), _1),
std::bind(&Console::toggleM1Collision, &myOSystem.console(), _1),
std::bind(&Console::toggleBLCollision, &myOSystem.console(), _1),
std::bind(&Console::togglePFCollision, &myOSystem.console(), _1),
std::bind(&Console::toggleCollisions, &myOSystem.console(), _1),
std::bind(&Console::toggleFixedColors, &myOSystem.console(), _1),
std::bind(&Console::toggleColorLoss, &myOSystem.console(), _1),
std::bind(&Console::toggleJitter, &myOSystem.console(), _1),
}; };
return ADJUST_FUNCTIONS[int(setting)]; return ADJUST_FUNCTIONS[int(setting)];
@ -446,8 +493,10 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
myAdjustActive = false; myAdjustActive = false;
myAdjustDirect = AdjustSetting::NONE; myAdjustDirect = AdjustSetting::NONE;
} }
const bool adjustActive = myAdjustActive; const bool adjustActive = myAdjustActive;
const AdjustSetting adjustDirect = myAdjustDirect; const AdjustSetting adjustAVDirect = myAdjustDirect;
if(pressed) if(pressed)
{ {
myAdjustActive = false; myAdjustActive = false;
@ -457,6 +506,36 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
switch(event) switch(event)
{ {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Allow adjusting several (mostly repeated) settings using the same four hotkeys
case Event::PreviousSettingGroup:
case Event::NextSettingGroup:
if (pressed && !repeated)
{
const int direction = event == Event::PreviousSettingGroup ? -1 : +1;
AdjustGroup adjustGroup = AdjustGroup(BSPF::clampw(int(getAdjustGroup()) + direction,
0, int(AdjustGroup::NUM_GROUPS) - 1));
string msg;
switch (adjustGroup)
{
case AdjustGroup::AV:
msg = "Audio & Video";
myAdjustSetting = AdjustSetting::START_AV_ADJ;
break;
case AdjustGroup::DEBUG:
msg = "Debug";
myAdjustSetting = AdjustSetting::START_DEBUG_ADJ;
break;
default:
break;
}
myOSystem.frameBuffer().showMessage(msg + " settings");
myAdjustActive = false;
}
break;
// Allow adjusting several (mostly repeated) settings using the same four hotkeys // Allow adjusting several (mostly repeated) settings using the same four hotkeys
case Event::PreviousSetting: case Event::PreviousSetting:
case Event::NextSetting: case Event::NextSetting:
@ -481,9 +560,9 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
const int direction = event == Event::SettingDecrease ? -1 : +1; const int direction = event == Event::SettingDecrease ? -1 : +1;
// if a "direct only" hotkey was pressed last, use this one // if a "direct only" hotkey was pressed last, use this one
if(adjustDirect != AdjustSetting::NONE) if(adjustAVDirect != AdjustSetting::NONE)
{ {
myAdjustDirect = adjustDirect; myAdjustDirect = adjustAVDirect;
getAdjustSetting(myAdjustDirect)(direction); getAdjustSetting(myAdjustDirect)(direction);
} }
else else
@ -853,7 +932,12 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return; return;
case Event::ToggleColorLoss: case Event::ToggleColorLoss:
if (pressed && !repeated) myOSystem.console().toggleColorLoss(); if (pressed && !repeated)
{
myOSystem.console().toggleColorLoss();
myAdjustSetting = AdjustSetting::COLOR_LOSS;
myAdjustActive = true;
}
return; return;
case Event::PaletteDecrease: case Event::PaletteDecrease:
@ -888,11 +972,21 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return; return;
case Event::ToggleJitter: case Event::ToggleJitter:
if (pressed && !repeated) myOSystem.console().toggleJitter(); if (pressed && !repeated)
{
myOSystem.console().toggleJitter();
myAdjustSetting = AdjustSetting::JITTER;
myAdjustActive = true;
}
return; return;
case Event::ToggleFrameStats: case Event::ToggleFrameStats:
if (pressed) myOSystem.frameBuffer().toggleFrameStats(); if (pressed && !repeated)
{
myOSystem.frameBuffer().toggleFrameStats();
myAdjustSetting = AdjustSetting::STATS;
myAdjustActive = true;
}
return; return;
case Event::ToggleTimeMachine: case Event::ToggleTimeMachine:
@ -941,63 +1035,138 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return; return;
case Event::ToggleP0Collision: case Event::ToggleP0Collision:
if (pressed && !repeated) myOSystem.console().toggleP0Collision(); if (pressed && !repeated)
{
myOSystem.console().toggleP0Collision();
myAdjustSetting = AdjustSetting::P0_CX;
myAdjustActive = true;
}
return; return;
case Event::ToggleP0Bit: case Event::ToggleP0Bit:
if (pressed && !repeated) myOSystem.console().toggleP0Bit(); if (pressed && !repeated)
{
myOSystem.console().toggleP0Bit();
myAdjustSetting = AdjustSetting::P0_ENAM;
myAdjustActive = true;
}
return; return;
case Event::ToggleP1Collision: case Event::ToggleP1Collision:
if (pressed && !repeated) myOSystem.console().toggleP1Collision(); if (pressed && !repeated)
{
myOSystem.console().toggleP1Collision();
myAdjustSetting = AdjustSetting::P1_CX;
myAdjustActive = true;
}
return; return;
case Event::ToggleP1Bit: case Event::ToggleP1Bit:
if (pressed && !repeated) myOSystem.console().toggleP1Bit(); if (pressed && !repeated)
{
myOSystem.console().toggleP1Bit();
myAdjustSetting = AdjustSetting::P1_ENAM;
myAdjustActive = true;
}
return; return;
case Event::ToggleM0Collision: case Event::ToggleM0Collision:
if (pressed && !repeated) myOSystem.console().toggleM0Collision(); if (pressed && !repeated)
{
myOSystem.console().toggleM0Collision();
myAdjustSetting = AdjustSetting::M0_CX;
myAdjustActive = true;
}
return; return;
case Event::ToggleM0Bit: case Event::ToggleM0Bit:
if (pressed && !repeated) myOSystem.console().toggleM0Bit(); if (pressed && !repeated)
{
myOSystem.console().toggleM0Bit();
myAdjustSetting = AdjustSetting::M0_ENAM;
myAdjustActive = true;
}
return; return;
case Event::ToggleM1Collision: case Event::ToggleM1Collision:
if (pressed && !repeated) myOSystem.console().toggleM1Collision(); if (pressed && !repeated)
{
myOSystem.console().toggleM1Collision();
myAdjustSetting = AdjustSetting::M1_CX;
myAdjustActive = true;
}
return; return;
case Event::ToggleM1Bit: case Event::ToggleM1Bit:
if (pressed && !repeated) myOSystem.console().toggleM1Bit(); if (pressed && !repeated)
{
myOSystem.console().toggleM1Bit();
myAdjustSetting = AdjustSetting::M1_ENAM;
myAdjustActive = true;
}
return; return;
case Event::ToggleBLCollision: case Event::ToggleBLCollision:
if (pressed && !repeated) myOSystem.console().toggleBLCollision(); if (pressed && !repeated)
{
myOSystem.console().toggleBLCollision();
myAdjustSetting = AdjustSetting::BL_CX;
myAdjustActive = true;
}
return; return;
case Event::ToggleBLBit: case Event::ToggleBLBit:
if (pressed) myOSystem.console().toggleBLBit(); if (pressed && !repeated)
{
myOSystem.console().toggleBLBit();
myAdjustSetting = AdjustSetting::BL_ENAM;
myAdjustActive = true;
}
return; return;
case Event::TogglePFCollision: case Event::TogglePFCollision:
if (pressed && !repeated) myOSystem.console().togglePFCollision(); if (pressed && !repeated)
{
myOSystem.console().togglePFCollision();
myAdjustSetting = AdjustSetting::PF_CX;
myAdjustActive = true;
}
return; return;
case Event::TogglePFBit: case Event::TogglePFBit:
if (pressed && !repeated) myOSystem.console().togglePFBit(); if (pressed && !repeated)
return; {
myOSystem.console().togglePFBit();
case Event::ToggleFixedColors: myAdjustSetting = AdjustSetting::PF_ENAM;
if (pressed) myOSystem.console().toggleFixedColors(); myAdjustActive = true;
}
return; return;
case Event::ToggleCollisions: case Event::ToggleCollisions:
if (pressed && !repeated) myOSystem.console().toggleCollisions(); if (pressed && !repeated)
{
myOSystem.console().toggleCollisions();
myAdjustSetting = AdjustSetting::ALL_CX;
myAdjustActive = true;
}
return; return;
case Event::ToggleBits: case Event::ToggleBits:
if (pressed && !repeated) myOSystem.console().toggleBits(); if (pressed && !repeated)
{
myOSystem.console().toggleBits();
myAdjustSetting = AdjustSetting::ALL_ENAM;
myAdjustActive = true;
}
return;
case Event::ToggleFixedColors:
if (pressed && !repeated)
{
myOSystem.console().toggleFixedColors();
myAdjustSetting = AdjustSetting::FIXED_COL;
myAdjustActive = true;
}
return; return;
case Event::SaveState: case Event::SaveState:
@ -2316,6 +2485,8 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { {
{ Event::ScanlinesDecrease, "Decrease scanlines", "" }, { Event::ScanlinesDecrease, "Decrease scanlines", "" },
{ Event::ScanlinesIncrease, "Increase scanlines", "" }, { Event::ScanlinesIncrease, "Increase scanlines", "" },
{ Event::PreviousSettingGroup, "Select previous setting group", "" },
{ Event::NextSettingGroup, "Select next setting group", "" },
{ Event::PreviousSetting, "Select previous setting", "" }, { Event::PreviousSetting, "Select previous setting", "" },
{ Event::NextSetting, "Select next setting", "" }, { Event::NextSetting, "Select next setting", "" },
{ Event::SettingDecrease, "Decrease current setting", "" }, { Event::SettingDecrease, "Decrease current setting", "" },
@ -2414,7 +2585,10 @@ const Event::EventSet EventHandler::MiscEvents = {
// Event::MouseAxisXMove, Event::MouseAxisYMove, // Event::MouseAxisXMove, Event::MouseAxisYMove,
// Event::MouseButtonLeftValue, Event::MouseButtonRightValue, // Event::MouseButtonLeftValue, Event::MouseButtonRightValue,
Event::HandleMouseControl, Event::ToggleGrabMouse, Event::HandleMouseControl, Event::ToggleGrabMouse,
Event::ToggleSAPortOrder, Event::PreviousMultiCartRom Event::ToggleSAPortOrder, Event::PreviousMultiCartRom,
Event::PreviousSettingGroup, Event::NextSettingGroup,
Event::PreviousSetting, Event::NextSetting,
Event::SettingDecrease, Event::SettingIncrease,
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -2435,8 +2609,6 @@ const Event::EventSet EventHandler::AudioVideoEvents = {
Event::PhosphorDecrease, Event::PhosphorIncrease, Event::TogglePhosphor, Event::PhosphorDecrease, Event::PhosphorIncrease, Event::TogglePhosphor,
Event::ScanlinesDecrease, Event::ScanlinesIncrease, Event::ScanlinesDecrease, Event::ScanlinesIncrease,
Event::ToggleInter, Event::ToggleInter,
Event::PreviousSetting, Event::NextSetting,
Event::SettingDecrease, Event::SettingIncrease,
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -420,15 +420,45 @@ class EventHandler
NTSC_ARTIFACTS, NTSC_ARTIFACTS,
NTSC_FRINGING, NTSC_FRINGING,
NTSC_BLEEDING, NTSC_BLEEDING,
// Other TV effects adjustables
PHOSPHOR, PHOSPHOR,
SCANLINES, SCANLINES,
INTERPOLATION, INTERPOLATION,
MAX_ADJ = INTERPOLATION,
// Only used via direct hotkeys // Only used via direct hotkeys
STATE, STATE,
PALETTE_CHANGE_ATTRIBUTE, PALETTE_CHANGE_ATTRIBUTE,
NTSC_CHANGE_ATTRIBUTE, NTSC_CHANGE_ATTRIBUTE,
NUM_ADJ // Debug
STATS,
P0_ENAM,
P1_ENAM,
M0_ENAM,
M1_ENAM,
BL_ENAM,
PF_ENAM,
ALL_ENAM,
P0_CX,
P1_CX,
M0_CX,
M1_CX,
BL_CX,
PF_CX,
ALL_CX,
FIXED_COL,
COLOR_LOSS,
JITTER,
// Ranges
NUM_ADJ,
START_AV_ADJ = VOLUME,
END_AV_ADJ = INTERPOLATION,
START_DEBUG_ADJ = STATS,
END_DEBUG_ADJ = JITTER,
};
enum class AdjustGroup
{
AV,
DEBUG,
NUM_GROUPS
}; };
private: private:
@ -459,6 +489,7 @@ class EventHandler
// The following two methods are used for adjusting several settings using global hotkeys // The following two methods are used for adjusting several settings using global hotkeys
// They return the function used to adjust the currenly selected setting // They return the function used to adjust the currenly selected setting
AdjustGroup getAdjustGroup();
AdjustFunction cycleAdjustSetting(int direction); AdjustFunction cycleAdjustSetting(int direction);
AdjustFunction getAdjustSetting(AdjustSetting setting); AdjustFunction getAdjustSetting(AdjustSetting setting);
@ -470,10 +501,10 @@ class EventHandler
string key; string key;
}; };
// ID of the currently selected global setting
AdjustSetting myAdjustSetting{AdjustSetting::VOLUME};
// If true, the setting is visible and its value can be changed // If true, the setting is visible and its value can be changed
bool myAdjustActive{false}; bool myAdjustActive{false};
// ID of the currently selected global setting
AdjustSetting myAdjustSetting{AdjustSetting::START_AV_ADJ};
// ID of the currently selected direct hotkey setting (0 if none) // ID of the currently selected direct hotkey setting (0 if none)
AdjustSetting myAdjustDirect{AdjustSetting::NONE}; AdjustSetting myAdjustDirect{AdjustSetting::NONE};
@ -525,7 +556,7 @@ class EventHandler
#else #else
REFRESH_SIZE = 0, REFRESH_SIZE = 0,
#endif #endif
EMUL_ACTIONLIST_SIZE = 157 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE, EMUL_ACTIONLIST_SIZE = 159 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE,
MENU_ACTIONLIST_SIZE = 18 MENU_ACTIONLIST_SIZE = 18
; ;

View File

@ -634,11 +634,15 @@ void FrameBuffer::drawFrameStats(float framesPerSecond)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::toggleFrameStats() void FrameBuffer::toggleFrameStats(bool toggle)
{ {
showFrameStats(!myStatsEnabled); if (toggle)
showFrameStats(!myStatsEnabled);
myOSystem.settings().setValue( myOSystem.settings().setValue(
myOSystem.settings().getBool("dev.settings") ? "dev.stats" : "plr.stats", myStatsEnabled); myOSystem.settings().getBool("dev.settings") ? "dev.stats" : "plr.stats", myStatsEnabled);
myOSystem.frameBuffer().showMessage(string("Console info ") +
(myStatsEnabled ? "enabled" : "disabled"));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -171,7 +171,7 @@ class FrameBuffer
/** /**
Toggles showing or hiding framerate statistics. Toggles showing or hiding framerate statistics.
*/ */
void toggleFrameStats(); void toggleFrameStats(bool toggle = true);
/** /**
Shows a message containing frame statistics for the current frame. Shows a message containing frame statistics for the current frame.

View File

@ -1029,9 +1029,13 @@ bool TIA::toggleBit(TIABit b, uInt8 mode)
mask = b; mask = b;
break; break;
default: case 2:
mask = (~mySpriteEnabledBits & b); mask = (~mySpriteEnabledBits & b);
break; break;
default:
mask = (mySpriteEnabledBits & b);
break;
} }
mySpriteEnabledBits = (mySpriteEnabledBits & ~b) | mask; mySpriteEnabledBits = (mySpriteEnabledBits & ~b) | mask;
@ -1047,9 +1051,11 @@ bool TIA::toggleBit(TIABit b, uInt8 mode)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TIA::toggleBits() bool TIA::toggleBits(bool toggle)
{ {
toggleBit(TIABit(0xFF), mySpriteEnabledBits > 0 ? 0 : 1); toggleBit(TIABit(0xFF), toggle
? mySpriteEnabledBits > 0 ? 0 : 1
: mySpriteEnabledBits);
return mySpriteEnabledBits; return mySpriteEnabledBits;
} }
@ -1068,9 +1074,13 @@ bool TIA::toggleCollision(TIABit b, uInt8 mode)
mask = b; mask = b;
break; break;
default: case 2:
mask = (~myCollisionsEnabledBits & b); mask = (~myCollisionsEnabledBits & b);
break; break;
default:
mask = (myCollisionsEnabledBits & b);
break;
} }
myCollisionsEnabledBits = (myCollisionsEnabledBits & ~b) | mask; myCollisionsEnabledBits = (myCollisionsEnabledBits & ~b) | mask;
@ -1086,9 +1096,11 @@ bool TIA::toggleCollision(TIABit b, uInt8 mode)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TIA::toggleCollisions() bool TIA::toggleCollisions(bool toggle)
{ {
toggleCollision(TIABit(0xFF), myCollisionsEnabledBits > 0 ? 0 : 1); toggleCollision(TIABit(0xFF), toggle
? myCollisionsEnabledBits > 0 ? 0 : 1
: myCollisionsEnabledBits);
return myCollisionsEnabledBits; return myCollisionsEnabledBits;
} }
@ -1207,6 +1219,9 @@ bool TIA::toggleJitter(uInt8 mode)
myEnableJitter = !myEnableJitter; myEnableJitter = !myEnableJitter;
break; break;
case 3:
break;
default: default:
throw runtime_error("invalid argument for toggleJitter"); throw runtime_error("invalid argument for toggleJitter");
} }

View File

@ -356,23 +356,25 @@ class TIA : public Device
disabling a graphical object also disables its collisions. disabling a graphical object also disables its collisions.
@param mode 1/0 indicates on/off, and values greater than 1 mean @param mode 1/0 indicates on/off, and values greater than 1 mean
flip the bit from its current state 2 means flip the bit from its current state
and values greater than 2 mean return current state
@return Whether the bit was enabled or disabled @return Whether the bit was enabled or disabled
*/ */
bool toggleBit(TIABit b, uInt8 mode = 2); bool toggleBit(TIABit b, uInt8 mode = 2);
bool toggleBits(); bool toggleBits(bool toggle = true);
/** /**
Enables/disable/toggle the specified (or all) TIA bit collision(s). Enables/disable/toggle the specified (or all) TIA bit collision(s).
@param mode 1/0 indicates on/off, and values greater than 1 mean @param mode 1/0 indicates on/off,
flip the collision from its current state 2 means flip the collision from its current state
and values greater than 2 mean return current state
@return Whether the collision was enabled or disabled @return Whether the collision was enabled or disabled
*/ */
bool toggleCollision(TIABit b, uInt8 mode = 2); bool toggleCollision(TIABit b, uInt8 mode = 2);
bool toggleCollisions(); bool toggleCollisions(bool toggle = true);
/** /**
Enables/disable/toggle/query 'fixed debug colors' mode. Enables/disable/toggle/query 'fixed debug colors' mode.