Files
mcpe/source/client/player/input/Mouse.hpp
Brent f7915a1dab Mac OS X 10.6 & More C++03 Support (#68)
* Mac OS X 10.6 & More C++03 Support

* Fix SDL2 options.txt loading for C++03

---------

Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com>
2023-08-27 11:46:15 +03:00

92 lines
1.7 KiB
C++

/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
#pragma once
#include <vector>
struct MouseAction;
class Mouse
{
public:
enum ButtonType
{
NONE,
LEFT,
RIGHT,
MIDDLE,
COUNT,
SCROLLWHEEL,
MIN = LEFT,
};
enum ButtonState
{
UP,
DOWN,
};
static void feed(ButtonType buttonType, ButtonState buttonState, int posX, int posY);
static short getX();
static short getY();
static bool next();
static bool isButtonDown(int btn);
static ButtonState getButtonState(ButtonType btn);
static ButtonType getEventButton();
static ButtonState getEventButtonState();
static MouseAction* getEvent();
static void setX(int x);
static void setY(int y);
static void reset();
static void reset2();
// @TODO: There's plenty of inlined code here. Out-line it.
private:
static std::vector<MouseAction> _inputs;
static int _index;
static int _x, _y;
static int _xOld, _yOld;
static ButtonState _buttonStates[Mouse::COUNT];
};
struct MouseAction
{
Mouse::ButtonType _buttonType;
Mouse::ButtonState _buttonState;
int _posX;
int _posY;
MouseAction()
{
_buttonType = Mouse::NONE;
_buttonState = Mouse::UP;
_posX = 0;
_posY = 0;
}
MouseAction(Mouse::ButtonType buttonType, Mouse::ButtonState buttonState, int posX, int posY)
{
_buttonType = buttonType;
_buttonState = buttonState;
_posX = posX;
_posY = posY;
}
bool isButton()
{
return
_buttonType == Mouse::LEFT ||
_buttonType == Mouse::RIGHT ||
_buttonType == Mouse::MIDDLE;
}
};