From 5450646b5c338d01123f8cdd740f91bf6ed357de Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Fri, 4 Oct 2024 16:45:28 +0200 Subject: [PATCH] android: add virtual gamepad transparency setting Issue #384 --- core/cfg/option.cpp | 1 + core/cfg/option.h | 1 + core/rend/osd.cpp | 7 +++++-- core/ui/gui.cpp | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/cfg/option.cpp b/core/cfg/option.cpp index b3bd2e5ad..cc5070642 100644 --- a/core/cfg/option.cpp +++ b/core/cfg/option.cpp @@ -168,6 +168,7 @@ Option OmxAudioHdmi("audio_hdmi", true, "omx"); Option MouseSensitivity("MouseSensitivity", 100, "input"); Option VirtualGamepadVibration("VirtualGamepadVibration", 20, "input"); +Option VirtualGamepadTransparency("VirtualGamepadTransparency", 37, "input"); std::array, 4> MapleMainDevices { Option("device1", MDT_SegaController, "input"), diff --git a/core/cfg/option.h b/core/cfg/option.h index c5ecd239b..4d1f283f7 100644 --- a/core/cfg/option.h +++ b/core/cfg/option.h @@ -534,6 +534,7 @@ extern Option OmxAudioHdmi; extern Option MouseSensitivity; extern Option VirtualGamepadVibration; +extern Option VirtualGamepadTransparency; extern std::array, 4> MapleMainDevices; extern std::array, 2>, 4> MapleExpansionDevices; extern Option PerGameVmu; diff --git a/core/rend/osd.cpp b/core/rend/osd.cpp index 9722b92f4..b10c5493c 100644 --- a/core/rend/osd.cpp +++ b/core/rend/osd.cpp @@ -26,10 +26,12 @@ #include +#ifndef LIBRETRO + #define OSD_TEX_W 512 #define OSD_TEX_H 256 -#if defined(__ANDROID__) && !defined(LIBRETRO) +#ifdef __ANDROID__ extern float vjoy_pos[15][8]; #else @@ -74,7 +76,7 @@ static void DrawButton(const float xy[8], u32 state) OSDVertex vtx; vtx.r = vtx.g = vtx.b = (0x7F - 0x40 * state / 255) * vjoy_pos[VJOY_VISIBLE][0]; - vtx.a = 0xA0 * vjoy_pos[VJOY_VISIBLE][4]; + vtx.a = (100 - config::VirtualGamepadTransparency) * 0xff / 100 * vjoy_pos[VJOY_VISIBLE][4]; vjoy_pos[VJOY_VISIBLE][4] += (vjoy_pos[VJOY_VISIBLE][0] - vjoy_pos[VJOY_VISIBLE][4]) / 2; vtx.x = xy[0]; vtx.y = xy[1]; @@ -172,6 +174,7 @@ u8 *loadOSDButtons(int &width, int &height) } return image_data; } +#endif // LIBRETRO u32 vmu_lcd_data[8][48 * 32]; bool vmu_lcd_status[8]; diff --git a/core/ui/gui.cpp b/core/ui/gui.cpp index 194cd813c..fa270de2d 100644 --- a/core/ui/gui.cpp +++ b/core/ui/gui.cpp @@ -1442,6 +1442,8 @@ static void gamepadSettingsPopup(const std::shared_ptr& gamepad) { header("Haptic"); OptionSlider("Power", config::VirtualGamepadVibration, 0, 100, "Haptic feedback power", "%d%%"); + header("View"); + OptionSlider("Transparency", config::VirtualGamepadTransparency, 0, 100, "Virtual gamepad buttons transparency", "%d%%"); } else if (gamepad->is_rumble_enabled()) {