1 Star 0 Fork 1

波波/Gut

forked from 2144/Gut 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Mouse.cpp 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
2144 提交于 2023-09-24 21:29 . s
#include "Mouse.h"
Mouse::Mouse()
{
}
bool Mouse::MousePressing(int i)
{
if (i < sizeof(this->states))
{
return states[i];
}
return false;
}
std::vector<Mouse::Event> Mouse::Events() const
{
return this->events;
}
Mouse::Vec2 Mouse::CurrenPos() const
{
return this->currentPos;
}
Mouse::Vec2 Mouse::ScrollDelta() const
{
return this->scrollDelta;
}
void Mouse::OnScroll(double x, double y)
{
this->scrollDelta.x = x;
this->scrollDelta.y = y;
}
void Mouse::OnCursorPos(double x, double y)
{
currentPos.x = x;
currentPos.y = y;
}
void Mouse::OnMouse(int key, int action, int mode)
{
Mouse::Event newE;
newE.key = key;
newE.action = action;
newE.mode = mode;
this->events.emplace_back(newE);
if (action == 0)
{
this->states[key] = false;
}
else if (action == 1)
{
this->states[key] = true;
}
}
bool Mouse::MouseEvent(int key, int mode, int action)
{
for (const auto& ev : events)
{
if (ev.key == key && ev.mode == mode && ev.action == action)
{
return true;
}
}
return false;
}
bool Mouse::MouseDown(int key, int mode)
{
return MouseEvent(key, mode, 1);
}
bool Mouse::MouseRelease(int key, int mode)
{
return MouseEvent(key, mode, 0);
}
void Mouse::OnClearEvent()
{
this->events.clear();
this->scrollDelta = { 0.0f,0.0f };
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/bobo110/gut.git
git@gitee.com:bobo110/gut.git
bobo110
gut
Gut
master

搜索帮助