12 #ifndef hifi_Keyboard_h
13 #define hifi_Keyboard_h
19 #include <QtCore/QObject>
23 #include <DependencyManager.h>
25 #include <shared/ReadWriteLockable.h>
26 #include <SettingHandle.h>
54 static Key::Type getKeyTypeFromString(
const QString& keyTypeString);
56 QUuid getID()
const {
return _keyID; }
57 void setID(
const QUuid&
id) { _keyID = id; }
59 void startTimer(
int time);
62 void setKeyString(QString keyString) { _keyString = keyString; }
63 QString getKeyString(
bool toUpper)
const;
64 int getScanCode(
bool toUpper)
const;
66 bool isPressed()
const {
return _pressed; }
67 void setIsPressed(
bool pressed) { _pressed = pressed; }
69 void setSwitchToLayerIndex(
int layerIndex) { _switchToLayer = layerIndex; }
70 int getSwitchToLayerIndex()
const {
return _switchToLayer; }
72 Type getKeyType()
const {
return _type; }
73 void setKeyType(Type type) { _type = type; }
75 glm::vec3 getCurrentLocalPosition()
const {
return _currentLocalPosition; }
77 void saveDimensionsAndLocalPosition();
79 void scaleKey(
float sensorToWorldScale);
81 Type _type { Type::CHARACTER };
83 int _switchToLayer { 0 };
84 bool _pressed {
false };
89 glm::vec3 _originalLocalPosition;
90 glm::vec3 _originalDimensions;
91 glm::vec3 _currentLocalPosition;
92 bool _originalDimensionsAndLocalPositionSaved {
false };
94 std::shared_ptr<QTimer> _timer { std::make_shared<QTimer>() };
97 class Keyboard :
public QObject,
public Dependency,
public ReadWriteLockable {
101 void createKeyboard();
102 void registerKeyboardHighlighting();
103 bool isRaised()
const;
104 void setRaised(
bool raised,
bool inputToHudUI =
false);
105 void setResetKeyboardPositionOnRaise(
bool reset);
106 bool isPassword()
const;
107 void setPassword(
bool password);
108 void enableRightMallet();
109 void scaleKeyboard(
float sensorToWorldScale);
110 void enableLeftMallet();
111 void disableRightMallet();
112 void disableLeftMallet();
114 void setLeftHandLaser(
unsigned int leftHandLaser);
115 void setRightHandLaser(
unsigned int rightHandLaser);
117 void setPreferMalletsOverLasers(
bool preferMalletsOverLasers);
118 bool getPreferMalletsOverLasers()
const;
120 bool getUse3DKeyboard()
const;
121 void setUse3DKeyboard(
bool use);
122 bool containsID(
const QUuid&
id)
const;
124 void loadKeyboardFile(
const QString& keyboardFile);
125 QSet<QUuid> getKeyIDs();
129 void handleTriggerBegin(
const QUuid&
id,
const PointerEvent& event);
130 void handleTriggerEnd(
const QUuid&
id,
const PointerEvent& event);
131 void handleTriggerContinue(
const QUuid&
id,
const PointerEvent& event);
132 void handleHoverBegin(
const QUuid&
id,
const PointerEvent& event);
133 void handleHoverEnd(
const QUuid&
id,
const PointerEvent& event);
138 glm::vec3 originalDimensions;
143 glm::vec3 dimensions;
144 glm::vec3 localPosition;
150 glm::vec3 localPosition;
151 glm::vec3 dimensions;
154 void raiseKeyboard(
bool raise)
const;
155 void raiseKeyboardAnchor(
bool raise)
const;
157 void disableStylus();
158 void enableSelectionLists();
159 void disableSelectionLists();
161 void setLayerIndex(
int layerIndex);
162 void clearKeyboardKeys();
163 void switchToLayer(
int layerIndex);
164 void updateTextDisplay();
165 bool shouldProcessEntityAndPointerEvent(
const PointerEvent& event)
const;
166 bool shouldProcessPointerEvent(
const PointerEvent& event)
const;
167 bool shouldProcessEntity()
const;
168 void addIncludeItemsToMallets();
170 void startLayerSwitchTimer();
171 bool isLayerSwitchTimerFinished()
const;
172 void handleSpecialKey(Key::Type keyType);
174 bool _raised {
false };
175 bool _resetKeyboardPositionOnRaise {
true };
176 bool _password {
false };
177 bool _capsEnabled {
false };
178 int _layerIndex { 0 };
180 unsigned int _leftHandStylus { 0 };
181 unsigned int _rightHandStylus { 0 };
182 unsigned int _leftHandLaser { 0 };
183 unsigned int _rightHandLaser { 0 };
184 SharedSoundPointer _keySound {
nullptr };
185 std::shared_ptr<QTimer> _layerSwitchTimer { std::make_shared<QTimer>() };
187 mutable ReadWriteLockable _use3DKeyboardLock;
188 mutable ReadWriteLockable _handLaserLock;
189 mutable ReadWriteLockable _preferMalletsOverLasersSettingLock;
190 mutable ReadWriteLockable _ignoreItemsLock;
194 QString _typedCharacters;
195 TextDisplay _textDisplay;
197 BackPlate _backPlate;
199 QSet<QUuid> _itemsToIgnore;
200 std::vector<QHash<QUuid, Key>> _keyboardLayers;
203 std::atomic<bool> _inputToHudUI {
false };
204 bool _created {
false };
Represents a 2D or 3D pointer to the scripting engine. Exposed as PointerEvent
Definition: PointerEvent.h:32