chore: KeyState, use auto where possible
This commit is contained in:
@ -756,7 +756,7 @@ void KeyState::updateKeyState()
|
||||
// get the current keyboard state
|
||||
KeyButtonSet keysDown;
|
||||
pollPressedKeys(keysDown);
|
||||
for (KeyButtonSet::const_iterator i = keysDown.begin(); i != keysDown.end(); ++i) {
|
||||
for (auto i = keysDown.begin(); i != keysDown.end(); ++i) {
|
||||
m_keys[*i] = 1;
|
||||
}
|
||||
|
||||
@ -772,7 +772,7 @@ void KeyState::updateKeyState()
|
||||
|
||||
void KeyState::addActiveModifierCB(KeyID, int32_t group, deskflow::KeyMap::KeyItem &keyItem, void *vcontext)
|
||||
{
|
||||
AddActiveModifierContext *context = static_cast<AddActiveModifierContext *>(vcontext);
|
||||
auto *context = static_cast<AddActiveModifierContext *>(vcontext);
|
||||
if (group == context->m_activeGroup && (keyItem.m_generates & context->m_mask) != 0) {
|
||||
context->m_activeModifiers.insert(std::make_pair(keyItem.m_generates, keyItem));
|
||||
}
|
||||
@ -825,7 +825,7 @@ void KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID, c
|
||||
return;
|
||||
}
|
||||
|
||||
KeyButton localID = (KeyButton)(keyItem->m_button & kButtonMask);
|
||||
auto localID = (KeyButton)(keyItem->m_button & kButtonMask);
|
||||
updateModifierKeyState(localID, oldActiveModifiers, m_activeModifiers);
|
||||
if (localID != 0) {
|
||||
// note keys down
|
||||
@ -858,7 +858,7 @@ bool KeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, int32_t count, KeyB
|
||||
if (keyItem == nullptr) {
|
||||
return false;
|
||||
}
|
||||
KeyButton localID = (KeyButton)(keyItem->m_button & kButtonMask);
|
||||
auto localID = (KeyButton)(keyItem->m_button & kButtonMask);
|
||||
if (localID == 0) {
|
||||
return false;
|
||||
}
|
||||
@ -872,7 +872,7 @@ bool KeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, int32_t count, KeyB
|
||||
if (localID != oldLocalID) {
|
||||
// replace key up with previous KeyButton but leave key down
|
||||
// alone so it uses the new KeyButton.
|
||||
for (Keystrokes::iterator index = keys.begin(); index != keys.end(); ++index) {
|
||||
for (auto index = keys.begin(); index != keys.end(); ++index) {
|
||||
if (index->m_type == Keystroke::kButton && index->m_data.m_button.m_button == localID) {
|
||||
index->m_data.m_button.m_button = oldLocalID;
|
||||
break;
|
||||
@ -914,7 +914,7 @@ bool KeyState::fakeKeyUp(KeyButton serverID)
|
||||
m_serverKeys[serverID] = 0;
|
||||
|
||||
// check if this is a modifier
|
||||
ModifierToKeys::iterator i = m_activeModifiers.begin();
|
||||
auto i = m_activeModifiers.begin();
|
||||
while (i != m_activeModifiers.end()) {
|
||||
if (i->second.m_button == localID && !i->second.m_lock) {
|
||||
// modifier is no longer down
|
||||
@ -1065,7 +1065,7 @@ void KeyState::fakeKeys(const Keystrokes &keys, uint32_t count)
|
||||
|
||||
// generate key events
|
||||
LOG((CLOG_DEBUG1 "keystrokes:"));
|
||||
for (Keystrokes::const_iterator k = keys.begin(); k != keys.end();) {
|
||||
for (auto k = keys.begin(); k != keys.end();) {
|
||||
if (k->m_type == Keystroke::kButton && k->m_data.m_button.m_repeat) {
|
||||
// repeat from here up to but not including the next key
|
||||
// with m_repeat == false count times.
|
||||
@ -1098,10 +1098,10 @@ void KeyState::updateModifierKeyState(
|
||||
{
|
||||
// get the pressed modifier buttons before and after
|
||||
deskflow::KeyMap::ButtonToKeyMap oldKeys, newKeys;
|
||||
for (ModifierToKeys::const_iterator i = oldModifiers.begin(); i != oldModifiers.end(); ++i) {
|
||||
for (auto i = oldModifiers.begin(); i != oldModifiers.end(); ++i) {
|
||||
oldKeys.insert(std::make_pair(i->second.m_button, &i->second));
|
||||
}
|
||||
for (ModifierToKeys::const_iterator i = newModifiers.begin(); i != newModifiers.end(); ++i) {
|
||||
for (auto i = newModifiers.begin(); i != newModifiers.end(); ++i) {
|
||||
newKeys.insert(std::make_pair(i->second.m_button, &i->second));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user