added suppression of unwanted global hotkey repeats

This commit is contained in:
Thomas Jentzsch 2021-10-27 11:13:37 +02:00
parent 93ef03f4d8
commit 3fc5f6d75e
2 changed files with 106 additions and 4 deletions

View File

@ -653,6 +653,102 @@ AdjustFunction EventHandler::getAdjustSetting(AdjustSetting setting)
return ADJUST_FUNCTIONS[int(setting)]; return ADJUST_FUNCTIONS[int(setting)];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::isAdjustRepeated(AdjustSetting setting)
{
const bool ADJUST_REPEATED[int(AdjustSetting::NUM_ADJ)] =
{
// *** Audio & Video group ***
true, // VOLUME
false, // ZOOM (always repeating)
false, // FULLSCREEN (always repeating)
#ifdef ADAPTABLE_REFRESH_SUPPORT
false, // ADAPT_REFRESH (always repeating)
#endif
true, // OVERSCAN
false, // TVFORMAT
true, // VCENTER
false, // ASPECT_RATIO (always repeating)
true, // VSIZE
// Palette adjustables
false, // PALETTE
true, // PALETTE_PHASE
true, // PALETTE_RED_SCALE
true, // PALETTE_RED_SHIFT
true, // PALETTE_GREEN_SCALE
true, // PALETTE_GREEN_SHIFT
true, // PALETTE_BLUE_SCALE
true, // PALETTE_BLUE_SHIFT
true, // PALETTE_HUE
true, // PALETTE_SATURATION
true, // PALETTE_CONTRAST
true, // PALETTE_BRIGHTNESS
true, // PALETTE_GAMMA
// NTSC filter adjustables
false, // NTSC_PRESET
true, // NTSC_SHARPNESS
true, // NTSC_RESOLUTION
true, // NTSC_ARTIFACTS
true, // NTSC_FRINGING
true, // NTSC_BLEEDING
// Other TV effects adjustables
true, // PHOSPHOR
true, // SCANLINES
false, // INTERPOLATION
// *** Input group ***
true, // DEADZONE
true, // ANALOG_DEADZONE
true, // ANALOG_SENSITIVITY
true, // ANALOG_LINEARITY
true, // DEJITTER_AVERAGING
true, // DEJITTER_REACTION
true, // DIGITAL_SENSITIVITY
true, // AUTO_FIRE
false, // FOUR_DIRECTIONS
false, // MOD_KEY_COMBOS
false, // SA_PORT_ORDER
false, // USE_MOUSE
true, // PADDLE_SENSITIVITY
true, // TRACKBALL_SENSITIVITY
true, // DRIVING_SENSITIVITY
false, // MOUSE_CURSOR
false, // GRAB_MOUSE
false, // LEFT_PORT
false, // RIGHT_PORT
false, // SWAP_PORTS
false, // SWAP_PADDLES
true, // PADDLE_CENTER_X
true, // PADDLE_CENTER_Y
false, // MOUSE_CONTROL
true, // MOUSE_RANGE
// *** Debug group ***
false, // STATS
false, // P0_ENAM
false, // P1_ENAM
false, // M0_ENAM
false, // M1_ENAM
false, // BL_ENAM
false, // PF_ENAM
false, // ALL_ENAM
false, // P0_CX
false, // P1_CX
false, // M0_CX
false, // M1_CX
false, // BL_CX
false, // PF_CX
false, // ALL_CX
false, // FIXED_COL
false, // COLOR_LOSS
false, // JITTER
// *** Only used via direct hotkeys ***
true, // STATE
true, // PALETTE_CHANGE_ATTRIBUTE
true, // NTSC_CHANGE_ATTRIBUTE
true, // CHANGE_SPEED
};
return ADJUST_REPEATED[int(setting)];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setAdjustSetting(AdjustSetting setting) void EventHandler::setAdjustSetting(AdjustSetting setting)
{ {
@ -752,16 +848,20 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
if(adjustAVDirect != AdjustSetting::NONE) if(adjustAVDirect != AdjustSetting::NONE)
{ {
myAdjustDirect = adjustAVDirect; myAdjustDirect = adjustAVDirect;
if(!repeated || isAdjustRepeated(myAdjustDirect))
getAdjustSetting(myAdjustDirect)(direction); getAdjustSetting(myAdjustDirect)(direction);
} }
else else
{ {
// Get (and display) the current adjustment function, // Get (and display) the current adjustment function,
// but only change its value if the function was already active before // but only change its value if the function was already active before
if(!repeated || isAdjustRepeated(myAdjustSetting))
{
getAdjustSetting(myAdjustSetting)(adjustActive ? direction : 0); getAdjustSetting(myAdjustSetting)(adjustActive ? direction : 0);
myAdjustActive = true; myAdjustActive = true;
} }
} }
}
return; return;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

View File

@ -566,11 +566,13 @@ class EventHandler
int getEmulActionListIndex(int idx, const Event::EventSet& events) const; int getEmulActionListIndex(int idx, const Event::EventSet& events) const;
int getActionListIndex(int idx, Event::Group group) const; int getActionListIndex(int idx, Event::Group group) const;
// The following two methods are used for adjusting several settings using global hotkeys // The following 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(); AdjustGroup getAdjustGroup();
AdjustFunction cycleAdjustSetting(int direction); AdjustFunction cycleAdjustSetting(int direction);
AdjustFunction getAdjustSetting(AdjustSetting setting); AdjustFunction getAdjustSetting(AdjustSetting setting);
// Check if the current adjustment should be repeated
bool isAdjustRepeated(AdjustSetting setting);
void setAdjustSetting(AdjustSetting setting); void setAdjustSetting(AdjustSetting setting);
PhysicalJoystickHandler& joyHandler() const { return *myPJoyHandler; } PhysicalJoystickHandler& joyHandler() const { return *myPJoyHandler; }