From 637f5d16d714cbb54269c8c6554c3d4bdbb21d2e Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Fri, 8 Apr 2022 11:39:50 -0400 Subject: [PATCH] Break out drag threshold dist/ms to config; lower gesture drag threshold ms --- src/Runtime.zig | 11 +++++------ src/config.zig | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Runtime.zig b/src/Runtime.zig index 941e274..19b9626 100644 --- a/src/Runtime.zig +++ b/src/Runtime.zig @@ -187,14 +187,13 @@ fn event_touch_handle(runtime: *@This(), evt_data: linput.input_event) !void { }; } else if (run == .FingerUp and runtime.touch_start != null) { defer runtime.touch_start = null; - if (utiltime.timeval_delta_ms(utiltime.now(), runtime.touch_start.?.start_time) > 2000) return; - const drag_threshold = 300; + if (utiltime.timeval_delta_ms(utiltime.now(), runtime.touch_start.?.start_time) > config.drag_threshold_ms) return; const swipe : ?types.DragSwipe = swipe: { - if (runtime.touch_pending.?.y > runtime.touch_start.?.coordinates.y + drag_threshold) break :swipe .UD; - if (runtime.touch_pending.?.y < runtime.touch_start.?.coordinates.y - drag_threshold) break :swipe .DU; - if (runtime.touch_pending.?.x > runtime.touch_start.?.coordinates.x + drag_threshold) break :swipe .LR; - if (runtime.touch_pending.?.x < runtime.touch_start.?.coordinates.x - drag_threshold) break :swipe .RL; + if (runtime.touch_pending.?.y > runtime.touch_start.?.coordinates.y + config.drag_threshold_dist) break :swipe .UD; + if (runtime.touch_pending.?.y < runtime.touch_start.?.coordinates.y - config.drag_threshold_dist) break :swipe .DU; + if (runtime.touch_pending.?.x > runtime.touch_start.?.coordinates.x + config.drag_threshold_dist) break :swipe .LR; + if (runtime.touch_pending.?.x < runtime.touch_start.?.coordinates.x - config.drag_threshold_dist) break :swipe .RL; break :swipe null; }; diff --git a/src/config.zig b/src/config.zig index 8f88cad..3ca7d14 100644 --- a/src/config.zig +++ b/src/config.zig @@ -19,6 +19,9 @@ pub const grid_batch_size = 15; pub const timeout_poll_ms = 50; +pub const drag_threshold_ms = 400; +pub const drag_threshold_dist = 300; + pub const keyboard = [_]types.GridItem{ // Row 1 .{ .t = "q" }, -- 2.34.2