mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-23 20:09:46 +03:00
* Outline all the Mouse and Keyboard code.
This commit is contained in:
@@ -8,13 +8,13 @@
|
||||
|
||||
#include "Mouse.hpp"
|
||||
|
||||
std::vector<MouseInput> Mouse::_inputs;
|
||||
std::vector<MouseAction> Mouse::_inputs;
|
||||
int Mouse::_index, Mouse::_x, Mouse::_y;
|
||||
int Mouse::_xOld, Mouse::_yOld, Mouse::_buttonStates[3];
|
||||
|
||||
void Mouse::feed(int x1, int x2, int x3, int x4)
|
||||
{
|
||||
_inputs.push_back(MouseInput(x1, x2, x3, x4));
|
||||
_inputs.push_back(MouseAction(x1, x2, x3, x4));
|
||||
|
||||
if (x1 >= 3)
|
||||
return;
|
||||
@@ -27,3 +27,72 @@ void Mouse::feed(int x1, int x2, int x3, int x4)
|
||||
_x = x3;
|
||||
_y = x4;
|
||||
}
|
||||
|
||||
short Mouse::getX()
|
||||
{
|
||||
return short(_x);
|
||||
}
|
||||
|
||||
short Mouse::getY()
|
||||
{
|
||||
return short(_y);
|
||||
}
|
||||
|
||||
bool Mouse::next()
|
||||
{
|
||||
if (_index + 1 >= int(_inputs.size()))
|
||||
return false;
|
||||
|
||||
_index++;
|
||||
return true;
|
||||
}
|
||||
|
||||
int Mouse::getEventButton()
|
||||
{
|
||||
return _inputs[_index].field_0;
|
||||
}
|
||||
|
||||
bool Mouse::isButtonDown(int btn)
|
||||
{
|
||||
return _buttonStates[btn];
|
||||
}
|
||||
|
||||
void Mouse::reset()
|
||||
{
|
||||
_inputs.clear();
|
||||
_index = -1;
|
||||
}
|
||||
|
||||
MouseAction* Mouse::getEvent()
|
||||
{
|
||||
return &_inputs[_index];
|
||||
}
|
||||
|
||||
int Mouse::getButtonState(int btn)
|
||||
{
|
||||
if (btn <= 0 || btn >= 3)
|
||||
return 0;
|
||||
|
||||
return _buttonStates[btn];
|
||||
}
|
||||
|
||||
void Mouse::setX(int x)
|
||||
{
|
||||
_x = x;
|
||||
}
|
||||
|
||||
void Mouse::setY(int y)
|
||||
{
|
||||
_y = y;
|
||||
}
|
||||
|
||||
void Mouse::reset2()
|
||||
{
|
||||
_xOld = _x;
|
||||
_yOld = _y;
|
||||
}
|
||||
|
||||
int Mouse::getEventButtonState()
|
||||
{
|
||||
return _inputs[_index].field_4;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user