mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-11-22 11:55:56 +00:00
Count number of taps, and add stub code to dispatch action.
This commit is contained in:
parent
6542994a25
commit
71318fe938
|
@ -11,7 +11,11 @@ signal swipe_down
|
||||||
|
|
||||||
var Accessible = preload("Accessible.gd")
|
var Accessible = preload("Accessible.gd")
|
||||||
|
|
||||||
export var explore_by_touch_distance = 5
|
export var min_swipe_distance = 5
|
||||||
|
|
||||||
|
export var tap_execute_interval = 100
|
||||||
|
|
||||||
|
export var explore_by_touch_interval = 150
|
||||||
|
|
||||||
var focus_restore_timer
|
var focus_restore_timer
|
||||||
|
|
||||||
|
@ -80,37 +84,57 @@ var touch_index = null
|
||||||
|
|
||||||
var touch_position = null
|
var touch_position = null
|
||||||
|
|
||||||
|
var touch_start_time = null
|
||||||
|
|
||||||
|
var touch_stop_time = null
|
||||||
|
|
||||||
var explore_by_touch = false
|
var explore_by_touch = false
|
||||||
|
|
||||||
|
var tap_count = 0
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if event is InputEventScreenTouch:
|
if event is InputEventScreenTouch:
|
||||||
print(event.position)
|
|
||||||
get_tree().set_input_as_handled()
|
get_tree().set_input_as_handled()
|
||||||
if touch_index and event.index != touch_index:
|
if touch_index and event.index != touch_index:
|
||||||
return
|
return
|
||||||
if event.pressed:
|
if event.pressed:
|
||||||
touch_index = event.index
|
touch_index = event.index
|
||||||
touch_position = event.position
|
touch_position = event.position
|
||||||
|
touch_start_time = OS.get_ticks_msec()
|
||||||
|
touch_stop_time = null
|
||||||
else:
|
else:
|
||||||
touch_index = null
|
touch_index = null
|
||||||
var relative = event.position - touch_position
|
var relative = event.position - touch_position
|
||||||
if abs(relative.x) > abs(relative.y):
|
if relative.length() < min_swipe_distance:
|
||||||
if relative.x > 0:
|
tap_count += 1
|
||||||
emit_signal("swipe_right")
|
|
||||||
else:
|
|
||||||
emit_signal("swipe_left")
|
|
||||||
else:
|
else:
|
||||||
if relative.y > 0:
|
if abs(relative.x) > abs(relative.y):
|
||||||
emit_signal("swipe_down")
|
if relative.x > 0:
|
||||||
|
emit_signal("swipe_right")
|
||||||
|
TTS.speak("Swipe right")
|
||||||
|
else:
|
||||||
|
emit_signal("swipe_left")
|
||||||
|
TTS.speak("Swipe left")
|
||||||
else:
|
else:
|
||||||
emit_signal("swipe_up")
|
if relative.y > 0:
|
||||||
|
emit_signal("swipe_down")
|
||||||
|
TTS.speak("Swipe down")
|
||||||
|
else:
|
||||||
|
emit_signal("swipe_up")
|
||||||
|
TTS.speak("Swipe up")
|
||||||
touch_position = null
|
touch_position = null
|
||||||
|
touch_start_time = null
|
||||||
|
touch_stop_time = OS.get_ticks_msec()
|
||||||
explore_by_touch = false
|
explore_by_touch = false
|
||||||
elif event is InputEventScreenDrag:
|
elif event is InputEventScreenDrag:
|
||||||
if touch_index and event.index != touch_index:
|
if touch_index and event.index != touch_index:
|
||||||
return
|
return
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
if touch_stop_time and OS.get_ticks_msec() - touch_stop_time >= tap_execute_interval and tap_count != 0:
|
||||||
|
touch_stop_time = null
|
||||||
|
TTS.speak("%s taps" % tap_count)
|
||||||
|
tap_count = 0
|
||||||
if focus_restore_timer and focus_restore_timer.time_left <= 0:
|
if focus_restore_timer and focus_restore_timer.time_left <= 0:
|
||||||
var focus = find_focusable_control(get_tree().root)
|
var focus = find_focusable_control(get_tree().root)
|
||||||
if focus and not focus.get_focus_owner():
|
if focus and not focus.get_focus_owner():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user