Skip to content

Commit eed5aad

Browse files
committed
Added swipe release flag
1 parent 66ea84f commit eed5aad

3 files changed

Lines changed: 6 additions & 11 deletions

File tree

examples/gesture/gesture.script

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ FMT = FMT .. "swipe_left: %s\n"
55
FMT = FMT .. "swipe_right: %s\n"
66
FMT = FMT .. "swipe_up: %s\n"
77
FMT = FMT .. "swipe_down: %s\n"
8+
FMT = FMT .. "swipe_released: %s\n"
89
FMT = FMT .. "tap: %s\n"
910
FMT = FMT .. "double_tap: %s\n"
1011
FMT = FMT .. "long_press: %s\n"
@@ -18,6 +19,7 @@ function on_message(self, message_id, message, sender)
1819
tostring(message.swipe_right),
1920
tostring(message.swipe_up),
2021
tostring(message.swipe_down),
22+
tostring(message.swipe_released == true),
2123
prettify({message.tap or {}}, " "),
2224
prettify({message.double_tap or {}}, " "),
2325
prettify({message.long_press or {}}, " "),

in/gesture.lua

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ M.SETTINGS = {
1818
--- maximum time between a pressed and release action to consider it a swipe
1919
swipe_time = 0.5,
2020

21-
--- detect swipe only on release. set to false to report swipe also before release
22-
swipe_on_release = true,
23-
2421
--- minimum time of a pressed/release sequence to consider it a long press
2522
long_press_time = 0.5,
2623

@@ -155,9 +152,6 @@ function M.create(settings)
155152
settings.swipe_threshold = settings.swipe_threshold or M.SETTINGS.swipe_threshold
156153
settings.swipe_time = settings.swipe_time or M.SETTINGS.swipe_time
157154
settings.long_press_time = settings.long_press_time or M.SETTINGS.long_press_time
158-
if settings.swipe_on_release == nil then
159-
settings.swipe_on_release = M.SETTINGS.wipe_on_release
160-
end
161155
if settings.multi_touch == nil then
162156
settings.multi_touch = M.SETTINGS.multi_touch
163157
end
@@ -208,15 +202,14 @@ function M.create(settings)
208202
state.swipe_right = false
209203
state.swipe_up = false
210204
state.swipe_down = false
205+
state.swipe_released = false
211206

212207
if touch.pressed then
213208
handle_pressed(touch, state, settings)
214209
elseif touch.released then
215210
handle_released(touch, state, settings)
216211
else
217-
if not settings.swipe_on_release then
218-
check_swipe(touch, state, settings)
219-
end
212+
check_swipe(touch, state, settings)
220213
if touch.repeated then
221214
handle_repeated(touch, state, settings)
222215
end
@@ -235,6 +228,7 @@ function M.create(settings)
235228
elseif single_state.is_long_press then
236229
gestures.long_press = single_state.long_press
237230
elseif single_state.is_swipe then
231+
gestures.swipe_released = not single_state.pressed
238232
gestures.swipe = single_state.swipe
239233
gestures.swipe_up = single_state.swipe_up
240234
gestures.swipe_down = single_state.swipe_down
@@ -262,6 +256,7 @@ function M.create(settings)
262256
elseif s1.is_long_press and s2.is_long_press then
263257
gestures.two_finger.long_press = true
264258
elseif s1.is_swipe and s2.is_swipe then
259+
gestures.two_finger_swipe_released = not s1.pressed and not s2.pressed
265260
gestures.two_finger.swipe_up = s1.swipe_up and s2.swipe_up
266261
gestures.two_finger.swipe_down = s1.swipe_down and s2.swipe_down
267262
gestures.two_finger.swipe_right = s1.swipe_right and s2.swipe_right

in/gesture.script

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ go.property("tap_threshold", 20)
77
go.property("double_tap_interval", 0.5)
88
go.property("swipe_threshold", 20)
99
go.property("swipe_time", 2)
10-
go.property("swipe_on_release", true)
1110
go.property("long_press_time", 1.0)
1211
go.property("acquire_input_focus", false)
1312
go.property("multi_touch", true)
@@ -19,7 +18,6 @@ function init(self)
1918
double_tap_interval = self.double_tap_interval,
2019
swipe_threshold = self.swipe_threshold,
2120
swipe_time = self.swipe_time,
22-
swipe_on_release = self.swipe_on_release,
2321
long_press_time = self.long_press_time,
2422
multi_touch = self.multi_touch,
2523
})

0 commit comments

Comments
 (0)