1 /* 2 * Copyright 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.input; 18 19 import com.android.internal.util.DataClass; 20 import com.android.tools.r8.keepanno.annotations.KeepItemKind; 21 import com.android.tools.r8.keepanno.annotations.UsedByNative; 22 23 /** 24 * A Java representation of hardware properties for a touchpad or mouse device. 25 * This class mirrors the Gestures library HardwareProperties C++ struct used for representing 26 * touchpad and mouse device properties, including touch area, resolution, and features like haptic 27 * feedback, multitouch, and scroll wheels. It facilitates interaction between native and managed 28 * code in Android. 29 */ 30 @DataClass( 31 genToString = true 32 ) 33 @UsedByNative( 34 description = "Called from JNI in jni/com_android_server_input_InputManagerService.cpp", 35 kind = KeepItemKind.CLASS_AND_MEMBERS) 36 public class TouchpadHardwareProperties { 37 /** 38 * The minimum X coordinate that the device can report. 39 */ 40 private float mLeft; 41 42 /** 43 * The minimum Y coordinate that the device can report. 44 */ 45 private float mTop; 46 47 /** 48 * The maximum X coordinate that the device can report. 49 */ 50 private float mRight; 51 52 /** 53 * The maximum Y coordinate that the device can report. 54 */ 55 private float mBottom; 56 57 /** 58 * The resolution of the X axis, in units per mm. Set to 0 if the 59 * resolution is unknown. 60 */ 61 private float mResX; 62 /** 63 * The resolutions of the Y axis, in units per mm. Set to 0 if the 64 * resolution is unknown. 65 */ 66 private float mResY; 67 68 /** 69 * The minimum orientation value. 70 */ 71 private float mOrientationMinimum; 72 /** 73 * The maximum orientation value. 74 */ 75 private float mOrientationMaximum; 76 77 /** 78 * The maximum number of finger slots that the device can report in one 79 * HardwareState struct. 80 */ 81 private short mMaxFingerCount; 82 83 /** 84 * Whether the touchpad has a button under its touch surface, allowing the 85 * user to click by pressing (almost) anywhere on the pad, as opposed to 86 * having one or more separate buttons for clicking. 87 */ 88 private boolean mIsButtonPad; 89 90 /** 91 * Whether the touchpad is haptic, meaning that it reports true pressure (not 92 * just touch area) via the pressure axis, and can provide haptic feedback. 93 */ 94 private boolean mIsHapticPad; 95 96 /** 97 * Whether the touchpad reports pressure values in any way. 98 */ 99 private boolean mReportsPressure = true; 100 101 /** 102 * Returns a string representation of this instance, including all fields. 103 */ toString()104 public String toString() { 105 return "HardwareProperties{" 106 + "left=" + mLeft 107 + ", top=" + mTop 108 + ", right=" + mRight 109 + ", bottom=" + mBottom 110 + ", resX=" + mResX 111 + ", resY=" + mResY 112 + ", orientationMinimum=" + mOrientationMinimum 113 + ", orientationMaximum=" + mOrientationMaximum 114 + ", maxFingerCount=" + mMaxFingerCount 115 + ", isButtonPad=" + mIsButtonPad 116 + ", isHapticPad=" + mIsHapticPad 117 + ", reportsPressure=" + mReportsPressure 118 + '}'; 119 } 120 121 122 // Code below generated by codegen v1.0.23. 123 // 124 // DO NOT MODIFY! 125 // CHECKSTYLE:OFF Generated code 126 // 127 // To regenerate run: 128 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/input 129 // /TouchpadHardwareProperties.java 130 // 131 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 132 // Settings > Editor > Code Style > Formatter Control 133 //@formatter:off 134 135 136 @DataClass.Generated.Member TouchpadHardwareProperties( float left, float top, float right, float bottom, float resX, float resY, float orientationMinimum, float orientationMaximum, short maxFingerCount, boolean isButtonPad, boolean isHapticPad, boolean reportsPressure)137 /* package-private */ TouchpadHardwareProperties( 138 float left, 139 float top, 140 float right, 141 float bottom, 142 float resX, 143 float resY, 144 float orientationMinimum, 145 float orientationMaximum, 146 short maxFingerCount, 147 boolean isButtonPad, 148 boolean isHapticPad, 149 boolean reportsPressure) { 150 this.mLeft = left; 151 this.mTop = top; 152 this.mRight = right; 153 this.mBottom = bottom; 154 this.mResX = resX; 155 this.mResY = resY; 156 this.mOrientationMinimum = orientationMinimum; 157 this.mOrientationMaximum = orientationMaximum; 158 this.mMaxFingerCount = maxFingerCount; 159 this.mIsButtonPad = isButtonPad; 160 this.mIsHapticPad = isHapticPad; 161 this.mReportsPressure = reportsPressure; 162 163 // onConstructed(); // You can define this method to get a callback 164 } 165 166 /** 167 * The minimum X coordinate that the device can report. 168 */ 169 @DataClass.Generated.Member getLeft()170 public float getLeft() { 171 return mLeft; 172 } 173 174 /** 175 * The minimum Y coordinate that the device can report. 176 */ 177 @DataClass.Generated.Member getTop()178 public float getTop() { 179 return mTop; 180 } 181 182 /** 183 * The maximum X coordinate that the device can report. 184 */ 185 @DataClass.Generated.Member getRight()186 public float getRight() { 187 return mRight; 188 } 189 190 /** 191 * The maximum Y coordinate that the device can report. 192 */ 193 @DataClass.Generated.Member getBottom()194 public float getBottom() { 195 return mBottom; 196 } 197 198 /** 199 * The resolution of the X axis, in units per mm. Set to 0 if the 200 * resolution is unknown. 201 */ 202 @DataClass.Generated.Member getResX()203 public float getResX() { 204 return mResX; 205 } 206 207 /** 208 * The resolutions of the Y axis, in units per mm. Set to 0 if the 209 * resolution is unknown. 210 */ 211 @DataClass.Generated.Member getResY()212 public float getResY() { 213 return mResY; 214 } 215 216 /** 217 * The minimum orientation value. 218 */ 219 @DataClass.Generated.Member getOrientationMinimum()220 public float getOrientationMinimum() { 221 return mOrientationMinimum; 222 } 223 224 /** 225 * The maximum orientation value. 226 */ 227 @DataClass.Generated.Member getOrientationMaximum()228 public float getOrientationMaximum() { 229 return mOrientationMaximum; 230 } 231 232 /** 233 * The maximum number of finger slots that the device can report in one 234 * HardwareState struct. 235 */ 236 @DataClass.Generated.Member getMaxFingerCount()237 public short getMaxFingerCount() { 238 return mMaxFingerCount; 239 } 240 241 /** 242 * Whether the touchpad has a button under its touch surface, allowing the 243 * user to click by pressing (almost) anywhere on the pad, as opposed to 244 * having one or more separate buttons for clicking. 245 */ 246 @DataClass.Generated.Member isIsButtonPad()247 public boolean isIsButtonPad() { 248 return mIsButtonPad; 249 } 250 251 /** 252 * Whether the touchpad is haptic, meaning that it reports true pressure (not 253 * just touch area) via the pressure axis, and can provide haptic feedback. 254 */ 255 @DataClass.Generated.Member isIsHapticPad()256 public boolean isIsHapticPad() { 257 return mIsHapticPad; 258 } 259 260 /** 261 * Whether the touchpad reports pressure values in any way. 262 */ 263 @DataClass.Generated.Member isReportsPressure()264 public boolean isReportsPressure() { 265 return mReportsPressure; 266 } 267 268 /** 269 * A builder for {@link TouchpadHardwareProperties} 270 */ 271 @SuppressWarnings("WeakerAccess") 272 @DataClass.Generated.Member 273 public static class Builder { 274 275 private float mLeft; 276 private float mTop; 277 private float mRight; 278 private float mBottom; 279 private float mResX; 280 private float mResY; 281 private float mOrientationMinimum; 282 private float mOrientationMaximum; 283 private short mMaxFingerCount; 284 private boolean mIsButtonPad; 285 private boolean mIsHapticPad; 286 private boolean mReportsPressure; 287 288 private long mBuilderFieldsSet = 0L; 289 290 /** 291 * Creates a new Builder. 292 * 293 * @param left 294 * The minimum X coordinate that the device can report. 295 * @param top 296 * The minimum Y coordinate that the device can report. 297 * @param right 298 * The maximum X coordinate that the device can report. 299 * @param bottom 300 * The maximum Y coordinate that the device can report. 301 * @param resX 302 * The resolution of the X axis, in units per mm. Set to 0 if the 303 * resolution is unknown. 304 * @param resY 305 * The resolutions of the Y axis, in units per mm. Set to 0 if the 306 * resolution is unknown. 307 * @param orientationMinimum 308 * The minimum orientation value. 309 * @param orientationMaximum 310 * The maximum orientation value. 311 * @param maxFingerCount 312 * The maximum number of finger slots that the device can report in one 313 * HardwareState struct. 314 * @param isButtonPad 315 * Whether the touchpad has a button under its touch surface, allowing the 316 * user to click by pressing (almost) anywhere on the pad, as opposed to 317 * having one or more separate buttons for clicking. 318 * @param isHapticPad 319 * Whether the touchpad is haptic, meaning that it reports true pressure (not 320 * just touch area) via the pressure axis, and can provide haptic feedback. 321 */ Builder( float left, float top, float right, float bottom, float resX, float resY, float orientationMinimum, float orientationMaximum, short maxFingerCount, boolean isButtonPad, boolean isHapticPad)322 public Builder( 323 float left, 324 float top, 325 float right, 326 float bottom, 327 float resX, 328 float resY, 329 float orientationMinimum, 330 float orientationMaximum, 331 short maxFingerCount, 332 boolean isButtonPad, 333 boolean isHapticPad) { 334 mLeft = left; 335 mTop = top; 336 mRight = right; 337 mBottom = bottom; 338 mResX = resX; 339 mResY = resY; 340 mOrientationMinimum = orientationMinimum; 341 mOrientationMaximum = orientationMaximum; 342 mMaxFingerCount = maxFingerCount; 343 mIsButtonPad = isButtonPad; 344 mIsHapticPad = isHapticPad; 345 } 346 347 /** 348 * The minimum X coordinate that the device can report. 349 */ 350 @DataClass.Generated.Member setLeft(float value)351 public @android.annotation.NonNull Builder setLeft(float value) { 352 checkNotUsed(); 353 mBuilderFieldsSet |= 0x1; 354 mLeft = value; 355 return this; 356 } 357 358 /** 359 * The minimum Y coordinate that the device can report. 360 */ 361 @DataClass.Generated.Member setTop(float value)362 public @android.annotation.NonNull Builder setTop(float value) { 363 checkNotUsed(); 364 mBuilderFieldsSet |= 0x2; 365 mTop = value; 366 return this; 367 } 368 369 /** 370 * The maximum X coordinate that the device can report. 371 */ 372 @DataClass.Generated.Member setRight(float value)373 public @android.annotation.NonNull Builder setRight(float value) { 374 checkNotUsed(); 375 mBuilderFieldsSet |= 0x4; 376 mRight = value; 377 return this; 378 } 379 380 /** 381 * The maximum Y coordinate that the device can report. 382 */ 383 @DataClass.Generated.Member setBottom(float value)384 public @android.annotation.NonNull Builder setBottom(float value) { 385 checkNotUsed(); 386 mBuilderFieldsSet |= 0x8; 387 mBottom = value; 388 return this; 389 } 390 391 /** 392 * The resolution of the X axis, in units per mm. Set to 0 if the 393 * resolution is unknown. 394 */ 395 @DataClass.Generated.Member setResX(float value)396 public @android.annotation.NonNull Builder setResX(float value) { 397 checkNotUsed(); 398 mBuilderFieldsSet |= 0x10; 399 mResX = value; 400 return this; 401 } 402 403 /** 404 * The resolutions of the Y axis, in units per mm. Set to 0 if the 405 * resolution is unknown. 406 */ 407 @DataClass.Generated.Member setResY(float value)408 public @android.annotation.NonNull Builder setResY(float value) { 409 checkNotUsed(); 410 mBuilderFieldsSet |= 0x20; 411 mResY = value; 412 return this; 413 } 414 415 /** 416 * The minimum orientation value. 417 */ 418 @DataClass.Generated.Member setOrientationMinimum(float value)419 public @android.annotation.NonNull Builder setOrientationMinimum(float value) { 420 checkNotUsed(); 421 mBuilderFieldsSet |= 0x40; 422 mOrientationMinimum = value; 423 return this; 424 } 425 426 /** 427 * The maximum orientation value. 428 */ 429 @DataClass.Generated.Member setOrientationMaximum(float value)430 public @android.annotation.NonNull Builder setOrientationMaximum(float value) { 431 checkNotUsed(); 432 mBuilderFieldsSet |= 0x80; 433 mOrientationMaximum = value; 434 return this; 435 } 436 437 /** 438 * The maximum number of finger slots that the device can report in one 439 * HardwareState struct. 440 */ 441 @DataClass.Generated.Member setMaxFingerCount(short value)442 public @android.annotation.NonNull Builder setMaxFingerCount(short value) { 443 checkNotUsed(); 444 mBuilderFieldsSet |= 0x100; 445 mMaxFingerCount = value; 446 return this; 447 } 448 449 /** 450 * Whether the touchpad has a button under its touch surface, allowing the 451 * user to click by pressing (almost) anywhere on the pad, as opposed to 452 * having one or more separate buttons for clicking. 453 */ 454 @DataClass.Generated.Member setIsButtonPad(boolean value)455 public @android.annotation.NonNull Builder setIsButtonPad(boolean value) { 456 checkNotUsed(); 457 mBuilderFieldsSet |= 0x200; 458 mIsButtonPad = value; 459 return this; 460 } 461 462 /** 463 * Whether the touchpad is haptic, meaning that it reports true pressure (not 464 * just touch area) via the pressure axis, and can provide haptic feedback. 465 */ 466 @DataClass.Generated.Member setIsHapticPad(boolean value)467 public @android.annotation.NonNull Builder setIsHapticPad(boolean value) { 468 checkNotUsed(); 469 mBuilderFieldsSet |= 0x400; 470 mIsHapticPad = value; 471 return this; 472 } 473 474 /** 475 * Whether the touchpad reports pressure values in any way. 476 */ 477 @DataClass.Generated.Member setReportsPressure(boolean value)478 public @android.annotation.NonNull Builder setReportsPressure(boolean value) { 479 checkNotUsed(); 480 mBuilderFieldsSet |= 0x800; 481 mReportsPressure = value; 482 return this; 483 } 484 485 /** Builds the instance. This builder should not be touched after calling this! */ build()486 public @android.annotation.NonNull TouchpadHardwareProperties build() { 487 checkNotUsed(); 488 mBuilderFieldsSet |= 0x1000; // Mark builder used 489 490 if ((mBuilderFieldsSet & 0x800) == 0) { 491 mReportsPressure = true; 492 } 493 TouchpadHardwareProperties o = new TouchpadHardwareProperties( 494 mLeft, 495 mTop, 496 mRight, 497 mBottom, 498 mResX, 499 mResY, 500 mOrientationMinimum, 501 mOrientationMaximum, 502 mMaxFingerCount, 503 mIsButtonPad, 504 mIsHapticPad, 505 mReportsPressure); 506 return o; 507 } 508 checkNotUsed()509 private void checkNotUsed() { 510 if ((mBuilderFieldsSet & 0x1000) != 0) { 511 throw new IllegalStateException( 512 "This Builder should not be reused. Use a new Builder instance instead"); 513 } 514 } 515 } 516 517 @DataClass.Generated( 518 time = 1723570664889L, 519 codegenVersion = "1.0.23", 520 sourceFile = "frameworks/base/services/core" 521 + "/java/com/android/server/input/TouchpadHardwareProperties.java", 522 inputSignatures = "private float mLeft\nprivate float mTop\nprivate float mRight\n" 523 + "private float mBottom\nprivate float mResX\nprivate float mResY\n" 524 + "private float mOrientationMinimum\nprivate float mOrientationMaximum\n" 525 + "private short mMaxFingerCount\nprivate boolean mIsButtonPad\n" 526 + "private boolean mIsHapticPad\nprivate boolean mReportsPressure\n" 527 + "public java.lang.String toString()\n" 528 + "class TouchpadHardwareProperties extends java.lang.Object implements []\n" 529 + "@com.android.internal.util.DataClass(genToString=true)") 530 @Deprecated __metadata()531 private void __metadata() {} 532 533 //@formatter:on 534 // End of generated code 535 } 536