MCPcopy Create free account
hub / github.com/android/ndk-samples / CookEvent

Function CookEvent

endless-tunnel/app/src/main/cpp/input_util.cpp:261–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261bool CookEvent(AInputEvent* event, CookedEventCallback callback) {
262 int type = AInputEvent_getType(event);
263 int src = AInputEvent_getSource(event);
264 bool isJoy = (type == AINPUT_EVENT_TYPE_MOTION) &&
265 (src & AINPUT_SOURCE_CLASS_MASK) == SOURCE_CLASS_JOYSTICK;
266
267 if (!_init_done) {
268 _init();
269 _init_done = true;
270 }
271
272 if (isJoy) {
273 return CookEvent_Joy(event, callback);
274 } else if (type == AINPUT_EVENT_TYPE_KEY) {
275 bool handled = _process_keys(false, event, callback);
276 if (AKeyEvent_getKeyCode(event) == AKEYCODE_BACK &&
277 0 == AKeyEvent_getAction(event)) {
278 // back key was pressed
279 struct CookedEvent ev;
280 memset(&ev, 0, sizeof(ev));
281 ev.type = COOKED_EVENT_TYPE_BACK;
282 return callback(&ev);
283 }
284 // Note: if you want to handle other keys, add code here. For now we only
285 // handle DPAD keys as indicated in _process_keys.
286 return handled;
287 } else if (type == AINPUT_EVENT_TYPE_MOTION) {
288 return CookEvent_Motion(event, callback);
289 }
290
291 return false;
292}

Callers 1

HandleInputMethod · 0.85

Calls 4

_initFunction · 0.85
CookEvent_JoyFunction · 0.85
_process_keysFunction · 0.85
CookEvent_MotionFunction · 0.85

Tested by

no test coverage detected