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>
46 static Key::Type getKeyTypeFromString(
const QString& keyTypeString);
48 QUuid getID()
const {
return _keyID; }
49 void setID(
const QUuid&
id) { _keyID = id; }
51 void startTimer(
int time);
54 void setKeyString(QString keyString) { _keyString = keyString; }
55 QString getKeyString(
bool toUpper)
const;
56 int getScanCode(
bool toUpper)
const;
58 bool isPressed()
const {
return _pressed; }
59 void setIsPressed(
bool pressed) { _pressed = pressed; }
61 void setSwitchToLayerIndex(
int layerIndex) { _switchToLayer = layerIndex; }
62 int getSwitchToLayerIndex()
const {
return _switchToLayer; }
64 Type getKeyType()
const {
return _type; }
65 void setKeyType(Type type) { _type = type; }
67 glm::vec3 getCurrentLocalPosition()
const {
return _currentLocalPosition; }
69 void saveDimensionsAndLocalPosition();
71 void scaleKey(
float sensorToWorldScale);
73 Type _type { Type::CHARACTER };
75 int _switchToLayer { 0 };
76 bool _pressed {
false };
81 glm::vec3 _originalLocalPosition;
82 glm::vec3 _originalDimensions;
83 glm::vec3 _currentLocalPosition;
84 bool _originalDimensionsAndLocalPositionSaved {
false };
86 std::shared_ptr<QTimer> _timer { std::make_shared<QTimer>() };
89 class Keyboard :
public QObject,
public Dependency,
public ReadWriteLockable {
93 void createKeyboard();
94 void registerKeyboardHighlighting();
95 bool isRaised()
const;
96 void setRaised(
bool raised);
97 void setResetKeyboardPositionOnRaise(
bool reset);
98 bool isPassword()
const;
99 void setPassword(
bool password);
100 void enableRightMallet();
101 void scaleKeyboard(
float sensorToWorldScale);
102 void enableLeftMallet();
103 void disableRightMallet();
104 void disableLeftMallet();
106 void setLeftHandLaser(
unsigned int leftHandLaser);
107 void setRightHandLaser(
unsigned int rightHandLaser);
109 void setPreferMalletsOverLasers(
bool preferMalletsOverLasers);
110 bool getPreferMalletsOverLasers()
const;
112 bool getUse3DKeyboard()
const;
113 void setUse3DKeyboard(
bool use);
114 bool containsID(
const QUuid&
id)
const;
116 void loadKeyboardFile(
const QString& keyboardFile);
117 QSet<QUuid> getKeyIDs();
121 void handleTriggerBegin(
const QUuid&
id,
const PointerEvent& event);
122 void handleTriggerEnd(
const QUuid&
id,
const PointerEvent& event);
123 void handleTriggerContinue(
const QUuid&
id,
const PointerEvent& event);
124 void handleHoverBegin(
const QUuid&
id,
const PointerEvent& event);
125 void handleHoverEnd(
const QUuid&
id,
const PointerEvent& event);
130 glm::vec3 originalDimensions;
135 glm::vec3 dimensions;
136 glm::vec3 localPosition;
142 glm::vec3 localPosition;
143 glm::vec3 dimensions;
146 void raiseKeyboard(
bool raise)
const;
147 void raiseKeyboardAnchor(
bool raise)
const;
149 void disableStylus();
150 void enableSelectionLists();
151 void disableSelectionLists();
153 void setLayerIndex(
int layerIndex);
154 void clearKeyboardKeys();
155 void switchToLayer(
int layerIndex);
156 void updateTextDisplay();
157 bool shouldProcessEntityAndPointerEvent(
const PointerEvent& event)
const;
158 bool shouldProcessPointerEvent(
const PointerEvent& event)
const;
159 bool shouldProcessEntity()
const;
160 void addIncludeItemsToMallets();
162 void startLayerSwitchTimer();
163 bool isLayerSwitchTimerFinished()
const;
165 bool _raised {
false };
166 bool _resetKeyboardPositionOnRaise {
true };
167 bool _password {
false };
168 bool _capsEnabled {
false };
169 int _layerIndex { 0 };
171 unsigned int _leftHandStylus { 0 };
172 unsigned int _rightHandStylus { 0 };
173 unsigned int _leftHandLaser { 0 };
174 unsigned int _rightHandLaser { 0 };
175 SharedSoundPointer _keySound {
nullptr };
176 std::shared_ptr<QTimer> _layerSwitchTimer { std::make_shared<QTimer>() };
178 mutable ReadWriteLockable _use3DKeyboardLock;
179 mutable ReadWriteLockable _handLaserLock;
180 mutable ReadWriteLockable _preferMalletsOverLasersSettingLock;
181 mutable ReadWriteLockable _ignoreItemsLock;
185 QString _typedCharacters;
186 TextDisplay _textDisplay;
188 BackPlate _backPlate;
190 QSet<QUuid> _itemsToIgnore;
191 std::vector<QHash<QUuid, Key>> _keyboardLayers;
193 bool _created {
false };
Represents a 2D or 3D pointer to the scripting engine. Exposed as PointerEvent
Definition: PointerEvent.h:30