From 152422bab1382575e951c1c11b5de3013b8b402a Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Thu, 1 Nov 2018 21:52:51 -0400 Subject: [PATCH] settings: Add Native type for mouse buttons --- src/core/frontend/input.h | 7 +++++++ src/core/settings.h | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/core/frontend/input.h b/src/core/frontend/input.h index 39bdf4e214..16fdcd376b 100644 --- a/src/core/frontend/input.h +++ b/src/core/frontend/input.h @@ -132,4 +132,11 @@ using MotionDevice = InputDevice, Math::Vec3 */ using TouchDevice = InputDevice>; +/** + * A mouse device is an input device that returns a tuple of two floats and four ints. + * The first two floats are X and Y device coordinates of the mouse (from 0-1). + * The s32s are the mouse wheel. + */ +using MouseDevice = InputDevice>; + } // namespace Input diff --git a/src/core/settings.h b/src/core/settings.h index e424479f29..d9aa14cd24 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -111,6 +111,30 @@ static const std::array mapping = {{ }}; } // namespace NativeAnalog +namespace NativeMouseButton { +enum Values { + Left, + Right, + Middle, + Forward, + Back, + + NumMouseButtons, +}; + +constexpr int MOUSE_HID_BEGIN = Left; +constexpr int MOUSE_HID_END = NumMouseButtons; +constexpr int NUM_MOUSE_HID = NumMouseButtons; + +static const std::array mapping = {{ + "left", + "right", + "middle", + "forward", + "back", +}}; +} // namespace NativeMouseButton + struct Values { // System bool use_docked_mode; @@ -122,6 +146,9 @@ struct Values { // Controls std::array buttons; std::array analogs; + bool mouse_enabled; + std::string mouse_device; + MouseButtonsRaw mouse_buttons; std::string motion_device; std::string touch_device; std::atomic_bool is_device_reload_pending{true};