/* Copyright 2016-2017 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 warranty 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 "quantum.h"
#if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE)
#include "rgb.h"
#endif
#ifdef PROTOCOL_LUFA
#include "outputselect.h"
#endif
#ifndef BREATHING_PERIOD
#define BREATHING_PERIOD 6
#endif
#include "backlight.h"
extern backlight_config_t backlight_config;
#ifdef FAUXCLICKY_ENABLE
#include "fauxclicky.h"
#endif
#ifdef API_ENABLE
#include "api.h"
#endif
#ifdef MIDI_ENABLE
#include "process_midi.h"
#endif
#ifdef VELOCIKEY_ENABLE
#include "velocikey.h"
#endif
#ifdef HAPTIC_ENABLE
#include "haptic.h"
#endif
#ifdef ENCODER_ENABLE
#include "encoder.h"
#endif
#ifdef AUDIO_ENABLE
#ifndef GOODBYE_SONG
#define GOODBYE_SONG SONG(GOODBYE_SOUND)
#endif
#ifndef AG_NORM_SONG
#define AG_NORM_SONG SONG(AG_NORM_SOUND)
#endif
#ifndef AG_SWAP_SONG
#define AG_SWAP_SONG SONG(AG_SWAP_SOUND)
#endif
float goodbye_song[][2] = GOODBYE_SONG;
float ag_norm_song[][2] = AG_NORM_SONG;
float ag_swap_song[][2] = AG_SWAP_SONG;
#ifdef DEFAULT_LAYER_SONGS
float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
#endif
#endif
static void do_code16 (uint16_t code, void (*f) (uint8_t)) {
switch (code) {
case QK_MODS ... QK_MODS_MAX:
break;
default:
return;
}
if (code & QK_LCTL)
f(KC_LCTL);
if (code & QK_LSFT)
f(KC_LSFT);
if (code & QK_LALT)
f(KC_LALT);
if (code & QK_LGUI)
f(KC_LGUI);
if (code < QK_RMODS_MIN) return;
if (code & QK_RCTL)
f(KC_RCTL);
if (code & QK_RSFT)
f(KC_RSFT);
if (code & QK_RALT)
f(KC_RALT);
if (code & QK_RGUI)
f(KC_RGUI);
}
static inline void qk_register_weak_mods(uint8_t kc) {
add_weak_mods(MOD_BIT(kc));
send_keyboard_report();
}
static inline void qk_unregister_weak_mods(uint8_t kc) {
del_weak_mods(MOD_BIT(kc));
send_keyboard_report();
}
static inline void qk_register_mods(uint8_t kc) {
add_weak_mods(MOD_BIT(kc));
send_keyboard_report();
}
static inline void qk_unregister_mods(uint8_t kc) {
del_weak_mods(MOD_BIT(kc));
send_keyboard_report();
}
void register_code16 (uint16_t code) {
if (IS_MOD(code) || code == KC_NO) {
do_code16 (code, qk_register_mods);
} else {
do_code16 (code, qk_register_weak_mods);
}
register_code (code);
}
void unregister_code16 (uint16_t code) {
unregister_code (code);
if (IS_MOD(code) || code == KC_NO) {
do_code16 (code, qk_unregister_mods);
} else {
do_code16 (code, qk_unregister_weak_mods);
}
}
void tap_code16(uint16_t code) {
register_code16(code);
#if TAP_CODE_DELAY > 0
wait_ms(TAP_CODE_DELAY);
#endif
unregister_code16(code);
}
__attribute__ ((weak))
bool process_action_kb(keyrecord_t *record) {
return true;
}
__attribute__ ((weak))
b
|