EHS/src/io/hid/Mouse.cpp

88 lines
1.5 KiB
C++
Raw Normal View History

2024-02-05 22:25:30 -08:00
#include "ehs/io/hid/Mouse.h"
namespace ehs
{
Mouse::Mouse()
{
}
Mouse::Mouse(Str_8 name, const UInt_64 id)
: HID(EHS_HID_MOUSE, (Str_8&&)name, id)
{
}
Mouse::Mouse(const Mouse& hid)
: HID(hid), delta(hid.delta)
{
}
Mouse& Mouse::operator=(const Mouse& hid)
{
if (this == &hid)
return *this;
HID::operator=(hid);
delta = hid.delta;
return *this;
}
void Mouse::Poll()
{
delta = {};
HID::Poll();
}
void Mouse::SetDelta(const Vec2_s32& newDelta)
{
delta = newDelta;
}
Vec2_s32 Mouse::GetDelta() const
{
return delta;
}
Mouse* Mouse::Clone() const
{
return new Mouse(*this);
}
const Button Mouse::Unknown("Unknown");
const Button Mouse::LMB("Left Mouse Button");
const Button Mouse::MMB("Middle Mouse Button");
const Button Mouse::RMB("Right Mouse Button");
const Button Mouse::Four("Mouse Button Four");
const Button Mouse::Five("Mouse Button Five");
const Button Mouse::ScrollUp("Scroll Up");
const Button Mouse::ScrollDown("Scroll Down");
const Button Mouse::ScrollLeft("Scroll Left");
const Button Mouse::ScrollRight("Scroll Right");
const Button Mouse::Back("Back Mouse Button");
const Button Mouse::Forward("Forward Mouse Button");
Button Mouse::TranslateXCB(const UInt_32 code)
{
switch (code)
{
case 1:
return Mouse::LMB;
case 2:
return Mouse::MMB;
case 3:
return Mouse::RMB;
case 4:
return Mouse::ScrollUp;
case 5:
return Mouse::ScrollDown;
case 8:
return Mouse::Back;
case 9:
return Mouse::Forward;
default:
return Mouse::Unknown;
}
}
}