| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "embedders/openglui/android/eventloop.h" | 5 #include "embedders/openglui/android/eventloop.h" |
| 6 | 6 |
| 7 #include "embedders/openglui/common/log.h" | 7 #include "embedders/openglui/common/log.h" |
| 8 | 8 |
| 9 /* | 9 /* |
| 10 * The Android lifecycle events are: | 10 * The Android lifecycle events are: |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 * this will be the same as eventTime. | 328 * this will be the same as eventTime. |
| 329 * Note that when chording keys, this value is the down time of the most | 329 * Note that when chording keys, this value is the down time of the most |
| 330 * recently pressed key, which may not be the same physical key of this | 330 * recently pressed key, which may not be the same physical key of this |
| 331 * event. */ | 331 * event. */ |
| 332 // TODO(gram): Use or remove this. | 332 // TODO(gram): Use or remove this. |
| 333 // int64_t key_down_time = AKeyEvent_getDownTime(event); | 333 // int64_t key_down_time = AKeyEvent_getDownTime(event); |
| 334 | 334 |
| 335 /* Get the time this event occurred, in the | 335 /* Get the time this event occurred, in the |
| 336 * java.lang.System.nanoTime() time base. */ | 336 * java.lang.System.nanoTime() time base. */ |
| 337 int64_t when = AKeyEvent_getEventTime(event); | 337 int64_t when = AKeyEvent_getEventTime(event); |
| 338 bool isAltKeyDown = (meta_state & AMETA_ALT_ON) != 0; |
| 339 bool isShiftKeyDown = (meta_state & AMETA_SHIFT_ON) != 0; |
| 340 bool isCtrlKeyDown = key_code < 32; |
| 338 | 341 |
| 339 LOGI("Got key event %d %d", type, key_code); | 342 LOGI("Got key event %d %d", type, key_code); |
| 340 if (input_handler_->OnKeyEvent(key_event, when, flags, key_code, | 343 |
| 341 meta_state, repeat) != 0) { | 344 if (input_handler_->OnKeyEvent(key_event, when, key_code, |
| 345 isAltKeyDown, isCtrlKeyDown, isShiftKeyDown, |
| 346 repeat) != 0) { |
| 342 return false; | 347 return false; |
| 343 } | 348 } |
| 344 return true; | 349 return true; |
| 345 } | 350 } |
| 346 | 351 |
| 347 int32_t EventLoop::ProcessInputEvent(AInputEvent* event) { | 352 int32_t EventLoop::ProcessInputEvent(AInputEvent* event) { |
| 348 int32_t event_type = AInputEvent_getType(event); | 353 int32_t event_type = AInputEvent_getType(event); |
| 349 LOGI("Got input event type %d", event_type); | 354 LOGI("Got input event type %d", event_type); |
| 350 switch (event_type) { | 355 switch (event_type) { |
| 351 case AINPUT_EVENT_TYPE_MOTION: | 356 case AINPUT_EVENT_TYPE_MOTION: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 363 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData); | 368 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData); |
| 364 event_loop->ProcessActivityEvent(command); | 369 event_loop->ProcessActivityEvent(command); |
| 365 } | 370 } |
| 366 | 371 |
| 367 int32_t EventLoop::InputCallback(android_app* application, | 372 int32_t EventLoop::InputCallback(android_app* application, |
| 368 AInputEvent* event) { | 373 AInputEvent* event) { |
| 369 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData); | 374 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData); |
| 370 return event_loop->ProcessInputEvent(event); | 375 return event_loop->ProcessInputEvent(event); |
| 371 } | 376 } |
| 372 | 377 |
| OLD | NEW |