PointerControllerInterface.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (C) 2014 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. #ifndef _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H
  17. #define _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H
  18. #include <input/Input.h>
  19. #include <utils/BitSet.h>
  20. #include <utils/RefBase.h>
  21. namespace android {
  22. /**
  23. * Interface for tracking a mouse / touch pad pointer and touch pad spots.
  24. *
  25. * The spots are sprites on screen that visually represent the positions of
  26. * fingers
  27. *
  28. * The pointer controller is responsible for providing synchronization and for tracking
  29. * display orientation changes if needed.
  30. */
  31. class PointerControllerInterface : public virtual RefBase {
  32. protected:
  33. PointerControllerInterface() { }
  34. virtual ~PointerControllerInterface() { }
  35. public:
  36. /* Gets the bounds of the region that the pointer can traverse.
  37. * Returns true if the bounds are available. */
  38. virtual bool getBounds(float* outMinX, float* outMinY,
  39. float* outMaxX, float* outMaxY) const = 0;
  40. /* Move the pointer. */
  41. virtual void move(float deltaX, float deltaY) = 0;
  42. /* Sets a mask that indicates which buttons are pressed. */
  43. virtual void setButtonState(int32_t buttonState) = 0;
  44. /* Gets a mask that indicates which buttons are pressed. */
  45. virtual int32_t getButtonState() const = 0;
  46. /* Sets the absolute location of the pointer. */
  47. virtual void setPosition(float x, float y) = 0;
  48. /* Gets the absolute location of the pointer. */
  49. virtual void getPosition(float* outX, float* outY) const = 0;
  50. enum Transition {
  51. // Fade/unfade immediately.
  52. TRANSITION_IMMEDIATE,
  53. // Fade/unfade gradually.
  54. TRANSITION_GRADUAL,
  55. };
  56. /* Fades the pointer out now. */
  57. virtual void fade(Transition transition) = 0;
  58. /* Makes the pointer visible if it has faded out.
  59. * The pointer never unfades itself automatically. This method must be called
  60. * by the client whenever the pointer is moved or a button is pressed and it
  61. * wants to ensure that the pointer becomes visible again. */
  62. virtual void unfade(Transition transition) = 0;
  63. enum Presentation {
  64. // Show the mouse pointer.
  65. PRESENTATION_POINTER,
  66. // Show spots and a spot anchor in place of the mouse pointer.
  67. PRESENTATION_SPOT,
  68. };
  69. /* Sets the mode of the pointer controller. */
  70. virtual void setPresentation(Presentation presentation) = 0;
  71. /* Sets the spots for the current gesture.
  72. * The spots are not subject to the inactivity timeout like the pointer
  73. * itself it since they are expected to remain visible for so long as
  74. * the fingers are on the touch pad.
  75. *
  76. * The values of the AMOTION_EVENT_AXIS_PRESSURE axis is significant.
  77. * For spotCoords, pressure != 0 indicates that the spot's location is being
  78. * pressed (not hovering).
  79. */
  80. virtual void setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex,
  81. BitSet32 spotIdBits) = 0;
  82. /* Removes all spots. */
  83. virtual void clearSpots() = 0;
  84. };
  85. } // namespace android
  86. #endif // _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H