#include "dl_input.h" #ifndef DL_DISABLE_RENDER #include "system/dl_system.h" #include "system/dl_time.h" namespace dl { Input* g_input; dl::Point Input::GetCursorPosition() { return Each::Limit(_cursorPos, {}, toPoint(g_system->GetWindowSize())); } void Input::_update_late() { if (!KeyDown(MouseCode::LEFT)) { _bClickDouble = false; return; } time_t t = g_time->GetFrameTimeStampMill(); // 上一帧双击,此帧只能是单击 if (_bClickDouble) { _bClickDouble = false; _tClickPre = t; _cursorPosClickPre = _cursorPos; return; } // 时间过长 if (t > _tClickPre + _tMaxClickDouble) { _bClickDouble = false; _tClickPre = t; _cursorPosClickPre = _cursorPos; return; } // 距离过长 if (Math::DistancePow2(_cursorPos, _cursorPosClickPre) > _disMaxClickDouble * _disMaxClickDouble) { _bClickDouble = false; _tClickPre = t; _cursorPosClickPre = _cursorPos; return; } _bClickDouble = true; } } #endif