aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GlobalHotkeysJoystick.cpp55
-rw-r--r--src/Overlay.cpp15
-rw-r--r--src/gui/GlobalSettingsPage.cpp5
3 files changed, 57 insertions, 18 deletions
diff --git a/src/GlobalHotkeysJoystick.cpp b/src/GlobalHotkeysJoystick.cpp
index dfe1e6f..2a33738 100644
--- a/src/GlobalHotkeysJoystick.cpp
+++ b/src/GlobalHotkeysJoystick.cpp
@@ -6,7 +6,12 @@
#include <sys/eventfd.h>
namespace gsr {
- static constexpr double double_click_timeout_seconds = 0.33;
+ static constexpr int button_pressed = 1;
+ static constexpr int playstation_button = 10;
+ static constexpr int x_button = 0;
+ static constexpr int circle_button = 1;
+ static constexpr int triangle_button = 2;
+ static constexpr int square_button = 3;
// Returns -1 on error
static int get_js_dev_input_id_from_filepath(const char *dev_input_filepath) {
@@ -99,6 +104,27 @@ namespace gsr {
if(it != bound_actions_by_id.end())
it->second("save_replay");
}
+
+ if(take_screenshot) {
+ take_screenshot = false;
+ auto it = bound_actions_by_id.find("take_screenshot");
+ if(it != bound_actions_by_id.end())
+ it->second("take_screenshot");
+ }
+
+ if(toggle_record) {
+ toggle_record = false;
+ auto it = bound_actions_by_id.find("toggle_record");
+ if(it != bound_actions_by_id.end())
+ it->second("toggle_record");
+ }
+
+ if(toggle_replay) {
+ toggle_replay = false;
+ auto it = bound_actions_by_id.find("toggle_replay");
+ if(it != bound_actions_by_id.end())
+ it->second("toggle_replay");
+ }
}
void GlobalHotkeysJoystick::read_events() {
@@ -156,22 +182,17 @@ namespace gsr {
if((event.type & JS_EVENT_BUTTON) == 0)
return;
- if(event.number == 8 && event.value == 1) {
- const double now = double_click_clock.get_elapsed_time_seconds();
- if(!prev_time_clicked.has_value()) {
- prev_time_clicked = now;
- return;
- }
-
- if(prev_time_clicked.has_value()) {
- const bool double_clicked = (now - prev_time_clicked.value()) < double_click_timeout_seconds;
- if(double_clicked) {
- save_replay = true;
- prev_time_clicked.reset();
- } else {
- prev_time_clicked = now;
- }
- }
+ if(event.number == playstation_button) {
+ playstation_button_pressed = event.value == button_pressed;
+ } else if(playstation_button_pressed && event.value == button_pressed) {
+ if(event.number == circle_button)
+ save_replay = true;
+ else if(event.number == triangle_button)
+ take_screenshot = true;
+ else if(event.number == square_button)
+ toggle_record = true;
+ else if(event.number == x_button)
+ toggle_replay = true;
}
}
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index 1147cc7..63f9822 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -339,6 +339,21 @@ namespace gsr {
overlay->save_replay();
});
+ global_hotkeys_js->bind_action("take_screenshot", [overlay](const std::string &id) {
+ fprintf(stderr, "pressed %s\n", id.c_str());
+ overlay->take_screenshot();
+ });
+
+ global_hotkeys_js->bind_action("toggle_record", [overlay](const std::string &id) {
+ fprintf(stderr, "pressed %s\n", id.c_str());
+ overlay->toggle_record();
+ });
+
+ global_hotkeys_js->bind_action("toggle_replay", [overlay](const std::string &id) {
+ fprintf(stderr, "pressed %s\n", id.c_str());
+ overlay->toggle_replay();
+ });
+
return global_hotkeys_js;
}
diff --git a/src/gui/GlobalSettingsPage.cpp b/src/gui/GlobalSettingsPage.cpp
index 0abb4f9..82baa86 100644
--- a/src/gui/GlobalSettingsPage.cpp
+++ b/src/gui/GlobalSettingsPage.cpp
@@ -340,7 +340,10 @@ namespace gsr {
list_ptr->add_widget(create_record_hotkey_options());
list_ptr->add_widget(create_stream_hotkey_options());
list_ptr->add_widget(create_screenshot_hotkey_options());
- list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Double-click the controller share button to save a replay", get_color_theme().text_color));
+ list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Press the PlayStation button and square to start/stop recording", get_color_theme().text_color));
+ list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Press the PlayStation button and X to start/stop replay", get_color_theme().text_color));
+ list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Press the PlayStation button and circle to save a replay", get_color_theme().text_color));
+ list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Press the PlayStation button and triangle to take a screenshot", get_color_theme().text_color));
list_ptr->add_widget(create_hotkey_control_buttons());
return subsection;
}