2019-12-16 03:28:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "d3d9_include.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2024-09-28 15:53:02 +03:00
|
|
|
/**
|
|
|
|
* \brief D3D9 Software Cursor
|
|
|
|
*/
|
|
|
|
struct D3D9_SOFTWARE_CURSOR {
|
2024-10-08 20:55:52 +03:00
|
|
|
UINT Width = 0;
|
2024-09-28 15:53:02 +03:00
|
|
|
UINT Height = 0;
|
|
|
|
UINT X = 0;
|
|
|
|
UINT Y = 0;
|
2024-10-08 20:55:52 +03:00
|
|
|
bool DrawCursor = false;
|
|
|
|
bool ResetCursor = false;
|
2024-09-28 15:53:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
constexpr uint32_t HardwareCursorWidth = 32u;
|
|
|
|
constexpr uint32_t HardwareCursorHeight = 32u;
|
2019-12-16 03:28:01 +00:00
|
|
|
constexpr uint32_t HardwareCursorFormatSize = 4u;
|
|
|
|
constexpr uint32_t HardwareCursorPitch = HardwareCursorWidth * HardwareCursorFormatSize;
|
|
|
|
|
|
|
|
// Format Size of 4 bytes (ARGB)
|
|
|
|
using CursorBitmap = uint8_t[HardwareCursorHeight * HardwareCursorPitch];
|
2024-07-06 23:43:38 +03:00
|
|
|
// Monochrome mask (1 bit)
|
2024-09-28 15:53:02 +03:00
|
|
|
using CursorMask = uint8_t[HardwareCursorHeight * HardwareCursorWidth / 8];
|
2019-12-16 03:28:01 +00:00
|
|
|
|
|
|
|
class D3D9Cursor {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2024-07-06 23:43:38 +03:00
|
|
|
#ifdef _WIN32
|
|
|
|
~D3D9Cursor() {
|
|
|
|
if (m_hCursor != nullptr)
|
|
|
|
::DestroyCursor(m_hCursor);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-09-28 15:53:02 +03:00
|
|
|
void ResetCursor();
|
|
|
|
|
2024-10-08 20:55:52 +03:00
|
|
|
void ResetHardwareCursor();
|
|
|
|
|
|
|
|
void ResetSoftwareCursor();
|
|
|
|
|
2019-12-16 03:28:01 +00:00
|
|
|
void UpdateCursor(int X, int Y);
|
|
|
|
|
2024-09-28 15:53:02 +03:00
|
|
|
void RefreshSoftwareCursorPosition();
|
|
|
|
|
2019-12-16 03:28:01 +00:00
|
|
|
BOOL ShowCursor(BOOL bShow);
|
|
|
|
|
|
|
|
HRESULT SetHardwareCursor(UINT XHotSpot, UINT YHotSpot, const CursorBitmap& bitmap);
|
|
|
|
|
2024-09-28 15:53:02 +03:00
|
|
|
HRESULT SetSoftwareCursor(UINT Width, UINT Height, UINT XHotSpot, UINT YHotSpot);
|
|
|
|
|
|
|
|
D3D9_SOFTWARE_CURSOR* GetSoftwareCursor() {
|
|
|
|
return &m_sCursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL IsSoftwareCursor() const {
|
|
|
|
return m_sCursor.Width > 0 && m_sCursor.Height > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL IsCursorVisible() const {
|
|
|
|
return m_visible;
|
|
|
|
}
|
|
|
|
|
2019-12-16 03:28:01 +00:00
|
|
|
private:
|
|
|
|
|
2024-09-28 15:53:02 +03:00
|
|
|
BOOL m_visible = FALSE;
|
|
|
|
D3D9_SOFTWARE_CURSOR m_sCursor;
|
2019-12-16 03:28:01 +00:00
|
|
|
|
2022-08-21 18:41:51 +00:00
|
|
|
#ifdef _WIN32
|
2024-09-28 15:53:02 +03:00
|
|
|
HCURSOR m_hCursor = nullptr;
|
2022-08-21 18:41:51 +00:00
|
|
|
#endif
|
2019-12-16 03:28:01 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|