mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 00:45:47 -04:00
Qt: Implement relative mouse mode
This commit is contained in:
@ -47,7 +47,7 @@ float Controller::GetVibrationMotorStrength(u32 motor)
|
||||
|
||||
void Controller::LoadSettings(const char* section) {}
|
||||
|
||||
bool Controller::GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale)
|
||||
bool Controller::GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale, bool* relative_mode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
virtual void LoadSettings(const char* section);
|
||||
|
||||
/// Returns the software cursor to use for this controller, if any.
|
||||
virtual bool GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale);
|
||||
virtual bool GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale, bool* relative_mode);
|
||||
|
||||
/// Creates a new controller of the specified type.
|
||||
static std::unique_ptr<Controller> Create(ControllerType type, u32 index);
|
||||
|
@ -917,20 +917,28 @@ void HostInterface::UpdateSoftwareCursor()
|
||||
{
|
||||
if (System::IsShutdown())
|
||||
{
|
||||
SetMouseMode(false, false);
|
||||
m_display->ClearSoftwareCursor();
|
||||
return;
|
||||
}
|
||||
|
||||
const Common::RGBA8Image* image = nullptr;
|
||||
float image_scale = 1.0f;
|
||||
bool relative_mode = false;
|
||||
bool hide_cursor = false;
|
||||
|
||||
for (u32 i = 0; i < NUM_CONTROLLER_AND_CARD_PORTS; i++)
|
||||
{
|
||||
Controller* controller = System::GetController(i);
|
||||
if (controller && controller->GetSoftwareCursor(&image, &image_scale))
|
||||
if (controller && controller->GetSoftwareCursor(&image, &image_scale, &relative_mode))
|
||||
{
|
||||
hide_cursor = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetMouseMode(relative_mode, hide_cursor);
|
||||
|
||||
if (image && image->IsValid())
|
||||
{
|
||||
m_display->SetSoftwareCursor(image->GetPixels(), image->GetWidth(), image->GetHeight(), image->GetByteStride(),
|
||||
@ -967,6 +975,8 @@ void HostInterface::RecreateSystem()
|
||||
System::ResetPerformanceCounters();
|
||||
}
|
||||
|
||||
void HostInterface::SetMouseMode(bool relative, bool hide_cursor) {}
|
||||
|
||||
void HostInterface::DisplayLoadingScreen(const char* message, int progress_min /*= -1*/, int progress_max /*= -1*/,
|
||||
int progress_value /*= -1*/)
|
||||
{
|
||||
|
@ -175,6 +175,9 @@ protected:
|
||||
/// Switches the GPU renderer by saving state, recreating the display window, and restoring state (if needed).
|
||||
virtual void RecreateSystem();
|
||||
|
||||
/// Enables "relative" mouse mode, locking the cursor position and returning relative coordinates.
|
||||
virtual void SetMouseMode(bool relative, bool hide_cursor);
|
||||
|
||||
/// Sets the user directory to the program directory, i.e. "portable mode".
|
||||
void SetUserDirectoryToProgramDirectory();
|
||||
|
||||
|
@ -280,12 +280,13 @@ void NamcoGunCon::LoadSettings(const char* section)
|
||||
m_x_scale = g_host_interface->GetFloatSettingValue(section, "XScale", 1.0f);
|
||||
}
|
||||
|
||||
bool NamcoGunCon::GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale)
|
||||
bool NamcoGunCon::GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale, bool* relative_mode)
|
||||
{
|
||||
if (!m_crosshair_image.IsValid())
|
||||
return false;
|
||||
|
||||
*image = &m_crosshair_image;
|
||||
*image_scale = m_crosshair_image_scale;
|
||||
*relative_mode = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
void Reset() override;
|
||||
bool DoState(StateWrapper& sw, bool apply_input_state) override;
|
||||
void LoadSettings(const char* section) override;
|
||||
bool GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale) override;
|
||||
bool GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale, bool* relative_mode) override;
|
||||
|
||||
void SetAxisState(s32 axis_code, float value) override;
|
||||
void SetButtonState(s32 button_code, bool pressed) override;
|
||||
|
@ -39,6 +39,8 @@ public:
|
||||
|
||||
void SetButtonState(Button button, bool pressed);
|
||||
|
||||
bool GetSoftwareCursor(const Common::RGBA8Image** image, float* image_scale, bool* relative_mode) override;
|
||||
|
||||
private:
|
||||
void UpdatePosition();
|
||||
|
||||
|
Reference in New Issue
Block a user