Chromium Code Reviews| 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 <android_native_app_glue.h> | 5 #include <android_native_app_glue.h> |
| 6 #include <cmath> | 6 #include <cmath> |
| 7 | 7 |
| 8 #include "jni/input_service.h" | 8 #include "embedders/android/input_service.h" |
| 9 #include "jni/log.h" | 9 #include "embedders/android/log.h" |
| 10 | 10 |
| 11 InputService::InputService(android_app* application, | 11 InputService::InputService(android_app* application, |
| 12 VMGlue* vm_glue, | 12 VMGlue* vm_glue, |
| 13 const int32_t& width, | 13 const int32_t& width, |
| 14 const int32_t& height) : | 14 const int32_t& height) : |
| 15 application_(application), | 15 application_(application), |
| 16 vm_glue_(vm_glue), | 16 vm_glue_(vm_glue), |
| 17 width_(width), | 17 width_(width), |
| 18 height_(height) { | 18 height_(height) { |
| 19 } | 19 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 int32_t key_code = AKeyEvent_getKeyCode(event); | 90 int32_t key_code = AKeyEvent_getKeyCode(event); |
| 91 /* Get the meta key state. */ | 91 /* Get the meta key state. */ |
| 92 int32_t meta_state = AKeyEvent_getMetaState(event); | 92 int32_t meta_state = AKeyEvent_getMetaState(event); |
| 93 /* Get the repeat count of the event. | 93 /* Get the repeat count of the event. |
| 94 * For both key up an key down events, this is the number of times the key | 94 * For both key up an key down events, this is the number of times the key |
| 95 * has repeated with the first down starting at 0 and counting up from | 95 * has repeated with the first down starting at 0 and counting up from |
| 96 * there. For multiple key events, this is the number of down/up pairs | 96 * there. For multiple key events, this is the number of down/up pairs |
| 97 * that have occurred. */ | 97 * that have occurred. */ |
| 98 int32_t repeat = AKeyEvent_getRepeatCount(event); | 98 int32_t repeat = AKeyEvent_getRepeatCount(event); |
| 99 | 99 |
| 100 /* Get the time of the most recent key down event, in the | |
| 101 * java.lang.System.nanoTime() time base. If this is a down event, | |
| 102 * this will be the same as eventTime. | |
| 103 * Note that when chording keys, this value is the down time of the most | |
| 104 * recently pressed key, which may not be the same physical key of this | |
| 105 * event. */ | |
| 106 int64_t key_down_time = AKeyEvent_getDownTime(event); | |
| 107 | |
|
gram
2013/01/09 17:51:36
Could we leave this in, and just comment out the l
vsm
2013/01/09 18:41:24
Done - added a TODO to use or remove.
On 2013/01/
| |
| 108 /* Get the time this event occurred, in the | 100 /* Get the time this event occurred, in the |
| 109 * java.lang.System.nanoTime() time base. */ | 101 * java.lang.System.nanoTime() time base. */ |
| 110 int64_t when = AKeyEvent_getEventTime(event); | 102 int64_t when = AKeyEvent_getEventTime(event); |
| 111 | 103 |
| 112 LOGI("Got key event %d %d", type, key_code); | 104 LOGI("Got key event %d %d", type, key_code); |
| 113 if (vm_glue_->OnKeyEvent(function, when, flags, key_code, | 105 if (vm_glue_->OnKeyEvent(function, when, flags, key_code, |
| 114 meta_state, repeat) != 0) { | 106 meta_state, repeat) != 0) { |
| 115 return false; | 107 return false; |
| 116 } | 108 } |
| 117 } else { | 109 } else { |
| 118 return false; | 110 return false; |
| 119 } | 111 } |
| 120 return true; | 112 return true; |
| 121 } | 113 } |
| OLD | NEW |