Created
August 25, 2019 11:39
-
-
Save optozorax/386d97aff4bd634a77727538dd400263 to your computer and use it in GitHub Desktop.
Использование std::funciton для QMK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline void press_key(int key, std::function<void()> f = [](){}) { | |
register_code(key); | |
f(); | |
unregister_code(key); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage 1 | |
register_code(KC_SLSH); | |
unregister_code(KC_SLSH); | |
// Usage 2 | |
register_code(KC_LCTL); | |
register_code(KC_C); | |
unregister_code(KC_C); | |
unregister_code(KC_LCTL); | |
// Usage 3 | |
register_code(KC_LCTL); | |
register_code(KC_LALT); | |
register_code(KC_LSHIFT); | |
register_code(KC_A); | |
unregister_code(KC_A); | |
register_code(KC_B); | |
unregister_code(KC_B); | |
unregister_code(KC_LSHIFT); | |
unregister_code(KC_LALT); | |
unregister_code(KC_LCTL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "common.h" | |
// Usage 1 | |
press_key(KC_SLSH); | |
// Usage 2 | |
press_key(KC_LCTL, [](){ | |
press_key(KC_C); | |
}); | |
// Usage 3 | |
press_key(KC_LCTL, [](){ | |
press_key(KC_LALT, [](){ | |
press_key(KC_LSHIFT, [](){ | |
press_key(KC_A); | |
press_key(KC_B); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment