android: add virtual gamepad transparency setting

Issue #384
This commit is contained in:
Flyinghead 2024-10-04 16:45:28 +02:00
parent 55e0211a57
commit 5450646b5c
4 changed files with 9 additions and 2 deletions

View File

@ -168,6 +168,7 @@ Option<bool> OmxAudioHdmi("audio_hdmi", true, "omx");
Option<int> MouseSensitivity("MouseSensitivity", 100, "input");
Option<int> VirtualGamepadVibration("VirtualGamepadVibration", 20, "input");
Option<int> VirtualGamepadTransparency("VirtualGamepadTransparency", 37, "input");
std::array<Option<MapleDeviceType>, 4> MapleMainDevices {
Option<MapleDeviceType>("device1", MDT_SegaController, "input"),

View File

@ -534,6 +534,7 @@ extern Option<bool> OmxAudioHdmi;
extern Option<int> MouseSensitivity;
extern Option<int> VirtualGamepadVibration;
extern Option<int> VirtualGamepadTransparency;
extern std::array<Option<MapleDeviceType>, 4> MapleMainDevices;
extern std::array<std::array<Option<MapleDeviceType>, 2>, 4> MapleExpansionDevices;
extern Option<bool> PerGameVmu;

View File

@ -26,10 +26,12 @@
#include <stb_image.h>
#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];

View File

@ -1442,6 +1442,8 @@ static void gamepadSettingsPopup(const std::shared_ptr<GamepadDevice>& 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())
{