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>
55 static Key::Type getKeyTypeFromString(
const QString& keyTypeString);
57 QUuid getID()
const {
return _keyID; }
58 void setID(
const QUuid&
id) { _keyID = id; }
60 void startTimer(
int time);
63 void setKeyString(QString keyString) { _keyString = keyString; }
64 QString getKeyString(
bool toUpper)
const;
65 int getScanCode(
bool toUpper)
const;
67 bool isPressed()
const {
return _pressed; }
68 void setIsPressed(
bool pressed) { _pressed = pressed; }
70 void setSwitchToLayerIndex(
int layerIndex) { _switchToLayer = layerIndex; }
71 int getSwitchToLayerIndex()
const {
return _switchToLayer; }
73 Type getKeyType()
const {
return _type; }
74 void setKeyType(Type type) { _type = type; }
76 glm::vec3 getCurrentLocalPosition()
const {
return _currentLocalPosition; }
78 void saveDimensionsAndLocalPosition();
80 void scaleKey(
float sensorToWorldScale);
82 Type _type { Type::CHARACTER };
84 int _switchToLayer { 0 };
85 bool _pressed {
false };
90 glm::vec3 _originalLocalPosition;
91 glm::vec3 _originalDimensions;
92 glm::vec3 _currentLocalPosition;
93 bool _originalDimensionsAndLocalPositionSaved {
false };
95 std::shared_ptr<QTimer> _timer { std::make_shared<QTimer>() };
98 class Keyboard :
public QObject,
public Dependency,
public ReadWriteLockable {
102 void createKeyboard();
103 void registerKeyboardHighlighting();
104 bool isRaised()
const;
105 void setRaised(
bool raised,
bool inputToHudUI =
false);
106 void setResetKeyboardPositionOnRaise(
bool reset);
107 bool isPassword()
const;
108 void setPassword(
bool password);
109 void enableRightMallet();
110 void scaleKeyboard(
float sensorToWorldScale);
111 void enableLeftMallet();
112 void disableRightMallet();
113 void disableLeftMallet();
115 void setLeftHandLaser(
unsigned int leftHandLaser);
116 void setRightHandLaser(
unsigned int rightHandLaser);
118 void setPreferMalletsOverLasers(
bool preferMalletsOverLasers);
119 bool getPreferMalletsOverLasers()
const;
121 bool getUse3DKeyboard()
const;
122 void setUse3DKeyboard(
bool use);
123 bool containsID(
const QUuid&
id)
const;
125 void loadKeyboardFile(
const QString& keyboardFile);
126 QSet<QUuid> getKeyIDs();
129 void emitKeyEvent(
const KeyEvent& event,
bool pressed)
const;
132 void handleTriggerBegin(
const QUuid&
id,
const PointerEvent& event);
133 void handleTriggerEnd(
const QUuid&
id,
const PointerEvent& event);
134 void handleTriggerContinue(
const QUuid&
id,
const PointerEvent& event);
135 void handleHoverBegin(
const QUuid&
id,
const PointerEvent& event);
136 void handleHoverEnd(
const QUuid&
id,
const PointerEvent& event);
141 glm::vec3 originalDimensions;
146 glm::vec3 dimensions;
147 glm::vec3 localPosition;
153 glm::vec3 localPosition;
154 glm::vec3 dimensions;
157 void raiseKeyboard(
bool raise)
const;
158 void raiseKeyboardAnchor(
bool raise)
const;
160 void disableStylus();
161 void enableSelectionLists();
162 void disableSelectionLists();
164 void setLayerIndex(
int layerIndex);
165 void clearKeyboardKeys();
166 void switchToLayer(
int layerIndex);
167 void updateTextDisplay();
168 bool shouldProcessEntityAndPointerEvent(
const PointerEvent& event)
const;
169 bool shouldProcessPointerEvent(
const PointerEvent& event)
const;
170 bool shouldProcessEntity()
const;
171 void addIncludeItemsToMallets();
173 void startLayerSwitchTimer();
174 bool isLayerSwitchTimerFinished()
const;
175 void handleSpecialKey(Key::Type keyType);
177 bool _raised {
false };
178 bool _resetKeyboardPositionOnRaise {
true };
179 bool _password {
false };
180 bool _capsEnabled {
false };
181 int _layerIndex { 0 };
183 unsigned int _leftHandStylus { 0 };
184 unsigned int _rightHandStylus { 0 };
185 unsigned int _leftHandLaser { 0 };
186 unsigned int _rightHandLaser { 0 };
187 SharedSoundPointer _keySound {
nullptr };
188 std::shared_ptr<QTimer> _layerSwitchTimer { std::make_shared<QTimer>() };
190 mutable ReadWriteLockable _use3DKeyboardLock;
191 mutable ReadWriteLockable _handLaserLock;
192 mutable ReadWriteLockable _preferMalletsOverLasersSettingLock;
193 mutable ReadWriteLockable _ignoreItemsLock;
197 QString _typedCharacters;
198 TextDisplay _textDisplay;
200 BackPlate _backPlate;
202 QSet<QUuid> _itemsToIgnore;
203 std::vector<QHash<QUuid, Key>> _keyboardLayers;
206 std::atomic<bool> _inputToHudUI {
false };
207 bool _created {
false };
Represents a keyboard event to the scripting engine. Exposed as KeyEvent
Definition: KeyEvent.h:27
Represents a 2D or 3D pointer to the scripting engine. Exposed as PointerEvent
Definition: PointerEvent.h:32