Skip to content

Commit

Permalink
Add an option for swap abxy buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Oct 18, 2024
1 parent 2b5be54 commit 4625664
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Binary file modified resources/font/keymap_keyboard.ttf
Binary file not shown.
Binary file added resources/font/keymap_keyboard_swap.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions wiliwili/include/utils/config_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum class SettingItem {
APP_LANG, // 应用语言
APP_RESOURCES, // 自定义界面布局
APP_UI_SCALE, // 界面缩放
APP_SWAP_ABXY, // A-B 交换 和 X-Y 交换
SCROLL_SPEED, // 列表滑动速度
HISTORY_REPORT,
PLAYER_STRATEGY,
Expand Down
19 changes: 14 additions & 5 deletions wiliwili/source/utils/config_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ std::unordered_map<SettingItem, ProgramOption> ProgramConfig::SETTING_MAP = {
{SettingItem::DANMAKU_STYLE_FONT, {"danmaku_style_font", {"stroke", "incline", "shadow", "pure"}, {}, 0}},

/// bool
{SettingItem::APP_SWAP_ABXY, {"app_swap_abxy", {}, {}, 0}},
{SettingItem::GAMEPAD_VIBRATION, {"gamepad_vibration", {}, {}, 1}},
#if defined(IOS) || defined(__PSV__)
{SettingItem::HIDE_BOTTOM_BAR, {"hide_bottom_bar", {}, {}, 1}},
Expand All @@ -115,14 +116,11 @@ std::unordered_map<SettingItem, ProgramOption> ProgramConfig::SETTING_MAP = {
{SettingItem::FULLSCREEN, {"fullscreen", {}, {}, 1}},
#endif
{SettingItem::HISTORY_REPORT, {"history_report", {}, {}, 1}},
{SettingItem::PLAYER_AUTO_PLAY, {"player_auto_play", {}, {}, 1}},
{SettingItem::PLAYER_BOTTOM_BAR, {"player_bottom_bar", {}, {}, 1}},
{SettingItem::PLAYER_HIGHLIGHT_BAR, {"player_highlight_bar", {}, {}, 0}},
{SettingItem::PLAYER_SKIP_OPENING_CREDITS, {"player_skip_opening_credits", {}, {}, 1}},
#if defined(__PSV__) || defined(PS4) || defined(__SWITCH__)
{SettingItem::PLAYER_LOW_QUALITY, {"player_low_quality", {}, {}, 1}},
#else
{SettingItem::PLAYER_LOW_QUALITY, {"player_low_quality", {}, {}, 0}},
#endif
#if defined(IOS) || defined(__PSV__) || defined(__SWITCH__)
{SettingItem::PLAYER_HWDEC, {"player_hwdec", {}, {}, 1}},
#else
Expand Down Expand Up @@ -617,6 +615,13 @@ void ProgramConfig::load() {

// 初始化一些在创建窗口之后才能初始化的内容
brls::Application::getWindowCreationDoneEvent()->subscribe([this]() {
// 是否交换按键
if (getBoolOption(SettingItem::APP_SWAP_ABXY)) {
// 对于 PSV/PS4 来说,初始化时会加载系统设置,可能在那时已经交换过按键
// 所以这里需要读取 isSwapInputKeys 的值,而不是直接设置为 true
brls::Application::setSwapInputKeys(!brls::Application::isSwapInputKeys());
}

// 初始化弹幕字体
std::string danmakuFont = getConfigDir() + "/danmaku.ttf";
// 只在应用模式下加载自定义字体 减少switch上的内存占用
Expand Down Expand Up @@ -829,7 +834,11 @@ void ProgramConfig::init() {
} else if (icon == "ps") {
brls::FontLoader::USER_ICON_PATH = BRLS_ASSET("font/keymap_ps.ttf");
} else {
brls::FontLoader::USER_ICON_PATH = BRLS_ASSET("font/keymap_keyboard.ttf");
if (getBoolOption(SettingItem::APP_SWAP_ABXY)) {
brls::FontLoader::USER_ICON_PATH = BRLS_ASSET("font/keymap_keyboard_swap.ttf");
} else {
brls::FontLoader::USER_ICON_PATH = BRLS_ASSET("font/keymap_keyboard.ttf");
}
}
#endif
}
Expand Down

0 comments on commit 4625664

Please sign in to comment.