OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/input/motion_event_android.h" | 5 #include "content/browser/renderer_host/input/motion_event_android.h" |
6 | 6 |
7 #include <android/input.h> | 7 #include <android/input.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/float_util.h" | 10 #include "base/float_util.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 } | 233 } |
234 | 234 |
235 float MotionEventAndroid::GetOrientation(size_t pointer_index) const { | 235 float MotionEventAndroid::GetOrientation(size_t pointer_index) const { |
236 DCHECK_LT(pointer_index, cached_pointer_count_); | 236 DCHECK_LT(pointer_index, cached_pointer_count_); |
237 if (pointer_index < MAX_POINTERS_TO_CACHE) | 237 if (pointer_index < MAX_POINTERS_TO_CACHE) |
238 return cached_pointers_[pointer_index].orientation; | 238 return cached_pointers_[pointer_index].orientation; |
239 return ToValidFloat(Java_MotionEvent_getOrientationF_I( | 239 return ToValidFloat(Java_MotionEvent_getOrientationF_I( |
240 AttachCurrentThread(), event_.obj(), pointer_index)); | 240 AttachCurrentThread(), event_.obj(), pointer_index)); |
241 } | 241 } |
242 | 242 |
| 243 float MotionEventAndroid::GetTilt(size_t pointer_index) const { |
| 244 DCHECK_LT(pointer_index, cached_pointer_count_); |
| 245 if (!event_.obj()) |
| 246 return 0.f; |
| 247 return Java_MotionEvent_getAxisValueF_I_I( |
| 248 AttachCurrentThread(), event_.obj(), AXIS_TILT, pointer_index); |
| 249 } |
| 250 |
243 float MotionEventAndroid::GetPressure(size_t pointer_index) const { | 251 float MotionEventAndroid::GetPressure(size_t pointer_index) const { |
244 DCHECK_LT(pointer_index, cached_pointer_count_); | 252 DCHECK_LT(pointer_index, cached_pointer_count_); |
245 // Note that this early return is a special case exercised only in testing, as | 253 // Note that this early return is a special case exercised only in testing, as |
246 // caching the pressure values is not a worthwhile optimization (they're | 254 // caching the pressure values is not a worthwhile optimization (they're |
247 // accessed at most once per event instance). | 255 // accessed at most once per event instance). |
248 if (!event_.obj()) | 256 if (!event_.obj()) |
249 return 0.f; | 257 return 0.f; |
250 return Java_MotionEvent_getPressureF_I( | 258 return Java_MotionEvent_getPressureF_I( |
251 AttachCurrentThread(), event_.obj(), pointer_index); | 259 AttachCurrentThread(), event_.obj(), pointer_index); |
252 } | 260 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 result.tool_type = FromAndroidToolType(pointer.tool_type); | 325 result.tool_type = FromAndroidToolType(pointer.tool_type); |
318 return result; | 326 return result; |
319 } | 327 } |
320 | 328 |
321 // static | 329 // static |
322 bool MotionEventAndroid::RegisterMotionEventAndroid(JNIEnv* env) { | 330 bool MotionEventAndroid::RegisterMotionEventAndroid(JNIEnv* env) { |
323 return JNI_MotionEvent::RegisterNativesImpl(env); | 331 return JNI_MotionEvent::RegisterNativesImpl(env); |
324 } | 332 } |
325 | 333 |
326 } // namespace content | 334 } // namespace content |
OLD | NEW |