Add methods to check for KeyActions and KeyModifiers

This commit is contained in:
Alexander Bock
2016-06-27 01:12:00 +02:00
parent 2550346835
commit 41ef7c1b55
2 changed files with 17 additions and 0 deletions

View File

@@ -68,6 +68,8 @@ enum class KeyAction : int {
Repeat = 2
};
bool hasKeyAction(KeyAction lhs, KeyAction rhs);
KeyAction operator|(KeyAction lhs, KeyAction rhs);
KeyAction operator|=(KeyAction& lhs, KeyAction rhs);
@@ -79,6 +81,8 @@ enum class KeyModifier : int {
Super = 0x0008
};
bool hasKeyModifier(KeyModifier lhs, KeyModifier rhs);
KeyModifier operator|(KeyModifier lhs, KeyModifier rhs);
KeyModifier operator|=(KeyModifier& lhs, KeyModifier rhs);

View File

@@ -36,6 +36,12 @@ namespace {
namespace openspace {
bool hasKeyModifier(KeyAction lhs, KeyAction rhs) {
return
static_cast<std::underlying_type_t<KeyAction>>(lhs) &
static_cast<std::underlying_type_t<KeyAction>>(rhs);
}
KeyAction operator|(KeyAction lhs, KeyAction rhs) {
return static_cast<KeyAction>(
static_cast<std::underlying_type_t<KeyAction>>(lhs) |
@@ -48,6 +54,13 @@ KeyAction operator|=(KeyAction& lhs, KeyAction rhs) {
return lhs;
}
bool hasKeyModifier(KeyModifier lhs, KeyModifier rhs) {
return
static_cast<std::underlying_type_t<KeyModifier>>(lhs) &
static_cast<std::underlying_type_t<KeyModifier>>(rhs);
}
KeyModifier operator|(KeyModifier lhs, KeyModifier rhs) {
return static_cast<KeyModifier>(
static_cast<std::underlying_type_t<KeyModifier>>(lhs) |