Merge pull request #988 from gedankenexperimenter/b/core.key-utils-const-correct

Make key variant test methods const-correct
pull/989/head
Jesse Vincent 4 years ago committed by GitHub
commit 34bb24a7f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -172,17 +172,17 @@ class Key {
// //
// The following functions return `true` if the `key` parameter is of the // The following functions return `true` if the `key` parameter is of the
// corresponding HID type (Keyboard, Consumer Control, or System Control). // corresponding HID type (Keyboard, Consumer Control, or System Control).
constexpr bool isKeyboardKey() { constexpr bool isKeyboardKey() const {
return ((flags_ & (RESERVED | SYNTHETIC)) == 0); return ((flags_ & (RESERVED | SYNTHETIC)) == 0);
} }
constexpr bool isSystemControlKey() { constexpr bool isSystemControlKey() const {
return ((flags_ & system_control_mask_) == (SYNTHETIC | IS_SYSCTL)); return ((flags_ & system_control_mask_) == (SYNTHETIC | IS_SYSCTL));
} }
constexpr bool isConsumerControlKey() { constexpr bool isConsumerControlKey() const {
return ((flags_ & consumer_control_mask_) == (SYNTHETIC | IS_CONSUMER)); return ((flags_ & consumer_control_mask_) == (SYNTHETIC | IS_CONSUMER));
} }
// Not a HID type, but also a builtin `Key` variant. // Not a HID type, but also a builtin `Key` variant.
constexpr bool isLayerKey() { constexpr bool isLayerKey() const {
return (flags_ == (SYNTHETIC | SWITCH_TO_KEYMAP)); return (flags_ == (SYNTHETIC | SWITCH_TO_KEYMAP));
} }
@ -194,7 +194,7 @@ class Key {
// modifier keys like `LSHIFT(Key_RightAlt)` and `Key_Meh`. It will not match // modifier keys like `LSHIFT(Key_RightAlt)` and `Key_Meh`. It will not match
// a key with only modifier flags (e.g. `LCTRL(RALT(Key_NoKey))`); this is an // a key with only modifier flags (e.g. `LCTRL(RALT(Key_NoKey))`); this is an
// intentional feature so that plugins can distinguish between the two. // intentional feature so that plugins can distinguish between the two.
constexpr bool isKeyboardModifier() { constexpr bool isKeyboardModifier() const {
return (isKeyboardKey() && return (isKeyboardKey() &&
(keyCode_ >= HID_KEYBOARD_FIRST_MODIFIER && (keyCode_ >= HID_KEYBOARD_FIRST_MODIFIER &&
keyCode_ <= HID_KEYBOARD_LAST_MODIFIER)); keyCode_ <= HID_KEYBOARD_LAST_MODIFIER));
@ -210,7 +210,7 @@ class Key {
// (and several plugins single them out for this reason), because they are // (and several plugins single them out for this reason), because they are
// used in a conceptually different way: to get a different symbol in the // used in a conceptually different way: to get a different symbol in the
// output. We don't normally think "type `shift`+`1`"; we think "type `!`". // output. We don't normally think "type `shift`+`1`"; we think "type `!`".
constexpr bool isKeyboardShift() { constexpr bool isKeyboardShift() const {
return (isKeyboardModifier() && return (isKeyboardModifier() &&
((keyCode_ == HID_KEYBOARD_LEFT_SHIFT || ((keyCode_ == HID_KEYBOARD_LEFT_SHIFT ||
keyCode_ == HID_KEYBOARD_RIGHT_SHIFT) || keyCode_ == HID_KEYBOARD_RIGHT_SHIFT) ||
@ -220,7 +220,7 @@ class Key {
// they are used chorded to change the result of typing those other // they are used chorded to change the result of typing those other
// keys. They're even more similar to `shift` keys. For both reasons, it's // keys. They're even more similar to `shift` keys. For both reasons, it's
// worth singling them out. // worth singling them out.
constexpr bool isLayerShift() { constexpr bool isLayerShift() const {
return (isLayerKey() && return (isLayerKey() &&
(keyCode_ >= LAYER_SHIFT_OFFSET)); (keyCode_ >= LAYER_SHIFT_OFFSET));
} }

Loading…
Cancel
Save