diff --git a/core/cfg/option.cpp b/core/cfg/option.cpp index 68c62bcba..77d335235 100644 --- a/core/cfg/option.cpp +++ b/core/cfg/option.cpp @@ -93,6 +93,7 @@ std::array, 4> CrosshairColor { Option("rend.CrossHairColor3"), Option("rend.CrossHairColor4"), }; +Option CrosshairSize("rend.CrosshairSize", 40); Option SkipFrame("ta.skip"); Option MaxThreads("pvr.MaxThreads", 3); Option AutoSkipFrame("pvr.AutoSkipFrame", 0); diff --git a/core/cfg/option.h b/core/cfg/option.h index 4e7489703..4a95f8e4a 100644 --- a/core/cfg/option.h +++ b/core/cfg/option.h @@ -456,6 +456,7 @@ extern Option PerStripSorting; extern Option DelayFrameSwapping; // Delay swapping frame until FB_R_SOF matches FB_W_SOF extern Option WidescreenGameHacks; extern std::array, 4> CrosshairColor; +extern Option CrosshairSize; extern Option SkipFrame; extern Option MaxThreads; extern Option AutoSkipFrame; // 0: none, 1: some, 2: more diff --git a/core/rend/dx11/dx11_overlay.cpp b/core/rend/dx11/dx11_overlay.cpp index bab450e04..741cc560f 100644 --- a/core/rend/dx11/dx11_overlay.cpp +++ b/core/rend/dx11/dx11_overlay.cpp @@ -172,11 +172,11 @@ void DX11Overlay::draw(u32 width, u32 height, bool vmu, bool crosshair) auto [x, y] = getCrosshairPosition(i); #ifdef LIBRETRO - float halfWidth = LIGHTGUN_CROSSHAIR_SIZE / 2.f / config::ScreenStretching * 100.f * config::RenderResolution / 480.f; - float halfHeight = LIGHTGUN_CROSSHAIR_SIZE / 2.f * config::RenderResolution / 480.f; + float halfWidth = lightgun_crosshair_size / 2.f / config::ScreenStretching * 100.f * config::RenderResolution / 480.f; + float halfHeight = lightgun_crosshair_size / 2.f * config::RenderResolution / 480.f; x /= config::ScreenStretching / 100.f; #else - float halfWidth = XHAIR_WIDTH * settings.display.uiScale / 2.f; + float halfWidth = config::CrosshairSize * settings.display.uiScale / 2.f; float halfHeight = halfWidth; #endif D3D11_VIEWPORT vp{}; diff --git a/core/rend/dx9/d3d_overlay.cpp b/core/rend/dx9/d3d_overlay.cpp index 271f555f2..fda6e2d5d 100644 --- a/core/rend/dx9/d3d_overlay.cpp +++ b/core/rend/dx9/d3d_overlay.cpp @@ -118,7 +118,7 @@ void D3DOverlay::draw(u32 width, u32 height, bool vmu, bool crosshair) continue; auto [x, y] = getCrosshairPosition(i); - float halfWidth = XHAIR_WIDTH * settings.display.uiScale / 2.f; + float halfWidth = config::CrosshairSize * settings.display.uiScale / 2.f; RECT rect { (long) (x - halfWidth), (long) (y - halfWidth), (long) (x + halfWidth), (long) (y + halfWidth) }; D3DCOLOR color = (config::CrosshairColor[i] & 0xFF00FF00) | ((config::CrosshairColor[i] >> 16) & 0xFF) diff --git a/core/rend/gles/gldraw.cpp b/core/rend/gles/gldraw.cpp index 6306e0a98..529bcc9b4 100644 --- a/core/rend/gles/gldraw.cpp +++ b/core/rend/gles/gldraw.cpp @@ -919,8 +919,8 @@ void DrawGunCrosshair(u8 port, int width, int height) if (lightgun_params[port].offscreen || lightgun_params[port].colour == 0) return; - float w = (float)LIGHTGUN_CROSSHAIR_SIZE * 4.f / 3.f / gl.ofbo.aspectRatio * config::RenderResolution / 480.f; - float h = (float)LIGHTGUN_CROSSHAIR_SIZE * config::RenderResolution / 480.f; + float w = lightgun_crosshair_size * 4.f / 3.f / gl.ofbo.aspectRatio * config::RenderResolution / 480.f; + float h = lightgun_crosshair_size * config::RenderResolution / 480.f; auto [x, y] = getCrosshairPosition(port); x -= w / 2; y -= h / 2; diff --git a/core/rend/gles/opengl_driver.cpp b/core/rend/gles/opengl_driver.cpp index 8705b661f..c0ef1f245 100644 --- a/core/rend/gles/opengl_driver.cpp +++ b/core/rend/gles/opengl_driver.cpp @@ -144,9 +144,9 @@ void OpenGLDriver::displayCrosshairs() ImVec2 pos; std::tie(pos.x, pos.y) = getCrosshairPosition(i); - pos.x -= (XHAIR_WIDTH * settings.display.uiScale) / 2.f; - pos.y += (XHAIR_WIDTH * settings.display.uiScale) / 2.f; - ImVec2 pos_b(pos.x + XHAIR_WIDTH * settings.display.uiScale, pos.y - XHAIR_HEIGHT * settings.display.uiScale); + pos.x -= (config::CrosshairSize * settings.display.uiScale) / 2.f; + pos.y += (config::CrosshairSize * settings.display.uiScale) / 2.f; + ImVec2 pos_b(pos.x + config::CrosshairSize * settings.display.uiScale, pos.y - config::CrosshairSize * settings.display.uiScale); ImGui::GetWindowDrawList()->AddImage(crosshairTexId, pos, pos_b, ImVec2(0, 1), ImVec2(1, 0), config::CrosshairColor[i]); } diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 0a48ea75f..6d8bb6060 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -1700,6 +1700,7 @@ static void gui_display_settings() ImGui::Spacing(); header("Dreamcast Devices"); { + bool is_there_any_xhair = false; for (int bus = 0; bus < MAPLE_PORTS; bus++) { ImGui::Text("Device %c", bus + 'A'); @@ -1790,10 +1791,15 @@ static void gui_display_settings() config::CrosshairColor[bus] = 0; } } + is_there_any_xhair |= enabled; ImGui::PopID(); } ImGui::PopItemWidth(); } + { + DisabledScope scope(!is_there_any_xhair); + OptionSlider("Crosshair Size", config::CrosshairSize, 10, 100); + } OptionCheckbox("Per Game VMU A1", config::PerGameVmu, "When enabled, each game has its own VMU on port 1 of controller A."); } diff --git a/core/rend/osd.h b/core/rend/osd.h index 63ed099db..52d65fa5a 100644 --- a/core/rend/osd.h +++ b/core/rend/osd.h @@ -48,9 +48,6 @@ void push_vmu_screen(int bus_id, int bus_port, u8* buffer); const u32 *getCrosshairTextureData(); std::pair getCrosshairPosition(int playerNum); -constexpr int XHAIR_WIDTH = 40; -constexpr int XHAIR_HEIGHT = 40; - static inline bool crosshairsNeeded() { if (config::CrosshairColor[0] == 0 && config::CrosshairColor[1] == 0 diff --git a/core/rend/vulkan/overlay.cpp b/core/rend/vulkan/overlay.cpp index 99101d385..ea8d68a52 100644 --- a/core/rend/vulkan/overlay.cpp +++ b/core/rend/vulkan/overlay.cpp @@ -210,12 +210,12 @@ void VulkanOverlay::Draw(vk::CommandBuffer commandBuffer, vk::Extent2D viewport, auto [x, y] = getCrosshairPosition(i); #ifdef LIBRETRO - float w = LIGHTGUN_CROSSHAIR_SIZE * scaling / config::ScreenStretching * 100.f; - float h = LIGHTGUN_CROSSHAIR_SIZE * scaling; + float w = lightgun_crosshair_size * scaling / config::ScreenStretching * 100.f; + float h = lightgun_crosshair_size * scaling; x /= config::ScreenStretching / 100.f; #else - float w = XHAIR_WIDTH * scaling; - float h = XHAIR_HEIGHT * scaling; + float w = config::CrosshairSize * scaling; + float h = config::CrosshairSize * scaling; #endif x -= w / 2; y -= h / 2; diff --git a/shell/libretro/libretro.cpp b/shell/libretro/libretro.cpp index a3fe5363f..a1a7f3387 100644 --- a/shell/libretro/libretro.cpp +++ b/shell/libretro/libretro.cpp @@ -609,6 +609,9 @@ static bool set_variable_visibility(void) { option_display.visible = lightgunSettingsShown; + option_display.key = CORE_OPTION_NAME "_lightgun_crosshair_size_scaling"; + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); + for (unsigned i = 0; i < 4; i++) { char key[256]; @@ -911,6 +914,12 @@ static void update_variables(bool first_startup) else allow_service_buttons = false; + var.key = CORE_OPTION_NAME "_lightgun_crosshair_size_scaling"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + lightgun_crosshair_size = (float)LIGHTGUN_CROSSHAIR_SIZE * std::stof(var.value) / 100.f; + else + lightgun_crosshair_size = (float)LIGHTGUN_CROSSHAIR_SIZE; + char key[256]; key[0] = '\0'; diff --git a/shell/libretro/libretro_core_options.h b/shell/libretro/libretro_core_options.h index 33440768c..f45f1f8e8 100644 --- a/shell/libretro/libretro_core_options.h +++ b/shell/libretro/libretro_core_options.h @@ -878,6 +878,44 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, "disabled" }, + { + CORE_OPTION_NAME "_lightgun_crosshair_size_scaling", + "Gun Crosshair Size Scaling", + NULL, + "", + NULL, + "input", + { + { "50%", NULL }, + { "60%", NULL }, + { "70%", NULL }, + { "80%", NULL }, + { "90%", NULL }, + { "100%", NULL }, + { "110%", NULL }, + { "120%", NULL }, + { "130%", NULL }, + { "140%", NULL }, + { "150%", NULL }, + { "160%", NULL }, + { "170%", NULL }, + { "180%", NULL }, + { "190%", NULL }, + { "200%", NULL }, + { "210%", NULL }, + { "220%", NULL }, + { "230%", NULL }, + { "240%", NULL }, + { "250%", NULL }, + { "260%", NULL }, + { "270%", NULL }, + { "280%", NULL }, + { "290%", NULL }, + { "300%", NULL }, + { NULL, NULL }, + }, + "100%", + }, { CORE_OPTION_NAME "_lightgun1_crosshair", "Gun Crosshair 1 Display", diff --git a/shell/libretro/vmu_xhair.cpp b/shell/libretro/vmu_xhair.cpp index 5a1cf7030..d90729f28 100644 --- a/shell/libretro/vmu_xhair.cpp +++ b/shell/libretro/vmu_xhair.cpp @@ -112,6 +112,7 @@ u8 lightgun_palette[LIGHTGUN_COLORS_COUNT*3] = }; lightgun_params_t lightgun_params[4]; +float lightgun_crosshair_size = (float)LIGHTGUN_CROSSHAIR_SIZE; std::pair getCrosshairPosition(int playerNum) { diff --git a/shell/libretro/vmu_xhair.h b/shell/libretro/vmu_xhair.h index 208eed9f9..4bf13709f 100644 --- a/shell/libretro/vmu_xhair.h +++ b/shell/libretro/vmu_xhair.h @@ -111,3 +111,4 @@ struct lightgun_params_t { extern u8 lightgun_palette[LIGHTGUN_COLORS_COUNT*3]; extern u8 lightgun_img_crosshair[LIGHTGUN_CROSSHAIR_SIZE*LIGHTGUN_CROSSHAIR_SIZE]; extern lightgun_params_t lightgun_params[4] ; +extern float lightgun_crosshair_size;