/**************************************************************************/1/* input_enums.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/error/error_macros.h"3334enum class InputEventType {35INVALID = -1,36KEY,37MOUSE_BUTTON,38MOUSE_MOTION,39JOY_MOTION,40JOY_BUTTON,41SCREEN_TOUCH,42SCREEN_DRAG,43MAGNIFY_GESTURE,44PAN_GESTURE,45MIDI,46SHORTCUT,47ACTION,48MAX,49};5051enum class HatDir {52UP = 0,53RIGHT = 1,54DOWN = 2,55LEFT = 3,56MAX = 4,57};5859enum class HatMask {60CENTER = 0,61UP = 1,62RIGHT = 2,63DOWN = 4,64LEFT = 8,65};6667enum class JoyAxis {68INVALID = -1,69LEFT_X = 0,70LEFT_Y = 1,71RIGHT_X = 2,72RIGHT_Y = 3,73TRIGGER_LEFT = 4,74TRIGGER_RIGHT = 5,75SDL_MAX = 6,76MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.77};7879enum class JoyButton {80INVALID = -1,81A = 0,82B = 1,83X = 2,84Y = 3,85BACK = 4,86GUIDE = 5,87START = 6,88LEFT_STICK = 7,89RIGHT_STICK = 8,90LEFT_SHOULDER = 9,91RIGHT_SHOULDER = 10,92DPAD_UP = 11,93DPAD_DOWN = 12,94DPAD_LEFT = 13,95DPAD_RIGHT = 14,96MISC1 = 15,97PADDLE1 = 16,98PADDLE2 = 17,99PADDLE3 = 18,100PADDLE4 = 19,101TOUCHPAD = 20,102SDL_MAX = 21,103MAX = 128, // Android supports up to 36 buttons. DirectInput supports up to 128 buttons.104};105106enum class MIDIMessage {107NONE = 0,108NOTE_OFF = 0x8,109NOTE_ON = 0x9,110AFTERTOUCH = 0xA,111CONTROL_CHANGE = 0xB,112PROGRAM_CHANGE = 0xC,113CHANNEL_PRESSURE = 0xD,114PITCH_BEND = 0xE,115SYSTEM_EXCLUSIVE = 0xF0,116QUARTER_FRAME = 0xF1,117SONG_POSITION_POINTER = 0xF2,118SONG_SELECT = 0xF3,119TUNE_REQUEST = 0xF6,120TIMING_CLOCK = 0xF8,121START = 0xFA,122CONTINUE = 0xFB,123STOP = 0xFC,124ACTIVE_SENSING = 0xFE,125SYSTEM_RESET = 0xFF,126};127128enum class MouseButton {129NONE = 0,130LEFT = 1,131RIGHT = 2,132MIDDLE = 3,133WHEEL_UP = 4,134WHEEL_DOWN = 5,135WHEEL_LEFT = 6,136WHEEL_RIGHT = 7,137MB_XBUTTON1 = 8, // "XBUTTON1" is a reserved word on Windows.138MB_XBUTTON2 = 9, // "XBUTTON2" is a reserved word on Windows.139};140141enum class MouseButtonMask {142NONE = 0,143LEFT = (1 << (int(MouseButton::LEFT) - 1)),144RIGHT = (1 << (int(MouseButton::RIGHT) - 1)),145MIDDLE = (1 << (int(MouseButton::MIDDLE) - 1)),146MB_XBUTTON1 = (1 << (int(MouseButton::MB_XBUTTON1) - 1)),147MB_XBUTTON2 = (1 << (int(MouseButton::MB_XBUTTON2) - 1)),148};149150inline MouseButtonMask mouse_button_to_mask(MouseButton button) {151ERR_FAIL_COND_V(button == MouseButton::NONE, MouseButtonMask::NONE);152153return MouseButtonMask(1 << ((int)button - 1));154}155156constexpr MouseButtonMask operator|(MouseButtonMask p_a, MouseButtonMask p_b) {157return static_cast<MouseButtonMask>(static_cast<int>(p_a) | static_cast<int>(p_b));158}159160constexpr MouseButtonMask &operator|=(MouseButtonMask &p_a, MouseButtonMask p_b) {161return p_a = p_a | p_b;162}163164165