summaryrefslogtreecommitdiffstats
path: root/src/hid_core/resources/touch_screen/touch_types.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/hid_core/resources/touch_screen/touch_types.h')
-rw-r--r--src/hid_core/resources/touch_screen/touch_types.h61
1 files changed, 57 insertions, 4 deletions
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<Common::Point<s32>, MAX_POINTS> points{};
+ std::array<Common::Point<s32>, MaxPoints> points{};
std::size_t active_points{};
Common::Point<s32> 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<u32> 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<Core::HID::TouchState, MAX_FINGERS> states{};
+ std::array<TouchState, MaxFingers> 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<u32, MaxFingers> 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<TouchState, 16> state;
+};
+static_assert(sizeof(AutoPilotState) == 0x288, "AutoPilotState is an invalid size");
+
} // namespace Service::HID