MCPcopy Create free account
hub / github.com/golang/mobile / processEvent

Function processEvent

app/android.go:400–430  ·  view source on GitHub ↗
(env *C.JNIEnv, e *C.AInputEvent)

Source from the content-addressed store, hash-verified

398}
399
400func processEvent(env *C.JNIEnv, e *C.AInputEvent) {
401 switch C.AInputEvent_getType(e) {
402 case C.AINPUT_EVENT_TYPE_KEY:
403 processKey(env, e)
404 case C.AINPUT_EVENT_TYPE_MOTION:
405 // At most one of the events in this batch is an up or down event; get its index and change.
406 upDownIndex := C.size_t(C.AMotionEvent_getAction(e)&C.AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> C.AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT
407 upDownType := touch.TypeMove
408 switch C.AMotionEvent_getAction(e) & C.AMOTION_EVENT_ACTION_MASK {
409 case C.AMOTION_EVENT_ACTION_DOWN, C.AMOTION_EVENT_ACTION_POINTER_DOWN:
410 upDownType = touch.TypeBegin
411 case C.AMOTION_EVENT_ACTION_UP, C.AMOTION_EVENT_ACTION_POINTER_UP:
412 upDownType = touch.TypeEnd
413 }
414
415 for i, n := C.size_t(0), C.AMotionEvent_getPointerCount(e); i < n; i++ {
416 t := touch.TypeMove
417 if i == upDownIndex {
418 t = upDownType
419 }
420 theApp.eventsIn <- touch.Event{
421 X: float32(C.AMotionEvent_getX(e, i)),
422 Y: float32(C.AMotionEvent_getY(e, i)),
423 Sequence: touch.Sequence(C.AMotionEvent_getPointerId(e, i)),
424 Type: t,
425 }
426 }
427 default:
428 log.Printf("unknown input event, type=%d", C.AInputEvent_getType(e))
429 }
430}
431
432func processKey(env *C.JNIEnv, e *C.AInputEvent) {
433 deviceID := C.AInputEvent_getDeviceId(e)

Callers 1

processEventsFunction · 0.85

Calls 3

SequenceTypeAlias · 0.92
processKeyFunction · 0.85
PrintfMethod · 0.80

Tested by

no test coverage detected