mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-04-08 12:24:52 +09:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f505323d56 | ||
|
|
309cc3425b | ||
|
|
81cb8f539f | ||
|
|
5214fb1d7f | ||
|
|
9aebe81ec4 | ||
|
|
d73bd68a70 | ||
|
|
3cb156aecb | ||
|
|
dea4393588 | ||
|
|
269d55d7eb | ||
|
|
c04e6a87e6 | ||
|
|
d8acac6ba9 | ||
|
|
010d4dd5aa | ||
|
|
e1397c1c97 | ||
|
|
aed169aa40 | ||
|
|
c396a1f922 | ||
|
|
f036fcbc0f |
@@ -31,7 +31,7 @@ These are the dependencies needed to build GPU Screen Recorder UI:
|
||||
## Runtime dependencies
|
||||
There are also additional dependencies needed at runtime:
|
||||
|
||||
* [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/) (version 5.0.0 or greater)
|
||||
* [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/) (version 5.0.0 or later)
|
||||
* [GPU Screen Recorder Notification](https://git.dec05eba.com/gpu-screen-recorder-notification/)
|
||||
|
||||
## Program behavior notes
|
||||
@@ -39,14 +39,14 @@ This program has to grab all keyboards and create a virtual keyboard (`gsr-ui vi
|
||||
This might cause issues for you if you use input remapping software. To workaround this you can go into settings and select "Only grab virtual devices"
|
||||
|
||||
# License
|
||||
This software is licensed under GPL3.0-only. Files under `fonts/` directory belong to the Noto Sans Google fonts project and they are licensed under `SIL Open Font License`.
|
||||
This software is licensed under GPL3.0-only. Files under `fonts/` directory belong to the Noto Sans Google fonts project and they are licensed under `SIL Open Font License`. `images/default.cur` it part of the [Adwaita icon theme](https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/tree/master) which is licensed under `Creative Commons Attribution-Share Alike 3.0`.
|
||||
|
||||
# Demo
|
||||
[](https://www.youtube.com/watch?v=SOqXusCTXXA)
|
||||
|
||||
# Screenshots
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
# Donations
|
||||
If you want to donate you can donate via bitcoin or monero.
|
||||
|
||||
7
TODO
7
TODO
@@ -107,4 +107,9 @@ When adding window capture only add it to recording and streaming and do the win
|
||||
|
||||
Show an error that prime run will be disabled when using desktop portal capture option. This can cause issues as the user may have selected a video codec option that isn't available on their iGPU but is available on the prime-run dGPU.
|
||||
|
||||
Is it possible to configure hotkey and the new hotkey to get triggered immediately?
|
||||
Is it possible to configure hotkey and the new hotkey to get triggered immediately?
|
||||
|
||||
For keyboards that report supporting mice the keyboard grab will be delayed until any key has been pressed (and then released), see: https://github.com/dec05eba/gpu-screen-recorder-issues/issues/97
|
||||
See if there is any way around this.
|
||||
|
||||
Instead of installing gsr-global-hotkeys in flatpak use kms-server-proxy to launch gsr-global-hotkeys inside the flatpak with root, just like gsr-kms-server. This removes the need to update gsr-global-hotkeys everytime there is an update.
|
||||
|
||||
BIN
images/default.cur
Normal file
BIN
images/default.cur
Normal file
Binary file not shown.
@@ -90,6 +90,7 @@ namespace gsr {
|
||||
RecordOptions record_options;
|
||||
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;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <mglpp/system/vec.hpp>
|
||||
|
||||
@@ -24,6 +25,21 @@ namespace gsr {
|
||||
mgl::vec2i size;
|
||||
};
|
||||
|
||||
struct GsrVersion {
|
||||
uint8_t major = 0;
|
||||
uint8_t minor = 0;
|
||||
uint8_t patch = 0;
|
||||
|
||||
bool operator>(const GsrVersion &other) const;
|
||||
bool operator>=(const GsrVersion &other) const;
|
||||
bool operator<(const GsrVersion &other) const;
|
||||
bool operator<=(const GsrVersion &other) const;
|
||||
bool operator==(const GsrVersion &other) const;
|
||||
bool operator!=(const GsrVersion &other) const;
|
||||
|
||||
std::string to_string() const;
|
||||
};
|
||||
|
||||
struct SupportedCaptureOptions {
|
||||
bool window = false;
|
||||
bool focused = false;
|
||||
@@ -40,6 +56,7 @@ namespace gsr {
|
||||
struct SystemInfo {
|
||||
DisplayServer display_server = DisplayServer::UNKNOWN;
|
||||
bool supports_app_audio = false;
|
||||
GsrVersion gsr_version;
|
||||
};
|
||||
|
||||
enum class GpuVendor {
|
||||
|
||||
@@ -92,5 +92,6 @@ namespace gsr {
|
||||
ConfigureHotkeyType configure_hotkey_type = ConfigureHotkeyType::NONE;
|
||||
|
||||
CustomRendererWidget *hotkey_overlay_ptr = nullptr;
|
||||
std::string hotkey_configure_action_name;
|
||||
};
|
||||
}
|
||||
@@ -97,6 +97,7 @@ namespace gsr {
|
||||
std::unique_ptr<List> create_replay_time();
|
||||
std::unique_ptr<RadioButton> create_start_replay_automatically();
|
||||
std::unique_ptr<CheckBox> create_save_replay_in_game_folder();
|
||||
std::unique_ptr<CheckBox> create_restart_replay_on_save();
|
||||
std::unique_ptr<Label> create_estimated_replay_file_size();
|
||||
void update_estimated_replay_file_size();
|
||||
std::unique_ptr<CheckBox> create_save_recording_in_game_folder();
|
||||
@@ -170,6 +171,7 @@ namespace gsr {
|
||||
List *stream_url_list_ptr = nullptr;
|
||||
List *container_list_ptr = nullptr;
|
||||
CheckBox *save_replay_in_game_folder_ptr = nullptr;
|
||||
CheckBox *restart_replay_on_save = nullptr;
|
||||
Label *estimated_file_size_ptr = nullptr;
|
||||
CheckBox *show_replay_started_notification_checkbox_ptr = nullptr;
|
||||
CheckBox *show_replay_stopped_notification_checkbox_ptr = nullptr;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
project('gsr-ui', ['c', 'cpp'], version : '1.1.0', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends')
|
||||
project('gsr-ui', ['c', 'cpp'], version : '1.1.5', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends')
|
||||
|
||||
if get_option('buildtype') == 'debug'
|
||||
add_project_arguments('-g3', language : ['c', 'cpp'])
|
||||
@@ -52,7 +52,7 @@ datadir = get_option('datadir')
|
||||
gsr_ui_resources_path = join_paths(prefix, datadir, 'gsr-ui')
|
||||
|
||||
add_project_arguments('-DGSR_UI_VERSION="' + meson.project_version() + '"', language: ['c', 'cpp'])
|
||||
add_project_arguments('-DGSR_FLATPAK_VERSION="5.1.0"', language: ['c', 'cpp'])
|
||||
add_project_arguments('-DGSR_FLATPAK_VERSION="5.1.2"', language: ['c', 'cpp'])
|
||||
|
||||
executable(
|
||||
meson.project_name(),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "gsr-ui"
|
||||
type = "executable"
|
||||
version = "1.1.0"
|
||||
version = "1.1.5"
|
||||
platforms = ["posix"]
|
||||
|
||||
[lang.cpp]
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <limits.h>
|
||||
#include <inttypes.h>
|
||||
#include <libgen.h>
|
||||
#include <iostream>
|
||||
#include <mglpp/window/Keyboard.hpp>
|
||||
|
||||
#define FORMAT_I32 "%" PRIi32
|
||||
@@ -149,6 +148,7 @@ namespace gsr {
|
||||
{"replay.record_options.restore_portal_session", &config.replay_config.record_options.restore_portal_session},
|
||||
{"replay.turn_on_replay_automatically_mode", &config.replay_config.turn_on_replay_automatically_mode},
|
||||
{"replay.save_video_in_game_folder", &config.replay_config.save_video_in_game_folder},
|
||||
{"replay.restart_replay_on_save", &config.replay_config.restart_replay_on_save},
|
||||
{"replay.show_replay_started_notifications", &config.replay_config.show_replay_started_notifications},
|
||||
{"replay.show_replay_stopped_notifications", &config.replay_config.show_replay_stopped_notifications},
|
||||
{"replay.show_replay_saved_notifications", &config.replay_config.show_replay_saved_notifications},
|
||||
|
||||
@@ -84,6 +84,8 @@ namespace gsr {
|
||||
}
|
||||
|
||||
bool GlobalHotkeysJoystick::bind_action(const std::string &id, GlobalHotkeyCallback callback) {
|
||||
if(num_poll_fd == 0)
|
||||
return false;
|
||||
return bound_actions_by_id.insert(std::make_pair(id, std::move(callback))).second;
|
||||
}
|
||||
|
||||
|
||||
@@ -166,6 +166,9 @@ namespace gsr {
|
||||
}
|
||||
|
||||
bool GlobalHotkeysLinux::bind_key_press(Hotkey hotkey, const std::string &id, GlobalHotkeyCallback callback) {
|
||||
if(process_id <= 0)
|
||||
return false;
|
||||
|
||||
if(bound_actions_by_id.find(id) != bound_actions_by_id.end())
|
||||
return false;
|
||||
|
||||
@@ -202,6 +205,9 @@ namespace gsr {
|
||||
}
|
||||
|
||||
void GlobalHotkeysLinux::unbind_all_keys() {
|
||||
if(process_id <= 0)
|
||||
return;
|
||||
|
||||
if(bound_actions_by_id.empty())
|
||||
return;
|
||||
|
||||
|
||||
@@ -6,6 +6,93 @@
|
||||
#include <string.h>
|
||||
|
||||
namespace gsr {
|
||||
bool GsrVersion::operator>(const GsrVersion &other) const {
|
||||
return major > other.major || (major == other.major && minor > other.minor) || (major == other.major && minor == other.minor && patch > other.patch);
|
||||
}
|
||||
|
||||
bool GsrVersion::operator>=(const GsrVersion &other) const {
|
||||
return major >= other.major || (major == other.major && minor >= other.minor) || (major == other.major && minor == other.minor && patch >= other.patch);
|
||||
}
|
||||
|
||||
bool GsrVersion::operator<(const GsrVersion &other) const {
|
||||
return !operator>=(other);
|
||||
}
|
||||
|
||||
bool GsrVersion::operator<=(const GsrVersion &other) const {
|
||||
return !operator>(other);
|
||||
}
|
||||
|
||||
bool GsrVersion::operator==(const GsrVersion &other) const {
|
||||
return major == other.major && minor == other.minor && patch == other.patch;
|
||||
}
|
||||
|
||||
bool GsrVersion::operator!=(const GsrVersion &other) const {
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
std::string GsrVersion::to_string() const {
|
||||
std::string result;
|
||||
if(major == 0 && minor == 0 && patch == 0)
|
||||
result = "Unknown";
|
||||
else
|
||||
result = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Returns -1 on error */
|
||||
static int parse_u8(const char *str, int size) {
|
||||
if(size <= 0)
|
||||
return -1;
|
||||
|
||||
int result = 0;
|
||||
for(int i = 0; i < size; ++i) {
|
||||
char c = str[i];
|
||||
if(c >= '0' && c <= '9') {
|
||||
result = result * 10 + (c - '0');
|
||||
if(result > 255)
|
||||
return -1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static GsrVersion parse_gsr_version(const std::string_view str) {
|
||||
GsrVersion result;
|
||||
uint8_t numbers[3];
|
||||
int number_index = 0;
|
||||
|
||||
size_t index = 0;
|
||||
while(true) {
|
||||
size_t next_index = str.find('.', index);
|
||||
if(next_index == std::string::npos)
|
||||
next_index = str.size();
|
||||
|
||||
const int number = parse_u8(str.data() + index, next_index - index);
|
||||
if(number == -1) {
|
||||
fprintf(stderr, "Error: gpu-screen-recorder --info contains invalid gsr version: %.*s\n", (int)str.size(), str.data());
|
||||
return {0, 0, 0};
|
||||
}
|
||||
|
||||
if(number_index >= 3) {
|
||||
fprintf(stderr, "Error: gpu-screen-recorder --info contains invalid gsr version: %.*s\n", (int)str.size(), str.data());
|
||||
return {0, 0, 0};
|
||||
}
|
||||
|
||||
numbers[number_index] = number;
|
||||
++number_index;
|
||||
index = next_index + 1;
|
||||
if(next_index == str.size())
|
||||
break;
|
||||
}
|
||||
|
||||
result.major = numbers[0];
|
||||
result.minor = numbers[1];
|
||||
result.patch = numbers[2];
|
||||
return result;
|
||||
}
|
||||
|
||||
static std::optional<KeyValue> parse_key_value(std::string_view line) {
|
||||
const size_t space_index = line.find('|');
|
||||
if(space_index == std::string_view::npos)
|
||||
@@ -25,6 +112,8 @@ namespace gsr {
|
||||
gsr_info->system_info.display_server = DisplayServer::WAYLAND;
|
||||
} else if(key_value->key == "supports_app_audio") {
|
||||
gsr_info->system_info.supports_app_audio = key_value->value == "yes";
|
||||
} else if(key_value->key == "gsr_version") {
|
||||
gsr_info->system_info.gsr_version = parse_gsr_version(key_value->value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -772,9 +772,32 @@ namespace gsr {
|
||||
if(cursor_size <= 1)
|
||||
cursor_size = 24;
|
||||
|
||||
XcursorImage *cursor_image = XcursorShapeLoadImage(XC_left_ptr, cursor_theme, cursor_size);
|
||||
XcursorImage *cursor_image = nullptr;
|
||||
for(int cursor_size_test : {cursor_size, 24}) {
|
||||
for(const char *cursor_theme_test : {cursor_theme, "default", "Adwaita"}) {
|
||||
for(unsigned int shape : {XC_left_ptr, XC_arrow}) {
|
||||
cursor_image = XcursorShapeLoadImage(shape, cursor_theme_test, cursor_size_test);
|
||||
if(cursor_image)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
if(!cursor_image) {
|
||||
fprintf(stderr, "Error: failed to get cursor, loading bundled default cursor instead\n");
|
||||
const std::string default_cursor_path = resources_path + "images/default.cur";
|
||||
for(int cursor_size_test : {cursor_size, 24}) {
|
||||
cursor_image = XcursorFilenameLoadImage(default_cursor_path.c_str(), cursor_size_test);
|
||||
if(cursor_image)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!cursor_image) {
|
||||
fprintf(stderr, "Error: failed to get cursor\n");
|
||||
XFixesShowCursor(xi_display, DefaultRootWindow(xi_display));
|
||||
XFlush(xi_display);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1866,6 +1889,11 @@ namespace gsr {
|
||||
"-o", output_directory.c_str()
|
||||
};
|
||||
|
||||
if(config.replay_config.restart_replay_on_save && gsr_info.system_info.gsr_version >= GsrVersion{5, 0, 3}) {
|
||||
args.push_back("-restart-replay-on-save");
|
||||
args.push_back("yes");
|
||||
}
|
||||
|
||||
add_common_gpu_screen_recorder_args(args, config.replay_config.record_options, audio_tracks, video_bitrate, region, audio_tracks_merged);
|
||||
|
||||
args.push_back(nullptr);
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace gsr {
|
||||
{
|
||||
if(icon_texture && icon_texture->is_valid()) {
|
||||
icon_sprite.set_texture(icon_texture);
|
||||
icon_sprite.set_height((int)(size.y * 0.5f));
|
||||
icon_sprite.set_height((int)(size.y * 0.45f));
|
||||
}
|
||||
this->description.set_color(mgl::Color(150, 150, 150));
|
||||
}
|
||||
@@ -242,4 +242,4 @@ namespace gsr {
|
||||
update_if_dirty();
|
||||
return size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ extern "C" {
|
||||
#include <mglpp/graphics/Text.hpp>
|
||||
|
||||
#ifndef GSR_UI_VERSION
|
||||
#define GSR_UI_VERSION "unknown"
|
||||
#define GSR_UI_VERSION "Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef GSR_FLATPAK_VERSION
|
||||
#define GSR_FLATPAK_VERSION "unknown"
|
||||
#define GSR_FLATPAK_VERSION "Unknown"
|
||||
#endif
|
||||
|
||||
namespace gsr {
|
||||
@@ -132,7 +132,7 @@ namespace gsr {
|
||||
if(!configure_hotkey_button)
|
||||
return;
|
||||
|
||||
mgl::Text title_text("Press a key combination to use for the hotkey \"Start/stop recording\":", get_theme().title_font);
|
||||
mgl::Text title_text("Press a key combination to use for the hotkey \"" + hotkey_configure_action_name + "\":", get_theme().title_font);
|
||||
mgl::Text hotkey_text(configure_hotkey_button->get_text(), get_theme().top_bar_font);
|
||||
mgl::Text description_text("The hotkey has to contain one or more of these keys: Alt, Ctrl, Shift and Super. Press Esc to cancel.", get_theme().body_font);
|
||||
const float text_max_width = std::max(title_text.get_bounds().size.x, std::max(hotkey_text.get_bounds().size.x, description_text.get_bounds().size.x));
|
||||
@@ -153,11 +153,14 @@ namespace gsr {
|
||||
title_text.set_position(mgl::vec2f(bg_rect.get_position() + mgl::vec2f(bg_rect.get_size().x*0.5f - title_text.get_bounds().size.x*0.5f, padding_vertical)).floor());
|
||||
window.draw(title_text);
|
||||
|
||||
//const float description_bottom = description_text.get_position().y + description_text.get_bounds().size.y;
|
||||
//const float remaining_height = (bg_rect.get_position().y + bg_rect.get_size().y) - description_bottom;
|
||||
hotkey_text.set_position(mgl::vec2f(bg_rect.get_position() + bg_rect.get_size()*0.5f - hotkey_text.get_bounds().size*0.5f).floor());
|
||||
window.draw(hotkey_text);
|
||||
|
||||
const float caret_padding_x = int(0.001f * get_theme().window_height);
|
||||
const mgl::vec2f caret_size = mgl::vec2f(std::max(2.0f, 0.002f * get_theme().window_height), hotkey_text.get_bounds().size.y).floor();
|
||||
mgl::Rectangle caret_rect(hotkey_text.get_position() + mgl::vec2f(hotkey_text.get_bounds().size.x + caret_padding_x, hotkey_text.get_bounds().size.y*0.5f - caret_size.y*0.5f).floor(), caret_size);
|
||||
window.draw(caret_rect);
|
||||
|
||||
description_text.set_position(mgl::vec2f(bg_rect.get_position() + mgl::vec2f(bg_rect.get_size().x*0.5f - description_text.get_bounds().size.x*0.5f, bg_rect.get_size().y - description_text.get_bounds().size.y - padding_vertical)).floor());
|
||||
window.draw(description_text);
|
||||
};
|
||||
@@ -253,7 +256,6 @@ namespace gsr {
|
||||
configure_hotkey_start(ConfigureHotkeyType::SHOW_HIDE);
|
||||
};
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -403,7 +405,11 @@ namespace gsr {
|
||||
auto list = std::make_unique<List>(List::Orientation::VERTICAL);
|
||||
|
||||
char str[128];
|
||||
snprintf(str, sizeof(str), "UI version: %s", GSR_UI_VERSION);
|
||||
const std::string gsr_version = gsr_info->system_info.gsr_version.to_string();
|
||||
snprintf(str, sizeof(str), "GSR version: %s", gsr_version.c_str());
|
||||
list->add_widget(std::make_unique<Label>(&get_theme().body_font, str, get_color_theme().text_color));
|
||||
|
||||
snprintf(str, sizeof(str), "GSR-UI version: %s", GSR_UI_VERSION);
|
||||
list->add_widget(std::make_unique<Label>(&get_theme().body_font, str, get_color_theme().text_color));
|
||||
|
||||
if(inside_flatpak) {
|
||||
@@ -577,6 +583,31 @@ namespace gsr {
|
||||
content_page_ptr->set_visible(false);
|
||||
hotkey_overlay_ptr->set_visible(true);
|
||||
overlay->unbind_all_keyboard_hotkeys();
|
||||
configure_hotkey_get_button_by_active_type()->set_text("");
|
||||
|
||||
switch(hotkey_type) {
|
||||
case ConfigureHotkeyType::NONE:
|
||||
hotkey_configure_action_name = "";
|
||||
break;
|
||||
case ConfigureHotkeyType::REPLAY_START_STOP:
|
||||
hotkey_configure_action_name = "Turn replay on/off";
|
||||
break;
|
||||
case ConfigureHotkeyType::REPLAY_SAVE:
|
||||
hotkey_configure_action_name = "Save replay";
|
||||
break;
|
||||
case ConfigureHotkeyType::RECORD_START_STOP:
|
||||
hotkey_configure_action_name = "Start/stop recording";
|
||||
break;
|
||||
case ConfigureHotkeyType::RECORD_PAUSE_UNPAUSE:
|
||||
hotkey_configure_action_name = "Pause/unpause recording";
|
||||
break;
|
||||
case ConfigureHotkeyType::STREAM_START_STOP:
|
||||
hotkey_configure_action_name = "Start/stop streaming";
|
||||
break;
|
||||
case ConfigureHotkeyType::SHOW_HIDE:
|
||||
hotkey_configure_action_name = "Show/hide UI";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalSettingsPage::configure_hotkey_cancel() {
|
||||
@@ -619,4 +650,4 @@ namespace gsr {
|
||||
hotkey_overlay_ptr->set_visible(false);
|
||||
overlay->rebind_all_keyboard_hotkeys();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,6 +664,12 @@ namespace gsr {
|
||||
return checkbox;
|
||||
}
|
||||
|
||||
std::unique_ptr<CheckBox> SettingsPage::create_restart_replay_on_save() {
|
||||
auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Restart replay on save");
|
||||
restart_replay_on_save = checkbox.get();
|
||||
return checkbox;
|
||||
}
|
||||
|
||||
std::unique_ptr<Label> SettingsPage::create_estimated_replay_file_size() {
|
||||
auto label = std::make_unique<Label>(&get_theme().body_font, "Estimated video max file size in RAM: 57.60MB", get_color_theme().text_color);
|
||||
estimated_file_size_ptr = label.get();
|
||||
@@ -693,6 +699,8 @@ namespace gsr {
|
||||
auto general_list = std::make_unique<List>(List::Orientation::VERTICAL);
|
||||
general_list->add_widget(create_start_replay_automatically());
|
||||
general_list->add_widget(create_save_replay_in_game_folder());
|
||||
if(gsr_info->system_info.gsr_version >= GsrVersion{5, 0, 3})
|
||||
general_list->add_widget(create_restart_replay_on_save());
|
||||
settings_list_ptr->add_widget(std::make_unique<Subsection>("General", std::move(general_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
|
||||
|
||||
auto checkboxes_list = std::make_unique<List>(List::Orientation::VERTICAL);
|
||||
@@ -1065,6 +1073,8 @@ namespace gsr {
|
||||
load_common(config.replay_config.record_options);
|
||||
turn_on_replay_automatically_mode_ptr->set_selected_item(config.replay_config.turn_on_replay_automatically_mode);
|
||||
save_replay_in_game_folder_ptr->set_checked(config.replay_config.save_video_in_game_folder);
|
||||
if(restart_replay_on_save)
|
||||
restart_replay_on_save->set_checked(config.replay_config.restart_replay_on_save);
|
||||
show_replay_started_notification_checkbox_ptr->set_checked(config.replay_config.show_replay_started_notifications);
|
||||
show_replay_stopped_notification_checkbox_ptr->set_checked(config.replay_config.show_replay_stopped_notifications);
|
||||
show_replay_saved_notification_checkbox_ptr->set_checked(config.replay_config.show_replay_saved_notifications);
|
||||
@@ -1193,6 +1203,8 @@ namespace gsr {
|
||||
save_common(config.replay_config.record_options);
|
||||
config.replay_config.turn_on_replay_automatically_mode = turn_on_replay_automatically_mode_ptr->get_selected_id();
|
||||
config.replay_config.save_video_in_game_folder = save_replay_in_game_folder_ptr->is_checked();
|
||||
if(restart_replay_on_save)
|
||||
config.replay_config.restart_replay_on_save = restart_replay_on_save->is_checked();
|
||||
config.replay_config.show_replay_started_notifications = show_replay_started_notification_checkbox_ptr->is_checked();
|
||||
config.replay_config.show_replay_stopped_notifications = show_replay_stopped_notification_checkbox_ptr->is_checked();
|
||||
config.replay_config.show_replay_saved_notifications = show_replay_saved_notification_checkbox_ptr->is_checked();
|
||||
|
||||
@@ -81,19 +81,19 @@ static void keyboard_event_fetch_update_key_states(keyboard_event *self, event_e
|
||||
}
|
||||
}
|
||||
|
||||
static void keyboard_event_process_key_state_change(keyboard_event *self, struct input_event event, event_extra_data *extra_data, int fd) {
|
||||
if(event.type != EV_KEY)
|
||||
static void keyboard_event_process_key_state_change(keyboard_event *self, const struct input_event *event, event_extra_data *extra_data, int fd) {
|
||||
if(event->type != EV_KEY)
|
||||
return;
|
||||
|
||||
if(!extra_data->key_states || event.code >= KEY_STATES_SIZE * 8)
|
||||
if(!extra_data->key_states || event->code >= KEY_STATES_SIZE * 8)
|
||||
return;
|
||||
|
||||
const unsigned int byte_index = event.code / 8;
|
||||
const unsigned char bit_index = event.code % 8;
|
||||
const unsigned int byte_index = event->code / 8;
|
||||
const unsigned char bit_index = event->code % 8;
|
||||
unsigned char key_byte_state = extra_data->key_states[byte_index];
|
||||
const bool prev_key_pressed = (key_byte_state & (1 << bit_index)) != KEY_RELEASE;
|
||||
|
||||
if(event.value == KEY_RELEASE) {
|
||||
if(event->value == KEY_RELEASE) {
|
||||
key_byte_state &= ~(1 << bit_index);
|
||||
if(prev_key_pressed)
|
||||
--extra_data->num_keys_pressed;
|
||||
@@ -154,6 +154,12 @@ static uint32_t keycode_to_modifier_bit(uint32_t keycode) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool key_is_mouse_button(uint32_t keycode) {
|
||||
return (keycode >= BTN_MISC && keycode <= BTN_GEAR_UP)
|
||||
|| (keycode >= BTN_TRIGGER_HAPPY && keycode <= BTN_TRIGGER_HAPPY40)
|
||||
|| (keycode >= BTN_DPAD_UP && keycode <= BTN_DPAD_RIGHT);
|
||||
}
|
||||
|
||||
static void keyboard_event_process_input_event_data(keyboard_event *self, event_extra_data *extra_data, int fd) {
|
||||
struct input_event event;
|
||||
if(read(fd, &event, sizeof(event)) != sizeof(event)) {
|
||||
@@ -171,8 +177,8 @@ static void keyboard_event_process_input_event_data(keyboard_event *self, event_
|
||||
//fprintf(stderr, "fd: %d, type: %d, pressed %d, value: %d\n", fd, event.type, event.code, event.value);
|
||||
//}
|
||||
|
||||
if(event.type == EV_KEY) {
|
||||
keyboard_event_process_key_state_change(self, event, extra_data, fd);
|
||||
if(event.type == EV_KEY && !key_is_mouse_button(event.code)) {
|
||||
keyboard_event_process_key_state_change(self, &event, extra_data, fd);
|
||||
const uint32_t modifier_bit = keycode_to_modifier_bit(event.code);
|
||||
if(modifier_bit == 0) {
|
||||
if(keyboard_event_on_key_pressed(self, &event, self->modifier_button_states))
|
||||
@@ -286,7 +292,7 @@ static bool keyboard_event_try_add_device_if_keyboard(keyboard_event *self, cons
|
||||
|
||||
unsigned long evbit = 0;
|
||||
ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), &evbit);
|
||||
const bool is_keyboard = evbit & (1 << EV_KEY);
|
||||
const bool is_keyboard = (evbit & (1 << EV_SYN)) && (evbit & (1 << EV_KEY)) && (evbit & (1 << EV_MSC)) && (evbit & (1 << EV_REP));
|
||||
|
||||
if(is_keyboard && strcmp(device_name, GSR_UI_VIRTUAL_KEYBOARD_NAME) != 0) {
|
||||
unsigned char key_bits[KEY_MAX/8 + 1] = {0};
|
||||
@@ -297,7 +303,7 @@ static bool keyboard_event_try_add_device_if_keyboard(keyboard_event *self, cons
|
||||
//const bool supports_touch_events = key_bits[BTN_TOUCH/8] & (1 << (BTN_TOUCH % 8));
|
||||
const bool supports_joystick_events = key_bits[BTN_JOYSTICK/8] & (1 << (BTN_JOYSTICK % 8));
|
||||
const bool supports_wheel_events = key_bits[BTN_WHEEL/8] & (1 << (BTN_WHEEL % 8));
|
||||
if(supports_key_events && !supports_mouse_events && !supports_joystick_events && !supports_wheel_events) {
|
||||
if(supports_key_events && !supports_joystick_events && !supports_wheel_events) {
|
||||
unsigned char *key_states = calloc(1, KEY_STATES_SIZE);
|
||||
if(key_states && self->num_event_polls < MAX_EVENT_POLLS) {
|
||||
//fprintf(stderr, "%s (%s) supports key inputs\n", dev_input_filepath, device_name);
|
||||
@@ -314,9 +320,16 @@ static bool keyboard_event_try_add_device_if_keyboard(keyboard_event *self, cons
|
||||
.num_keys_pressed = 0
|
||||
};
|
||||
|
||||
keyboard_event_fetch_update_key_states(self, &self->event_extra_data[self->num_event_polls], fd);
|
||||
if(self->event_extra_data[self->num_event_polls].num_keys_pressed > 0)
|
||||
fprintf(stderr, "Info: device not grabbed yet because some keys are still being pressed: /dev/input/event%d\n", dev_input_id);
|
||||
if(supports_mouse_events) {
|
||||
fprintf(stderr, "Info: device not grabbed yet because it might be a mouse: /dev/input/event%d\n", dev_input_id);
|
||||
fsync(fd);
|
||||
if(ioctl(fd, EVIOCGKEY(KEY_STATES_SIZE), self->event_extra_data[self->num_event_polls].key_states) == -1)
|
||||
fprintf(stderr, "Warning: failed to fetch key states for device: /dev/input/event%d\n", dev_input_id);
|
||||
} else {
|
||||
keyboard_event_fetch_update_key_states(self, &self->event_extra_data[self->num_event_polls], fd);
|
||||
if(self->event_extra_data[self->num_event_polls].num_keys_pressed > 0)
|
||||
fprintf(stderr, "Info: device not grabbed yet because some keys are still being pressed: /dev/input/event%d\n", dev_input_id);
|
||||
}
|
||||
|
||||
++self->num_event_polls;
|
||||
return true;
|
||||
@@ -389,14 +402,20 @@ static int setup_virtual_keyboard_input(const char *name) {
|
||||
success &= (ioctl(fd, UI_SET_EVBIT, EV_SYN) != -1);
|
||||
success &= (ioctl(fd, UI_SET_EVBIT, EV_MSC) != -1);
|
||||
success &= (ioctl(fd, UI_SET_EVBIT, EV_KEY) != -1);
|
||||
success &= (ioctl(fd, UI_SET_EVBIT, EV_REP) != -1);
|
||||
success &= (ioctl(fd, UI_SET_EVBIT, EV_REL) != -1);
|
||||
success &= (ioctl(fd, UI_SET_EVBIT, EV_LED) != -1);
|
||||
|
||||
success &= (ioctl(fd, UI_SET_MSCBIT, MSC_SCAN) != -1);
|
||||
for(int i = 1; i < KEY_MAX; ++i) {
|
||||
success &= (ioctl(fd, UI_SET_KEYBIT, i) != -1);
|
||||
}
|
||||
|
||||
success &= (ioctl(fd, UI_SET_EVBIT, EV_REL) != -1);
|
||||
success &= (ioctl(fd, UI_SET_RELBIT, REL_X) != -1);
|
||||
success &= (ioctl(fd, UI_SET_RELBIT, REL_Y) != -1);
|
||||
success &= (ioctl(fd, UI_SET_RELBIT, REL_Z) != -1);
|
||||
for(int i = 0; i < REL_MAX; ++i) {
|
||||
success &= (ioctl(fd, UI_SET_RELBIT, i) != -1);
|
||||
}
|
||||
for(int i = 0; i < LED_MAX; ++i) {
|
||||
success &= (ioctl(fd, UI_SET_LEDBIT, i) != -1);
|
||||
}
|
||||
|
||||
// success &= (ioctl(fd, UI_SET_EVBIT, EV_ABS) != -1);
|
||||
// success &= (ioctl(fd, UI_SET_ABSBIT, ABS_X) != -1);
|
||||
@@ -638,13 +657,13 @@ static void keyboard_event_parse_stdin_command(keyboard_event *self, const char
|
||||
.modifiers = modifiers
|
||||
};
|
||||
++self->num_global_hotkeys;
|
||||
fprintf(stderr, "Info: bound hotkey: %s\n", action);
|
||||
fprintf(stderr, "Info: binded hotkey: %s\n", action);
|
||||
} else if(strncmp(command, "unbind_all", 10) == 0) {
|
||||
for(int i = 0; i < self->num_global_hotkeys; ++i) {
|
||||
free(self->global_hotkeys[i].action);
|
||||
}
|
||||
self->num_global_hotkeys = 0;
|
||||
fprintf(stderr, "Info: unbound all hotkeys\n");
|
||||
fprintf(stderr, "Info: unbinded all hotkeys\n");
|
||||
} else {
|
||||
fprintf(stderr, "Warning: got invalid command: \"%s\", expected command to start with either \"bind\" or \"unbind_all\"\n", command);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user