Input.cpp revision 56194ebec6212e229f4ccdaa4b187166d20013ef
1// 2// Copyright 2010 The Android Open Source Project 3// 4// Provides a pipe-based transport for native events in the NDK. 5// 6#define LOG_TAG "Input" 7 8//#define LOG_NDEBUG 0 9 10#define DEBUG_PROBE 0 11 12#include <stdlib.h> 13#include <unistd.h> 14#include <ctype.h> 15 16#include <ui/Input.h> 17 18#include <math.h> 19 20#ifdef HAVE_ANDROID_OS 21#include <binder/Parcel.h> 22 23#include "SkPoint.h" 24#include "SkMatrix.h" 25#include "SkScalar.h" 26#endif 27 28namespace android { 29 30static const char* CONFIGURATION_FILE_DIR[] = { 31 "idc/", 32 "keylayout/", 33 "keychars/", 34}; 35 36static const char* CONFIGURATION_FILE_EXTENSION[] = { 37 ".idc", 38 ".kl", 39 ".kcm", 40}; 41 42static bool isValidNameChar(char ch) { 43 return isascii(ch) && (isdigit(ch) || isalpha(ch) || ch == '-' || ch == '_'); 44} 45 46static void appendInputDeviceConfigurationFileRelativePath(String8& path, 47 const String8& name, InputDeviceConfigurationFileType type) { 48 path.append(CONFIGURATION_FILE_DIR[type]); 49 for (size_t i = 0; i < name.length(); i++) { 50 char ch = name[i]; 51 if (!isValidNameChar(ch)) { 52 ch = '_'; 53 } 54 path.append(&ch, 1); 55 } 56 path.append(CONFIGURATION_FILE_EXTENSION[type]); 57} 58 59String8 getInputDeviceConfigurationFilePathByDeviceIdentifier( 60 const InputDeviceIdentifier& deviceIdentifier, 61 InputDeviceConfigurationFileType type) { 62 if (deviceIdentifier.vendor !=0 && deviceIdentifier.product != 0) { 63 if (deviceIdentifier.version != 0) { 64 // Try vendor product version. 65 String8 versionPath(getInputDeviceConfigurationFilePathByName( 66 String8::format("Vendor_%04x_Product_%04x_Version_%04x", 67 deviceIdentifier.vendor, deviceIdentifier.product, 68 deviceIdentifier.version), 69 type)); 70 if (!versionPath.isEmpty()) { 71 return versionPath; 72 } 73 } 74 75 // Try vendor product. 76 String8 productPath(getInputDeviceConfigurationFilePathByName( 77 String8::format("Vendor_%04x_Product_%04x", 78 deviceIdentifier.vendor, deviceIdentifier.product), 79 type)); 80 if (!productPath.isEmpty()) { 81 return productPath; 82 } 83 } 84 85 // Try device name. 86 return getInputDeviceConfigurationFilePathByName(deviceIdentifier.name, type); 87} 88 89String8 getInputDeviceConfigurationFilePathByName( 90 const String8& name, InputDeviceConfigurationFileType type) { 91 // Search system repository. 92 String8 path; 93 path.setTo(getenv("ANDROID_ROOT")); 94 path.append("/usr/"); 95 appendInputDeviceConfigurationFileRelativePath(path, name, type); 96#if DEBUG_PROBE 97 LOGD("Probing for system provided input device configuration file: path='%s'", path.string()); 98#endif 99 if (!access(path.string(), R_OK)) { 100#if DEBUG_PROBE 101 LOGD("Found"); 102#endif 103 return path; 104 } 105 106 // Search user repository. 107 // TODO Should only look here if not in safe mode. 108 path.setTo(getenv("ANDROID_DATA")); 109 path.append("/system/devices/"); 110 appendInputDeviceConfigurationFileRelativePath(path, name, type); 111#if DEBUG_PROBE 112 LOGD("Probing for system user input device configuration file: path='%s'", path.string()); 113#endif 114 if (!access(path.string(), R_OK)) { 115#if DEBUG_PROBE 116 LOGD("Found"); 117#endif 118 return path; 119 } 120 121 // Not found. 122#if DEBUG_PROBE 123 LOGD("Probe failed to find input device configuration file: name='%s', type=%d", 124 name.string(), type); 125#endif 126 return String8(); 127} 128 129 130// --- InputEvent --- 131 132void InputEvent::initialize(int32_t deviceId, int32_t source) { 133 mDeviceId = deviceId; 134 mSource = source; 135} 136 137void InputEvent::initialize(const InputEvent& from) { 138 mDeviceId = from.mDeviceId; 139 mSource = from.mSource; 140} 141 142// --- KeyEvent --- 143 144bool KeyEvent::hasDefaultAction(int32_t keyCode) { 145 switch (keyCode) { 146 case AKEYCODE_HOME: 147 case AKEYCODE_BACK: 148 case AKEYCODE_CALL: 149 case AKEYCODE_ENDCALL: 150 case AKEYCODE_VOLUME_UP: 151 case AKEYCODE_VOLUME_DOWN: 152 case AKEYCODE_VOLUME_MUTE: 153 case AKEYCODE_POWER: 154 case AKEYCODE_CAMERA: 155 case AKEYCODE_HEADSETHOOK: 156 case AKEYCODE_MENU: 157 case AKEYCODE_NOTIFICATION: 158 case AKEYCODE_FOCUS: 159 case AKEYCODE_SEARCH: 160 case AKEYCODE_MEDIA_PLAY: 161 case AKEYCODE_MEDIA_PAUSE: 162 case AKEYCODE_MEDIA_PLAY_PAUSE: 163 case AKEYCODE_MEDIA_STOP: 164 case AKEYCODE_MEDIA_NEXT: 165 case AKEYCODE_MEDIA_PREVIOUS: 166 case AKEYCODE_MEDIA_REWIND: 167 case AKEYCODE_MEDIA_RECORD: 168 case AKEYCODE_MEDIA_FAST_FORWARD: 169 case AKEYCODE_MUTE: 170 return true; 171 } 172 173 return false; 174} 175 176bool KeyEvent::hasDefaultAction() const { 177 return hasDefaultAction(getKeyCode()); 178} 179 180bool KeyEvent::isSystemKey(int32_t keyCode) { 181 switch (keyCode) { 182 case AKEYCODE_MENU: 183 case AKEYCODE_SOFT_RIGHT: 184 case AKEYCODE_HOME: 185 case AKEYCODE_BACK: 186 case AKEYCODE_CALL: 187 case AKEYCODE_ENDCALL: 188 case AKEYCODE_VOLUME_UP: 189 case AKEYCODE_VOLUME_DOWN: 190 case AKEYCODE_VOLUME_MUTE: 191 case AKEYCODE_MUTE: 192 case AKEYCODE_POWER: 193 case AKEYCODE_HEADSETHOOK: 194 case AKEYCODE_MEDIA_PLAY: 195 case AKEYCODE_MEDIA_PAUSE: 196 case AKEYCODE_MEDIA_PLAY_PAUSE: 197 case AKEYCODE_MEDIA_STOP: 198 case AKEYCODE_MEDIA_NEXT: 199 case AKEYCODE_MEDIA_PREVIOUS: 200 case AKEYCODE_MEDIA_REWIND: 201 case AKEYCODE_MEDIA_RECORD: 202 case AKEYCODE_MEDIA_FAST_FORWARD: 203 case AKEYCODE_CAMERA: 204 case AKEYCODE_FOCUS: 205 case AKEYCODE_SEARCH: 206 return true; 207 } 208 209 return false; 210} 211 212bool KeyEvent::isSystemKey() const { 213 return isSystemKey(getKeyCode()); 214} 215 216void KeyEvent::initialize( 217 int32_t deviceId, 218 int32_t source, 219 int32_t action, 220 int32_t flags, 221 int32_t keyCode, 222 int32_t scanCode, 223 int32_t metaState, 224 int32_t repeatCount, 225 nsecs_t downTime, 226 nsecs_t eventTime) { 227 InputEvent::initialize(deviceId, source); 228 mAction = action; 229 mFlags = flags; 230 mKeyCode = keyCode; 231 mScanCode = scanCode; 232 mMetaState = metaState; 233 mRepeatCount = repeatCount; 234 mDownTime = downTime; 235 mEventTime = eventTime; 236} 237 238void KeyEvent::initialize(const KeyEvent& from) { 239 InputEvent::initialize(from); 240 mAction = from.mAction; 241 mFlags = from.mFlags; 242 mKeyCode = from.mKeyCode; 243 mScanCode = from.mScanCode; 244 mMetaState = from.mMetaState; 245 mRepeatCount = from.mRepeatCount; 246 mDownTime = from.mDownTime; 247 mEventTime = from.mEventTime; 248} 249 250 251// --- PointerCoords --- 252 253float PointerCoords::getAxisValue(int32_t axis) const { 254 if (axis < 0 || axis > 63) { 255 return 0; 256 } 257 258 uint64_t axisBit = 1LL << axis; 259 if (!(bits & axisBit)) { 260 return 0; 261 } 262 uint32_t index = __builtin_popcountll(bits & (axisBit - 1LL)); 263 return values[index]; 264} 265 266status_t PointerCoords::setAxisValue(int32_t axis, float value) { 267 if (axis < 0 || axis > 63) { 268 return NAME_NOT_FOUND; 269 } 270 271 uint64_t axisBit = 1LL << axis; 272 uint32_t index = __builtin_popcountll(bits & (axisBit - 1LL)); 273 if (!(bits & axisBit)) { 274 uint32_t count = __builtin_popcountll(bits); 275 if (count >= MAX_AXES) { 276 tooManyAxes(axis); 277 return NO_MEMORY; 278 } 279 bits |= axisBit; 280 for (uint32_t i = count; i > index; i--) { 281 values[i] = values[i - 1]; 282 } 283 } 284 values[index] = value; 285 return OK; 286} 287 288float* PointerCoords::editAxisValue(int32_t axis) { 289 if (axis < 0 || axis > 63) { 290 return NULL; 291 } 292 293 uint64_t axisBit = 1LL << axis; 294 if (!(bits & axisBit)) { 295 return NULL; 296 } 297 uint32_t index = __builtin_popcountll(bits & (axisBit - 1LL)); 298 return &values[index]; 299} 300 301#ifdef HAVE_ANDROID_OS 302status_t PointerCoords::readFromParcel(Parcel* parcel) { 303 bits = parcel->readInt64(); 304 305 uint32_t count = __builtin_popcountll(bits); 306 if (count > MAX_AXES) { 307 return BAD_VALUE; 308 } 309 310 for (uint32_t i = 0; i < count; i++) { 311 values[i] = parcel->readInt32(); 312 } 313 return OK; 314} 315 316status_t PointerCoords::writeToParcel(Parcel* parcel) const { 317 parcel->writeInt64(bits); 318 319 uint32_t count = __builtin_popcountll(bits); 320 for (uint32_t i = 0; i < count; i++) { 321 parcel->writeInt32(values[i]); 322 } 323 return OK; 324} 325#endif 326 327void PointerCoords::tooManyAxes(int axis) { 328 LOGW("Could not set value for axis %d because the PointerCoords structure is full and " 329 "cannot contain more than %d axis values.", axis, int(MAX_AXES)); 330} 331 332 333// --- MotionEvent --- 334 335void MotionEvent::initialize( 336 int32_t deviceId, 337 int32_t source, 338 int32_t action, 339 int32_t flags, 340 int32_t edgeFlags, 341 int32_t metaState, 342 float xOffset, 343 float yOffset, 344 float xPrecision, 345 float yPrecision, 346 nsecs_t downTime, 347 nsecs_t eventTime, 348 size_t pointerCount, 349 const int32_t* pointerIds, 350 const PointerCoords* pointerCoords) { 351 InputEvent::initialize(deviceId, source); 352 mAction = action; 353 mFlags = flags; 354 mEdgeFlags = edgeFlags; 355 mMetaState = metaState; 356 mXOffset = xOffset; 357 mYOffset = yOffset; 358 mXPrecision = xPrecision; 359 mYPrecision = yPrecision; 360 mDownTime = downTime; 361 mPointerIds.clear(); 362 mPointerIds.appendArray(pointerIds, pointerCount); 363 mSampleEventTimes.clear(); 364 mSamplePointerCoords.clear(); 365 addSample(eventTime, pointerCoords); 366} 367 368void MotionEvent::copyFrom(const MotionEvent* other, bool keepHistory) { 369 InputEvent::initialize(other->mDeviceId, other->mSource); 370 mAction = other->mAction; 371 mFlags = other->mFlags; 372 mEdgeFlags = other->mEdgeFlags; 373 mMetaState = other->mMetaState; 374 mXOffset = other->mXOffset; 375 mYOffset = other->mYOffset; 376 mXPrecision = other->mXPrecision; 377 mYPrecision = other->mYPrecision; 378 mDownTime = other->mDownTime; 379 mPointerIds = other->mPointerIds; 380 381 if (keepHistory) { 382 mSampleEventTimes = other->mSampleEventTimes; 383 mSamplePointerCoords = other->mSamplePointerCoords; 384 } else { 385 mSampleEventTimes.clear(); 386 mSampleEventTimes.push(other->getEventTime()); 387 mSamplePointerCoords.clear(); 388 size_t pointerCount = other->getPointerCount(); 389 size_t historySize = other->getHistorySize(); 390 mSamplePointerCoords.appendArray(other->mSamplePointerCoords.array() 391 + (historySize * pointerCount), pointerCount); 392 } 393} 394 395void MotionEvent::addSample( 396 int64_t eventTime, 397 const PointerCoords* pointerCoords) { 398 mSampleEventTimes.push(eventTime); 399 mSamplePointerCoords.appendArray(pointerCoords, getPointerCount()); 400} 401 402const PointerCoords* MotionEvent::getRawPointerCoords(size_t pointerIndex) const { 403 return &mSamplePointerCoords[getHistorySize() * getPointerCount() + pointerIndex]; 404} 405 406float MotionEvent::getRawAxisValue(int32_t axis, size_t pointerIndex) const { 407 return getRawPointerCoords(pointerIndex)->getAxisValue(axis); 408} 409 410float MotionEvent::getAxisValue(int32_t axis, size_t pointerIndex) const { 411 float value = getRawPointerCoords(pointerIndex)->getAxisValue(axis); 412 switch (axis) { 413 case AMOTION_EVENT_AXIS_X: 414 value += mXOffset; 415 break; 416 case AMOTION_EVENT_AXIS_Y: 417 value += mYOffset; 418 break; 419 } 420 return value; 421} 422 423const PointerCoords* MotionEvent::getHistoricalRawPointerCoords( 424 size_t pointerIndex, size_t historicalIndex) const { 425 return &mSamplePointerCoords[historicalIndex * getPointerCount() + pointerIndex]; 426} 427 428float MotionEvent::getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex, 429 size_t historicalIndex) const { 430 return getHistoricalRawPointerCoords(pointerIndex, historicalIndex)->getAxisValue(axis); 431} 432 433float MotionEvent::getHistoricalAxisValue(int32_t axis, size_t pointerIndex, 434 size_t historicalIndex) const { 435 float value = getHistoricalRawPointerCoords(pointerIndex, historicalIndex)->getAxisValue(axis); 436 switch (axis) { 437 case AMOTION_EVENT_AXIS_X: 438 value += mXOffset; 439 break; 440 case AMOTION_EVENT_AXIS_Y: 441 value += mYOffset; 442 break; 443 } 444 return value; 445} 446 447void MotionEvent::offsetLocation(float xOffset, float yOffset) { 448 mXOffset += xOffset; 449 mYOffset += yOffset; 450} 451 452static inline void scaleAxisValue(PointerCoords& c, int axis, float scaleFactor) { 453 float* value = c.editAxisValue(axis); 454 if (value) { 455 *value *= scaleFactor; 456 } 457} 458 459void MotionEvent::scale(float scaleFactor) { 460 mXOffset *= scaleFactor; 461 mYOffset *= scaleFactor; 462 mXPrecision *= scaleFactor; 463 mYPrecision *= scaleFactor; 464 465 size_t numSamples = mSamplePointerCoords.size(); 466 for (size_t i = 0; i < numSamples; i++) { 467 PointerCoords& c = mSamplePointerCoords.editItemAt(i); 468 // No need to scale pressure or size since they are normalized. 469 // No need to scale orientation since it is meaningless to do so. 470 scaleAxisValue(c, AMOTION_EVENT_AXIS_X, scaleFactor); 471 scaleAxisValue(c, AMOTION_EVENT_AXIS_Y, scaleFactor); 472 scaleAxisValue(c, AMOTION_EVENT_AXIS_TOUCH_MAJOR, scaleFactor); 473 scaleAxisValue(c, AMOTION_EVENT_AXIS_TOUCH_MINOR, scaleFactor); 474 scaleAxisValue(c, AMOTION_EVENT_AXIS_TOOL_MAJOR, scaleFactor); 475 scaleAxisValue(c, AMOTION_EVENT_AXIS_TOOL_MINOR, scaleFactor); 476 } 477} 478 479#ifdef HAVE_ANDROID_OS 480static inline float transformAngle(const SkMatrix* matrix, float angleRadians) { 481 // Construct and transform a vector oriented at the specified clockwise angle from vertical. 482 // Coordinate system: down is increasing Y, right is increasing X. 483 SkPoint vector; 484 vector.fX = SkFloatToScalar(sinf(angleRadians)); 485 vector.fY = SkFloatToScalar(-cosf(angleRadians)); 486 matrix->mapVectors(& vector, 1); 487 488 // Derive the transformed vector's clockwise angle from vertical. 489 float result = atan2f(SkScalarToFloat(vector.fX), SkScalarToFloat(-vector.fY)); 490 if (result < - M_PI_2) { 491 result += M_PI; 492 } else if (result > M_PI_2) { 493 result -= M_PI; 494 } 495 return result; 496} 497 498void MotionEvent::transform(const SkMatrix* matrix) { 499 float oldXOffset = mXOffset; 500 float oldYOffset = mYOffset; 501 502 // The tricky part of this implementation is to preserve the value of 503 // rawX and rawY. So we apply the transformation to the first point 504 // then derive an appropriate new X/Y offset that will preserve rawX and rawY. 505 SkPoint point; 506 float rawX = getRawX(0); 507 float rawY = getRawY(0); 508 matrix->mapXY(SkFloatToScalar(rawX + oldXOffset), SkFloatToScalar(rawY + oldYOffset), 509 & point); 510 float newX = SkScalarToFloat(point.fX); 511 float newY = SkScalarToFloat(point.fY); 512 float newXOffset = newX - rawX; 513 float newYOffset = newY - rawY; 514 515 mXOffset = newXOffset; 516 mYOffset = newYOffset; 517 518 // Apply the transformation to all samples. 519 size_t numSamples = mSamplePointerCoords.size(); 520 for (size_t i = 0; i < numSamples; i++) { 521 PointerCoords& c = mSamplePointerCoords.editItemAt(i); 522 float* xPtr = c.editAxisValue(AMOTION_EVENT_AXIS_X); 523 float* yPtr = c.editAxisValue(AMOTION_EVENT_AXIS_Y); 524 if (xPtr && yPtr) { 525 float x = *xPtr + oldXOffset; 526 float y = *yPtr + oldYOffset; 527 matrix->mapXY(SkFloatToScalar(x), SkFloatToScalar(y), & point); 528 *xPtr = SkScalarToFloat(point.fX) - newXOffset; 529 *yPtr = SkScalarToFloat(point.fY) - newYOffset; 530 } 531 532 float* orientationPtr = c.editAxisValue(AMOTION_EVENT_AXIS_ORIENTATION); 533 if (orientationPtr) { 534 *orientationPtr = transformAngle(matrix, *orientationPtr); 535 } 536 } 537} 538 539status_t MotionEvent::readFromParcel(Parcel* parcel) { 540 size_t pointerCount = parcel->readInt32(); 541 size_t sampleCount = parcel->readInt32(); 542 if (pointerCount == 0 || pointerCount > MAX_POINTERS || sampleCount == 0) { 543 return BAD_VALUE; 544 } 545 546 mDeviceId = parcel->readInt32(); 547 mSource = parcel->readInt32(); 548 mAction = parcel->readInt32(); 549 mFlags = parcel->readInt32(); 550 mEdgeFlags = parcel->readInt32(); 551 mMetaState = parcel->readInt32(); 552 mXOffset = parcel->readFloat(); 553 mYOffset = parcel->readFloat(); 554 mXPrecision = parcel->readFloat(); 555 mYPrecision = parcel->readFloat(); 556 mDownTime = parcel->readInt64(); 557 558 mPointerIds.clear(); 559 mPointerIds.setCapacity(pointerCount); 560 mSampleEventTimes.clear(); 561 mSampleEventTimes.setCapacity(sampleCount); 562 mSamplePointerCoords.clear(); 563 mSamplePointerCoords.setCapacity(sampleCount * pointerCount); 564 565 for (size_t i = 0; i < pointerCount; i++) { 566 mPointerIds.push(parcel->readInt32()); 567 } 568 569 while (sampleCount-- > 0) { 570 mSampleEventTimes.push(parcel->readInt64()); 571 for (size_t i = 0; i < pointerCount; i++) { 572 mSamplePointerCoords.push(); 573 status_t status = mSamplePointerCoords.editTop().readFromParcel(parcel); 574 if (status) { 575 return status; 576 } 577 } 578 } 579 return OK; 580} 581 582status_t MotionEvent::writeToParcel(Parcel* parcel) const { 583 size_t pointerCount = mPointerIds.size(); 584 size_t sampleCount = mSampleEventTimes.size(); 585 586 parcel->writeInt32(pointerCount); 587 parcel->writeInt32(sampleCount); 588 589 parcel->writeInt32(mDeviceId); 590 parcel->writeInt32(mSource); 591 parcel->writeInt32(mAction); 592 parcel->writeInt32(mFlags); 593 parcel->writeInt32(mEdgeFlags); 594 parcel->writeInt32(mMetaState); 595 parcel->writeFloat(mXOffset); 596 parcel->writeFloat(mYOffset); 597 parcel->writeFloat(mXPrecision); 598 parcel->writeFloat(mYPrecision); 599 parcel->writeInt64(mDownTime); 600 601 for (size_t i = 0; i < pointerCount; i++) { 602 parcel->writeInt32(mPointerIds.itemAt(i)); 603 } 604 605 const PointerCoords* pc = mSamplePointerCoords.array(); 606 for (size_t h = 0; h < sampleCount; h++) { 607 parcel->writeInt64(mSampleEventTimes.itemAt(h)); 608 for (size_t i = 0; i < pointerCount; i++) { 609 status_t status = (pc++)->writeToParcel(parcel); 610 if (status) { 611 return status; 612 } 613 } 614 } 615 return OK; 616} 617#endif 618 619bool MotionEvent::isTouchEvent(int32_t source, int32_t action) { 620 if (source & AINPUT_SOURCE_CLASS_POINTER) { 621 // Specifically excludes HOVER_MOVE and SCROLL. 622 switch (action & AMOTION_EVENT_ACTION_MASK) { 623 case AMOTION_EVENT_ACTION_DOWN: 624 case AMOTION_EVENT_ACTION_MOVE: 625 case AMOTION_EVENT_ACTION_UP: 626 case AMOTION_EVENT_ACTION_POINTER_DOWN: 627 case AMOTION_EVENT_ACTION_POINTER_UP: 628 case AMOTION_EVENT_ACTION_CANCEL: 629 case AMOTION_EVENT_ACTION_OUTSIDE: 630 return true; 631 } 632 } 633 return false; 634} 635 636 637// --- InputDeviceInfo --- 638 639InputDeviceInfo::InputDeviceInfo() { 640 initialize(-1, String8("uninitialized device info")); 641} 642 643InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) : 644 mId(other.mId), mName(other.mName), mSources(other.mSources), 645 mKeyboardType(other.mKeyboardType), 646 mMotionRanges(other.mMotionRanges) { 647} 648 649InputDeviceInfo::~InputDeviceInfo() { 650} 651 652void InputDeviceInfo::initialize(int32_t id, const String8& name) { 653 mId = id; 654 mName = name; 655 mSources = 0; 656 mKeyboardType = AINPUT_KEYBOARD_TYPE_NONE; 657 mMotionRanges.clear(); 658} 659 660const InputDeviceInfo::MotionRange* InputDeviceInfo::getMotionRange(int32_t axis) const { 661 ssize_t index = mMotionRanges.indexOfKey(axis); 662 return index >= 0 ? & mMotionRanges.valueAt(index) : NULL; 663} 664 665void InputDeviceInfo::addSource(uint32_t source) { 666 mSources |= source; 667} 668 669void InputDeviceInfo::addMotionRange(int32_t axis, float min, float max, 670 float flat, float fuzz) { 671 MotionRange range = { min, max, flat, fuzz }; 672 addMotionRange(axis, range); 673} 674 675void InputDeviceInfo::addMotionRange(int32_t axis, const MotionRange& range) { 676 mMotionRanges.add(axis, range); 677} 678 679} // namespace android 680