From 70df557c2bb5d08bfbe7d8ed7f942ecbdcaf0453 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 7 Nov 2025 22:05:14 +0100 Subject: [PATCH] Add led indicator setting, use one setting for notifications, move it under general --- TODO | 2 - include/Config.hpp | 14 +- include/LedIndicator.hpp | 27 ++++ include/Overlay.hpp | 5 +- include/gui/ScreenshotSettingsPage.hpp | 6 +- include/gui/SettingsPage.hpp | 14 +- meson.build | 1 + src/Config.cpp | 17 ++- src/LedIndicator.cpp | 51 +++++++ src/Overlay.cpp | 161 ++++++++++++++++------ src/gui/ScreenshotSettingsPage.cpp | 30 ++-- src/gui/SettingsPage.cpp | 126 ++++++----------- tools/gsr-global-hotkeys/keyboard_event.c | 5 +- 13 files changed, 291 insertions(+), 168 deletions(-) create mode 100644 include/LedIndicator.hpp create mode 100644 src/LedIndicator.cpp diff --git a/TODO b/TODO index 211726c..c00d893 100644 --- a/TODO +++ b/TODO @@ -216,8 +216,6 @@ The UI is unusable on a vertical monitor. Steam overlay interfers with controller input in gsr ui. Maybe move controller handling the gsr-global-hotkeys to do a grab on the controller, to only give the key input to gsr ui. -Add option to show recording status with scroll lock led (use x11 xkb). Blink when starting/stopping recording and set led on when recording is running and set led off when not recording. - For joysticks (gamepads) create a virtual device for each one (/dev/uinput) that has the same vendor, product and name. This is to make sure that it behaves the same way in applications since applications access joysticks directly through /dev/input/eventN or /dev/input/jsN. It needs the same number of buttons and pretend to be a controller of the same time, for example a ps4 controller so that games automatically display ps4 buttons if supported. diff --git a/include/Config.hpp b/include/Config.hpp index 88bc8f5..1445fbc 100644 --- a/include/Config.hpp +++ b/include/Config.hpp @@ -60,6 +60,9 @@ namespace gsr { bool overclock = false; bool record_cursor = true; bool restore_portal_session = true; + + bool show_notifications = true; + bool use_led_indicator = false; }; struct MainConfig { @@ -93,8 +96,6 @@ namespace gsr { struct StreamingConfig { RecordOptions record_options; - bool show_streaming_started_notifications = true; - bool show_streaming_stopped_notifications = true; std::string streaming_service = "twitch"; YoutubeStreamConfig youtube; TwitchStreamConfig twitch; @@ -106,9 +107,6 @@ namespace gsr { struct RecordConfig { RecordOptions record_options; bool save_video_in_game_folder = false; - bool show_recording_started_notifications = true; - bool show_video_saved_notifications = true; - bool show_video_paused_notifications = true; std::string save_directory; std::string container = "mp4"; ConfigHotkey start_stop_hotkey; @@ -120,9 +118,6 @@ namespace gsr { std::string turn_on_replay_automatically_mode = "dont_turn_on_automatically"; bool save_video_in_game_folder = false; bool restart_replay_on_save = false; - bool show_replay_started_notifications = true; - bool show_replay_stopped_notifications = true; - bool show_replay_saved_notifications = true; std::string save_directory; std::string container = "mp4"; int32_t replay_time = 60; @@ -145,7 +140,8 @@ namespace gsr { bool save_screenshot_in_game_folder = false; bool save_screenshot_to_clipboard = false; - bool show_screenshot_saved_notifications = true; + bool show_notifications = true; + bool use_led_indicator = false; std::string save_directory; ConfigHotkey take_screenshot_hotkey; ConfigHotkey take_screenshot_region_hotkey; diff --git a/include/LedIndicator.hpp b/include/LedIndicator.hpp new file mode 100644 index 0000000..f7bb77b --- /dev/null +++ b/include/LedIndicator.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include +#include + +namespace gsr { + class LedIndicator { + public: + LedIndicator(Display *dpy); + LedIndicator(const LedIndicator&) = delete; + LedIndicator& operator=(const LedIndicator&) = delete; + ~LedIndicator(); + + void set_led(bool enabled); + void blink(); + void update(); + private: + void update_led(bool new_state); + private: + Display *dpy = nullptr; + Atom scroll_lock_atom = None; + bool led_indicator_on = false; + bool led_enabled = false; + bool perform_blink = false; + mgl::Clock blink_timer; + }; +} \ No newline at end of file diff --git a/include/Overlay.hpp b/include/Overlay.hpp index 44745ad..b5a902f 100644 --- a/include/Overlay.hpp +++ b/include/Overlay.hpp @@ -11,6 +11,7 @@ #include "RegionSelector.hpp" #include "WindowSelector.hpp" #include "ClipboardFile.hpp" +#include "LedIndicator.hpp" #include "CursorTracker/CursorTracker.hpp" #include @@ -235,7 +236,7 @@ namespace gsr { std::unique_ptr global_hotkeys = nullptr; std::unique_ptr global_hotkeys_js = nullptr; - Display *x11_mapping_display = nullptr; + Display *x11_dpy = nullptr; XEvent x11_mapping_xev; mgl::Clock replay_save_clock; @@ -269,5 +270,7 @@ namespace gsr { bool hide_ui = false; double notification_duration_multiplier = 1.0; ClipboardFile clipboard_file; + + std::unique_ptr led_indicator = nullptr; }; } \ No newline at end of file diff --git a/include/gui/ScreenshotSettingsPage.hpp b/include/gui/ScreenshotSettingsPage.hpp index 8dd1e44..52f86c5 100644 --- a/include/gui/ScreenshotSettingsPage.hpp +++ b/include/gui/ScreenshotSettingsPage.hpp @@ -43,8 +43,9 @@ namespace gsr { std::unique_ptr create_file_info_section(); std::unique_ptr create_save_screenshot_in_game_folder(); std::unique_ptr create_save_screenshot_to_clipboard(); + std::unique_ptr create_notifications(); + std::unique_ptr create_led_indicator(); std::unique_ptr create_general_section(); - std::unique_ptr create_notifications_section(); std::unique_ptr create_settings(); void add_widgets(); @@ -71,7 +72,8 @@ namespace gsr { Button *save_directory_button_ptr = nullptr; CheckBox *save_screenshot_in_game_folder_checkbox_ptr = nullptr; CheckBox *save_screenshot_to_clipboard_checkbox_ptr = nullptr; - CheckBox *show_screenshot_saved_notification_checkbox_ptr = nullptr; + CheckBox *show_notification_checkbox_ptr = nullptr; + CheckBox *led_indicator_checkbox_ptr = nullptr; PageStack *page_stack = nullptr; }; diff --git a/include/gui/SettingsPage.hpp b/include/gui/SettingsPage.hpp index f3af3c8..872d760 100644 --- a/include/gui/SettingsPage.hpp +++ b/include/gui/SettingsPage.hpp @@ -112,6 +112,8 @@ namespace gsr { std::unique_ptr create_save_recording_in_game_folder(); std::unique_ptr