Overte C++ Documentation
AvatarInputs.h
1 //
2 // Created by Bradley Austin Davis 2015/06/19
3 // Copyright 2013 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 #ifndef hifi_AvatarInputs_h
10 #define hifi_AvatarInputs_h
11 
12 #include <QQuickItem>
13 #include <OffscreenUi.h>
14 
15 #define AI_PROPERTY(type, name, initialValue) \
16  Q_PROPERTY(type name READ name NOTIFY name##Changed) \
17 public: \
18  type name() { return _##name; }; \
19 private: \
20  type _##name{ initialValue };
21 
22 class AvatarInputs : public QObject {
23  Q_OBJECT
24  HIFI_QML_DECL
25 
26  /*@jsdoc
27  * The <code>AvatarInputs</code> API provides facilities to manage user inputs.
28  *
29  * @namespace AvatarInputs
30  *
31  * @hifi-interface
32  * @hifi-client-entity
33  * @hifi-avatar
34  *
35  * @property {boolean} cameraEnabled - <code>true</code> if webcam face tracking is enabled, <code>false</code> if it is
36  * disabled.
37  * <em>Read-only.</em>
38  * <p class="important">Deprecated: This property is deprecated and has been removed.</p>
39  * @property {boolean} cameraMuted - <code>true</code> if webcam face tracking is muted (temporarily disabled),
40  * <code>false</code> it if isn't.
41  * <em>Read-only.</em>
42  * <p class="important">Deprecated: This property is deprecated and has been removed.</p>
43  * @property {boolean} ignoreRadiusEnabled - <code>true</code> if the privacy shield is enabled, <code>false</code> if it
44  * is disabled.
45  * <em>Read-only.</em>
46  * @property {boolean} isHMD - <code>true</code> if the display mode is HMD, <code>false</code> if it isn't.
47  * <em>Read-only.</em>
48  * @property {boolean} showAudioTools - <code>true</code> if the microphone mute button and audio level meter are shown,
49  * <code>false</code> if they are hidden.
50  * @property {boolean} showBubbleTools - <code>true</code> if the privacy shield UI button is shown, <code>false</code> if
51  * it is hidden.
52  */
53 
54  AI_PROPERTY(bool, isHMD, false)
55 
56  Q_PROPERTY(bool showAudioTools READ showAudioTools WRITE setShowAudioTools NOTIFY showAudioToolsChanged)
57  Q_PROPERTY(bool showBubbleTools READ showBubbleTools WRITE setShowBubbleTools NOTIFY showBubbleToolsChanged)
58  Q_PROPERTY(bool ignoreRadiusEnabled READ getIgnoreRadiusEnabled NOTIFY ignoreRadiusEnabledChanged)
59  //Q_PROPERTY(bool enteredIgnoreRadius READ getEnteredIgnoreRadius NOTIFY enteredIgnoreRadiusChanged)
60 
61 public:
62  static AvatarInputs* getInstance();
63 
64  /*@jsdoc
65  * Converts non-linear audio loudness to a linear audio level.
66  * @function AvatarInputs.loudnessToAudioLevel
67  * @param {number} loudness - The non-linear audio loudness.
68  * @returns {number} The linear audio level.
69  */
70  Q_INVOKABLE float loudnessToAudioLevel(float loudness);
71 
72  AvatarInputs(QObject* parent = nullptr);
73  void update();
74  bool showAudioTools() const { return _showAudioTools; }
75  bool showBubbleTools() const { return _showBubbleTools; }
76  bool getIgnoreRadiusEnabled() const;
77  //bool getEnteredIgnoreRadius() const;
78 
79 public slots:
80 
81  /*@jsdoc
82  * Sets whether or not the microphone mute button and audio level meter is shown.
83  * @function AvatarInputs.setShowAudioTools
84  * @param {boolean} showAudioTools - <code>true</code> to show the microphone mute button and audio level meter,
85  * <code>false</code> to hide it.
86  */
87  void setShowAudioTools(bool showAudioTools);
88 
89  /*@jsdoc
90  * Sets whether or not the privacy shield button is shown.
91  * @function AvatarInputs.setShowBubbleTools
92  * @param {boolean} showBubbleTools - <code>true</code> to show the privacy shield button, <code>false</code> to hide it.
93  */
94  void setShowBubbleTools(bool showBubbleTools);
95 
96 signals:
97 
98  /*@jsdoc
99  * Triggered when webcam face tracking is enabled or disabled.
100  * @deprecated This signal is deprecated and has been removed.
101  * @function AvatarInputs.cameraEnabledChanged
102  * @returns {Signal}
103  */
104 
105  /*@jsdoc
106  * Triggered when webcam face tracking is muted (temporarily disabled) or unmuted.
107  * @deprecated This signal is deprecated and has been removed.
108  * @function AvatarInputs.cameraMutedChanged
109  * @returns {Signal}
110  */
111 
112  /*@jsdoc
113  * Triggered when the display mode changes between desktop and HMD.
114  * @function AvatarInputs.isHMDChanged
115  * @returns {Signal}
116  */
117  void isHMDChanged();
118 
119  /*@jsdoc
120  * Triggered when the visibility of the microphone mute button and audio level meter changes.
121  * @function AvatarInputs.showAudioToolsChanged
122  * @param {boolean} show - <code>true</code> if the microphone mute button and audio level meter are shown,
123  * <code>false</code> if they are is hidden.
124  * @returns {Signal}
125  */
126  void showAudioToolsChanged(bool show);
127 
128  /*@jsdoc
129  * Triggered when the visibility of the privacy shield button changes.
130  * @function AvatarInputs.showBubbleToolsChanged
131  * @param {boolean} show - <code>true</code> if the privacy shield UI button is shown, <code>false</code> if
132  * it is hidden.
133  * @returns {Signal}
134  */
135  void showBubbleToolsChanged(bool show);
136 
137  /*@jsdoc
138  * Triggered when another user enters the privacy shield.
139  * @function AvatarInputs.avatarEnteredIgnoreRadius
140  * @param {QUuid} avatarID - The session ID of the user that entered the privacy shield.
141  * @returns {Signal}
142  * @example <caption>Report when a user enters the privacy shield.</caption>
143  * AvatarInputs.avatarEnteredIgnoreRadius.connect(function(avatarID) {
144  * print("User entered the privacy shield: " + avatarID);
145  * };
146  */
147  void avatarEnteredIgnoreRadius(QUuid avatarID);
148 
149  /*@jsdoc
150  * Triggered when another user leaves the privacy shield.
151  * <p><strong>Note:</strong> Currently doesn't work.</p>
152  * @function AvatarInputs.avatarLeftIgnoreRadius
153  * @param {QUuid} avatarID - The session ID of the user that exited the privacy shield.
154  * @returns {Signal}
155  * @deprecated This signal is deprecated and will be removed.
156  */
157  void avatarLeftIgnoreRadius(QUuid avatarID);
158 
159  /*@jsdoc
160  * Triggered when the privacy shield is enabled or disabled.
161  * @function AvatarInputs.ignoreRadiusEnabledChanged
162  * @param {boolean} enabled - <code>true</code> if the privacy shield is enabled, <code>false</code> if it is disabled.
163  * @returns {Signal}
164  */
165  void ignoreRadiusEnabledChanged(bool enabled);
166 
167  /*@jsdoc
168  * Triggered when another user enters the privacy shield.
169  * @function AvatarInputs.enteredIgnoreRadiusChanged
170  * @returns {Signal}
171  */
172  void enteredIgnoreRadiusChanged();
173 
174 protected:
175 
176  /*@jsdoc
177  * Resets sensors, audio, avatar animations, and the avatar rig.
178  * @function AvatarInputs.resetSensors
179  */
180  Q_INVOKABLE void resetSensors();
181 
182  /*@jsdoc
183  * Toggles the muting (temporary disablement) of webcam face tracking on/off.
184  * <p class="important">Deprecated: This function is deprecated and has been removed.</p>
185  * @function AvatarInputs.toggleCameraMute
186  */
187 
188 private:
189  void onAvatarEnteredIgnoreRadius();
190  void onAvatarLeftIgnoreRadius();
191  float _trailingAudioLoudness{ 0 };
192  bool _showAudioTools { true };
193  bool _showBubbleTools{ true };
194 };
195 
196 #endif // hifi_AvatarInputs_h