1
0
Fork 0

Keyboard: Fixes for superseded audio and default layer functionality (#4557)

This commit is contained in:
zvecr 2018-12-05 21:12:07 +00:00 committed by Drashna Jaelre
parent ff3369ac5d
commit 161afe2e54
3 changed files with 15 additions and 71 deletions

View file

@ -18,20 +18,19 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CONFIG_USER_H #pragma once
#define CONFIG_USER_H
#include "../../config.h" // place overrides here
#define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \
SONG(COLEMAK_SOUND), \
SONG(DVORAK_SOUND) \
}
/* Use I2C or Serial, not both */ /* Use I2C or Serial, not both */
#define USE_SERIAL #define USE_SERIAL
// #define USE_I2C // #define USE_I2C
/* Select hand configuration */ /* Select hand configuration */
#define MASTER_LEFT #define MASTER_LEFT
// #define MASTER_RIGHT // #define MASTER_RIGHT
// #define EE_HANDS // #define EE_HANDS
#endif

View file

@ -1,7 +1,5 @@
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
extern keymap_config_t keymap_config;
// Each layer gets a name for readability, which is then used in the keymap matrix below. // Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them // Layer names don't all need to be of the same length, obviously, and you can also skip them
@ -16,15 +14,12 @@ extern keymap_config_t keymap_config;
enum custom_keycodes { enum custom_keycodes {
QWERTY = SAFE_RANGE, QWERTY = SAFE_RANGE,
COLEMAK, COLEMAK,
DVORAK, DVORAK
LOWER,
RAISE,
ADJUST,
}; };
// Fillers to make layering more clear #define LOWER MO(_LOWER)
#define _______ KC_TRNS #define RAISE MO(_RAISE)
#define XXXXXXX KC_NO #define ADJUST MO(_ADJUST)
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Qwerty /* Qwerty
@ -138,74 +133,27 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}; };
#ifdef AUDIO_ENABLE uint32_t layer_state_set_user(uint32_t state) {
float tone_qwerty[][2] = SONG(QWERTY_SOUND); return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
float tone_dvorak[][2] = SONG(DVORAK_SOUND);
float tone_colemak[][2] = SONG(COLEMAK_SOUND);
#endif
void persistent_default_layer_set(uint16_t default_layer) {
eeconfig_update_default_layer(default_layer);
default_layer_set(default_layer);
} }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) { switch (keycode) {
case QWERTY: case QWERTY:
if (record->event.pressed) { if (record->event.pressed) {
#ifdef AUDIO_ENABLE set_single_persistent_default_layer(_QWERTY);
PLAY_SONG(tone_qwerty);
#endif
persistent_default_layer_set(1UL<<_QWERTY);
} }
return false; return false;
break;
case COLEMAK: case COLEMAK:
if (record->event.pressed) { if (record->event.pressed) {
#ifdef AUDIO_ENABLE set_single_persistent_default_layer(_COLEMAK);
PLAY_SONG(tone_colemak);
#endif
persistent_default_layer_set(1UL<<_COLEMAK);
} }
return false; return false;
break;
case DVORAK: case DVORAK:
if (record->event.pressed) { if (record->event.pressed) {
#ifdef AUDIO_ENABLE set_single_persistent_default_layer(_DVORAK);
PLAY_SONG(tone_dvorak);
#endif
persistent_default_layer_set(1UL<<_DVORAK);
} }
return false; return false;
break;
case LOWER:
if (record->event.pressed) {
layer_on(_LOWER);
update_tri_layer(_LOWER, _RAISE, _ADJUST);
} else {
layer_off(_LOWER);
update_tri_layer(_LOWER, _RAISE, _ADJUST);
}
return false;
break;
case RAISE:
if (record->event.pressed) {
layer_on(_RAISE);
update_tri_layer(_LOWER, _RAISE, _ADJUST);
} else {
layer_off(_RAISE);
update_tri_layer(_LOWER, _RAISE, _ADJUST);
}
return false;
break;
case ADJUST:
if (record->event.pressed) {
layer_on(_ADJUST);
} else {
layer_off(_ADJUST);
}
return false;
break;
} }
return true; return true;
} }

View file

@ -1,3 +0,0 @@
ifndef QUANTUM_DIR
include ../../../../Makefile
endif