(env *C.JNIEnv, e *C.AInputEvent)
| 398 | } |
| 399 | |
| 400 | func 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 | |
| 432 | func processKey(env *C.JNIEnv, e *C.AInputEvent) { |
| 433 | deviceID := C.AInputEvent_getDeviceId(e) |
no test coverage detected