VirtualTouchpad.h revision 3002b8a74431dd7c005269cf9306443a4b4963f1
189af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel#ifndef ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H 289af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel#define ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H 389af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel 489af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel#include <utils/Errors.h> 589af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel#include <utils/RefBase.h> 689af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel#include <utils/StrongPointer.h> 789af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel 889af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedelnamespace android { 989af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedelnamespace dvr { 1089af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel 1189af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel// Provides a virtual touchpad for injecting events into the input system. 1289af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel// 1389af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedelclass VirtualTouchpad : public RefBase { 1489af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel public: 153002b8a74431dd7c005269cf9306443a4b4963f1Kevin Schoedel enum : int { 163002b8a74431dd7c005269cf9306443a4b4963f1Kevin Schoedel PRIMARY = 0, 173002b8a74431dd7c005269cf9306443a4b4963f1Kevin Schoedel VIRTUAL = 1, 183002b8a74431dd7c005269cf9306443a4b4963f1Kevin Schoedel }; 193002b8a74431dd7c005269cf9306443a4b4963f1Kevin Schoedel 2089af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // Create a virtual touchpad. 2189af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // Implementations should provide this, and hide their constructors. 2289af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // For the user, switching implementations should be as simple as changing 2389af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // the class whose |Create()| is called. 2489af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel static sp<VirtualTouchpad> Create() { 2589af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel return sp<VirtualTouchpad>(); 2689af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel } 2789af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel 2889af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // Generate a simulated touch event. 2989af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // 303002b8a74431dd7c005269cf9306443a4b4963f1Kevin Schoedel // @param touchpad Touchpad selector index. 3189af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // @param x Horizontal touch position. 3289af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // @param y Vertical touch position. 3389af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // Values must be in the range [0.0, 1.0). 3489af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // @param pressure Touch pressure. 3589af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // Positive values represent contact; use 1.0f if contact 3689af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // is binary. Use 0.0f for no contact. 3789af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // @returns OK on success. 3889af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // 393002b8a74431dd7c005269cf9306443a4b4963f1Kevin Schoedel virtual status_t Touch(int touchpad, float x, float y, float pressure) = 0; 4089af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel 4189af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // Generate a simulated touchpad button state. 4289af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // 433002b8a74431dd7c005269cf9306443a4b4963f1Kevin Schoedel // @param touchpad Touchpad selector index. 4489af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // @param buttons A union of MotionEvent BUTTON_* values. 4589af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // @returns OK on success. 4689af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // 4789af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // Currently only BUTTON_BACK is supported, as the implementation 4889af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // restricts itself to operations actually required by VrWindowManager. 4989af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel // 503002b8a74431dd7c005269cf9306443a4b4963f1Kevin Schoedel virtual status_t ButtonState(int touchpad, int buttons) = 0; 5189af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel 5289af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel protected: 5389af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel VirtualTouchpad() {} 543002b8a74431dd7c005269cf9306443a4b4963f1Kevin Schoedel ~VirtualTouchpad() override {} 5589af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel 5689af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel private: 5789af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel VirtualTouchpad(const VirtualTouchpad&) = delete; 5889af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel void operator=(const VirtualTouchpad&) = delete; 5989af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel}; 6089af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel 6189af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel} // namespace dvr 6289af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel} // namespace android 6389af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel 6489af70bce420f011adfeb0f80984b3895c4d7d9bKevin Schoedel#endif // ANDROID_DVR_VIRTUAL_TOUCHPAD_INTERFACE_H 65