mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-10 05:38:49 +00:00
Hotkey config changes (#3391)
* This works, but it's missing some hotkeys and the GUI isn't hooked up to anything now * More hotkeys * Remove debug log * clang * accidentally used the wrong value here * gui changes for new backend (#10) * gui changes for new backend * fix lmeta * don't erase non-hotkey lines * do not erase hotkey configs in kbm or controller guis * Fix repeated inputs * Documentation --------- Co-authored-by: rainmakerv2 <30595646+rainmakerv3@users.noreply.github.com>
This commit is contained in:
@@ -1077,7 +1077,22 @@ void setDefaultValues() {
|
||||
m_language = 1;
|
||||
}
|
||||
|
||||
constexpr std::string_view GetDefaultKeyboardConfig() {
|
||||
constexpr std::string_view GetDefaultGlobalConfig() {
|
||||
return R"(# Anything put here will be loaded for all games,
|
||||
# alongside the game's config or default.ini depending on your preference.
|
||||
|
||||
hotkey_renderdoc_capture = f12
|
||||
hotkey_fullscreen = f11
|
||||
hotkey_show_fps = f10
|
||||
hotkey_pause = f9
|
||||
hotkey_reload_inputs = f8
|
||||
hotkey_toggle_mouse_to_joystick = f7
|
||||
hotkey_toggle_mouse_to_gyro = f6
|
||||
hotkey_quit = lctrl, lshift, end
|
||||
)";
|
||||
}
|
||||
|
||||
constexpr std::string_view GetDefaultInputConfig() {
|
||||
return R"(#Feeling lost? Check out the Help section!
|
||||
|
||||
# Keyboard bindings
|
||||
@@ -1151,7 +1166,7 @@ analog_deadzone = rightjoystick, 2, 127
|
||||
override_controller_color = false, 0, 0, 255
|
||||
)";
|
||||
}
|
||||
std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id) {
|
||||
std::filesystem::path GetFoolproofInputConfigFile(const std::string& game_id) {
|
||||
// Read configuration file of the game, and if it doesn't exist, generate it from default
|
||||
// If that doesn't exist either, generate that from getDefaultConfig() and try again
|
||||
// If even the folder is missing, we start with that.
|
||||
@@ -1168,7 +1183,7 @@ std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id) {
|
||||
// Check if the default config exists
|
||||
if (!std::filesystem::exists(default_config_file)) {
|
||||
// If the default config is also missing, create it from getDefaultConfig()
|
||||
const auto default_config = GetDefaultKeyboardConfig();
|
||||
const auto default_config = GetDefaultInputConfig();
|
||||
std::ofstream default_config_stream(default_config_file);
|
||||
if (default_config_stream) {
|
||||
default_config_stream << default_config;
|
||||
@@ -1180,6 +1195,17 @@ std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id) {
|
||||
return default_config_file;
|
||||
}
|
||||
|
||||
// Create global config if it doesn't exist yet
|
||||
if (game_id == "global" && !std::filesystem::exists(config_file)) {
|
||||
if (!std::filesystem::exists(config_file)) {
|
||||
const auto global_config = GetDefaultGlobalConfig();
|
||||
std::ofstream global_config_stream(config_file);
|
||||
if (global_config_stream) {
|
||||
global_config_stream << global_config;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If game-specific config doesn't exist, create it from the default config
|
||||
if (!std::filesystem::exists(config_file)) {
|
||||
std::filesystem::copy(default_config_file, config_file);
|
||||
|
||||
@@ -156,7 +156,7 @@ std::filesystem::path getAddonInstallDir();
|
||||
|
||||
void setDefaultValues();
|
||||
|
||||
// todo: name and function location pending
|
||||
std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id = "");
|
||||
constexpr std::string_view GetDefaultGlobalConfig();
|
||||
std::filesystem::path GetFoolproofInputConfigFile(const std::string& game_id = "");
|
||||
|
||||
}; // namespace Config
|
||||
|
||||
Reference in New Issue
Block a user