Add Button Shortcut Configuration

This commit is contained in:
Lorenzooone 2024-06-09 19:10:46 +02:00
parent 495682d651
commit 21dc761796
17 changed files with 986 additions and 79 deletions

View File

@ -140,7 +140,7 @@ file(MAKE_DIRECTORY ${TOOLS_DATA_DIR})
set(OUTPUT_NAME cc3dsfs)
add_executable(CMakeBin2C tools/bin2c.cpp)
add_executable(${OUTPUT_NAME} source/cc3dsfs.cpp source/utils.cpp source/audio_data.cpp source/audio.cpp source/frontend.cpp source/TextRectangle.cpp source/WindowScreen.cpp source/WindowScreen_Menu.cpp source/3dscapture.cpp source/conversions.cpp source/ExtraButtons.cpp source/Menus/ConnectionMenu.cpp source/Menus/OptionSelectionMenu.cpp source/Menus/MainMenu.cpp source/Menus/VideoMenu.cpp source/Menus/CropMenu.cpp source/Menus/PARMenu.cpp source/Menus/RotationMenu.cpp source/Menus/OffsetMenu.cpp source/Menus/AudioMenu.cpp source/Menus/BFIMenu.cpp source/Menus/RelativePositionMenu.cpp source/Menus/ResolutionMenu.cpp source/Menus/FileConfigMenu.cpp source/Menus/ExtraSettingsMenu.cpp source/Menus/StatusMenu.cpp source/Menus/LicenseMenu.cpp ${TOOLS_DATA_DIR}/font_ttf.cpp)
add_executable(${OUTPUT_NAME} source/cc3dsfs.cpp source/utils.cpp source/audio_data.cpp source/audio.cpp source/frontend.cpp source/TextRectangle.cpp source/WindowScreen.cpp source/WindowScreen_Menu.cpp source/3dscapture.cpp source/conversions.cpp source/ExtraButtons.cpp source/Menus/ConnectionMenu.cpp source/Menus/OptionSelectionMenu.cpp source/Menus/MainMenu.cpp source/Menus/VideoMenu.cpp source/Menus/CropMenu.cpp source/Menus/PARMenu.cpp source/Menus/RotationMenu.cpp source/Menus/OffsetMenu.cpp source/Menus/AudioMenu.cpp source/Menus/BFIMenu.cpp source/Menus/RelativePositionMenu.cpp source/Menus/ResolutionMenu.cpp source/Menus/FileConfigMenu.cpp source/Menus/ExtraSettingsMenu.cpp source/Menus/StatusMenu.cpp source/Menus/LicenseMenu.cpp source/WindowCommands.cpp source/Menus/ShortcutMenu.cpp source/Menus/ActionSelectionMenu.cpp ${TOOLS_DATA_DIR}/font_ttf.cpp)
add_dependencies(${OUTPUT_NAME} FTD3XX_BUILD_PROJECT CMakeBin2C)
target_link_libraries(${OUTPUT_NAME} PRIVATE sfml-graphics sfml-audio sfml-window sfml-system ${ftd3xx_BINARY_DIR}/${FTD3XX_SUBFOLDER}/${FTD3XX_LIB} ${EXTRA_LIBRARIES})
target_link_directories(${OUTPUT_NAME} PRIVATE ${ftd3xx_BINARY_DIR}/${FTD3XX_SUBFOLDER})

View File

@ -9,7 +9,9 @@
class ExtraButton {
public:
void initialize(int id, sf::Keyboard::Key corresponding_key, bool is_power, float first_re_press_time, float later_re_press_time, bool use_pud_up);
void initialize(int id, sf::Keyboard::Key corresponding_key, bool is_power, float first_re_press_time, float later_re_press_time, bool use_pud_up, std::string name);
std::string get_name();
bool is_button_x(sf::Keyboard::Key corresponding_key);
void poll(std::queue<SFEvent> &events_queue);
void end();
private:
@ -23,6 +25,7 @@ private:
float later_re_press_time;
std::chrono::time_point<std::chrono::high_resolution_clock> last_press_time;
bool is_time_valid;
std::string name;
#ifdef RASPI
gpiod_line *gpioline_ptr;
#endif

View File

@ -0,0 +1,31 @@
#ifndef __ACTIONSELECTIONMENU_HPP
#define __ACTIONSELECTIONMENU_HPP
#include "OptionSelectionMenu.hpp"
#include <chrono>
#include "TextRectangle.hpp"
#include "sfml_gfx_structs.hpp"
#include "display_structs.hpp"
#include "WindowCommands.hpp"
#define ACTION_SELECTION_MENU_NO_ACTION -1
#define ACTION_SELECTION_MENU_BACK -2
class ActionSelectionMenu : public OptionSelectionMenu {
public:
ActionSelectionMenu(bool font_load_success, sf::Font &text_font);
~ActionSelectionMenu();
void prepare(float scaling_factor, int view_size_x, int view_size_y, PossibleWindowCommands curr_cmd);
void insert_data(std::vector<const WindowCommand*> &possible_actions);
int selected_index = ACTION_SELECTION_MENU_NO_ACTION;
void reset_output_option();
protected:
void set_output_option(int index, int action);
int get_num_options();
std::string get_string_option(int index, int action);
void class_setup();
private:
std::vector<const WindowCommand*> *possible_actions;
};
#endif

View File

@ -23,6 +23,7 @@ enum MainMenuOutAction{
MAIN_MENU_LICENSES,
MAIN_MENU_EXTRA_SETTINGS,
MAIN_MENU_SHUTDOWN,
MAIN_MENU_SHORTCUT_SETTINGS,
};
class MainMenu : public OptionSelectionMenu {
@ -30,7 +31,7 @@ public:
MainMenu(bool font_load_success, sf::Font &text_font);
~MainMenu();
void prepare(float scaling_factor, int view_size_x, int view_size_y, bool connected);
void insert_data(ScreenType s_type, bool is_fullscreen, bool mono_app_mode);
void insert_data(ScreenType s_type, bool is_fullscreen, bool mono_app_mode, bool enable_shortcuts);
MainMenuOutAction selected_index = MainMenuOutAction::MAIN_MENU_NO_ACTION;
void reset_output_option();
protected:

30
include/Menus/ShortcutMenu.hpp Executable file
View File

@ -0,0 +1,30 @@
#ifndef __SHORTCUTMENU_HPP
#define __SHORTCUTMENU_HPP
#include "OptionSelectionMenu.hpp"
#include <chrono>
#include "TextRectangle.hpp"
#include "sfml_gfx_structs.hpp"
#include "display_structs.hpp"
#define SHORTCUT_MENU_NO_ACTION -1
#define SHORTCUT_MENU_BACK -2
class ShortcutMenu : public OptionSelectionMenu {
public:
ShortcutMenu(bool font_load_success, sf::Font &text_font);
~ShortcutMenu();
void prepare(float scaling_factor, int view_size_x, int view_size_y);
void insert_data(std::vector<std::string> &shortcut_names);
int selected_index = SHORTCUT_MENU_NO_ACTION;
void reset_output_option();
protected:
void set_output_option(int index, int action);
int get_num_options();
std::string get_string_option(int index, int action);
void class_setup();
private:
std::vector<std::string> *shortcut_names;
};
#endif

64
include/WindowCommands.hpp Executable file
View File

@ -0,0 +1,64 @@
#ifndef __WINDOWCOMMANDS_HPP
#define __WINDOWCOMMANDS_HPP
#include "utils.hpp"
#include <vector>
#include <string>
enum PossibleWindowCommands {
WINDOW_COMMAND_NONE = 0,
WINDOW_COMMAND_CONNECT,
WINDOW_COMMAND_SPLIT,
WINDOW_COMMAND_FULLSCREEN,
WINDOW_COMMAND_CROP,
WINDOW_COMMAND_ASYNC,
WINDOW_COMMAND_VSYNC,
WINDOW_COMMAND_MENU_SCALING_INC,
WINDOW_COMMAND_MENU_SCALING_DEC,
WINDOW_COMMAND_WINDOW_SCALING_INC,
WINDOW_COMMAND_WINDOW_SCALING_DEC,
WINDOW_COMMAND_RATIO_CYCLE,
WINDOW_COMMAND_RATIO_TOP,
WINDOW_COMMAND_RATIO_BOT,
WINDOW_COMMAND_BLUR,
WINDOW_COMMAND_TRANSPOSE,
WINDOW_COMMAND_SCREEN_OFFSET,
WINDOW_COMMAND_SUB_SCREEN_DISTANCE,
WINDOW_COMMAND_CANVAS_X,
WINDOW_COMMAND_CANVAS_Y,
WINDOW_COMMAND_ROT_INC,
WINDOW_COMMAND_ROT_DEC,
WINDOW_COMMAND_ROT_TOP_INC,
WINDOW_COMMAND_ROT_TOP_DEC,
WINDOW_COMMAND_ROT_BOT_INC,
WINDOW_COMMAND_ROT_BOT_DEC,
WINDOW_COMMAND_PADDING,
WINDOW_COMMAND_TOP_PAR,
WINDOW_COMMAND_BOT_PAR,
WINDOW_COMMAND_AUDIO_MUTE,
WINDOW_COMMAND_VOLUME_INC,
WINDOW_COMMAND_VOLUME_DEC,
WINDOW_COMMAND_AUDIO_RESTART,
WINDOW_COMMAND_LOAD_PROFILE_STARTUP,
WINDOW_COMMAND_LOAD_PROFILE_1,
WINDOW_COMMAND_LOAD_PROFILE_2,
WINDOW_COMMAND_LOAD_PROFILE_3,
WINDOW_COMMAND_LOAD_PROFILE_4,
WINDOW_COMMAND_SAVE_PROFILE_STARTUP,
WINDOW_COMMAND_SAVE_PROFILE_1,
WINDOW_COMMAND_SAVE_PROFILE_2,
WINDOW_COMMAND_SAVE_PROFILE_3,
WINDOW_COMMAND_SAVE_PROFILE_4,
};
struct WindowCommand {
PossibleWindowCommands cmd;
std::string name;
bool usable_always;
bool available_mono_extra;
};
const WindowCommand* get_window_command(PossibleWindowCommands cmd);
void create_window_commands_list(std::vector<const WindowCommand*> &list_to_fill, bool is_mono_extra);
#endif

View File

@ -6,7 +6,7 @@
enum ScreenType { TOP, BOTTOM, JOINT };
enum BottomRelativePosition { UNDER_TOP, LEFT_TOP, ABOVE_TOP, RIGHT_TOP, BOT_REL_POS_END };
enum CurrMenuType { DEFAULT_MENU_TYPE, CONNECT_MENU_TYPE, MAIN_MENU_TYPE, VIDEO_MENU_TYPE, AUDIO_MENU_TYPE, CROP_MENU_TYPE, TOP_PAR_MENU_TYPE, BOTTOM_PAR_MENU_TYPE, ROTATION_MENU_TYPE, OFFSET_MENU_TYPE, BFI_MENU_TYPE, LOAD_MENU_TYPE, SAVE_MENU_TYPE, RESOLUTION_MENU_TYPE, EXTRA_MENU_TYPE, STATUS_MENU_TYPE, LICENSES_MENU_TYPE, RELATIVE_POS_MENU_TYPE };
enum CurrMenuType { DEFAULT_MENU_TYPE, CONNECT_MENU_TYPE, MAIN_MENU_TYPE, VIDEO_MENU_TYPE, AUDIO_MENU_TYPE, CROP_MENU_TYPE, TOP_PAR_MENU_TYPE, BOTTOM_PAR_MENU_TYPE, ROTATION_MENU_TYPE, OFFSET_MENU_TYPE, BFI_MENU_TYPE, LOAD_MENU_TYPE, SAVE_MENU_TYPE, RESOLUTION_MENU_TYPE, EXTRA_MENU_TYPE, STATUS_MENU_TYPE, LICENSES_MENU_TYPE, RELATIVE_POS_MENU_TYPE, SHORTCUTS_MENU_TYPE, ACTION_SELECTION_MENU_TYPE };
struct ScreenInfo {
bool is_blurred;

View File

@ -27,7 +27,10 @@
#include "ExtraSettingsMenu.hpp"
#include "StatusMenu.hpp"
#include "LicenseMenu.hpp"
#include "ShortcutMenu.hpp"
#include "ActionSelectionMenu.hpp"
#include "display_structs.hpp"
#include "WindowCommands.hpp"
struct HeldTime {
std::chrono::time_point<std::chrono::high_resolution_clock> start_time;
@ -39,11 +42,16 @@ struct FPSArray {
int index;
};
struct ExtraButtonShortcuts {
const WindowCommand *enter_shortcut;
const WindowCommand *page_up_shortcut;
};
class WindowScreen {
public:
ScreenInfo m_info;
WindowScreen(ScreenType stype, CaptureStatus* capture_status, DisplayData* display_data, AudioData* audio_data);
WindowScreen(ScreenType stype, CaptureStatus* capture_status, DisplayData* display_data, AudioData* audio_data, ExtraButtonShortcuts* extra_button_shortcuts);
~WindowScreen();
void build();
@ -97,6 +105,7 @@ private:
double frame_time;
DisplayData* display_data;
AudioData* audio_data;
ExtraButtonShortcuts* extra_button_shortcuts;
std::chrono::time_point<std::chrono::high_resolution_clock> last_mouse_action_time;
std::chrono::time_point<std::chrono::high_resolution_clock> last_window_creation_time;
HeldTime touch_right_click_action;
@ -129,10 +138,17 @@ private:
ExtraSettingsMenu *extra_menu;
StatusMenu *status_menu;
LicenseMenu *license_menu;
ShortcutMenu *shortcut_menu;
ActionSelectionMenu *action_selection_menu;
std::vector<const CropData*> possible_crops;
std::vector<const PARData*> possible_pars;
std::vector<sf::VideoMode> possible_resolutions;
std::vector<FileData> possible_files;
std::vector<std::string> possible_buttons_names;
std::vector<const WindowCommand **> possible_buttons_ptrs;
std::vector<bool> possible_buttons_extras;
int chosen_button;
std::vector<const WindowCommand*> possible_actions;
FPSArray in_fps;
FPSArray draw_fps;
std::chrono::time_point<std::chrono::high_resolution_clock> last_draw_time;
@ -180,6 +196,8 @@ private:
void print_notification_on_off(std::string base_text, bool value);
void print_notification_float(std::string base_text, float value, int decimals);
void set_close(int ret_val);
bool can_execute_cmd(const WindowCommand* window_cmd, bool is_extra, bool is_always);
bool execute_cmd(PossibleWindowCommands id);
void split_change();
void fullscreen_change();
void async_change();
@ -237,6 +255,8 @@ private:
void setup_fileconfig_menu(bool is_save, bool reset_data = true);
void setup_resolution_menu(bool reset_data = true);
void setup_extra_menu(bool reset_data = true);
void setup_shortcuts_menu(bool reset_data = true);
void setup_action_selection_menu(bool reset_data = true);
void setup_status_menu(bool reset_data = true);
void setup_licenses_menu(bool reset_data = true);
void setup_relative_pos_menu(bool reset_data = true);

View File

@ -35,5 +35,6 @@ JoystickAction get_joystick_action(uint32_t joystickId, uint32_t joy_button);
void init_extra_buttons_poll(int page_up_id, int page_down_id, int enter_id, int power_id, bool use_pud_up);
void end_extra_buttons_poll();
void extra_buttons_poll(std::queue<SFEvent> &events_queue);
std::string get_extra_button_name(sf::Keyboard::Key corresponding_key);
#endif

View File

@ -1,8 +1,9 @@
#include "ExtraButtons.hpp"
static ExtraButton pi_page_up, pi_page_down, pi_enter, pi_power;
static ExtraButton* pi_buttons[] = {&pi_page_up, &pi_page_down, &pi_enter, &pi_power};
void ExtraButton::initialize(int id, sf::Keyboard::Key corresponding_key, bool is_power, float first_re_press_time, float later_re_press_time, bool use_pud_up) {
void ExtraButton::initialize(int id, sf::Keyboard::Key corresponding_key, bool is_power, float first_re_press_time, float later_re_press_time, bool use_pud_up, std::string name) {
this->id = id;
this->is_power = is_power;
this->corresponding_key = corresponding_key;
@ -12,6 +13,7 @@ void ExtraButton::initialize(int id, sf::Keyboard::Key corresponding_key, bool i
this->last_press_time = std::chrono::high_resolution_clock::now();
this->first_re_press_time = first_re_press_time;
this->later_re_press_time = later_re_press_time;
this->name = name;
#ifdef RASPI
if(this->id >= 0) {
std::string gpio_str = "GPIO" + std::to_string(this->id);
@ -48,6 +50,16 @@ bool ExtraButton::is_pressed() {
return false;
}
std::string ExtraButton::get_name() {
if(this->is_valid())
return this->name;
return "";
}
bool ExtraButton::is_button_x(sf::Keyboard::Key corresponding_key) {
return this->is_valid() && this->corresponding_key == corresponding_key;
}
bool ExtraButton::is_valid() {
#ifdef RASPI
return this->initialized && (this->id >= 0) && this->gpioline_ptr;
@ -86,23 +98,26 @@ void ExtraButton::poll(std::queue<SFEvent> &events_queue) {
events_queue.emplace(event_kind, this->corresponding_key, 0, 0, 0, sf::Joystick::Axis::X, 0, sf::Mouse::Left, 0, 0, this->is_power, true);
}
std::string get_extra_button_name(sf::Keyboard::Key corresponding_key) {
for(int i = 0; i < sizeof(pi_buttons) / sizeof(pi_buttons[0]); i++)
if(pi_buttons[i]->is_button_x(corresponding_key))
return pi_buttons[i]->get_name();
return "";
}
void init_extra_buttons_poll(int page_up_id, int page_down_id, int enter_id, int power_id, bool use_pud_up) {
pi_page_up.initialize(page_up_id, sf::Keyboard::PageUp, false, 0.5, 0.03, use_pud_up);
pi_page_down.initialize(page_down_id, sf::Keyboard::PageDown, false, 0.5, 0.03, use_pud_up);
pi_enter.initialize(enter_id, sf::Keyboard::Enter, false, 0.5, 0.075, use_pud_up);
pi_power.initialize(power_id, sf::Keyboard::Escape, true, 30.0, 30.0, use_pud_up);
pi_page_up.initialize(page_up_id, sf::Keyboard::PageUp, false, 0.5, 0.03, use_pud_up, "Select");
pi_page_down.initialize(page_down_id, sf::Keyboard::PageDown, false, 0.5, 0.03, use_pud_up, "Menu");
pi_enter.initialize(enter_id, sf::Keyboard::Enter, false, 0.5, 0.075, use_pud_up, "Enter");
pi_power.initialize(power_id, sf::Keyboard::Escape, true, 30.0, 30.0, use_pud_up, "Power");
}
void end_extra_buttons_poll() {
pi_page_up.end();
pi_page_down.end();
pi_enter.end();
pi_power.end();
for(int i = 0; i < sizeof(pi_buttons) / sizeof(pi_buttons[0]); i++)
pi_buttons[i]->end();
}
void extra_buttons_poll(std::queue<SFEvent> &events_queue) {
pi_page_down.poll(events_queue);
pi_page_up.poll(events_queue);
pi_enter.poll(events_queue);
pi_power.poll(events_queue);
for(int i = 0; i < sizeof(pi_buttons) / sizeof(pi_buttons[0]); i++)
pi_buttons[i]->poll(events_queue);
}

View File

@ -0,0 +1,68 @@
#include "ActionSelectionMenu.hpp"
ActionSelectionMenu::ActionSelectionMenu(bool font_load_success, sf::Font &text_font) : OptionSelectionMenu(){
this->initialize(font_load_success, text_font);
}
ActionSelectionMenu::~ActionSelectionMenu() {
}
void ActionSelectionMenu::class_setup() {
this->num_options_per_screen = 5;
this->min_elements_text_scaling_factor = num_options_per_screen + 2;
this->width_factor_menu = 16;
this->width_divisor_menu = 9;
this->base_height_factor_menu = 12;
this->base_height_divisor_menu = 6;
this->min_text_size = 0.3;
this->max_width_slack = 1.1;
this->menu_color = sf::Color(30, 30, 60, 192);
this->title = "Action Choice";
this->show_back_x = true;
this->show_x = false;
this->show_title = true;
}
void ActionSelectionMenu::insert_data(std::vector<const WindowCommand*> &possible_actions) {
this->possible_actions = &possible_actions;
this->prepare_options();
}
void ActionSelectionMenu::reset_output_option() {
this->selected_index = ACTION_SELECTION_MENU_NO_ACTION;
}
void ActionSelectionMenu::set_output_option(int index, int action) {
if(index >= this->get_num_options())
this->selected_index = ACTION_SELECTION_MENU_BACK;
else if(index == BACK_X_OUTPUT_OPTION)
this->selected_index = ACTION_SELECTION_MENU_BACK;
else
this->selected_index = index;
}
int ActionSelectionMenu::get_num_options() {
return this->possible_actions->size();
}
std::string ActionSelectionMenu::get_string_option(int index, int action) {
return (*this->possible_actions)[index]->name;
}
void ActionSelectionMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_y, PossibleWindowCommands curr_cmd) {
int num_pages = this->get_num_pages();
if(this->future_data.page >= num_pages)
this->future_data.page = num_pages - 1;
int start = this->future_data.page * this->num_options_per_screen;
for(int i = 0; i < this->num_options_per_screen + 1; i++) {
int index = (i * this->single_option_multiplier) + this->elements_start_id;
if(!this->future_enabled_labels[index])
continue;
int real_index = start + i;
if((*this->possible_actions)[real_index]->cmd == curr_cmd)
this->labels[index]->setText("<" + this->get_string_option(real_index, DEFAULT_ACTION) + ">");
else
this->labels[index]->setText(this->get_string_option(real_index, DEFAULT_ACTION));
}
this->base_prepare(menu_scaling_factor, view_size_x, view_size_y);
}

View File

@ -106,6 +106,13 @@ static const MainMenuOptionInfo extra_settings_option = {
.enabled_normal_mode = false, .enabled_mono_mode = true,
.out_action = MAIN_MENU_EXTRA_SETTINGS};
static const MainMenuOptionInfo shortcut_option = {
.base_name = "Shortcuts", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.enabled_normal_mode = true, .enabled_mono_mode = true,
.out_action = MAIN_MENU_SHORTCUT_SETTINGS};
static const MainMenuOptionInfo shutdown_option = {
.base_name = "Shutdown", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
@ -123,6 +130,7 @@ static const MainMenuOptionInfo* pollable_options[] = {
&audio_settings_option,
&save_profiles_option,
&load_profiles_option,
&shortcut_option,
&status_option,
&licenses_option,
&extra_settings_option,
@ -156,7 +164,7 @@ void MainMenu::class_setup() {
this->show_title = true;
}
void MainMenu::insert_data(ScreenType s_type, bool is_fullscreen, bool mono_app_mode) {
void MainMenu::insert_data(ScreenType s_type, bool is_fullscreen, bool mono_app_mode, bool enable_shortcut) {
this->num_enabled_options = 0;
for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) {
bool valid = true;
@ -174,6 +182,8 @@ void MainMenu::insert_data(ScreenType s_type, bool is_fullscreen, bool mono_app_
valid = valid && pollable_options[i]->enabled_mono_mode;
else
valid = valid && pollable_options[i]->enabled_normal_mode;
if((pollable_options[i]->out_action == MAIN_MENU_SHORTCUT_SETTINGS) && (!enable_shortcut))
valid = false;
if(valid) {
this->options_indexes[this->num_enabled_options] = i;
this->num_enabled_options++;

54
source/Menus/ShortcutMenu.cpp Executable file
View File

@ -0,0 +1,54 @@
#include "ShortcutMenu.hpp"
ShortcutMenu::ShortcutMenu(bool font_load_success, sf::Font &text_font) : OptionSelectionMenu(){
this->initialize(font_load_success, text_font);
}
ShortcutMenu::~ShortcutMenu() {
}
void ShortcutMenu::class_setup() {
this->num_options_per_screen = 5;
this->min_elements_text_scaling_factor = num_options_per_screen + 2;
this->width_factor_menu = 16;
this->width_divisor_menu = 9;
this->base_height_factor_menu = 12;
this->base_height_divisor_menu = 6;
this->min_text_size = 0.3;
this->max_width_slack = 1.1;
this->menu_color = sf::Color(30, 30, 60, 192);
this->title = "Shortcut Settings";
this->show_back_x = true;
this->show_x = false;
this->show_title = true;
}
void ShortcutMenu::insert_data(std::vector<std::string> &shortcut_names) {
this->shortcut_names = &shortcut_names;
this->prepare_options();
}
void ShortcutMenu::reset_output_option() {
this->selected_index = SHORTCUT_MENU_NO_ACTION;
}
void ShortcutMenu::set_output_option(int index, int action) {
if(index >= this->get_num_options())
this->selected_index = SHORTCUT_MENU_BACK;
else if(index == BACK_X_OUTPUT_OPTION)
this->selected_index = SHORTCUT_MENU_BACK;
else
this->selected_index = index;
}
int ShortcutMenu::get_num_options() {
return this->shortcut_names->size();
}
std::string ShortcutMenu::get_string_option(int index, int action) {
return (*this->shortcut_names)[index];
}
void ShortcutMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_y) {
this->base_prepare(menu_scaling_factor, view_size_x, view_size_y);
}

361
source/WindowCommands.cpp Executable file
View File

@ -0,0 +1,361 @@
#include "WindowCommands.hpp"
static const WindowCommand none_cmd = {
.cmd = WINDOW_COMMAND_NONE,
.name = "Nothing",
.usable_always = true,
.available_mono_extra = true,
};
static const WindowCommand connect_cmd = {
.cmd = WINDOW_COMMAND_CONNECT,
.name = "Connection",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand split_cmd = {
.cmd = WINDOW_COMMAND_SPLIT,
.name = "Split",
.usable_always = true,
.available_mono_extra = false,
};
static const WindowCommand fullscreen_cmd = {
.cmd = WINDOW_COMMAND_FULLSCREEN,
.name = "Fullscreen",
.usable_always = true,
.available_mono_extra = false,
};
static const WindowCommand crop_cmd = {
.cmd = WINDOW_COMMAND_CROP,
.name = "Crop",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand async_cmd = {
.cmd = WINDOW_COMMAND_ASYNC,
.name = "Async",
.usable_always = true,
.available_mono_extra = true,
};
static const WindowCommand vsync_cmd = {
.cmd = WINDOW_COMMAND_VSYNC,
.name = "VSync",
.usable_always = true,
.available_mono_extra = true,
};
static const WindowCommand menu_scaling_inc_cmd = {
.cmd = WINDOW_COMMAND_MENU_SCALING_INC,
.name = "Inc. Menu Scaling",
.usable_always = true,
.available_mono_extra = true,
};
static const WindowCommand menu_scaling_dec_cmd = {
.cmd = WINDOW_COMMAND_MENU_SCALING_DEC,
.name = "Dec. Menu Scaling",
.usable_always = true,
.available_mono_extra = true,
};
static const WindowCommand window_scaling_inc_cmd = {
.cmd = WINDOW_COMMAND_WINDOW_SCALING_INC,
.name = "Inc. Window Scaling",
.usable_always = true,
.available_mono_extra = true,
};
static const WindowCommand window_scaling_dec_cmd = {
.cmd = WINDOW_COMMAND_WINDOW_SCALING_DEC,
.name = "Dec. Window Scaling",
.usable_always = true,
.available_mono_extra = true,
};
static const WindowCommand ratio_cycle_cmd = {
.cmd = WINDOW_COMMAND_RATIO_CYCLE,
.name = "Cycle Screens Ratio",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand ratio_top_cmd = {
.cmd = WINDOW_COMMAND_RATIO_TOP,
.name = "Inc. Top Ratio",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand ratio_bot_cmd = {
.cmd = WINDOW_COMMAND_RATIO_BOT,
.name = "Inc. Bottom Ratio",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand blur_cmd = {
.cmd = WINDOW_COMMAND_BLUR,
.name = "Blur",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand transpose_cmd = {
.cmd = WINDOW_COMMAND_TRANSPOSE,
.name = "Screens Rel. Pos.",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand screen_offset_cmd = {
.cmd = WINDOW_COMMAND_SCREEN_OFFSET,
.name = "Screen Offset",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand sub_screen_distance_cmd = {
.cmd = WINDOW_COMMAND_SUB_SCREEN_DISTANCE,
.name = "Sub-Screen Distance",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand canvas_x_cmd = {
.cmd = WINDOW_COMMAND_CANVAS_X,
.name = "Canvas X Pos.",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand canvas_y_cmd = {
.cmd = WINDOW_COMMAND_CANVAS_Y,
.name = "Canvas Y Pos.",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand rot_inc_cmd = {
.cmd = WINDOW_COMMAND_ROT_INC,
.name = "Rotate Screens Right",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand rot_dec_cmd = {
.cmd = WINDOW_COMMAND_ROT_DEC,
.name = "Rotate Screens Left",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand rot_top_inc_cmd = {
.cmd = WINDOW_COMMAND_ROT_TOP_INC,
.name = "Rot. Top Screen Right",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand rot_top_dec_cmd = {
.cmd = WINDOW_COMMAND_ROT_TOP_DEC,
.name = "Rot. Top Screen Left",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand rot_bot_inc_cmd = {
.cmd = WINDOW_COMMAND_ROT_BOT_INC,
.name = "Rot. Bot. Screen Right",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand rot_bot_dec_cmd = {
.cmd = WINDOW_COMMAND_ROT_BOT_DEC,
.name = "Rot. Bot. Screen Left",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand padding_cmd = {
.cmd = WINDOW_COMMAND_PADDING,
.name = "Extra Padding",
.usable_always = false,
.available_mono_extra = false,
};
static const WindowCommand top_par_cmd = {
.cmd = WINDOW_COMMAND_TOP_PAR,
.name = "Top Screen PAR",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand bot_par_cmd = {
.cmd = WINDOW_COMMAND_BOT_PAR,
.name = "Bottom Screen PAR",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand audio_mute_cmd = {
.cmd = WINDOW_COMMAND_AUDIO_MUTE,
.name = "Mute Audio",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand volume_inc_cmd = {
.cmd = WINDOW_COMMAND_VOLUME_INC,
.name = "Increase Volume",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand volume_dec_cmd = {
.cmd = WINDOW_COMMAND_VOLUME_DEC,
.name = "Decrease Volume",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand audio_restart_cmd = {
.cmd = WINDOW_COMMAND_AUDIO_RESTART,
.name = "Restart Audio",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand load_startup_cmd = {
.cmd = WINDOW_COMMAND_LOAD_PROFILE_STARTUP,
.name = "Load Initial Profile",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand load_profile_1_cmd = {
.cmd = WINDOW_COMMAND_LOAD_PROFILE_1,
.name = "Load Profile 1",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand load_profile_2_cmd = {
.cmd = WINDOW_COMMAND_LOAD_PROFILE_2,
.name = "Load Profile 2",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand load_profile_3_cmd = {
.cmd = WINDOW_COMMAND_LOAD_PROFILE_3,
.name = "Load Profile 3",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand load_profile_4_cmd = {
.cmd = WINDOW_COMMAND_LOAD_PROFILE_4,
.name = "Load Profile 4",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand save_startup_cmd = {
.cmd = WINDOW_COMMAND_SAVE_PROFILE_STARTUP,
.name = "Save Initial Profile",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand save_profile_1_cmd = {
.cmd = WINDOW_COMMAND_SAVE_PROFILE_1,
.name = "Save Profile 1",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand save_profile_2_cmd = {
.cmd = WINDOW_COMMAND_SAVE_PROFILE_2,
.name = "Save Profile 2",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand save_profile_3_cmd = {
.cmd = WINDOW_COMMAND_SAVE_PROFILE_3,
.name = "Save Profile 3",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand save_profile_4_cmd = {
.cmd = WINDOW_COMMAND_SAVE_PROFILE_4,
.name = "Save Profile 4",
.usable_always = false,
.available_mono_extra = true,
};
static const WindowCommand* possible_cmds[] = {
&none_cmd,
&connect_cmd,
&split_cmd,
&fullscreen_cmd,
&crop_cmd,
&async_cmd,
&vsync_cmd,
&menu_scaling_inc_cmd,
&menu_scaling_dec_cmd,
&window_scaling_inc_cmd,
&window_scaling_dec_cmd,
&ratio_cycle_cmd,
&ratio_top_cmd,
&ratio_bot_cmd,
&blur_cmd,
&transpose_cmd,
&screen_offset_cmd,
&sub_screen_distance_cmd,
&canvas_x_cmd,
&canvas_y_cmd,
&rot_inc_cmd,
&rot_dec_cmd,
&rot_top_inc_cmd,
&rot_top_dec_cmd,
&rot_bot_inc_cmd,
&rot_bot_dec_cmd,
&padding_cmd,
&top_par_cmd,
&bot_par_cmd,
&audio_mute_cmd,
&volume_inc_cmd,
&volume_dec_cmd,
&audio_restart_cmd,
&load_startup_cmd,
&load_profile_1_cmd,
&load_profile_2_cmd,
&load_profile_3_cmd,
&load_profile_4_cmd,
&save_startup_cmd,
&save_profile_1_cmd,
&save_profile_2_cmd,
&save_profile_3_cmd,
&save_profile_4_cmd,
};
void create_window_commands_list(std::vector<const WindowCommand*> &list_to_fill, bool is_mono_extra) {
for(int i = 0; i < sizeof(possible_cmds) / sizeof(possible_cmds[0]); i++)
if(possible_cmds[i]->available_mono_extra || (!is_mono_extra))
list_to_fill.push_back(possible_cmds[i]);
}
const WindowCommand* get_window_command(PossibleWindowCommands cmd) {
for(int i = 0; i < sizeof(possible_cmds) / sizeof(possible_cmds[0]); i++)
if(possible_cmds[i]->cmd == cmd)
return possible_cmds[i];
return &none_cmd;
}

View File

@ -11,7 +11,7 @@
#define TOP_ROUNDED_PADDING 0
#define BOTTOM_ROUNDED_PADDING 5
WindowScreen::WindowScreen(ScreenType stype, CaptureStatus* capture_status, DisplayData* display_data, AudioData* audio_data) {
WindowScreen::WindowScreen(ScreenType stype, CaptureStatus* capture_status, DisplayData* display_data, AudioData* audio_data, ExtraButtonShortcuts* extra_button_shortcuts) {
this->m_stype = stype;
insert_basic_crops(this->possible_crops, this->m_stype);
insert_basic_pars(this->possible_pars);
@ -32,6 +32,7 @@ WindowScreen::WindowScreen(ScreenType stype, CaptureStatus* capture_status, Disp
this->m_in_rect_bot.setTexture(&this->in_tex);
this->display_data = display_data;
this->audio_data = audio_data;
this->extra_button_shortcuts = extra_button_shortcuts;
this->last_window_creation_time = std::chrono::high_resolution_clock::now();
this->last_mouse_action_time = std::chrono::high_resolution_clock::now();
this->last_draw_time = std::chrono::high_resolution_clock::now();

View File

@ -20,6 +20,10 @@ static float check_held_diff(std::chrono::time_point<std::chrono::high_resolutio
return diff.count();
}
static bool is_shortcut_valid() {
return (get_extra_button_name(sf::Keyboard::Enter) != "") || (get_extra_button_name(sf::Keyboard::PageUp) != "");
}
void FPSArrayInit(FPSArray *array) {
array->data = new double[FPS_WINDOW_SIZE];
array->index = 0;
@ -69,6 +73,8 @@ void WindowScreen::init_menus() {
this->extra_menu = new ExtraSettingsMenu(this->font_load_success, this->text_font);
this->status_menu = new StatusMenu(this->font_load_success, this->text_font);
this->license_menu = new LicenseMenu(this->font_load_success, this->text_font);
this->shortcut_menu = new ShortcutMenu(this->font_load_success, this->text_font);
this->action_selection_menu = new ActionSelectionMenu(this->font_load_success, this->text_font);
}
void WindowScreen::destroy_menus() {
@ -87,6 +93,8 @@ void WindowScreen::destroy_menus() {
delete this->extra_menu;
delete this->status_menu;
delete this->license_menu;
delete this->shortcut_menu;
delete this->action_selection_menu;
}
void WindowScreen::set_close(int ret_val) {
@ -259,6 +267,140 @@ void WindowScreen::bottom_pos_change(int new_bottom_pos) {
}
}
bool WindowScreen::can_execute_cmd(const WindowCommand* window_cmd, bool is_extra, bool is_always) {
if((!window_cmd->usable_always) && is_always)
return false;
if((!window_cmd->available_mono_extra) && is_extra && this->display_data->mono_app_mode)
return false;
return true;
}
bool WindowScreen::execute_cmd(PossibleWindowCommands id) {
bool consumed = true;
switch(id) {
case WINDOW_COMMAND_CONNECT:
this->m_prepare_open = true;
break;
case WINDOW_COMMAND_SPLIT:
this->split_change();
break;
case WINDOW_COMMAND_FULLSCREEN:
this->fullscreen_change();
break;
case WINDOW_COMMAND_CROP:
this->crop_value_change(this->m_info.crop_kind + 1);
break;
case WINDOW_COMMAND_ASYNC:
this->async_change();
break;
case WINDOW_COMMAND_VSYNC:
this->vsync_change();
break;
case WINDOW_COMMAND_MENU_SCALING_INC:
this->menu_scaling_change(true);
break;
case WINDOW_COMMAND_MENU_SCALING_DEC:
this->menu_scaling_change(false);
break;
case WINDOW_COMMAND_WINDOW_SCALING_INC:
this->window_scaling_change(true);
break;
case WINDOW_COMMAND_WINDOW_SCALING_DEC:
this->window_scaling_change(false);
break;
case WINDOW_COMMAND_RATIO_CYCLE:
this->ratio_change(true, true);
break;
case WINDOW_COMMAND_RATIO_TOP:
this->ratio_change(true);
break;
case WINDOW_COMMAND_RATIO_BOT:
this->ratio_change(false);
break;
case WINDOW_COMMAND_BLUR:
this->blur_change();
break;
case WINDOW_COMMAND_TRANSPOSE:
this->bottom_pos_change(this->m_info.bottom_pos + 1);
break;
case WINDOW_COMMAND_SCREEN_OFFSET:
this->offset_change(this->m_info.subscreen_offset, 0.5);
break;
case WINDOW_COMMAND_SUB_SCREEN_DISTANCE:
this->offset_change(this->m_info.subscreen_attached_offset, 0.5);
break;
case WINDOW_COMMAND_CANVAS_X:
this->offset_change(this->m_info.total_offset_x, 0.5);
break;
case WINDOW_COMMAND_CANVAS_Y:
this->offset_change(this->m_info.total_offset_y, 0.5);
break;
case WINDOW_COMMAND_ROT_INC:
this->rotation_change(this->m_info.top_rotation, true);
this->rotation_change(this->m_info.bot_rotation, true);
break;
case WINDOW_COMMAND_ROT_DEC:
this->rotation_change(this->m_info.top_rotation, false);
this->rotation_change(this->m_info.bot_rotation, false);
break;
case WINDOW_COMMAND_ROT_TOP_INC:
this->rotation_change(this->m_info.top_rotation, true);
break;
case WINDOW_COMMAND_ROT_TOP_DEC:
this->rotation_change(this->m_info.top_rotation, false);
break;
case WINDOW_COMMAND_ROT_BOT_INC:
this->rotation_change(this->m_info.bot_rotation, true);
break;
case WINDOW_COMMAND_ROT_BOT_DEC:
this->rotation_change(this->m_info.bot_rotation, false);
break;
case WINDOW_COMMAND_PADDING:
this->padding_change();
break;
case WINDOW_COMMAND_TOP_PAR:
this->par_value_change(this->m_info.top_par + 1, true);
break;
case WINDOW_COMMAND_BOT_PAR:
this->par_value_change(this->m_info.bot_par + 1, false);
break;
case WINDOW_COMMAND_AUDIO_MUTE:
audio_data->change_audio_mute();
break;
case WINDOW_COMMAND_VOLUME_DEC:
audio_data->change_audio_volume(false);
break;
case WINDOW_COMMAND_VOLUME_INC:
audio_data->change_audio_volume(true);
break;
case WINDOW_COMMAND_AUDIO_RESTART:
audio_data->request_audio_restart();
break;
case WINDOW_COMMAND_LOAD_PROFILE_STARTUP:
this->m_prepare_load = STARTUP_FILE_INDEX;
break;
case WINDOW_COMMAND_LOAD_PROFILE_1:
case WINDOW_COMMAND_LOAD_PROFILE_2:
case WINDOW_COMMAND_LOAD_PROFILE_3:
case WINDOW_COMMAND_LOAD_PROFILE_4:
this->m_prepare_load = id - WINDOW_COMMAND_LOAD_PROFILE_1 + 1;
break;
case WINDOW_COMMAND_SAVE_PROFILE_STARTUP:
this->m_prepare_save = STARTUP_FILE_INDEX;
break;
case WINDOW_COMMAND_SAVE_PROFILE_1:
case WINDOW_COMMAND_SAVE_PROFILE_2:
case WINDOW_COMMAND_SAVE_PROFILE_3:
case WINDOW_COMMAND_SAVE_PROFILE_4:
this->m_prepare_save = id - WINDOW_COMMAND_SAVE_PROFILE_1 + 1;
break;
default:
consumed = false;
break;
}
return consumed;
}
bool WindowScreen::common_poll(SFEvent &event_data) {
bool consumed = true;
switch(event_data.type) {
@ -269,35 +411,35 @@ bool WindowScreen::common_poll(SFEvent &event_data) {
case sf::Event::TextEntered:
switch(event_data.unicode) {
case 's':
this->split_change();
this->execute_cmd(WINDOW_COMMAND_SPLIT);
break;
case 'f':
this->fullscreen_change();
this->execute_cmd(WINDOW_COMMAND_FULLSCREEN);
break;
case 'a':
this->async_change();
this->execute_cmd(WINDOW_COMMAND_ASYNC);
break;
case 'v':
this->vsync_change();
this->execute_cmd(WINDOW_COMMAND_VSYNC);
break;
case 'z':
this->menu_scaling_change(false);
this->execute_cmd(WINDOW_COMMAND_MENU_SCALING_DEC);
break;
case 'x':
this->menu_scaling_change(true);
this->execute_cmd(WINDOW_COMMAND_MENU_SCALING_INC);
break;
case '-':
this->window_scaling_change(false);
this->execute_cmd(WINDOW_COMMAND_WINDOW_SCALING_DEC);
break;
case '0':
this->window_scaling_change(true);
this->execute_cmd(WINDOW_COMMAND_WINDOW_SCALING_INC);
break;
default:
@ -387,7 +529,7 @@ void WindowScreen::setup_main_menu(bool reset_data) {
this->curr_menu = MAIN_MENU_TYPE;
if(reset_data)
this->main_menu->reset_data();
this->main_menu->insert_data(this->m_stype, this->m_info.is_fullscreen, this->display_data->mono_app_mode);
this->main_menu->insert_data(this->m_stype, this->m_info.is_fullscreen, this->display_data->mono_app_mode, is_shortcut_valid());
}
}
@ -538,6 +680,41 @@ void WindowScreen::setup_extra_menu(bool reset_data) {
}
}
void WindowScreen::setup_action_selection_menu(bool reset_data) {
if(this->curr_menu != ACTION_SELECTION_MENU_TYPE) {
this->curr_menu = ACTION_SELECTION_MENU_TYPE;
if(reset_data)
this->action_selection_menu->reset_data();
this->possible_actions.clear();
create_window_commands_list(this->possible_actions, this->possible_buttons_extras[this->chosen_button] && this->display_data->mono_app_mode);
this->action_selection_menu->insert_data(this->possible_actions);
}
}
void WindowScreen::setup_shortcuts_menu(bool reset_data) {
if(!is_shortcut_valid())
return;
if(this->curr_menu != SHORTCUTS_MENU_TYPE) {
this->curr_menu = SHORTCUTS_MENU_TYPE;
if(reset_data)
this->shortcut_menu->reset_data();
this->possible_buttons_names.clear();
this->possible_buttons_ptrs.clear();
this->possible_buttons_extras.clear();
if(get_extra_button_name(sf::Keyboard::Enter) != "") {
this->possible_buttons_ptrs.push_back(&extra_button_shortcuts->enter_shortcut);
this->possible_buttons_names.push_back(get_extra_button_name(sf::Keyboard::Enter) + " Button: " + extra_button_shortcuts->enter_shortcut->name);
this->possible_buttons_extras.push_back(true);
}
if(get_extra_button_name(sf::Keyboard::PageUp) != "") {
this->possible_buttons_ptrs.push_back(&extra_button_shortcuts->page_up_shortcut);
this->possible_buttons_names.push_back(get_extra_button_name(sf::Keyboard::PageUp) + " Button: " + extra_button_shortcuts->page_up_shortcut->name);
this->possible_buttons_extras.push_back(true);
}
this->shortcut_menu->insert_data(this->possible_buttons_names);
}
}
void WindowScreen::setup_status_menu(bool reset_data) {
if(this->curr_menu != STATUS_MENU_TYPE) {
this->curr_menu = STATUS_MENU_TYPE;
@ -585,8 +762,11 @@ bool WindowScreen::no_menu_poll(SFEvent &event_data) {
case sf::Event::KeyPressed:
switch(event_data.code) {
case sf::Keyboard::Enter:
if(event_data.is_extra)
this->ratio_change(true, true);
if(event_data.is_extra) {
consumed = this->can_execute_cmd(extra_button_shortcuts->enter_shortcut, true, false);
if(consumed)
this->execute_cmd(extra_button_shortcuts->enter_shortcut->cmd);
}
else
this->setup_main_menu();
break;
@ -597,8 +777,11 @@ bool WindowScreen::no_menu_poll(SFEvent &event_data) {
consumed = false;
break;
case sf::Keyboard::PageUp:
if(event_data.is_extra)
this->crop_value_change(this->m_info.crop_kind + 1);
if(event_data.is_extra){
consumed = this->can_execute_cmd(extra_button_shortcuts->page_up_shortcut, true, false);
if(consumed)
this->execute_cmd(extra_button_shortcuts->page_up_shortcut->cmd);
}
else
consumed = false;
break;
@ -644,11 +827,11 @@ bool WindowScreen::main_poll(SFEvent &event_data) {
case sf::Event::TextEntered:
switch(event_data.unicode) {
case 'c':
this->crop_value_change(this->m_info.crop_kind + 1);
this->execute_cmd(WINDOW_COMMAND_CROP);
break;
case 'b':
this->blur_change();
this->execute_cmd(WINDOW_COMMAND_BLUR);
break;
//case 'i':
@ -656,89 +839,87 @@ bool WindowScreen::main_poll(SFEvent &event_data) {
// break;
case 'o':
this->m_prepare_open = true;
this->execute_cmd(WINDOW_COMMAND_CONNECT);
break;
case 't':
this->bottom_pos_change(this->m_info.bottom_pos + 1);
this->execute_cmd(WINDOW_COMMAND_TRANSPOSE);
break;
case '6':
this->offset_change(this->m_info.subscreen_offset, 0.5);
this->execute_cmd(WINDOW_COMMAND_SCREEN_OFFSET);
break;
case '7':
this->offset_change(this->m_info.subscreen_attached_offset, 0.5);
this->execute_cmd(WINDOW_COMMAND_SUB_SCREEN_DISTANCE);
break;
case '4':
this->offset_change(this->m_info.total_offset_x, 0.5);
this->execute_cmd(WINDOW_COMMAND_CANVAS_X);
break;
case '5':
this->offset_change(this->m_info.total_offset_y, 0.5);
this->execute_cmd(WINDOW_COMMAND_CANVAS_Y);
break;
case 'y':
this->ratio_change(true);
this->execute_cmd(WINDOW_COMMAND_RATIO_TOP);
break;
case 'u':
this->ratio_change(false);
this->execute_cmd(WINDOW_COMMAND_RATIO_BOT);
break;
case '8':
this->rotation_change(this->m_info.top_rotation, false);
this->rotation_change(this->m_info.bot_rotation, false);
this->execute_cmd(WINDOW_COMMAND_ROT_DEC);
break;
case '9':
this->rotation_change(this->m_info.top_rotation, true);
this->rotation_change(this->m_info.bot_rotation, true);
this->execute_cmd(WINDOW_COMMAND_ROT_INC);
break;
case 'h':
this->rotation_change(this->m_info.top_rotation, false);
this->execute_cmd(WINDOW_COMMAND_ROT_TOP_DEC);
break;
case 'j':
this->rotation_change(this->m_info.top_rotation, true);
this->execute_cmd(WINDOW_COMMAND_ROT_TOP_INC);
break;
case 'k':
this->rotation_change(this->m_info.bot_rotation, false);
this->execute_cmd(WINDOW_COMMAND_ROT_BOT_DEC);
break;
case 'l':
this->rotation_change(this->m_info.bot_rotation, true);
this->execute_cmd(WINDOW_COMMAND_ROT_BOT_INC);
break;
case 'r':
this->padding_change();
this->execute_cmd(WINDOW_COMMAND_PADDING);
break;
case '2':
this->par_value_change(this->m_info.top_par + 1, true);
this->execute_cmd(WINDOW_COMMAND_TOP_PAR);
break;
case '3':
this->par_value_change(this->m_info.bot_par + 1, false);
this->execute_cmd(WINDOW_COMMAND_BOT_PAR);
break;
case 'm':
audio_data->change_audio_mute();
this->execute_cmd(WINDOW_COMMAND_AUDIO_MUTE);
break;
case ',':
audio_data->change_audio_volume(false);
this->execute_cmd(WINDOW_COMMAND_VOLUME_DEC);
break;
case '.':
audio_data->change_audio_volume(true);
this->execute_cmd(WINDOW_COMMAND_VOLUME_INC);
break;
case 'n':
audio_data->request_audio_restart();
this->execute_cmd(WINDOW_COMMAND_AUDIO_RESTART);
break;
default:
@ -754,14 +935,14 @@ bool WindowScreen::main_poll(SFEvent &event_data) {
case sf::Keyboard::F2:
case sf::Keyboard::F3:
case sf::Keyboard::F4:
this->m_prepare_load = event_data.code - sf::Keyboard::F1 + 1;
this->execute_cmd(static_cast<PossibleWindowCommands>(WINDOW_COMMAND_LOAD_PROFILE_1 + (event_data.code - sf::Keyboard::F1)));
break;
case sf::Keyboard::F5:
case sf::Keyboard::F6:
case sf::Keyboard::F7:
case sf::Keyboard::F8:
this->m_prepare_save = event_data.code - sf::Keyboard::F5 + 1;
this->execute_cmd(static_cast<PossibleWindowCommands>(WINDOW_COMMAND_SAVE_PROFILE_1 + (event_data.code - sf::Keyboard::F5)));
break;
default:
consumed = false;
@ -890,6 +1071,10 @@ void WindowScreen::poll() {
this->setup_extra_menu();
done = true;
break;
case MAIN_MENU_SHORTCUT_SETTINGS:
this->setup_shortcuts_menu();
done = true;
break;
case MAIN_MENU_SHUTDOWN:
this->set_close(1);
this->curr_menu = DEFAULT_MENU_TYPE;
@ -1307,6 +1492,42 @@ void WindowScreen::poll() {
continue;
}
break;
case SHORTCUTS_MENU_TYPE:
if(this->shortcut_menu->poll(event_data)) {
switch(this->shortcut_menu->selected_index) {
case SHORTCUT_MENU_BACK:
this->setup_main_menu(false);
done = true;
break;
case SHORTCUT_MENU_NO_ACTION:
break;
default:
this->chosen_button = this->shortcut_menu->selected_index;
this->setup_action_selection_menu();
done = true;
break;
}
this->shortcut_menu->reset_output_option();
continue;
}
break;
case ACTION_SELECTION_MENU_TYPE:
if(this->action_selection_menu->poll(event_data)) {
switch(this->action_selection_menu->selected_index) {
case ACTION_SELECTION_MENU_BACK:
this->setup_shortcuts_menu(false);
done = true;
break;
case ACTION_SELECTION_MENU_NO_ACTION:
break;
default:
(*this->possible_buttons_ptrs[this->chosen_button]) = this->possible_actions[this->action_selection_menu->selected_index];
break;
}
this->action_selection_menu->reset_output_option();
continue;
}
break;
case STATUS_MENU_TYPE:
if(this->status_menu->poll(event_data)) {
switch(this->status_menu->selected_index) {
@ -1389,7 +1610,7 @@ int WindowScreen::get_ret_val() {
}
bool WindowScreen::query_reset_request() {
auto curr_time = std::chrono::high_resolution_clock::now();
std::chrono::time_point<std::chrono::high_resolution_clock> curr_time = std::chrono::high_resolution_clock::now();
if(check_held_diff(curr_time, this->right_click_action) > this->bad_resolution_timeout)
return true;
if(check_held_diff(curr_time, this->enter_action) > this->bad_resolution_timeout)
@ -1470,12 +1691,12 @@ void WindowScreen::poll_window() {
}
else {
this->reset_held_times();
this->touch_right_click_action.started = false;
check_held_reset(false, this->touch_right_click_action);
}
}
else {
this->reset_held_times();
this->touch_right_click_action.started = false;
check_held_reset(false, this->touch_right_click_action);
}
}
@ -1526,6 +1747,12 @@ void WindowScreen::prepare_menu_draws(int view_size_x, int view_size_y) {
case EXTRA_MENU_TYPE:
this->extra_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y);
break;
case SHORTCUTS_MENU_TYPE:
this->shortcut_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y);
break;
case ACTION_SELECTION_MENU_TYPE:
this->action_selection_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, (*this->possible_buttons_ptrs[this->chosen_button])->cmd);
break;
case STATUS_MENU_TYPE:
this->status_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, FPSArrayGetAverage(&in_fps), FPSArrayGetAverage(&poll_fps), FPSArrayGetAverage(&draw_fps));
break;
@ -1584,6 +1811,12 @@ void WindowScreen::execute_menu_draws() {
case EXTRA_MENU_TYPE:
this->extra_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win);
break;
case SHORTCUTS_MENU_TYPE:
this->shortcut_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win);
break;
case ACTION_SELECTION_MENU_TYPE:
this->action_selection_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win);
break;
case STATUS_MENU_TYPE:
this->status_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win);
break;

View File

@ -58,7 +58,7 @@ static void SuccessConnectionOutTextGenerator(OutTextData &out_text_data, Captur
}
}
static bool load(const std::string path, const std::string name, ScreenInfo &top_info, ScreenInfo &bottom_info, ScreenInfo &joint_info, DisplayData &display_data, AudioData *audio_data, OutTextData &out_text_data) {
static bool load(const std::string path, const std::string name, ScreenInfo &top_info, ScreenInfo &bottom_info, ScreenInfo &joint_info, DisplayData &display_data, AudioData *audio_data, OutTextData &out_text_data, ExtraButtonShortcuts* extra_button_shortcuts) {
std::ifstream file(path + name);
std::string line;
@ -96,6 +96,16 @@ static bool load(const std::string path, const std::string name, ScreenInfo &top
continue;
}
if(key == "extra_button_enter_short") {
extra_button_shortcuts->enter_shortcut = get_window_command(static_cast<PossibleWindowCommands>(std::stoi(value)));
continue;
}
if(key == "extra_button_page_up_short") {
extra_button_shortcuts->page_up_shortcut = get_window_command(static_cast<PossibleWindowCommands>(std::stoi(value)));
continue;
}
if(audio_data->load_audio_data(key, value))
continue;
}
@ -111,22 +121,24 @@ static bool load(const std::string path, const std::string name, ScreenInfo &top
return result;
}
static void defaults_reload(FrontendData *frontend_data, AudioData* audio_data) {
static void defaults_reload(FrontendData *frontend_data, AudioData* audio_data, ExtraButtonShortcuts* extra_button_shortcuts) {
reset_screen_info(frontend_data->top_screen->m_info);
reset_screen_info(frontend_data->bot_screen->m_info);
reset_screen_info(frontend_data->joint_screen->m_info);
audio_data->reset();
extra_button_shortcuts->enter_shortcut = get_window_command(WINDOW_COMMAND_RATIO_CYCLE);
extra_button_shortcuts->page_up_shortcut = get_window_command(WINDOW_COMMAND_CROP);
reset_display_data(&frontend_data->display_data);
if(frontend_data->display_data.mono_app_mode)
frontend_data->joint_screen->m_info.is_fullscreen = true;
frontend_data->reload = true;
}
static void load_layout_file(int load_index, FrontendData *frontend_data, AudioData* audio_data, OutTextData &out_text_data, bool skip_io, bool do_print) {
static void load_layout_file(int load_index, FrontendData *frontend_data, AudioData* audio_data, OutTextData &out_text_data, ExtraButtonShortcuts* extra_button_shortcuts, bool skip_io, bool do_print) {
if(skip_io)
return;
defaults_reload(frontend_data, audio_data);
defaults_reload(frontend_data, audio_data, extra_button_shortcuts);
if(load_index == SIMPLE_RESET_DATA_INDEX) {
UpdateOutText(out_text_data, "Reset detected. Defaults re-loaded", "Reset detected\nDefaults re-loaded", TEXT_KIND_WARNING);
@ -136,16 +148,16 @@ static void load_layout_file(int load_index, FrontendData *frontend_data, AudioD
bool name_load_success = false;
std::string layout_name = LayoutNameGenerator(load_index);
std::string layout_path = LayoutPathGenerator(load_index);
bool op_success = load(layout_path, layout_name, frontend_data->top_screen->m_info, frontend_data->bot_screen->m_info, frontend_data->joint_screen->m_info, frontend_data->display_data, audio_data, out_text_data);
bool op_success = load(layout_path, layout_name, frontend_data->top_screen->m_info, frontend_data->bot_screen->m_info, frontend_data->joint_screen->m_info, frontend_data->display_data, audio_data, out_text_data, extra_button_shortcuts);
if(do_print && op_success) {
std::string load_name = load_layout_name(load_index, name_load_success);
UpdateOutText(out_text_data, "Layout loaded from: " + layout_path + layout_name, "Layout " + load_name + " loaded", TEXT_KIND_SUCCESS);
}
else if(!op_success)
defaults_reload(frontend_data, audio_data);
defaults_reload(frontend_data, audio_data, extra_button_shortcuts);
}
static bool save(const std::string path, const std::string name, const std::string save_name, const ScreenInfo &top_info, const ScreenInfo &bottom_info, const ScreenInfo &joint_info, DisplayData &display_data, AudioData *audio_data, OutTextData &out_text_data) {
static bool save(const std::string path, const std::string name, const std::string save_name, const ScreenInfo &top_info, const ScreenInfo &bottom_info, const ScreenInfo &joint_info, DisplayData &display_data, AudioData *audio_data, OutTextData &out_text_data, ExtraButtonShortcuts* extra_button_shortcuts) {
#if (!defined(_MSC_VER)) || (_MSC_VER > 1916)
std::filesystem::create_directories(path);
#else
@ -163,13 +175,15 @@ static bool save(const std::string path, const std::string name, const std::stri
file << save_screen_info("top_", top_info);
file << "split=" << display_data.split << std::endl;
file << "fast_poll=" << display_data.fast_poll << std::endl;
file << "extra_button_enter_short=" << extra_button_shortcuts->enter_shortcut->cmd << std::endl;
file << "extra_button_page_up_short=" << extra_button_shortcuts->page_up_shortcut->cmd << std::endl;
file << audio_data->save_audio_data();
file.close();
return true;
}
static void save_layout_file(int save_index, FrontendData *frontend_data, AudioData* audio_data, OutTextData &out_text_data, bool skip_io, bool do_print) {
static void save_layout_file(int save_index, FrontendData *frontend_data, AudioData* audio_data, OutTextData &out_text_data, ExtraButtonShortcuts* extra_button_shortcuts, bool skip_io, bool do_print) {
if(skip_io)
return;
@ -180,7 +194,7 @@ static void save_layout_file(int save_index, FrontendData *frontend_data, AudioD
std::string save_name = load_layout_name(save_index, name_load_success);
std::string layout_name = LayoutNameGenerator(save_index);
std::string layout_path = LayoutPathGenerator(save_index);
bool op_success = save(layout_path, layout_name, save_name, frontend_data->top_screen->m_info, frontend_data->bot_screen->m_info, frontend_data->joint_screen->m_info, frontend_data->display_data, audio_data, out_text_data);
bool op_success = save(layout_path, layout_name, save_name, frontend_data->top_screen->m_info, frontend_data->bot_screen->m_info, frontend_data->joint_screen->m_info, frontend_data->display_data, audio_data, out_text_data, extra_button_shortcuts);
if(do_print && op_success) {
UpdateOutText(out_text_data, "Layout saved to: " + layout_path + layout_name, "Layout " + save_name + " saved", TEXT_KIND_SUCCESS);
}
@ -272,20 +286,21 @@ static int mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data,
bool skip_io = false;
int num_allowed_blanks = MAX_ALLOWED_BLANKS;
OutTextData out_text_data;
ExtraButtonShortcuts extra_button_shortcuts;
out_text_data.consumed = true;
int ret_val = 0;
out_buf = new VideoOutputData;
memset(out_buf, 0, sizeof(VideoOutputData));
WindowScreen top_screen(ScreenType::TOP, &capture_data->status, &frontend_data.display_data, audio_data);
WindowScreen bot_screen(ScreenType::BOTTOM, &capture_data->status, &frontend_data.display_data, audio_data);
WindowScreen joint_screen(ScreenType::JOINT, &capture_data->status, &frontend_data.display_data, audio_data);
WindowScreen top_screen(ScreenType::TOP, &capture_data->status, &frontend_data.display_data, audio_data, &extra_button_shortcuts);
WindowScreen bot_screen(ScreenType::BOTTOM, &capture_data->status, &frontend_data.display_data, audio_data, &extra_button_shortcuts);
WindowScreen joint_screen(ScreenType::JOINT, &capture_data->status, &frontend_data.display_data, audio_data, &extra_button_shortcuts);
frontend_data.top_screen = &top_screen;
frontend_data.bot_screen = &bot_screen;
frontend_data.joint_screen = &joint_screen;
load_layout_file(STARTUP_FILE_INDEX, &frontend_data, audio_data, out_text_data, skip_io, false);
load_layout_file(STARTUP_FILE_INDEX, &frontend_data, audio_data, out_text_data, &extra_button_shortcuts, skip_io, false);
// Due to the risk for seizures, at the start of the program, set BFI to false!
top_screen.m_info.bfi = false;
bot_screen.m_info.bfi = false;
@ -361,10 +376,10 @@ static int mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data,
check_close_application(joint_screen, capture_data, ret_val);
if((load_index = top_screen.load_data()) || (load_index = bot_screen.load_data()) || (load_index = joint_screen.load_data()))
load_layout_file(load_index, &frontend_data, audio_data, out_text_data, skip_io, true);
load_layout_file(load_index, &frontend_data, audio_data, out_text_data, &extra_button_shortcuts, skip_io, true);
if((save_index = top_screen.save_data()) || (save_index = bot_screen.save_data()) || (save_index = joint_screen.save_data())) {
save_layout_file(save_index, &frontend_data, audio_data, out_text_data, skip_io, true);
save_layout_file(save_index, &frontend_data, audio_data, out_text_data, &extra_button_shortcuts, skip_io, true);
top_screen.update_save_menu();
bot_screen.update_save_menu();
joint_screen.update_save_menu();
@ -400,7 +415,7 @@ static int mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data,
bot_screen.after_thread_join();
joint_screen.after_thread_join();
save_layout_file(STARTUP_FILE_INDEX, &frontend_data, audio_data, out_text_data, skip_io, false);
save_layout_file(STARTUP_FILE_INDEX, &frontend_data, audio_data, out_text_data, &extra_button_shortcuts, skip_io, false);
if(!out_text_data.consumed) {
ConsoleOutText(out_text_data.full_text);