Static methods for determining if a key is currently being pressed and to generate keyboard/key events. More...
#include <keyboard.h>
Classes | |
class | Callback |
Callback class to use to get keyboard events. More... | |
Public Types | |
enum | Key { Any = -1, Invalid = 0, Backspace, Tab, Clear, Return, ShiftLock, Pause, CapsLock, Escape, Space, PageUp, PageDown, End, Home, LeftArrow, UpArrow, RightArrow, DownArrow, Select, Print, Execute, PrintScreen, Insert, Delete, Help, Zero = 0x30, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, A = 0x41, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9, Multiply, Add, Separator, Subtract, Decimal, Divide, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, NumLock, ScrollLock, LeftShift, RightShift, LeftControl, RightControl, Comma, Period, LeftAlt, RightAlt } |
Enumeration of different keys available. More... | |
typedef std::vector< Key > | KeyList |
Public Member Functions | |
Keyboard () | |
Constructor. | |
~Keyboard () | |
Destructor. | |
bool | RegisterCallback (Callback *cb) |
Register a callback to receive keyboard events. | |
void | RemoveCallback (Callback *cb) |
Remove a callback to receive keyboard events. | |
bool | IsActive () const |
Static Public Member Functions | |
static bool | IsKeyDown (const Key key=Any) |
Checks if a key on the keyboard in being pressed. | |
static Key | GetCurrentKey () |
Gets the current key being pressed. | |
static KeyList | GetPressedKeys () |
static bool | FakeKeyPress (const Key key, const bool releaseFlag=true, const bool directX=false) |
Method used to generate a fake keyboard event. | |
static bool | FakeKeyRelease (const Key key, const bool directX=false) |
Method used to generate a fake keyboard event. | |
static unsigned int | LookupHostSystemKey (const Key key) |
Method used to convert from generic key enumeration to OS specific value. | |
static Key | LookupFromHostSystemKey (const unsigned int hostKey) |
Method used to convert from the host system key value to a CxUtils Keyboard::Key enumeration value. | |
static std::string | ToString (const Key key) |
Method used to lookup a string version of a key. | |
static Key | FromString (const std::string &strKey) |
Method used to convert a string to a key value. | |
Static Public Attributes | |
static const unsigned int | MaxKeys = 256 |
Current max supported keys. |
Static methods for determining if a key is currently being pressed and to generate keyboard/key events.
Dependencies for Linux: libx11, libxtst
Definition at line 60 of file keyboard.h.
typedef std::vector<Key> CxUtils::Keyboard::KeyList |
Definition at line 173 of file keyboard.h.
Enumeration of different keys available.
Definition at line 70 of file keyboard.h.
Keyboard::Keyboard | ( | ) |
Constructor.
Definition at line 128 of file keyboard.cpp.
Keyboard::~Keyboard | ( | ) |
Destructor.
Definition at line 139 of file keyboard.cpp.
bool Keyboard::FakeKeyPress | ( | const Key | key, |
const bool | releaseFlag = true , |
||
const bool | directX = false |
||
) | [static] |
Method used to generate a fake keyboard event.
[in] | key | The key to generate a fake keyboard event for. |
[in] | releaseFlag | If true, the method will also generate a key up command after the key down event. |
[in] | directX | Flag only used in Windows. If you are tryign to fake a key press for a DirectX application (video games) then you must set this to true because direct X uses hardware scan codes, which other applications do not. |
Definition at line 443 of file keyboard.cpp.
bool Keyboard::FakeKeyRelease | ( | const Key | key, |
const bool | directX = false |
||
) | [static] |
Method used to generate a fake keyboard event.
[in] | key | The key to generate a fake keyboard event for. |
[in] | directX | Flag only used in Windows. If you are tryign to fake a key press for a DirectX application (video games) then you must set this to true because direct X uses hardware scan codes, which other applications do not. |
Definition at line 513 of file keyboard.cpp.
Keyboard::Key Keyboard::FromString | ( | const std::string & | strKey ) | [static] |
Method used to convert a string to a key value.
[in] | strKey | String verion of key to convert to enumeration. |
Definition at line 2016 of file keyboard.cpp.
Keyboard::Key Keyboard::GetCurrentKey | ( | ) | [static] |
Gets the current key being pressed.
Definition at line 360 of file keyboard.cpp.
Keyboard::KeyList Keyboard::GetPressedKeys | ( | ) | [static] |
Definition at line 414 of file keyboard.cpp.
bool CxUtils::Keyboard::IsActive | ( | ) | const [inline] |
Definition at line 205 of file keyboard.h.
bool Keyboard::IsKeyDown | ( | const Key | key = Any ) |
[static] |
Checks if a key on the keyboard in being pressed.
[in] | key | The key to check for being pressed. If the value is Any, default, then the method will check for any key that is pressed. The console or program does not have to be active (this is a passive method). |
Definition at line 266 of file keyboard.cpp.
Keyboard::Key Keyboard::LookupFromHostSystemKey | ( | const unsigned int | hostKey ) | [static] |
Method used to convert from the host system key value to a CxUtils Keyboard::Key enumeration value.
[in] | hostKey | the host system key to convert from. |
Definition at line 1187 of file keyboard.cpp.
unsigned int Keyboard::LookupHostSystemKey | ( | const Key | key ) | [static] |
Method used to convert from generic key enumeration to OS specific value.
[in] | key | The key to perform lookup for. |
Definition at line 567 of file keyboard.cpp.
bool Keyboard::RegisterCallback | ( | Callback * | cb ) |
Register a callback to receive keyboard events.
[in] | cb | Pointer to callback object to run when keys are pressed or released. |
Definition at line 156 of file keyboard.cpp.
void Keyboard::RemoveCallback | ( | Callback * | cb ) |
Remove a callback to receive keyboard events.
[in] | cb | Pointer to callback object to remove. |
Definition at line 181 of file keyboard.cpp.
std::string Keyboard::ToString | ( | const Key | key ) | [static] |
Method used to lookup a string version of a key.
[in] | key | The key to get string equivalent for. |
Definition at line 1699 of file keyboard.cpp.
const unsigned int CxUtils::Keyboard::MaxKeys = 256 [static] |
Current max supported keys.
Definition at line 63 of file keyboard.h.