From ecd317e020324d73300a3459577dea14641e1402 Mon Sep 17 00:00:00 2001 From: zhenyan121 <3367366583@qq.com> Date: Sun, 7 Dec 2025 15:53:59 +0800 Subject: [PATCH] Add mouse motion --- src/input/InputManager.cpp | 14 ++++++++++++-- src/input/InputState.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/input/InputManager.cpp b/src/input/InputManager.cpp index 0497840..5b197de 100644 --- a/src/input/InputManager.cpp +++ b/src/input/InputManager.cpp @@ -10,10 +10,20 @@ SDL_AppResult InputManager::handleInputEvent(const SDL_Event* event) { if (event->button.button == SDL_BUTTON_LEFT) { // 更新状态 m_currentInputState.mouseCilckOn = {event->button.x, event->button.y}; + m_currentInputState.leftMouseDown = true; - - return SDL_APP_CONTINUE; + break; } + case SDL_EVENT_MOUSE_BUTTON_UP: + if (event->button.button == SDL_BUTTON_LEFT) { + m_currentInputState.leftMouseDown = false; + + break; + } + case SDL_EVENT_MOUSE_MOTION: + m_currentInputState.mouseCurrentPosition = {static_cast(event->motion.x), + static_cast(event->motion.y)}; + break; } return SDL_APP_CONTINUE; } diff --git a/src/input/InputState.h b/src/input/InputState.h index f00fa7d..84007ff 100644 --- a/src/input/InputState.h +++ b/src/input/InputState.h @@ -3,4 +3,6 @@ struct InputState { std::pair mouseCilckOn; + bool leftMouseDown = false; + std::pair mouseCurrentPosition; };