New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/mobile/event: touch events should be timestamped #10448
Comments
I don't think we can reason about APIs like this. We need example programs that are built, reviewed, and submitted to reason on. Before working on any more API changes, please build example apps that use them and mail them out. From there hopefully we can all see what is necessary from the APIs. |
Although I agree that this may not be the ideal way to propose new APIs (or report API bugs), mailing out samples are not ideal either. Gesture detection algorithms are well known algorithms that require event time and identification of events (which will be supported once https://go-review.googlesource.com/#/c/1895/ is submitted). I want to detect whether user double tapped or not. I shouldn't be reimplementing the event listener to expose event IDs and their timestamps to mail out a sample in order to justify this proposal. For reference, some of the popular gesture detectors are available on https://android.googlesource.com/platform/development/+/master/ndk/sources/android/ndk_helper/gestureDetector.cpp. |
I cannot review an API without seeing how it is used. |
See the snippet below. I detect it as a single tap iff start and end happens less than a sec in between, and the touch boundary doesn't change significantly. var lastStartTime time.Time
var lastStartLoc geom.Point
func touch(t event.Touch) {
switch t.Type {
case event.TouchStart:
lastStartTime = time.Now()
lastStartLoc = t.Loc
case event.TouchEnd:
// TODO(jbd): make sure end event is owned by the touch event
diffX := math.Abs(float64(t.Loc.X) - float64(lastStartLoc.X))
diffY := math.Abs(float64(t.Loc.Y) - float64(lastStartLoc.Y))
diffTime := time.Now().Sub(lastStartTime)
if diffTime < 2*time.Second && diffX < 30 && diffY < 30 {
log.Println("single tap detected")
}
}
} |
Touch events should be timestamped to determine the order. Order is critical to determine the direction and the speed of the gesture.
cc/ @crawshaw @hyangah
The text was updated successfully, but these errors were encountered: