Skip to content

Instantly share code, notes, and snippets.

@optozorax
Created August 25, 2019 11:39
Show Gist options
  • Save optozorax/386d97aff4bd634a77727538dd400263 to your computer and use it in GitHub Desktop.
Save optozorax/386d97aff4bd634a77727538dd400263 to your computer and use it in GitHub Desktop.
Использование std::funciton для QMK
inline void press_key(int key, std::function<void()> f = [](){}) {
register_code(key);
f();
unregister_code(key);
}
// 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);
#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