@@ -25,25 +25,53 @@ namespace dxvk {
25
25
}
26
26
27
27
28
- HRESULT D3D9Cursor::SetHardwareCursor (UINT XHotSpot, UINT YHotSpot, const CursorBitmap& bitmap) {
29
- DWORD mask[32 ];
30
- std::memset (mask, ~0 , sizeof (mask));
28
+ HRESULT D3D9Cursor::SetHardwareCursor (
29
+ UINT XHotSpot,
30
+ UINT YHotSpot,
31
+ const std::vector<uint8_t >& bitmap,
32
+ bool cursorEmulation,
33
+ UINT width,
34
+ UINT height,
35
+ HWND window) {
36
+ bool noPreviousHardwareCursor = false ;
37
+
38
+ uint32_t cursorWidth = cursorEmulation ? width : HardwareCursorWidth;
39
+ uint32_t cursorHeight = cursorEmulation ? height : HardwareCursorHeight;
40
+
41
+ // For color icons, the hbmMask and hbmColor bitmaps
42
+ // are the same size, each of which is the size of the icon.
43
+ std::vector<DWORD> mask (cursorWidth * cursorHeight, ~0 );
31
44
32
45
ICONINFO info;
33
46
info.fIcon = FALSE ;
34
47
info.xHotspot = XHotSpot;
35
48
info.yHotspot = YHotSpot;
36
- info.hbmMask = ::CreateBitmap (HardwareCursorWidth, HardwareCursorHeight , 1 , 1 , mask);
37
- info.hbmColor = ::CreateBitmap (HardwareCursorWidth, HardwareCursorHeight , 1 , 32 , &bitmap[0 ]);
49
+ info.hbmMask = ::CreateBitmap (cursorWidth, cursorHeight , 1 , 1 , & mask[ 0 ] );
50
+ info.hbmColor = ::CreateBitmap (cursorWidth, cursorHeight , 1 , 32 , &bitmap[0 ]);
38
51
39
52
if (m_hCursor != nullptr )
40
53
::DestroyCursor (m_hCursor);
54
+ else
55
+ noPreviousHardwareCursor = true ;
41
56
42
57
m_hCursor = ::CreateIconIndirect (&info);
43
58
44
59
::DeleteObject (info.hbmMask);
45
60
::DeleteObject (info.hbmColor);
46
61
62
+ if (cursorEmulation) {
63
+ ::SetClassLongPtr (window, GCLP_HCURSOR, reinterpret_cast <LONG_PTR>(m_hCursor));
64
+
65
+ CURSORINFO ci;
66
+ while (::GetCursorInfo (&ci) && ci.flags == 0u )
67
+ ::ShowCursor (TRUE );
68
+
69
+ // Castle Strike needs one extra initial increment
70
+ // to display the emulated cursor on its menu
71
+ if (noPreviousHardwareCursor)
72
+ ::ShowCursor (TRUE );
73
+ }
74
+
47
75
ShowCursor (m_visible);
48
76
49
77
return D3D_OK;
@@ -60,7 +88,14 @@ namespace dxvk {
60
88
}
61
89
62
90
63
- HRESULT D3D9Cursor::SetHardwareCursor (UINT XHotSpot, UINT YHotSpot, const CursorBitmap& bitmap) {
91
+ HRESULT D3D9Cursor::SetHardwareCursor (
92
+ UINT XHotSpot,
93
+ UINT YHotSpot,
94
+ const std::vector<uint8_t >& bitmap,
95
+ bool cursorEmulation,
96
+ UINT width,
97
+ UINT height,
98
+ HWND window) {
64
99
Logger::warn (" D3D9Cursor::SetHardwareCursor: Not supported on current platform." );
65
100
66
101
return D3D_OK;
0 commit comments