File: VirtualTouchpad.h

package info (click to toggle)
android-platform-tools 34.0.5-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 150,900 kB
  • sloc: cpp: 805,786; java: 293,500; ansic: 128,288; xml: 127,491; python: 41,481; sh: 14,245; javascript: 9,665; cs: 3,846; asm: 2,049; makefile: 1,917; yacc: 440; awk: 368; ruby: 183; sql: 140; perl: 88; lex: 67
file content (88 lines) | stat: -rw-r--r-- 2,616 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H
#define ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H

#include "dvr/virtual_touchpad_client.h"

#include <memory>
#include <utils/Errors.h>
#include <utils/String8.h>

namespace android {
namespace dvr {

// Provides a virtual touchpad for injecting events into the input system.
//
class VirtualTouchpad {
 public:
  enum : int {
    PRIMARY = DVR_VIRTUAL_TOUCHPAD_PRIMARY,
    VIRTUAL = DVR_VIRTUAL_TOUCHPAD_VIRTUAL,
  };

  virtual ~VirtualTouchpad() {}

  // Create a virtual touchpad.
  // Implementations should provide this, and hide their constructors.
  // For the user, switching implementations should be as simple as changing
  // the class whose |Create()| is called.
  // Implementations should be minimial; major resource allocation should
  // be performed in Attach().
  static std::unique_ptr<VirtualTouchpad> Create() {
    return nullptr;
  }

  // Initialize a virtual touchpad.
  virtual status_t Attach() = 0;

  // Shut down a virtual touchpad.
  virtual status_t Detach() = 0;

  // Generate a simulated touch event.
  //
  // @param touchpad Touchpad selector index.
  // @param x Horizontal touch position.
  // @param y Vertical touch position.
  //            Values must be in the range [0.0, 1.0).
  // @param pressure Touch pressure.
  //            Positive values represent contact; use 1.0f if contact
  //            is binary. Use 0.0f for no contact.
  // @returns OK on success.
  //
  virtual status_t Touch(int touchpad, float x, float y, float pressure) = 0;

  // Generate a simulated touchpad button state.
  //
  // @param touchpad Touchpad selector index.
  // @param buttons A union of MotionEvent BUTTON_* values.
  // @returns OK on success.
  //
  // Currently only BUTTON_BACK is supported, as the implementation
  // restricts itself to operations actually required by VrWindowManager.
  //
  virtual status_t ButtonState(int touchpad, int buttons) = 0;

  // Generate a simulated scroll event.
  //
  // @param touchpad Touchpad selector index.
  // @param x Horizontal scroll increment.
  // @param y Vertical scroll increment.
  //            Values must be in the range [-1.0, 1.0].
  // @returns OK on success.
  //
  virtual status_t Scroll(int touchpad, float x, float y) = 0;

  // Report state for 'dumpsys'.
  virtual void dumpInternal(String8& result) = 0;

 protected:
  VirtualTouchpad() {}

 private:
  VirtualTouchpad(const VirtualTouchpad&) = delete;
  void operator=(const VirtualTouchpad&) = delete;
};

}  // namespace dvr
}  // namespace android

#endif  // ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H