Skip to content

Commit

Permalink
ADHD Multi-Monitor Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaldaien committed Dec 29, 2024
1 parent 05052fc commit be5e1ad
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 18 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

24.12.29.1
==========
+ Added a new display mode to blackout secondary monitors while playing
games (Refer to Display | ADHD Multi-Monitor Mode).
+ Added keybind for ADHD Multi-Monitor Mode to Monitor Management keys
in the Display menu.
+ Added command console variable to toggle this mode:

Display.MultiMonitorFocus {true|false} Default: false

24.12.29
========
Expand Down
7 changes: 7 additions & 0 deletions include/SpecialK/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,13 @@ struct sk_config_t
false, false, false, 0
}, L"ToggleHDR"
};
SK_ConfigSerializedKeybind
multimonitor_focus_keybind = {
SK_Keybind {
"Toggle ADHD MultiMonitor Mode", L"<Not Bound>",
false, false, false, 0
}, L"ToggleADHDMultiMonitor"
};
} monitors;

struct widget_s {
Expand Down
28 changes: 15 additions & 13 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1678,20 +1678,21 @@ auto DeclKeybind =
ConfigEntry (screenshots.png.store_hdr, L"Use HDR PNG file format for HDR screenshots", osd_ini, L"Screenshot.HDR", L"StorePNG"),
ConfigEntry (screenshots.allow_hdr_clipboard, L"Use HDR for Windows Clipboard screenshots", osd_ini, L"Screenshot.HDR", L"AllowClipboardHDR"),
ConfigEntry (screenshots.png.st2084_bits, L"Use n-bit Quantization to save Disk Space", osd_ini, L"Screenshot.HDR", L"MaxST2084QuantizedBits"),
Keybind ( &config.render.keys.hud_toggle, L"Toggle Game's HUD", osd_ini, L"Game.HUD"),
Keybind ( &config.osd.keys.console_toggle, L"Toggle SK's Command Console", osd_ini, L"OSD.System"),
Keybind ( &config.screenshots.game_hud_free_keybind, L"Take a screenshot without the HUD", osd_ini, L"Screenshot.System"),
Keybind ( &config.screenshots.sk_osd_free_keybind, L"Take a screenshot without SK's OSD", osd_ini, L"Screenshot.System"),
Keybind ( &config.screenshots.
Keybind (&config.render.keys.hud_toggle, L"Toggle Game's HUD", osd_ini, L"Game.HUD"),
Keybind (&config.osd.keys.console_toggle, L"Toggle SK's Command Console", osd_ini, L"OSD.System"),
Keybind (&config.screenshots.game_hud_free_keybind, L"Take a screenshot without the HUD", osd_ini, L"Screenshot.System"),
Keybind (&config.screenshots.sk_osd_free_keybind, L"Take a screenshot without SK's OSD", osd_ini, L"Screenshot.System"),
Keybind (&config.screenshots.
sk_osd_insertion_keybind, L"Take a screenshot and insert SK's OSD", osd_ini, L"Screenshot.System"),
Keybind ( &config.screenshots.no_3rd_party_keybind, L"Take a screenshot before third-party overlays", osd_ini, L"Screenshot.System"),
Keybind ( &config.screenshots.clipboard_only_keybind,L"Take a screenshot and copy it to the clipboard only", osd_ini, L"Screenshot.System"),
Keybind ( &config.screenshots.snipping_keybind, L"Snip a screenshot and copy it to the clipboard", osd_ini, L"Screenshot.System"),
Keybind (&config.screenshots.no_3rd_party_keybind, L"Take a screenshot before third-party overlays", osd_ini, L"Screenshot.System"),
Keybind (&config.screenshots.clipboard_only_keybind, L"Take a screenshot and copy it to the clipboard only", osd_ini, L"Screenshot.System"),
Keybind (&config.screenshots.snipping_keybind, L"Snip a screenshot and copy it to the clipboard", osd_ini, L"Screenshot.System"),

Keybind ( &config.monitors.monitor_primary_keybind, L"Move Game to Primary Monitor", osd_ini, L"Display.Monitor"),
Keybind ( &config.monitors.monitor_next_keybind, L"Move Game to Next Monitor", osd_ini, L"Display.Monitor"),
Keybind ( &config.monitors.monitor_prev_keybind, L"Move Game to Previous Monitor", osd_ini, L"Display.Monitor"),
Keybind ( &config.monitors.monitor_toggle_hdr, L"Toggle HDR on Selected Monitor", osd_ini, L"Display.Monitor"),
Keybind (&config.monitors.multimonitor_focus_keybind,L"Toggle Multi-Monitor Focus Mode", osd_ini, L"Display.Monitor"),
Keybind (&config.monitors.monitor_primary_keybind, L"Move Game to Primary Monitor", osd_ini, L"Display.Monitor"),
Keybind (&config.monitors.monitor_next_keybind, L"Move Game to Next Monitor", osd_ini, L"Display.Monitor"),
Keybind (&config.monitors.monitor_prev_keybind, L"Move Game to Previous Monitor", osd_ini, L"Display.Monitor"),
Keybind (&config.monitors.monitor_toggle_hdr, L"Toggle HDR on Selected Monitor", osd_ini, L"Display.Monitor"),

Keybind ( &config.render.framerate.latent_sync.
tearline_move_down_keybind, L"Move Tear Location Down 1 Scanline", osd_ini, L"LatentSync.Control"),
Expand Down Expand Up @@ -1911,7 +1912,7 @@ auto DeclKeybind =
ConfigEntry (display.force_windowed, L"Force Windowed Mode", dll_ini, L"Display.Output", L"ForceWindowed"),
ConfigEntry (display.force_10bpc_sdr, L"Force 10-bpc (SDR) Output", dll_ini, L"Display.Output", L"Force10bpcSDR"),
ConfigEntry (display.aspect_ratio_stretch, L"Fill monitor background (eg. black bars) in windowed mode", dll_ini, L"Display.Output", L"AspectRatioStretch"),
ConfigEntry (display.multimonitor_focus_mode, L"Displays black background on all except the game's monitor",dll_ini, L"Display.Output", L"BlackoutSecondaryDisplays"),
ConfigEntry (display.multimonitor_focus_mode, L"Displays black background on all except the game's monitor",dll_ini, L"Display.Output", L"MultiMonitorADHDRelief"),
ConfigEntry (display.allow_refresh_change, L"Allow Current Game to change Refresh Rate", dll_ini, L"Display.Output", L"AllowRefreshRateChanges"),


Expand Down Expand Up @@ -5480,6 +5481,7 @@ auto DeclKeybind =
LoadKeybind (&config.monitors.monitor_next_keybind);
LoadKeybind (&config.monitors.monitor_prev_keybind);
LoadKeybind (&config.monitors.monitor_toggle_hdr);
LoadKeybind (&config.monitors.multimonitor_focus_keybind);

LoadKeybind (&config.render.framerate.latent_sync.tearline_move_up_keybind);
LoadKeybind (&config.render.framerate.latent_sync.tearline_move_down_keybind);
Expand Down
11 changes: 8 additions & 3 deletions src/control_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2091,7 +2091,7 @@ SK_Display_ResolutionSelectUI (bool bMarkDirty)
ImGui::SetItemTooltip ("Some engines may require a game restart to adjust to new aspect ratio.");
}

if (ImGui::Checkbox ("Multi-Monitor Sleep", &config.display.focus_mode))
if (ImGui::Checkbox ("ADHD Multi-Monitor Mode", &config.display.focus_mode))
{
if (config.display.focus_mode)
{
Expand All @@ -2100,11 +2100,15 @@ SK_Display_ResolutionSelectUI (bool bMarkDirty)
}

SK_Win32_BringBackgroundWindowToTop ();
SK_ImGui_AdjustCursor ();

config.utility.save_async ();
}

ImGui::SetItemTooltip (
"Covers secondary monitors with a black window to reduce distractions "
"while playing games."
);

ImGui::EndGroup ();
fWhitePointSliderWidth =
ImGui::GetItemRectSize ().x;
Expand Down Expand Up @@ -3209,7 +3213,8 @@ SK_ImGui_ControlPanel (void)
&config.monitors.monitor_primary_keybind,
&config.monitors.monitor_next_keybind,
&config.monitors.monitor_prev_keybind,
&config.monitors.monitor_toggle_hdr
&config.monitors.monitor_toggle_hdr,
&config.monitors.multimonitor_focus_keybind,
};

// Keybinds made using a menu option must process their popups here
Expand Down
14 changes: 13 additions & 1 deletion src/widgets/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ SK_ImGui_WidgetRegistry::DispatchKeybinds ( BOOL Control,


static
std::array <SK_ConfigSerializedKeybind *, 20>
std::array <SK_ConfigSerializedKeybind *, 21>
special_keys = {
&config.screenshots.game_hud_free_keybind,
&config.screenshots.sk_osd_free_keybind,
Expand All @@ -961,6 +961,7 @@ SK_ImGui_WidgetRegistry::DispatchKeybinds ( BOOL Control,
&config.monitors.monitor_next_keybind,
&config.monitors.monitor_prev_keybind,
&config.monitors.monitor_toggle_hdr,
&config.monitors.multimonitor_focus_keybind,

&config.render.framerate.latent_sync.tearline_move_up_keybind,
&config.render.framerate.latent_sync.tearline_move_down_keybind,
Expand Down Expand Up @@ -1073,6 +1074,17 @@ SK_ImGui_WidgetRegistry::DispatchKeybinds ( BOOL Control,
}
}

else if ( keybind == &config.monitors.multimonitor_focus_keybind )
{
config.display.focus_mode = !config.display.focus_mode;
config.window.background_render = true; // Required for this to work reliably
config.window.always_on_top = SmartAlwaysOnTop; // Needed to fix taskbar visibility

SK_Win32_BringBackgroundWindowToTop ();

config.utility.save_async ();
}

else if ( keybind == &config.monitors.monitor_primary_keybind )
{
const SK_RenderBackend& rb =
Expand Down
5 changes: 5 additions & 0 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,11 @@ class SK_WindowManager : public SK_IVariableListener
top_most_
);

cmd->AddVariable (
"Display.MultiMonitorFocus",
SK_CreateVar (SK_IVariable::Boolean, &config.display.focus_mode)
);

borderless_ =
SK_CreateVar (SK_IVariable::Boolean, &config.window.borderless, this);

Expand Down

0 comments on commit be5e1ad

Please sign in to comment.