Overte C++ Documentation
VirtualPadManager.h
1 //
2 // Created by Gabriel Calero & Cristian Duarte on 01/16/2018
3 // Copyright 2018 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 
9 #pragma once
10 #include <stdint.h>
11 #include <DependencyManager.h>
12 
13 #include <GLMHelpers.h>
14 
15 namespace VirtualPad {
16  class Instance {
17  public:
18  virtual bool isBeingTouched();
19  virtual void setBeingTouched(bool touched);
20  virtual void setFirstTouch(glm::vec2 point);
21  virtual glm::vec2 getFirstTouch();
22  virtual void setCurrentTouch(glm::vec2 point);
23  virtual glm::vec2 getCurrentTouch();
24  virtual bool isShown();
25  virtual void setShown(bool show);
26  private:
27  bool _isBeingTouched;
28  glm::vec2 _firstTouch;
29  glm::vec2 _currentTouch;
30  bool _shown;
31  };
32 
33  class Manager : public QObject, public Dependency {
34  Q_OBJECT
35  SINGLETON_DEPENDENCY
36  Manager();
37  Manager(const Manager& other) = delete;
38  public:
39  static Manager& instance();
40  Instance* getLeftVirtualPad();
41  bool isEnabled();
42  void enable(bool enable);
43  bool isHidden();
44  void hide(bool hide);
45  int extraBottomMargin();
46  void setExtraBottomMargin(int margin);
47 
48  enum Button {
49  JUMP,
50  HANDSHAKE
51  };
52 
53  glm::vec2 getButtonPosition(Button button);
54  void setButtonPosition(Button button, glm::vec2 point);
55 
56  void requestHapticFeedback(int duration);
57 
58  static const float DPI;
59  static const float BASE_DIAMETER_PIXELS;
60  static const float BASE_MARGIN_PIXELS;
61  static const float STICK_RADIUS_PIXELS;
62  static const float BTN_TRIMMED_RADIUS_PIXELS;
63  static const float BTN_FULL_PIXELS;
64  static const float BTN_BOTTOM_MARGIN_PIXELS;
65  static const float BTN_RIGHT_MARGIN_PIXELS;
66 
67  signals:
68  void hapticFeedbackRequested(int duration);
69 
70  private:
71  Instance _leftVPadInstance;
72  bool _enabled { true };
73  bool _hidden;
74  int _extraBottomMargin { 0 };
75  std::map<Button, glm::vec2> _buttonsPositions;
76  };
77 }
78 
79