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
10namespace android {
11namespace dvr {
12
13// Provides a virtual touchpad for injecting events into the input system.
14//
15class VirtualTouchpad {
16 public:
17  enum : int {
18    PRIMARY = DVR_VIRTUAL_TOUCHPAD_PRIMARY,
19    VIRTUAL = DVR_VIRTUAL_TOUCHPAD_VIRTUAL,
20  };
21
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().
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  // Report state for 'dumpsys'.
65  virtual void dumpInternal(String8& result) = 0;
66
67 protected:
68  VirtualTouchpad() {}
69
70 private:
71  VirtualTouchpad(const VirtualTouchpad&) = delete;
72  void operator=(const VirtualTouchpad&) = delete;
73};
74
75}  // namespace dvr
76}  // namespace android
77
78#endif  // ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H
79