OLD | NEW |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
1 #include <android_native_app_glue.h> | 5 #include <android_native_app_glue.h> |
2 #include <cmath> | 6 #include <cmath> |
3 | 7 |
4 #include "bin/log.h" | |
5 #include "jni/input_service.h" | 8 #include "jni/input_service.h" |
| 9 #include "jni/log.h" |
6 | 10 |
7 InputService::InputService(android_app* application, | 11 InputService::InputService(android_app* application, |
8 VMGlue* vm_glue, | 12 VMGlue* vm_glue, |
9 const int32_t& width, | 13 const int32_t& width, |
10 const int32_t& height) : | 14 const int32_t& height) : |
11 application_(application), | 15 application_(application), |
12 vm_glue_(vm_glue), | 16 vm_glue_(vm_glue), |
13 width_(width), | 17 width_(width), |
14 height_(height) { | 18 height_(height) { |
15 } | 19 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 function = "onMotionPointerUp"; | 51 function = "onMotionPointerUp"; |
48 break; | 52 break; |
49 default: | 53 default: |
50 break; | 54 break; |
51 } | 55 } |
52 if (function != NULL) { | 56 if (function != NULL) { |
53 // For now we just get the last coords. | 57 // For now we just get the last coords. |
54 float move_x = AMotionEvent_getX(event, 0); | 58 float move_x = AMotionEvent_getX(event, 0); |
55 float move_y = AMotionEvent_getY(event, 0); | 59 float move_y = AMotionEvent_getY(event, 0); |
56 int64_t when = AMotionEvent_getEventTime(event); | 60 int64_t when = AMotionEvent_getEventTime(event); |
57 Log::Print("Got motion event %d at %f, %f", type, move_x, move_y); | 61 LOGI("Got motion event %d at %f, %f", type, move_x, move_y); |
58 | 62 |
59 if (vm_glue_->OnMotionEvent(function, when, move_x, move_y) != 0) { | 63 if (vm_glue_->OnMotionEvent(function, when, move_x, move_y) != 0) { |
60 return false; | 64 return false; |
61 } | 65 } |
62 } else { | 66 } else { |
63 return false; | 67 return false; |
64 } | 68 } |
65 return true; | 69 return true; |
66 } | 70 } |
67 | 71 |
(...skipping 30 matching lines...) Expand all Loading... |
98 * this will be the same as eventTime. | 102 * this will be the same as eventTime. |
99 * Note that when chording keys, this value is the down time of the most | 103 * Note that when chording keys, this value is the down time of the most |
100 * recently pressed key, which may not be the same physical key of this | 104 * recently pressed key, which may not be the same physical key of this |
101 * event. */ | 105 * event. */ |
102 int64_t key_down_time = AKeyEvent_getDownTime(event); | 106 int64_t key_down_time = AKeyEvent_getDownTime(event); |
103 | 107 |
104 /* Get the time this event occurred, in the | 108 /* Get the time this event occurred, in the |
105 * java.lang.System.nanoTime() time base. */ | 109 * java.lang.System.nanoTime() time base. */ |
106 int64_t when = AKeyEvent_getEventTime(event); | 110 int64_t when = AKeyEvent_getEventTime(event); |
107 | 111 |
108 Log::Print("Got key event %d %d", type, key_code); | 112 LOGI("Got key event %d %d", type, key_code); |
109 if (vm_glue_->OnKeyEvent(function, when, flags, key_code, | 113 if (vm_glue_->OnKeyEvent(function, when, flags, key_code, |
110 meta_state, repeat) != 0) { | 114 meta_state, repeat) != 0) { |
111 return false; | 115 return false; |
112 } | 116 } |
113 } else { | 117 } else { |
114 return false; | 118 return false; |
115 } | 119 } |
116 return true; | 120 return true; |
117 } | 121 } |
118 | |
OLD | NEW |