Skip to content

Instantly share code, notes, and snippets.

@burakcan
Created September 11, 2019 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burakcan/6b5bee724824bf778f3a2698543e4abf to your computer and use it in GitHub Desktop.
Save burakcan/6b5bee724824bf778f3a2698543e4abf to your computer and use it in GitHub Desktop.
enum custom_keycodes {
LAUGH = SAFE_RANGE
};
static uint16_t random_value = 157;
const uint16_t random_chars[9] = {
KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch(keycode) {
case LAUGH:
if (record->event.pressed) {
uint8_t clockbyte=0;
clockbyte = TCNT1 % 256;
uint8_t rval;
random_value = ((random_value + randadd) * randmul) % randmod;
uint8_t len = ((random_value ^ clockbyte) % 4) + 4;
for (uint8_t i = 0; i <= len; i++) {
random_value = ((random_value + randadd) * randmul) % randmod;
rval = (random_value ^ clockbyte) % 9;
register_code(random_chars[rval]);
unregister_code(random_chars[rval]);
}
}
return false;
}
return true;
}
@Ardakilic
Copy link

#define randadd 53
#define randmul 181
#define randmod 167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment