qmk-firmware/users/alfrdmalr/alfrdmalr.c
Alfred Maler ed6586e25b
[Keymap] Feature/alfrdmalr/keymap update ()
* WIP do not merge

* first pass at custom preonic layout

* add auto shift and reset via leader key

* Update readme

* update copyright notice

* formatting changes

* fix: use MO instead of process_record_user

* added backslash and moved grave position

* remove extraneous 'j' characer in NUMPAD template

* update template formatting

* remove process_record_user

* swap "!" with "@"

* fix readme formatting

* update readme layout image

* restore settings layer

* add windows minimize sequence

* fix: switch to correct seq function for three-key sequence

* fix: missing semicolon

* refactor: move keymap to userspace and generic 5x12 layout

* add numlock to numpad layer

* add readme

* update readme formatting

* remove unused wrappers from layout keymap

* update readme title to reflect new location

* remove alfrdmalr directory from preonic/keymaps

* add ortho 4x12 support

* add 'trilayer' settings and update keymap

* update SYMBOLS layer to SYMBOL

* remove minimize sequence

* clean up user config

* add brightness controls

* update settings ascii

* moved some symbols around to make vim/linux smoother
2020-03-03 10:13:42 -08:00

95 lines
2.2 KiB
C

#include "alfrdmalr.h"
#include "muse.h"
bool muse_mode = false;
uint8_t last_muse_note = 0;
uint16_t muse_counter = 0;
uint8_t muse_offset = 70;
uint16_t muse_tempo = 50;
LEADER_EXTERNS();
void matrix_scan_user(void) {
#ifdef AUDIO_ENABLE
if (muse_mode) {
if (muse_counter == 0) {
uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
if (muse_note != last_muse_note) {
stop_note(compute_freq_for_midi_note(last_muse_note));
play_note(compute_freq_for_midi_note(muse_note), 0xF);
last_muse_note = muse_note;
}
}
muse_counter = (muse_counter + 1) % muse_tempo;
} else {
if (muse_counter) {
stop_all_notes();
muse_counter = 0;
}
}
#endif
LEADER_DICTIONARY() {
leading = false;
// reset keyboard to bootloader
SEQ_FIVE_KEYS(KC_R, KC_E, KC_S, KC_E, KC_T) {
reset_keyboard();
}
leader_end();
}
}
bool syml_pressed = false;
bool symr_pressed = false;
bool settings_active = false;
bool symbols_active = false;
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch(keycode) {
case SYML:
if (record->event.pressed) {
syml_pressed = true;
} else {
syml_pressed = false;
}
break;
case SYMR:
if (record->event.pressed) {
symr_pressed = true;
} else {
symr_pressed = false;
}
break;
}
// trilayer-esque behavior. If both SYMBOL layer keys are held, then the
// settings layer is open. If only one is held, SYMBOL is active.
if (syml_pressed && symr_pressed) {
layer_on(_SETTINGS);
settings_active = true;
} else if (syml_pressed || symr_pressed) {
if (settings_active) {
layer_off(_SETTINGS);
settings_active = false;
}
layer_on(_SYMBOL);
symbols_active = true;
} else {
if (symbols_active) {
layer_off(_SYMBOL);
symbols_active = false;
}
}
return true;
}
// allow access to the settings layer to turn music mode back off
bool music_mask_user(uint16_t keycode) {
switch (keycode) {
case SYML:
case SYMR:
return false;
default:
return true;
}
}