12 #ifndef hifi_TouchscreenDevice_h
13 #define hifi_TouchscreenDevice_h
15 #include <controllers/InputDevice.h>
16 #include "InputPlugin.h"
17 #include <QtGui/qtouchdevice.h>
22 class TouchscreenDevice :
public InputPlugin {
26 enum TouchAxisChannel {
33 enum TouchGestureAxisChannel {
34 TOUCH_GESTURE_PINCH_POS = TOUCH_AXIS_Y_NEG + 1,
35 TOUCH_GESTURE_PINCH_NEG,
39 virtual bool isSupported()
const override;
40 virtual const QString getName()
const override {
return NAME; }
42 virtual void pluginFocusOutEvent()
override { _inputDevice->focusOutEvent(); }
43 virtual void pluginUpdate(
float deltaTime,
const controller::InputCalibrationData& inputCalibrationData)
override;
45 void touchBeginEvent(
const QTouchEvent* event);
46 void touchEndEvent(
const QTouchEvent* event);
47 void touchUpdateEvent(
const QTouchEvent* event);
48 void touchGestureEvent(
const QGestureEvent* event);
50 static const char* NAME;
54 class InputDevice :
public controller::InputDevice {
56 InputDevice() : controller::InputDevice(
"Touchscreen") {}
59 virtual controller::Input::NamedVector getAvailableInputs()
const override;
60 virtual QString getDefaultMappingConfig()
const override;
61 virtual void update(
float deltaTime,
const controller::InputCalibrationData& inputCalibrationData)
override;
62 virtual void focusOutEvent()
override;
64 controller::Input makeInput(TouchAxisChannel axis)
const;
65 controller::Input makeInput(TouchGestureAxisChannel gesture)
const;
67 friend class TouchscreenDevice;
71 const std::shared_ptr<InputDevice>& getInputDevice()
const {
return _inputDevice; }
74 qreal _lastPinchScale;
77 glm::vec2 _screenDPIScale;
78 glm::vec2 _firstTouchVec;
79 glm::vec2 _currentTouchVec;
81 std::shared_ptr<InputDevice> _inputDevice { std::make_shared<InputDevice>() };