Ocean
apple/macos/Keyboard.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_PLATFORM_APPLE_MACOS_KEYBOARD_H
9 #define META_OCEAN_PLATFORM_APPLE_MACOS_KEYBOARD_H
10 
12 
14 
15 namespace Ocean
16 {
17 
18 namespace Platform
19 {
20 
21 namespace Apple
22 {
23 
24 namespace MacOS
25 {
26 
27 /**
28  * This class implements keyboard functionalities.
29  * @ingroup platformapplemacos
30  */
32 {
33  public:
34 
35  /**
36  * Translates a virtual key code to the corresponsing character key and key description.
37  * @param vKey Virtual key code to translate
38  * @param key Resulting key character or name
39  * @return True, if succeeded
40  */
41  static bool translateVirtualkey(const unsigned short vKey, std::string& key);
42 
43  /**
44  * Returns whether all specified keys of the keyboard are currently pushed (down) or not.
45  * @param keys The keys for that the states are requested (may be a combination of several keys)
46  * @param synchron True, to request the state synchronously with the message queue; False, to request the state in the current moment
47  * @return True, if so; also True if no key is provided
48  */
49  static bool allKeysDown(const Key keys, const bool synchron = true);
50 
51  /**
52  * Returns whether at least one key of the specified keys of the keyboard is currently pushed (down) or not.
53  * @param keys The keys for that the states are requested (may be a combination of several keys)
54  * @param synchron True, to request the state synchronously with the message queue; False, to request the state in the current moment
55  * @return True, if so; also True if no key is provided
56  */
57  static bool oneKeyDown(const Key keys, const bool synchron = true);
58 
59  /**
60  * Returns wheater exactly one (specified key) is currently pushed (down) or not.
61  * @param key One unique key for that the state is requested, must not be a combination of several keys
62  * @param synchron True, to request the state synchronously with the message queue; False, to request the state in the current moment
63  * @return True, if so
64  */
65  static bool isKeyDown(const Key key, const bool synchron = true);
66 
67  /**
68  * Returns the current key state for the shift, control and menu keys.
69  * This function does not distinguish between the left and a right key version.
70  * @return Current key state
71  */
72  static Key currentKeyState(const bool synchron = true);
73 
74  protected:
75 
76  /**
77  * Returns wheater exactly one (specified key) is currently pushed (down) or not.
78  * @param nVirtualKey The virtual key code for that the state is requested
79  * @param synchron True, to request the state synchronously with the message queue; False, to request the state in the current moment
80  * @return True, if so
81  */
82  static bool keyState(const unsigned short nVirtualKey, const bool synchron);
83 };
84 
85 }
86 
87 }
88 
89 }
90 
91 }
92 
93 #endif // META_OCEAN_PLATFORM_APPLE_MACOS_KEYBOARD_H
This class implements keyboard functionalities.
Definition: apple/macos/Keyboard.h:32
static bool translateVirtualkey(const unsigned short vKey, std::string &key)
Translates a virtual key code to the corresponsing character key and key description.
static bool allKeysDown(const Key keys, const bool synchron=true)
Returns whether all specified keys of the keyboard are currently pushed (down) or not.
static bool isKeyDown(const Key key, const bool synchron=true)
Returns wheater exactly one (specified key) is currently pushed (down) or not.
static bool oneKeyDown(const Key keys, const bool synchron=true)
Returns whether at least one key of the specified keys of the keyboard is currently pushed (down) or ...
static Key currentKeyState(const bool synchron=true)
Returns the current key state for the shift, control and menu keys.
static bool keyState(const unsigned short nVirtualKey, const bool synchron)
Returns wheater exactly one (specified key) is currently pushed (down) or not.
This class implements keyboard functionalities.
Definition: Keyboard.h:25
Key
Definition of individual keyboard keys.
Definition: Keyboard.h:32
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15