mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Add controller hotkey to show/hide ui
This commit is contained in:
@@ -40,7 +40,7 @@ This might cause issues for you if you use input remapping software. To workarou
|
|||||||
# License
|
# 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 `CC BY-SA 3.0`.\
|
`images/default.cur` it part of the [Adwaita icon theme](https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/tree/master) which is licensed under `CC BY-SA 3.0`.\
|
||||||
The D-Pad images under `images/` were created by [Julio Cacko](https://juliocacko.itch.io/free-input-prompts) and they are licensed under `CC0 1.0 Universal`.\
|
The controller buttons under `images/` were created by [Julio Cacko](https://juliocacko.itch.io/free-input-prompts) and they are licensed under `CC0 1.0 Universal`.\
|
||||||
The PlayStation logo under `images/` was created by [ArksDigital](https://arks.itch.io/ps4-buttons) and it's are licensed under `CC BY 4.0`.
|
The PlayStation logo under `images/` was created by [ArksDigital](https://arks.itch.io/ps4-buttons) and it's are licensed under `CC BY 4.0`.
|
||||||
|
|
||||||
# Reporting bugs, contributing patches, questions or donation
|
# Reporting bugs, contributing patches, questions or donation
|
||||||
|
|||||||
BIN
images/ps4_options.png
Normal file
BIN
images/ps4_options.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 801 B |
@@ -24,6 +24,7 @@ namespace gsr {
|
|||||||
// take_screenshot
|
// take_screenshot
|
||||||
// toggle_record
|
// toggle_record
|
||||||
// toggle_replay
|
// toggle_replay
|
||||||
|
// toggle_show
|
||||||
bool bind_action(const std::string &id, GlobalHotkeyCallback callback) override;
|
bool bind_action(const std::string &id, GlobalHotkeyCallback callback) override;
|
||||||
void poll_events() override;
|
void poll_events() override;
|
||||||
private:
|
private:
|
||||||
@@ -58,6 +59,7 @@ namespace gsr {
|
|||||||
bool take_screenshot = false;
|
bool take_screenshot = false;
|
||||||
bool toggle_record = false;
|
bool toggle_record = false;
|
||||||
bool toggle_replay = false;
|
bool toggle_replay = false;
|
||||||
|
bool toggle_show = false;
|
||||||
int hotplug_poll_index = -1;
|
int hotplug_poll_index = -1;
|
||||||
Hotplug hotplug;
|
Hotplug hotplug;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ namespace gsr {
|
|||||||
mgl::Texture screenshot_texture;
|
mgl::Texture screenshot_texture;
|
||||||
|
|
||||||
mgl::Texture ps4_home_texture;
|
mgl::Texture ps4_home_texture;
|
||||||
|
mgl::Texture ps4_options_texture;
|
||||||
mgl::Texture ps4_dpad_up_texture;
|
mgl::Texture ps4_dpad_up_texture;
|
||||||
mgl::Texture ps4_dpad_down_texture;
|
mgl::Texture ps4_dpad_down_texture;
|
||||||
mgl::Texture ps4_dpad_left_texture;
|
mgl::Texture ps4_dpad_left_texture;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
namespace gsr {
|
namespace gsr {
|
||||||
static constexpr int button_pressed = 1;
|
static constexpr int button_pressed = 1;
|
||||||
|
static constexpr int options_button = 9;
|
||||||
static constexpr int playstation_button = 10;
|
static constexpr int playstation_button = 10;
|
||||||
static constexpr int axis_up_down = 7;
|
static constexpr int axis_up_down = 7;
|
||||||
static constexpr int axis_left_right = 6;
|
static constexpr int axis_left_right = 6;
|
||||||
@@ -123,6 +124,13 @@ namespace gsr {
|
|||||||
if(it != bound_actions_by_id.end())
|
if(it != bound_actions_by_id.end())
|
||||||
it->second("toggle_replay");
|
it->second("toggle_replay");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(toggle_show) {
|
||||||
|
toggle_show = false;
|
||||||
|
auto it = bound_actions_by_id.find("toggle_show");
|
||||||
|
if(it != bound_actions_by_id.end())
|
||||||
|
it->second("toggle_show");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalHotkeysJoystick::read_events() {
|
void GlobalHotkeysJoystick::read_events() {
|
||||||
@@ -180,12 +188,15 @@ namespace gsr {
|
|||||||
if((event.type & JS_EVENT_BUTTON) == JS_EVENT_BUTTON) {
|
if((event.type & JS_EVENT_BUTTON) == JS_EVENT_BUTTON) {
|
||||||
if(event.number == playstation_button)
|
if(event.number == playstation_button)
|
||||||
playstation_button_pressed = event.value == button_pressed;
|
playstation_button_pressed = event.value == button_pressed;
|
||||||
|
else if(event.number == options_button && event.value == button_pressed)
|
||||||
|
toggle_show = true;
|
||||||
} else if((event.type & JS_EVENT_AXIS) == JS_EVENT_AXIS && playstation_button_pressed) {
|
} else if((event.type & JS_EVENT_AXIS) == JS_EVENT_AXIS && playstation_button_pressed) {
|
||||||
const int trigger_threshold = 16383;
|
const int trigger_threshold = 16383;
|
||||||
const bool prev_up_pressed = up_pressed;
|
const bool prev_up_pressed = up_pressed;
|
||||||
const bool prev_down_pressed = down_pressed;
|
const bool prev_down_pressed = down_pressed;
|
||||||
const bool prev_left_pressed = left_pressed;
|
const bool prev_left_pressed = left_pressed;
|
||||||
const bool prev_right_pressed = right_pressed;
|
const bool prev_right_pressed = right_pressed;
|
||||||
|
|
||||||
if(event.number == axis_up_down) {
|
if(event.number == axis_up_down) {
|
||||||
up_pressed = event.value <= -trigger_threshold;
|
up_pressed = event.value <= -trigger_threshold;
|
||||||
down_pressed = event.value >= trigger_threshold;
|
down_pressed = event.value >= trigger_threshold;
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ namespace gsr {
|
|||||||
static void bind_linux_hotkeys(GlobalHotkeysLinux *global_hotkeys, Overlay *overlay) {
|
static void bind_linux_hotkeys(GlobalHotkeysLinux *global_hotkeys, Overlay *overlay) {
|
||||||
global_hotkeys->bind_key_press(
|
global_hotkeys->bind_key_press(
|
||||||
config_hotkey_to_hotkey(overlay->get_config().main_config.show_hide_hotkey),
|
config_hotkey_to_hotkey(overlay->get_config().main_config.show_hide_hotkey),
|
||||||
"show_hide", [overlay](const std::string &id) {
|
"toggle_show", [overlay](const std::string &id) {
|
||||||
fprintf(stderr, "pressed %s\n", id.c_str());
|
fprintf(stderr, "pressed %s\n", id.c_str());
|
||||||
overlay->toggle_show();
|
overlay->toggle_show();
|
||||||
});
|
});
|
||||||
@@ -334,6 +334,11 @@ namespace gsr {
|
|||||||
if(!global_hotkeys_js->start())
|
if(!global_hotkeys_js->start())
|
||||||
fprintf(stderr, "Warning: failed to start joystick hotkeys\n");
|
fprintf(stderr, "Warning: failed to start joystick hotkeys\n");
|
||||||
|
|
||||||
|
global_hotkeys_js->bind_action("toggle_show", [overlay](const std::string &id) {
|
||||||
|
fprintf(stderr, "pressed %s\n", id.c_str());
|
||||||
|
overlay->toggle_show();
|
||||||
|
});
|
||||||
|
|
||||||
global_hotkeys_js->bind_action("save_replay", [overlay](const std::string &id) {
|
global_hotkeys_js->bind_action("save_replay", [overlay](const std::string &id) {
|
||||||
fprintf(stderr, "pressed %s\n", id.c_str());
|
fprintf(stderr, "pressed %s\n", id.c_str());
|
||||||
overlay->save_replay();
|
overlay->save_replay();
|
||||||
|
|||||||
@@ -117,6 +117,9 @@ namespace gsr {
|
|||||||
if(!theme->ps4_home_texture.load_from_file((resources_path + "images/ps4_home.png").c_str(), mgl::Texture::LoadOptions{false, false, true}))
|
if(!theme->ps4_home_texture.load_from_file((resources_path + "images/ps4_home.png").c_str(), mgl::Texture::LoadOptions{false, false, true}))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if(!theme->ps4_options_texture.load_from_file((resources_path + "images/ps4_options.png").c_str(), mgl::Texture::LoadOptions{false, false, true}))
|
||||||
|
goto error;
|
||||||
|
|
||||||
if(!theme->ps4_dpad_up_texture.load_from_file((resources_path + "images/ps4_dpad_up.png").c_str(), mgl::Texture::LoadOptions{false, false, true}))
|
if(!theme->ps4_dpad_up_texture.load_from_file((resources_path + "images/ps4_dpad_up.png").c_str(), mgl::Texture::LoadOptions{false, false, true}))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|||||||
@@ -363,6 +363,7 @@ namespace gsr {
|
|||||||
list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Enable controller hotkeys?", get_color_theme().text_color));
|
list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Enable controller hotkeys?", get_color_theme().text_color));
|
||||||
list_ptr->add_widget(create_enable_joystick_hotkeys_button());
|
list_ptr->add_widget(create_enable_joystick_hotkeys_button());
|
||||||
list_ptr->add_widget(std::make_unique<LineSeparator>(LineSeparator::Orientation::HORIZONTAL, subsection->get_inner_size().x));
|
list_ptr->add_widget(std::make_unique<LineSeparator>(LineSeparator::Orientation::HORIZONTAL, subsection->get_inner_size().x));
|
||||||
|
list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_options_texture, get_theme().body_font.get_character_size(), "to show/hide the UI"));
|
||||||
list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_up_texture, get_theme().body_font.get_character_size(), "to take a screenshot"));
|
list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_up_texture, get_theme().body_font.get_character_size(), "to take a screenshot"));
|
||||||
list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_down_texture, get_theme().body_font.get_character_size(), "to save a replay"));
|
list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_down_texture, get_theme().body_font.get_character_size(), "to save a replay"));
|
||||||
list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_left_texture, get_theme().body_font.get_character_size(), "to start/stop recording"));
|
list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_left_texture, get_theme().body_font.get_character_size(), "to start/stop recording"));
|
||||||
|
|||||||
Reference in New Issue
Block a user