diff options
Diffstat (limited to 'chromium/device/gamepad/public/cpp/gamepad.h')
-rw-r--r-- | chromium/device/gamepad/public/cpp/gamepad.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/chromium/device/gamepad/public/cpp/gamepad.h b/chromium/device/gamepad/public/cpp/gamepad.h index 9203c4ffbe1..3477d3d251a 100644 --- a/chromium/device/gamepad/public/cpp/gamepad.h +++ b/chromium/device/gamepad/public/cpp/gamepad.h @@ -8,6 +8,8 @@ #include <stddef.h> #include <cstdint> +#include <limits> + #include "base/component_export.h" #include "base/strings/string16.h" @@ -20,12 +22,14 @@ class GamepadButton { // Matches XInput's trigger deadzone. static constexpr float kDefaultButtonPressedThreshold = 30.f / 255.f; - GamepadButton() : pressed(false), touched(false), value(0.) {} + GamepadButton() = default; GamepadButton(bool pressed, bool touched, double value) - : pressed(pressed), touched(touched), value(value) {} - bool pressed; - bool touched; - double value; + : used(true), pressed(pressed), touched(touched), value(value) {} + // Whether the button is actually reported by the gamepad at all. + bool used{false}; + bool pressed{false}; + bool touched{false}; + double value{0.}; }; enum class GamepadHapticActuatorType { kVibration = 0, kDualRumble = 1 }; @@ -125,6 +129,14 @@ class COMPONENT_EXPORT(GAMEPAD_PUBLIC) Gamepad { // Number of valid entries in the axes array. unsigned axes_length; + // Bitfield indicating which entries of the axes array are actually used. If + // the axes index is actually used for this gamepad then the corresponding bit + // will be 1. + uint32_t axes_used; + static_assert(Gamepad::kAxesLengthCap <= + std::numeric_limits<uint32_t>::digits, + "axes_used is not large enough"); + // Normalized values representing axes, in the range [-1..1]. double axes[kAxesLengthCap]; |