2016-07-17 20:25:24 +00:00
|
|
|
#ifndef ACTIONSTATUS_H
|
|
|
|
#define ACTIONSTATUS_H
|
|
|
|
|
|
|
|
#include "GameKeys.h"
|
|
|
|
#include "Joystick.h"
|
|
|
|
|
|
|
|
class ActionSet;
|
|
|
|
|
|
|
|
const unsigned mouseExtraButtons = 8;
|
|
|
|
|
2017-02-15 03:34:32 +00:00
|
|
|
// *_END is non-inclusive!
|
2016-07-17 20:25:24 +00:00
|
|
|
enum ActionButtonType
|
|
|
|
{
|
2024-09-22 00:36:18 +00:00
|
|
|
// Only concerns real mouse buttons, not whatever is mapped to "left mouse"
|
|
|
|
MOUSE_BUTTON_REAL_LEFT = KEY_MAXARRAY + 1,
|
|
|
|
MOUSE_BUTTON_REAL_RIGHT,
|
|
|
|
MOUSE_BUTTON_REAL_MIDDLE,
|
|
|
|
|
|
|
|
MOUSE_BUTTON_LEFT,
|
2016-07-17 20:25:24 +00:00
|
|
|
MOUSE_BUTTON_RIGHT,
|
|
|
|
MOUSE_BUTTON_MIDDLE,
|
|
|
|
MOUSE_BUTTON_EXTRA_START,
|
|
|
|
MOUSE_BUTTON_EXTRA_END = MOUSE_BUTTON_EXTRA_START + mouseExtraButtons,
|
|
|
|
|
2021-01-12 13:24:30 +00:00
|
|
|
// maps to whatever is configured as the primary joystick x/y axes
|
|
|
|
JOY_STICK_LEFT = MOUSE_BUTTON_EXTRA_END,
|
|
|
|
JOY_STICK_RIGHT,
|
|
|
|
JOY_STICK_UP,
|
|
|
|
JOY_STICK_DOWN,
|
|
|
|
|
|
|
|
INTERNALLY_USED_ACTION_BUTTONS_END, // Engine needs anything above this for handling inputs properly
|
|
|
|
|
|
|
|
JOY_BUTTON_0 = INTERNALLY_USED_ACTION_BUTTONS_END,
|
2016-07-17 20:25:24 +00:00
|
|
|
JOY_BUTTON_END = JOY_BUTTON_0 + MAX_JOYSTICK_BTN,
|
|
|
|
|
|
|
|
JOY_AXIS_0_POS = JOY_BUTTON_END,
|
|
|
|
JOY_AXIS_END_POS = JOY_AXIS_0_POS + MAX_JOYSTICK_AXIS,
|
|
|
|
|
|
|
|
JOY_AXIS_0_NEG = JOY_AXIS_END_POS,
|
|
|
|
JOY_AXIS_END_NEG = JOY_AXIS_0_NEG + MAX_JOYSTICK_AXIS,
|
|
|
|
|
2020-07-07 20:30:25 +00:00
|
|
|
JOY_HAT_BEGIN = JOY_AXIS_END_NEG,
|
|
|
|
JOY_HAT_0_LEFT = JOY_HAT_BEGIN,
|
|
|
|
JOY_HAT_END_LEFT = JOY_HAT_0_LEFT + MAX_JOYSTICK_HATS,
|
|
|
|
|
|
|
|
JOY_HAT_0_RIGHT = JOY_HAT_END_LEFT,
|
|
|
|
JOY_HAT_END_RIGHT = JOY_HAT_0_RIGHT + MAX_JOYSTICK_HATS,
|
|
|
|
|
|
|
|
JOY_HAT_0_UP = JOY_HAT_END_RIGHT,
|
|
|
|
JOY_HAT_END_UP = JOY_HAT_0_UP + MAX_JOYSTICK_HATS,
|
|
|
|
|
|
|
|
JOY_HAT_0_DOWN = JOY_HAT_END_UP,
|
|
|
|
JOY_HAT_END_DOWN = JOY_HAT_0_DOWN + MAX_JOYSTICK_HATS,
|
|
|
|
JOY_HAT_END = JOY_HAT_END_DOWN,
|
|
|
|
|
|
|
|
ACTION_BUTTON_ENUM_SIZE = JOY_HAT_END
|
2016-07-17 20:25:24 +00:00
|
|
|
};
|
|
|
|
|
2020-07-07 20:30:25 +00:00
|
|
|
ActionButtonType joyHatToActionButton(unsigned hatID, JoyHatDirection dir);
|
|
|
|
|
2016-07-17 20:25:24 +00:00
|
|
|
class ActionButtonStatus
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ActionButtonStatus();
|
|
|
|
void update();
|
|
|
|
inline bool getKeyState(int k) const { return !!status[k]; }
|
|
|
|
inline bool isKeyChanged(int k) { return !!changed[k]; }
|
|
|
|
void import(const ActionSet& as);
|
2016-07-17 23:27:58 +00:00
|
|
|
void importQuery(const int *pKeys, size_t num);
|
2016-07-17 20:25:24 +00:00
|
|
|
inline const std::vector<int>& getToQuery() const {return toQuery; }
|
|
|
|
inline int getJoystickID() const { return joystickID; }
|
|
|
|
private:
|
|
|
|
void _queryAllStatus();
|
|
|
|
bool _queryStatus(int k) const;
|
|
|
|
|
|
|
|
int joystickID;
|
|
|
|
unsigned char status[ACTION_BUTTON_ENUM_SIZE];
|
|
|
|
unsigned char changed[ACTION_BUTTON_ENUM_SIZE];
|
|
|
|
std::vector<int> toQuery;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|