• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H
2 #define ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H
3 
4 #include "dvr/virtual_touchpad_client.h"
5 
6 #include <memory>
7 #include <utils/Errors.h>
8 #include <utils/String8.h>
9 
10 namespace android {
11 namespace dvr {
12 
13 // Provides a virtual touchpad for injecting events into the input system.
14 //
15 class VirtualTouchpad {
16  public:
17   enum : int {
18     PRIMARY = DVR_VIRTUAL_TOUCHPAD_PRIMARY,
19     VIRTUAL = DVR_VIRTUAL_TOUCHPAD_VIRTUAL,
20   };
21 
~VirtualTouchpad()22   virtual ~VirtualTouchpad() {}
23 
24   // Create a virtual touchpad.
25   // Implementations should provide this, and hide their constructors.
26   // For the user, switching implementations should be as simple as changing
27   // the class whose |Create()| is called.
28   // Implementations should be minimial; major resource allocation should
29   // be performed in Attach().
Create()30   static std::unique_ptr<VirtualTouchpad> Create() {
31     return nullptr;
32   }
33 
34   // Initialize a virtual touchpad.
35   virtual status_t Attach() = 0;
36 
37   // Shut down a virtual touchpad.
38   virtual status_t Detach() = 0;
39 
40   // Generate a simulated touch event.
41   //
42   // @param touchpad Touchpad selector index.
43   // @param x Horizontal touch position.
44   // @param y Vertical touch position.
45   //            Values must be in the range [0.0, 1.0).
46   // @param pressure Touch pressure.
47   //            Positive values represent contact; use 1.0f if contact
48   //            is binary. Use 0.0f for no contact.
49   // @returns OK on success.
50   //
51   virtual status_t Touch(int touchpad, float x, float y, float pressure) = 0;
52 
53   // Generate a simulated touchpad button state.
54   //
55   // @param touchpad Touchpad selector index.
56   // @param buttons A union of MotionEvent BUTTON_* values.
57   // @returns OK on success.
58   //
59   // Currently only BUTTON_BACK is supported, as the implementation
60   // restricts itself to operations actually required by VrWindowManager.
61   //
62   virtual status_t ButtonState(int touchpad, int buttons) = 0;
63 
64   // Generate a simulated scroll event.
65   //
66   // @param touchpad Touchpad selector index.
67   // @param x Horizontal scroll increment.
68   // @param y Vertical scroll increment.
69   //            Values must be in the range [-1.0, 1.0].
70   // @returns OK on success.
71   //
72   virtual status_t Scroll(int touchpad, float x, float y) = 0;
73 
74   // Report state for 'dumpsys'.
75   virtual void dumpInternal(String8& result) = 0;
76 
77  protected:
VirtualTouchpad()78   VirtualTouchpad() {}
79 
80  private:
81   VirtualTouchpad(const VirtualTouchpad&) = delete;
82   void operator=(const VirtualTouchpad&) = delete;
83 };
84 
85 }  // namespace dvr
86 }  // namespace android
87 
88 #endif  // ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H
89