mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
ImGui: Implement cursor support on Windows
This commit is contained in:
parent
3cc7d6ef7a
commit
8cc77c0997
3 changed files with 35 additions and 0 deletions
|
@ -41,6 +41,7 @@
|
|||
#include "Common/Input/KeyCodes.h"
|
||||
#include "Common/Thread/ThreadUtil.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "ext/imgui/imgui_impl_platform.h"
|
||||
|
||||
#include "Core/Core.h"
|
||||
#include "Core/Config.h"
|
||||
|
@ -611,6 +612,31 @@ namespace MainWindow
|
|||
case WM_SETFOCUS:
|
||||
break;
|
||||
|
||||
case WM_SETCURSOR:
|
||||
if ((lParam & 0xFFFF) == HTCLIENT && g_Config.bShowImDebugger) {
|
||||
LPTSTR win32_cursor = 0;
|
||||
switch (ImGui_ImplPlatform_GetCursor()) {
|
||||
case ImGuiMouseCursor_Arrow: win32_cursor = IDC_ARROW; break;
|
||||
case ImGuiMouseCursor_TextInput: win32_cursor = IDC_IBEAM; break;
|
||||
case ImGuiMouseCursor_ResizeAll: win32_cursor = IDC_SIZEALL; break;
|
||||
case ImGuiMouseCursor_ResizeEW: win32_cursor = IDC_SIZEWE; break;
|
||||
case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break;
|
||||
case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break;
|
||||
case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
|
||||
case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break;
|
||||
case ImGuiMouseCursor_NotAllowed: win32_cursor = IDC_NO; break;
|
||||
}
|
||||
if (win32_cursor) {
|
||||
SetCursor(::LoadCursor(nullptr, win32_cursor));
|
||||
} else {
|
||||
SetCursor(nullptr);
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
if (firstErase) {
|
||||
firstErase = false;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include "imgui_impl_platform.h"
|
||||
|
||||
static ImGuiMouseCursor g_cursor = ImGuiMouseCursor_Arrow;
|
||||
|
||||
void ImGui_ImplPlatform_KeyEvent(const KeyInput &key) {
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
|
||||
|
@ -94,6 +96,7 @@ void ImGui_ImplPlatform_NewFrame() {
|
|||
|
||||
double now = time_now_d();
|
||||
|
||||
g_cursor = ImGui::GetMouseCursor();
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
io.DisplaySize = ImVec2(g_display.pixel_xres, g_display.pixel_yres);
|
||||
io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
||||
|
@ -102,6 +105,10 @@ void ImGui_ImplPlatform_NewFrame() {
|
|||
lastTime = now;
|
||||
}
|
||||
|
||||
ImGuiMouseCursor ImGui_ImplPlatform_GetCursor() {
|
||||
return g_cursor;
|
||||
}
|
||||
|
||||
// Written by chatgpt
|
||||
ImGuiKey KeyCodeToImGui(InputKeyCode keyCode) {
|
||||
switch (keyCode) {
|
||||
|
|
|
@ -14,3 +14,5 @@ void ImGui_ImplPlatform_NewFrame();
|
|||
void ImGui_ImplPlatform_KeyEvent(const KeyInput &key);
|
||||
void ImGui_ImplPlatform_TouchEvent(const TouchInput &touch);
|
||||
void ImGui_ImplPlatform_AxisEvent(const AxisInput &axis);
|
||||
|
||||
ImGuiMouseCursor ImGui_ImplPlatform_GetCursor();
|
||||
|
|
Loading…
Add table
Reference in a new issue