mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 06:14:08 +08:00
Add mouse motion
This commit is contained in:
@@ -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<float>(event->motion.x),
|
||||
static_cast<float>(event->motion.y)};
|
||||
break;
|
||||
}
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@
|
||||
struct InputState
|
||||
{
|
||||
std::pair<float, float> mouseCilckOn;
|
||||
bool leftMouseDown = false;
|
||||
std::pair<float, float> mouseCurrentPosition;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user