@@ -44,4 +44,53 @@ std::string formatAddressIntoOffsetImpl(uintptr_t addr, bool module) {
4444 return fmt::format (" {:#x}" , addr - reinterpret_cast <uintptr_t >(mod));
4545}
4646
47- #endif
47+ // mostly copied from gd-imgui-cocos
48+ void setMouseCursor () {
49+ // Shows imgui's cursor instead of hidden cursor if out of GD Window
50+ bool isCursorVisible = false ;
51+ CURSORINFO ci = { sizeof (ci) };
52+ if (GetCursorInfo (&ci)) {
53+ isCursorVisible = (ci.flags & CURSOR_SHOWING) != 0 ;
54+ }
55+ // whether to draw a fake cursor
56+ ImGui::GetIO ().MouseDrawCursor = DevTools::get ()->isVisible () && !isCursorVisible && !shouldPassEventsToGDButTransformed ();
57+
58+ struct GLFWCursorData {
59+ void * next = nullptr ;
60+ HCURSOR cursor;
61+ };
62+ auto & cursorField = *reinterpret_cast <GLFWCursorData**>(reinterpret_cast <uintptr_t >(
63+ CCEGLView::get ()->getWindow ()) + 0x50 );
64+
65+ auto cursor = ImGui::GetIO ().MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor ();
66+ static ImGuiMouseCursor lastCursor = ImGuiMouseCursor_COUNT;
67+ if (cursor != lastCursor) {
68+ lastCursor = cursor;
69+
70+ auto winCursor = IDC_ARROW;
71+ switch (cursor) {
72+ case ImGuiMouseCursor_Arrow: winCursor = IDC_ARROW; break ;
73+ case ImGuiMouseCursor_TextInput: winCursor = IDC_IBEAM; break ;
74+ case ImGuiMouseCursor_ResizeAll: winCursor = IDC_SIZEALL; break ;
75+ case ImGuiMouseCursor_ResizeEW: winCursor = IDC_SIZEWE; break ;
76+ case ImGuiMouseCursor_ResizeNS: winCursor = IDC_SIZENS; break ;
77+ case ImGuiMouseCursor_ResizeNESW: winCursor = IDC_SIZENESW; break ;
78+ case ImGuiMouseCursor_ResizeNWSE: winCursor = IDC_SIZENWSE; break ;
79+ case ImGuiMouseCursor_Hand: winCursor = IDC_HAND; break ;
80+ case ImGuiMouseCursor_NotAllowed: winCursor = IDC_NO; break ;
81+ }
82+ if (cursorField) {
83+ cursorField->cursor = LoadCursor (NULL , winCursor);
84+ }
85+ else {
86+ // must be heap allocated
87+ cursorField = new GLFWCursorData {
88+ .next = nullptr ,
89+ .cursor = LoadCursor (NULL , winCursor)
90+ };
91+ }
92+ }
93+ }
94+
95+ #endif
96+
0 commit comments