VirtualTouchpad.h revision 3002b8a74431dd7c005269cf9306443a4b4963f1
1#ifndef ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H
2#define ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H
3
4#include <utils/Errors.h>
5#include <utils/RefBase.h>
6#include <utils/StrongPointer.h>
7
8namespace android {
9namespace dvr {
10
11// Provides a virtual touchpad for injecting events into the input system.
12//
13class VirtualTouchpad : public RefBase {
14 public:
15  enum : int {
16    PRIMARY = 0,
17    VIRTUAL = 1,
18  };
19
20  // Create a virtual touchpad.
21  // Implementations should provide this, and hide their constructors.
22  // For the user, switching implementations should be as simple as changing
23  // the class whose |Create()| is called.
24  static sp<VirtualTouchpad> Create() {
25    return sp<VirtualTouchpad>();
26  }
27
28  // Generate a simulated touch event.
29  //
30  // @param touchpad Touchpad selector index.
31  // @param x Horizontal touch position.
32  // @param y Vertical touch position.
33  //            Values must be in the range [0.0, 1.0).
34  // @param pressure Touch pressure.
35  //            Positive values represent contact; use 1.0f if contact
36  //            is binary. Use 0.0f for no contact.
37  // @returns OK on success.
38  //
39  virtual status_t Touch(int touchpad, float x, float y, float pressure) = 0;
40
41  // Generate a simulated touchpad button state.
42  //
43  // @param touchpad Touchpad selector index.
44  // @param buttons A union of MotionEvent BUTTON_* values.
45  // @returns OK on success.
46  //
47  // Currently only BUTTON_BACK is supported, as the implementation
48  // restricts itself to operations actually required by VrWindowManager.
49  //
50  virtual status_t ButtonState(int touchpad, int buttons) = 0;
51
52 protected:
53  VirtualTouchpad() {}
54  ~VirtualTouchpad() override {}
55
56 private:
57  VirtualTouchpad(const VirtualTouchpad&) = delete;
58  void operator=(const VirtualTouchpad&) = delete;
59};
60
61}  // namespace dvr
62}  // namespace android
63
64#endif  // ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H
65