@@ -77,12 +77,6 @@ function M.create(settings)
7777 two_finger = {},
7878 }
7979
80- -- the state of a single touch
81- local single_state = create_touch_state ()
82-
83- -- the state of individual multi touch points
84- local multi_states = {}
85-
8680 local pinch = {
8781 center = vmath .vector3 (),
8882 }
@@ -187,6 +181,8 @@ function M.create(settings)
187181 end
188182
189183
184+ -- the state of a single touch
185+ local single_state = create_touch_state ()
190186 local function handle_single_touch (action )
191187 clear_gesture_state ()
192188 handle_touch (action , single_state )
@@ -207,23 +203,11 @@ function M.create(settings)
207203 end
208204 end
209205
210-
211- local function handle_multi_touch (action )
212- assert (action .touch and # action .touch == 2 )
206+ -- the state of individual multi touch points
207+ local multi_states = {}
208+ local current_touch_count = 0
209+ local function handle_multi_touch (t1 , t2 )
213210 clear_gesture_state ()
214- local t1 = action .touch [1 ]
215- local t2 = action .touch [2 ]
216-
217- -- there seems to be an issue with multi touch where the first press
218- -- doesn't get registered
219- if not multi_states [t1 .id ] then
220- multi_states [t1 .id ] = create_touch_state ()
221- t1 .pressed = true
222- end
223- if not multi_states [t2 .id ] then
224- multi_states [t2 .id ] = create_touch_state ()
225- t2 .pressed = true
226- end
227211 local s1 = multi_states [t1 .id ]
228212 local s2 = multi_states [t2 .id ]
229213 handle_touch (t1 , s1 )
@@ -261,8 +245,19 @@ function M.create(settings)
261245
262246 function instance .on_input (action_id , action )
263247 if action .touch then
264- if settings .multi_touch and # action .touch == 2 then
265- handle_multi_touch (action )
248+ if settings .multi_touch then
249+ if # action .touch == 2 then
250+ local t1 = action .touch [1 ]
251+ local t2 = action .touch [2 ]
252+ if current_touch_count < 2 then
253+ multi_states [t1 .id ] = create_touch_state ()
254+ multi_states [t2 .id ] = create_touch_state ()
255+ t1 .pressed = true
256+ t2 .pressed = true
257+ end
258+ handle_multi_touch (t1 , t2 )
259+ end
260+ current_touch_count = # action .touch
266261 return gestures
267262 end
268263 elseif action_id == settings .action_id then
0 commit comments