Skip to content

Instantly share code, notes, and snippets.

@bpizzi
Created December 16, 2021 12:09
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 bpizzi/fc616842afdbe44714259f89bef27076 to your computer and use it in GitHub Desktop.
Save bpizzi/fc616842afdbe44714259f89bef27076 to your computer and use it in GitHub Desktop.
/* Copyright 2015-2021 Jack Humbert
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied wao the config.o the config.rranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include QMK_KEYBOARD_H
#include "keymap_french.h"
#include "muse.h"
enum planck_layers {
_QWERTY,
_LOWER,
_RAISE,
_ADJUST,
_SPECIAL,
_FKEYS,
_TMUX
};
o the config.
enum planck_keycodes {
AZERTY = SAFE_RANGE,
BACKLIT,
TMX_ALT,
TMX_LFT,
TMX_DWN,
TMX_UP,
TMX_RGT
};
#define LOWER MO(_LOWER)
#define RAISE MO(_RAISE)
#define SPECIAL MO(_SPECIAL)
#define FKEYS MO(_FKEYS)
void keyboard_post_init_user(void) {
debug_enable=true;
debug_matrix=true;
//debug_keyboard=true;
//debug_mouse=true;
}
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QWERTY] = LAYOUT_planck_grid(
KC_ESC, FR_A, FR_Z, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, FR_M, FKEYS,
KC_LSFT, C_S_T(KC_Z), KC_X, KC_C, KC_V, KC_B, KC_N, FR_COMM, FR_SCLN, FR_COLN, FR_EXLM, KC_RSFT,
SPECIAL, KC_LGUI, KC_LALT, KC_LCTRL,LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
),
[_LOWER] = LAYOUT_planck_grid(
FR_1, FR_2, FR_3, KC_PGUP, KC_HOME, _______, FR_LCBR, FR_RCBR, _______, _______, FR_DQUO, FR_QUOT,
FR_4, FR_5, FR_6, KC_PGDN, KC_END, _______, FR_LPRN, FR_RPRN, _______, _______, FR_MINS, FR_UNDS,
FR_7, FR_8, FR_9, _______, _______, _______, FR_LBRC, FR_RBRC, _______, _______, _______, FR_BSLS,
_______, FR_0, _______, KC_TRNS, _______, FR_AMPR, FR_AMPR, _______, _______, _______, _______, _______
),
[_RAISE] = LAYOUT_planck_grid(
KC_TAB, FR_AGRV, FR_EACU, FR_DIAE, _______, FR_PERC, FR_PLUS, FR_UGRV, _______, _______, _______, _______,
_______, FR_AT, FR_EGRV, FR_GRV, _______, FR_DLR, FR_HASH, _______, _______, _______, _______, _______,
_______, _______, FR_CCED, FR_CIRC, _______, FR_TILD, FR_EQL, _______, _______, _______, _______, _______,
_______, _______, _______, _______, KC_TRNS, FR_PIPE, FR_PIPE, KC_TRNS, _______, _______, _______, _______
),o the config.
[_SPECIAL] = LAYOUT_planck_grid(
KC_ACL0, KC_ACL1, KC_ACL2, KC_MS_U, _______, _______, _______, _______, _______, _______, _______, LSG(KC_ENT),
_______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, KC_BTN1, KC_BTN3, KC_BTN2, _______, _______,
_______, _______, _______, _______, _______, OSL(_TMUX), _______, _______, _______, _______, _______, _______,
KC_TRNS, _______, _______, _______, FR_LABK, KC_ENT, KC_ENT, FR_RABK, _______, _______, _______, _______
),
[_FKEYS] = LAYOUT_planck_grid(
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_TRNS,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),
[_TMUX] = LAYOUT_planck_grid(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, TMX_LFT, TMX_DWN, TMX_UP, TMX_RGT, _______, _______,
_______, _______, _______, LCTL(KC_C), LCTL(KC_V), LCTL(KC_B), _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),
[_ADJUST] = LAYOUT_planck_grid(
_______, RESET, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______,
_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, AZERTY, _______, _______, _______, _______,
_______, MUV_DE, MUV_IN, _______, _______, MI_ON, MI_OFF, TERM_ON, TERM_OFF, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, MU_MOD, MU_OFF, MU_ON
),
};
#ifdef AUDIO_ENABLE
float plover_song[][2] = SONG(PLOVER_SOUND);
float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
#endif
layer_state_t layer_state_set_user(layer_state_t state) {
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case AZERTY:
if (record->event.pressed) {
print("mode just switched to azerty and this is a huge string\n");
set_single_persistent_default_layer(_QWERTY);
}
return false;
break;
case TMX_ALT:
SEND_STRING(SS_LCTL("b"));
return false;
break;
case TMX_LFT:
SEND_STRING(SS_LCTL("b") SS_TAP(X_LEFT));
return false;
break;
case TMX_UP:
SEND_STRING(SS_LCTL("b") SS_TAP(X_UP));
return false;
break;
case TMX_DWN:
SEND_STRING(SS_LCTL("b") SS_TAP(X_DOWN));
return false;
break;
case TMX_RGT:
SEND_STRING(SS_LCTL("b") SS_TAP(X_RIGHT));
return false;
break;
case BACKLIT:
if (record->event.pressed) {
register_code(KC_RSFT);
#ifdef BACKLIGHT_ENABLE
backlight_step();
#endif
#ifdef KEYBOARD_planck_rev5
writePinLow(E6);
#endif
} else {
unregister_code(KC_RSFT);
#ifdef KEYBOARD_planck_rev5
writePinHigh(E6);
#endif
}
return false;
break;
}
return true;
}
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;
bool encoder_update_user(uint8_t index, bool clockwise) {
if (muse_mode) {
if (IS_LAYER_ON(_RAISE)) {
if (clockwise) {o the config.
muse_offset++;
} else {
muse_offset--;
}
} else {
if (clockwise) {
muse_tempo+=1;
} else {
muse_tempo-=1;
}
}
} else {
if (clockwise) {
#ifdef MOUSEKEY_ENABLE
tap_code(KC_MS_WH_DOWN);
#else
tap_code(KC_PGDN);
#endif
} else {
#ifdef MOUSEKEY_ENABLE
tap_code(KC_MS_WH_UP);
#else
tap_code(KC_PGUP);
#endif
}
}
return true;
}
bool dip_switch_update_user(uint8_t index, bool active) {
switch (index) {
case 0: {
#ifdef AUDIO_ENABLE
static bool play_sound = false;
#endif
if (active) {
#ifdef AUDIO_ENABLE
if (play_sound) { PLAY_SONG(plover_song); }
#endif
layer_on(_ADJUST);
} else {
#ifdef AUDIO_ENABLE
if (play_sound) { PLAY_SONG(plover_gb_song); }
#endif
layer_off(_ADJUST);
}
#ifdef AUDIO_ENABLE
play_sound = true;
#endif
break;
}
case 1:
if (active) {
muse_mode = true;
} else {
muse_mode = false;
}
}
return true;
}
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
}
bool music_mask_user(uint16_t keycode) {
switch (keycode) {
case RAISE:
case LOWER:
case SPECIAL:
return false;
default:
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment