From 575183d6dcd8da9b10ee41e47be4b7d4f8631783 Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Tue, 16 Jan 2024 12:17:18 -0600 Subject: service: hid: Fully implement touch resource --- src/hid_core/resources/touch_screen/touch_types.h | 61 +++++++++++++++++++++-- 1 file changed, 57 insertions(+), 4 deletions(-) (limited to 'src/hid_core/resources/touch_screen/touch_types.h') diff --git a/src/hid_core/resources/touch_screen/touch_types.h b/src/hid_core/resources/touch_screen/touch_types.h index 97ee847da..362088939 100644 --- a/src/hid_core/resources/touch_screen/touch_types.h +++ b/src/hid_core/resources/touch_screen/touch_types.h @@ -13,8 +13,20 @@ #include "hid_core/hid_types.h" namespace Service::HID { -static constexpr std::size_t MAX_FINGERS = 16; -static constexpr size_t MAX_POINTS = 4; +constexpr std::size_t MaxFingers = 16; +constexpr std::size_t MaxPoints = 4; +constexpr u32 TouchSensorWidth = 1280; +constexpr u32 TouchSensorHeight = 720; +constexpr s32 MaxRotationAngle = 270; +constexpr u32 MaxTouchDiameter = 30; +constexpr u32 TouchBorders = 15; + +// HW is around 700, value is set to 400 to make it easier to trigger with mouse +constexpr f32 SwipeThreshold = 400.0f; // Threshold in pixels/s +constexpr f32 AngleThreshold = 0.015f; // Threshold in radians +constexpr f32 PinchThreshold = 0.5f; // Threshold in pixels +constexpr f32 PressDelay = 0.5f; // Time in seconds +constexpr f32 DoubleTapDelay = 0.35f; // Time in seconds // This is nn::hid::GestureType enum class GestureType : u32 { @@ -28,6 +40,7 @@ enum class GestureType : u32 { Swipe, // Fast press movement and release of a single point Pinch, // All points moving away/closer to the midpoint Rotate, // All points rotating from the midpoint + GestureTypeMax = Rotate, }; // This is nn::hid::GestureDirection @@ -69,7 +82,7 @@ struct GestureState { static_assert(sizeof(GestureState) == 0x60, "GestureState is an invalid size"); struct GestureProperties { - std::array, MAX_POINTS> points{}; + std::array, MaxPoints> points{}; std::size_t active_points{}; Common::Point mid_point{}; s64 detection_count{}; @@ -78,13 +91,53 @@ struct GestureProperties { f32 angle{}; }; +// This is nn::hid::TouchState +struct TouchState { + u64 delta_time{}; + Core::HID::TouchAttribute attribute{}; + u32 finger{}; + Common::Point position{}; + u32 diameter_x{}; + u32 diameter_y{}; + s32 rotation_angle{}; +}; +static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size"); + // This is nn::hid::TouchScreenState struct TouchScreenState { s64 sampling_number{}; s32 entry_count{}; INSERT_PADDING_BYTES(4); // Reserved - std::array states{}; + std::array states{}; }; static_assert(sizeof(TouchScreenState) == 0x290, "TouchScreenState is an invalid size"); +struct TouchFingerMap { + s32 finger_count{}; + Core::HID::TouchScreenModeForNx touch_mode; + INSERT_PADDING_BYTES(3); + std::array finger_ids{}; +}; +static_assert(sizeof(TouchFingerMap) == 0x48, "TouchFingerMap is an invalid size"); + +struct TouchAruidData { + u64 aruid; + u32 basic_gesture_id; + u64 used_1; + u64 used_2; + u64 used_3; + u64 used_4; + GestureType gesture_type; + u16 resolution_width; + u16 resolution_height; + TouchFingerMap finger_map; +}; +static_assert(sizeof(TouchAruidData) == 0x80, "TouchAruidData is an invalid size"); + +struct AutoPilotState { + u64 count; + std::array state; +}; +static_assert(sizeof(AutoPilotState) == 0x288, "AutoPilotState is an invalid size"); + } // namespace Service::HID -- cgit v1.2.3