hbl: support different keys for any-app vs specific

This also makes the default configuration:

To override a generic app, hold R.
To override album, do not hold R.
This commit is contained in:
Michael Scire 2019-11-21 04:21:23 -08:00 committed by SciresM
parent 421324b498
commit 5484740cab
2 changed files with 21 additions and 3 deletions

View file

@ -2,7 +2,8 @@
title_id=010000000000100D title_id=010000000000100D
override_any_app=true override_any_app=true
path=atmosphere/hbl.nsp path=atmosphere/hbl.nsp
override_key=R override_key=!R
override_any_app_key=R
[default_config] [default_config]
override_key=!L override_key=!L

View file

@ -28,6 +28,7 @@ namespace ams::cfg {
struct HblOverrideConfig { struct HblOverrideConfig {
OverrideKey override_key; OverrideKey override_key;
OverrideKey override_any_app_key;
ncm::ProgramId program_id; ncm::ProgramId program_id;
bool override_any_app; bool override_any_app;
}; };
@ -50,6 +51,10 @@ namespace ams::cfg {
HblOverrideConfig g_hbl_override_config = { HblOverrideConfig g_hbl_override_config = {
.override_key = { .override_key = {
.key_combination = KEY_R,
.override_by_default = true,
},
.override_any_app_key = {
.key_combination = KEY_R, .key_combination = KEY_R,
.override_by_default = false, .override_by_default = false,
}, },
@ -136,6 +141,8 @@ namespace ams::cfg {
} else { } else {
/* I guess we default to not changing the value? */ /* I guess we default to not changing the value? */
} }
} else if (strcasecmp(name, "override_any_app_key") == 0) {
g_hbl_override_config.override_any_app_key = ParseOverrideKey(value);
} }
} else if (strcasecmp(section, "default_config") == 0) { } else if (strcasecmp(section, "default_config") == 0) {
if (strcasecmp(name, "override_key") == 0) { if (strcasecmp(name, "override_key") == 0) {
@ -169,6 +176,14 @@ namespace ams::cfg {
return (cfg.override_by_default ^ keys_triggered); return (cfg.override_by_default ^ keys_triggered);
} }
inline bool IsApplicationHblProgramId(ncm::ProgramId program_id) {
return g_hbl_override_config.override_any_app && ncm::IsApplicationProgramId(program_id);
}
inline bool IsSpecificHblProgramId(ncm::ProgramId program_id) {
return program_id == g_hbl_override_config.program_id;
}
void ParseIniFile(util::ini::Handler handler, const char *path, void *user_ctx) { void ParseIniFile(util::ini::Handler handler, const char *path, void *user_ctx) {
/* Mount the SD card. */ /* Mount the SD card. */
FsFileSystem sd_fs = {}; FsFileSystem sd_fs = {};
@ -229,7 +244,9 @@ namespace ams::cfg {
} }
/* Detect Hbl. */ /* Detect Hbl. */
if (IsHblProgramId(program_id) && IsOverrideMatch(status, g_hbl_override_config.override_key)) { if ((IsApplicationHblProgramId(program_id) && IsOverrideMatch(status, g_hbl_override_config.override_any_app_key)) ||
(IsSpecificHblProgramId(program_id) && IsOverrideMatch(status, g_hbl_override_config.override_key)))
{
status.SetHbl(); status.SetHbl();
} }
@ -249,7 +266,7 @@ namespace ams::cfg {
/* HBL Configuration utilities. */ /* HBL Configuration utilities. */
bool IsHblProgramId(ncm::ProgramId program_id) { bool IsHblProgramId(ncm::ProgramId program_id) {
return (g_hbl_override_config.override_any_app && ncm::IsApplicationProgramId(program_id)) || (program_id == g_hbl_override_config.program_id); return IsApplicationHblProgramId(program_id) || IsSpecificHblProgramId(program_id);
} }
const char *GetHblPath() { const char *GetHblPath() {