1 /* 2 * Copyright (C) 2014-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9 #pragma once 10 11 /*! 12 \file 13 \ingroup joystick 14 */ 15 16 #include "input/InputTypes.h" 17 18 #include <set> 19 #include <string> 20 21 namespace KODI 22 { 23 namespace JOYSTICK 24 { 25 /*! 26 * \brief Name of a physical feature belonging to the joystick 27 */ 28 using FeatureName = std::string; 29 30 /*! 31 * \brief Types of features used in the joystick library 32 * 33 * Available types: 34 * 35 * 1) scalar[*] 36 * 2) analog stick 37 * 3) accelerometer 38 * 4) rumble motor 39 * 5) relative pointer 40 * 6) absolute pointer 41 * 7) wheel 42 * 8) throttle 43 * 9) keyboard key 44 * 45 * [*] All three driver primitives (buttons, hats and axes) have a state that 46 * can be represented using a single scalar value. For this reason, 47 * features that map to a single primitive are called "scalar features". 48 */ 49 enum class FEATURE_TYPE 50 { 51 UNKNOWN, 52 SCALAR, 53 ANALOG_STICK, 54 ACCELEROMETER, 55 MOTOR, 56 RELPOINTER, 57 ABSPOINTER, 58 WHEEL, 59 THROTTLE, 60 KEY, 61 }; 62 63 /*! 64 * \brief Categories of features used in the joystick library 65 */ 66 enum class FEATURE_CATEGORY 67 { 68 UNKNOWN, 69 FACE, 70 SHOULDER, 71 TRIGGER, 72 ANALOG_STICK, 73 ACCELEROMETER, 74 HAPTICS, 75 MOUSE_BUTTON, 76 POINTER, 77 LIGHTGUN, 78 OFFSCREEN, // Virtual button to shoot light gun offscreen 79 KEY, // A keyboard key 80 KEYPAD, // A key on a numeric keymap, including star and pound 81 HARDWARE, // A button or functionality on the console 82 WHEEL, 83 JOYSTICK, 84 PADDLE, 85 }; 86 87 /*! 88 * \brief Direction arrows on the hat (directional pad) 89 */ 90 using HAT_DIRECTION = INPUT::CARDINAL_DIRECTION; 91 92 /*! 93 * \brief States in which a hat can be 94 */ 95 using HAT_STATE = INPUT::INTERCARDINAL_DIRECTION; 96 97 /*! 98 * \brief Typedef for analog stick directions 99 */ 100 using ANALOG_STICK_DIRECTION = INPUT::CARDINAL_DIRECTION; 101 102 /*! 103 * \brief Directions of motion for a relative pointer 104 */ 105 using RELATIVE_POINTER_DIRECTION = INPUT::CARDINAL_DIRECTION; 106 107 /*! 108 * \brief Directions in which a semiaxis can point 109 */ 110 enum class SEMIAXIS_DIRECTION 111 { 112 NEGATIVE = -1, // semiaxis lies in the interval [-1.0, 0.0] 113 ZERO = 0, // semiaxis is unknown or invalid 114 POSITIVE = 1, // semiaxis lies in the interval [0.0, 1.0] 115 }; 116 117 /*! 118 * \brief Directions on a wheel 119 */ 120 enum class WHEEL_DIRECTION 121 { 122 NONE, 123 RIGHT, 124 LEFT, 125 }; 126 127 /*! 128 * \brief Directions on a throttle 129 */ 130 enum class THROTTLE_DIRECTION 131 { 132 NONE, 133 UP, 134 DOWN, 135 }; 136 137 /*! 138 * \brief Types of input available for scalar features 139 */ 140 enum class INPUT_TYPE 141 { 142 UNKNOWN, 143 DIGITAL, 144 ANALOG, 145 }; 146 147 /*! 148 * \brief Type of driver primitive 149 */ 150 enum class PRIMITIVE_TYPE 151 { 152 UNKNOWN = 0, // primitive has no type (invalid) 153 BUTTON, // a digital button 154 HAT, // one of the four direction arrows on a D-pad 155 SEMIAXIS, // the positive or negative half of an axis 156 MOTOR, // a rumble motor 157 KEY, // a keyboard key 158 MOUSE_BUTTON, // a mouse button 159 RELATIVE_POINTER, // a relative pointer, such as on a mouse 160 }; 161 162 /*! 163 * \ingroup joystick 164 * \brief Action entry in joystick.xml 165 */ 166 struct KeymapAction 167 { 168 unsigned int actionId; 169 std::string actionString; 170 unsigned int holdTimeMs; 171 std::set<std::string> hotkeys; 172 173 bool operator<(const KeymapAction& rhs) const { return holdTimeMs < rhs.holdTimeMs; } 174 }; 175 176 /*! 177 * \ingroup joystick 178 * \brief Container that sorts action entries by their holdtime 179 */ 180 struct KeymapActionGroup 181 { 182 int windowId = -1; 183 std::set<KeymapAction> actions; 184 }; 185 } // namespace JOYSTICK 186 } // namespace KODI 187