GPUDevice: Move software cursor to ImGuiManager
This commit is contained in:
@ -69,7 +69,7 @@ std::optional<u32> Controller::GetAnalogInputBytes() const
|
||||
|
||||
void Controller::LoadSettings(SettingsInterface& si, const char* section) {}
|
||||
|
||||
bool Controller::GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale, bool* relative_mode)
|
||||
bool Controller::GetSoftwareCursor(std::string* image_path, float* image_scale, bool* relative_mode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public:
|
||||
virtual void LoadSettings(SettingsInterface& si, const char* section);
|
||||
|
||||
/// Returns the software cursor to use for this controller, if any.
|
||||
virtual bool GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale, bool* relative_mode);
|
||||
virtual bool GetSoftwareCursor(std::string* image_path, float* image_scale, bool* relative_mode);
|
||||
|
||||
/// Creates a new controller of the specified type.
|
||||
static std::unique_ptr<Controller> Create(ControllerType type, u32 index);
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
#include "guncon.h"
|
||||
#include "gpu.h"
|
||||
#include "host.h"
|
||||
#include "resources.h"
|
||||
#include "system.h"
|
||||
|
||||
#include "util/gpu_device.h"
|
||||
@ -12,6 +11,7 @@
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/log.h"
|
||||
#include "common/path.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
@ -19,7 +19,9 @@ Log_SetChannel(GunCon);
|
||||
|
||||
static constexpr std::array<u8, static_cast<size_t>(GunCon::Button::Count)> s_button_indices = {{13, 3, 14}};
|
||||
|
||||
GunCon::GunCon(u32 index) : Controller(index) {}
|
||||
GunCon::GunCon(u32 index) : Controller(index)
|
||||
{
|
||||
}
|
||||
|
||||
GunCon::~GunCon() = default;
|
||||
|
||||
@ -248,22 +250,10 @@ void GunCon::LoadSettings(SettingsInterface& si, const char* section)
|
||||
{
|
||||
Controller::LoadSettings(si, section);
|
||||
|
||||
std::string path = si.GetStringValue(section, "CrosshairImagePath");
|
||||
if (path != m_crosshair_image_path)
|
||||
{
|
||||
m_crosshair_image_path = std::move(path);
|
||||
if (m_crosshair_image_path.empty() || !m_crosshair_image.LoadFromFile(m_crosshair_image_path.c_str()))
|
||||
{
|
||||
m_crosshair_image.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
m_crosshair_image_path = si.GetStringValue(section, "CrosshairImagePath");
|
||||
#ifndef __ANDROID__
|
||||
if (!m_crosshair_image.IsValid())
|
||||
{
|
||||
m_crosshair_image.SetPixels(Resources::CROSSHAIR_IMAGE_WIDTH, Resources::CROSSHAIR_IMAGE_HEIGHT,
|
||||
Resources::CROSSHAIR_IMAGE_DATA.data());
|
||||
}
|
||||
if (m_crosshair_image_path.empty())
|
||||
m_crosshair_image_path = Path::Combine(EmuFolders::Resources, "images/crosshair.png");
|
||||
#endif
|
||||
|
||||
m_crosshair_image_scale = si.GetFloatValue(section, "CrosshairScale", 1.0f);
|
||||
@ -271,12 +261,12 @@ void GunCon::LoadSettings(SettingsInterface& si, const char* section)
|
||||
m_x_scale = si.GetFloatValue(section, "XScale", 1.0f);
|
||||
}
|
||||
|
||||
bool GunCon::GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale, bool* relative_mode)
|
||||
bool GunCon::GetSoftwareCursor(std::string* image_path, float* image_scale, bool* relative_mode)
|
||||
{
|
||||
if (!m_crosshair_image.IsValid())
|
||||
if (m_crosshair_image_path.empty())
|
||||
return false;
|
||||
|
||||
*image = &m_crosshair_image;
|
||||
*image_path = m_crosshair_image_path;
|
||||
*image_scale = m_crosshair_image_scale;
|
||||
*relative_mode = false;
|
||||
return true;
|
||||
|
||||
@ -32,7 +32,7 @@ public:
|
||||
bool DoState(StateWrapper& sw, bool apply_input_state) override;
|
||||
|
||||
void LoadSettings(SettingsInterface& si, const char* section) override;
|
||||
bool GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale, bool* relative_mode) override;
|
||||
bool GetSoftwareCursor(std::string* image_path, float* image_scale, bool* relative_mode) override;
|
||||
|
||||
float GetBindState(u32 index) const override;
|
||||
void SetBindState(u32 index, float value) override;
|
||||
@ -56,7 +56,6 @@ private:
|
||||
YMSB
|
||||
};
|
||||
|
||||
Common::RGBA8Image m_crosshair_image;
|
||||
std::string m_crosshair_image_path;
|
||||
float m_crosshair_image_scale = 1.0f;
|
||||
float m_x_scale = 1.0f;
|
||||
|
||||
@ -349,6 +349,7 @@ void Host::RenderDisplay(bool skip_present)
|
||||
FullscreenUI::Render();
|
||||
ImGuiManager::RenderTextOverlays();
|
||||
ImGuiManager::RenderOSDMessages();
|
||||
ImGuiManager::RenderSoftwareCursors();
|
||||
}
|
||||
|
||||
// Debug windows are always rendered, otherwise mouse input breaks on skip.
|
||||
|
||||
@ -215,7 +215,7 @@ void PlayStationMouse::LoadSettings(SettingsInterface& si, const char* section)
|
||||
m_use_relative_mode = si.GetBoolValue(section, "RelativeMouseMode", false);
|
||||
}
|
||||
|
||||
bool PlayStationMouse::GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale, bool* relative_mode)
|
||||
bool PlayStationMouse::GetSoftwareCursor(std::string* image_path, float* image_scale, bool* relative_mode)
|
||||
{
|
||||
*relative_mode = m_use_relative_mode;
|
||||
return m_use_relative_mode;
|
||||
|
||||
@ -36,7 +36,7 @@ public:
|
||||
bool Transfer(const u8 data_in, u8* data_out) override;
|
||||
|
||||
void LoadSettings(SettingsInterface& si, const char* section) override;
|
||||
bool GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale, bool* relative_mode) override;
|
||||
bool GetSoftwareCursor(std::string* image_path, float* image_scale, bool* relative_mode) override;
|
||||
|
||||
private:
|
||||
void UpdatePosition();
|
||||
|
||||
@ -4624,11 +4624,11 @@ void System::UpdateSoftwareCursor()
|
||||
if (!IsValid())
|
||||
{
|
||||
Host::SetMouseMode(false, false);
|
||||
g_gpu_device->ClearSoftwareCursor();
|
||||
ImGuiManager::ClearSoftwareCursor(0);
|
||||
return;
|
||||
}
|
||||
|
||||
const Common::RGBA8Image* image = nullptr;
|
||||
std::string image_path;
|
||||
float image_scale = 1.0f;
|
||||
bool relative_mode = false;
|
||||
bool hide_cursor = false;
|
||||
@ -4636,7 +4636,7 @@ void System::UpdateSoftwareCursor()
|
||||
for (u32 i = 0; i < NUM_CONTROLLER_AND_CARD_PORTS; i++)
|
||||
{
|
||||
Controller* controller = System::GetController(i);
|
||||
if (controller && controller->GetSoftwareCursor(&image, &image_scale, &relative_mode))
|
||||
if (controller && controller->GetSoftwareCursor(&image_path, &image_scale, &relative_mode))
|
||||
{
|
||||
hide_cursor = true;
|
||||
break;
|
||||
@ -4645,15 +4645,10 @@ void System::UpdateSoftwareCursor()
|
||||
|
||||
Host::SetMouseMode(relative_mode, hide_cursor);
|
||||
|
||||
if (image && image->IsValid())
|
||||
{
|
||||
g_gpu_device->SetSoftwareCursor(image->GetPixels(), image->GetWidth(), image->GetHeight(), image->GetPitch(),
|
||||
image_scale);
|
||||
}
|
||||
if (!image_path.empty())
|
||||
ImGuiManager::SetSoftwareCursor(0, std::move(image_path), image_scale);
|
||||
else
|
||||
{
|
||||
g_gpu_device->ClearSoftwareCursor();
|
||||
}
|
||||
ImGuiManager::ClearSoftwareCursor(0);
|
||||
}
|
||||
|
||||
void System::RequestDisplaySize(float scale /*= 0.0f*/)
|
||||
|
||||
Reference in New Issue
Block a user