// // KeyboardScriptingInterface.h // interface/src/scripting // // Created by Dante Ruiz on 2018-08-27. // Copyright 2017 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_KeyboardScriptingInterface_h #define hifi_KeyboardScriptingInterface_h #include #include #include "DependencyManager.h" /**jsdoc * The Keyboard API provides facilities to use an in-world, virtual keyboard. When enabled, this keyboard is * displayed instead of the 2D keyboard that raises at the bottom of the tablet or Web entities when a text input field has * focus and you're in HMD mode. * * @namespace Keyboard * * @hifi-interface * @hifi-client-entity * @hifi-avatar * * @property {boolean} raised - true if the virtual keyboard is visible, false if it isn't. * @property {boolean} password - true if "*"s are displayed on the virtual keyboard's display * instead of the characters typed, false if the actual characters are displayed. * @property {boolean} use3DKeyboard - true if user settings have "Use Virtual Keyboard" enabled, * false if it's disabled. Read-only. * @property {boolean} preferMalletsOverLasers - true if user settings for the virtual keyboard have "Mallets" * selected, false if "Lasers" is selected. Read-only. */ class KeyboardScriptingInterface : public QObject, public Dependency { Q_OBJECT Q_PROPERTY(bool raised READ isRaised WRITE setRaised) Q_PROPERTY(bool password READ isPassword WRITE setPassword) Q_PROPERTY(bool use3DKeyboard READ getUse3DKeyboard CONSTANT); Q_PROPERTY(bool preferMalletsOverLasers READ getPreferMalletsOverLasers CONSTANT) public: KeyboardScriptingInterface() = default; ~KeyboardScriptingInterface() = default; /**jsdoc * Loads a JSON file that defines the virtual keyboard's layout. The default JSON file used is * {@link https://github.com/highfidelity/hifi/blob/master/interface/resources/config/keyboard.json|https://github.com/highfidelity/hifi/.../keyboard.json}. * @function Keyboard.loadKeyboardFile * @param {string} path - The keyboard JSON file. */ Q_INVOKABLE void loadKeyboardFile(const QString& string); /**jsdoc * Enables the left mallet so that it is displayed when in HMD mode. * @function Keyboard.enableLeftMallet */ Q_INVOKABLE void enableLeftMallet(); /**jsdoc * Enables the right mallet so that it is displayed when in HMD mode. * @function Keyboard.enableRightMallet */ Q_INVOKABLE void enableRightMallet(); /**jsdoc * Disables the left mallet so that it is not displayed when in HMD mode. * @function Keyboard.disableLeftMallet */ Q_INVOKABLE void disableLeftMallet(); /**jsdoc * Disables the right mallet so that it is not displayed when in HMD mode. * @function Keyboard.disableRightMallet */ Q_INVOKABLE void disableRightMallet(); /**jsdoc * Configures the virtual keyboard to recognize a ray pointer as the left hand's laser. * @function Keyboard.setLeftHandLaser * @param {number} leftHandLaser - The ID of a ray pointer created by {@link Pointers.createPointer}. */ Q_INVOKABLE void setLeftHandLaser(unsigned int leftHandLaser); /**jsdoc * Configures the virtual keyboard to recognize a ray pointer as the right hand's laser. * @function Keyboard.setRightHandLaser * @param {number} rightHandLaser - The ID of a ray pointer created by {@link Pointers.createPointer}. */ Q_INVOKABLE void setRightHandLaser(unsigned int rightHandLaser); /**jsdoc * Checks whether an entity is part of the virtual keyboard. * @function Keyboard.containsID * @param {Uuid} entityID - The entity ID. * @returns {boolean} true if the entity is part of the virtual keyboard, false if it isn't. */ Q_INVOKABLE bool containsID(const QUuid& overlayID) const; private: bool getPreferMalletsOverLasers() const; bool isRaised() const; void setRaised(bool raised); bool isPassword() const; void setPassword(bool password); bool getUse3DKeyboard() const; }; #endif