introduces new format [broken] [skip ci]

process_keycode_update
Jack Humbert 8 years ago
parent 6b2a3492b7
commit 98ac10fd74

@ -1,90 +1,90 @@
/* /*
Copyright 2012 Jun Wako <wakojun@gmail.com> Copyright 2012 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License 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_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H
#include "config_common.h" #include "config_common.h"
/* USB Device descriptor parameter */ /* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED #define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x3060 #define PRODUCT_ID 0x3060
#define DEVICE_VER 0x0001 #define DEVICE_VER 0x0001
#define MANUFACTURER xyxjj #define MANUFACTURER xyxjj
#define PRODUCT DeltaSplit75 #define PRODUCT DeltaSplit75
#define DESCRIPTION 75% split keyboard #define DESCRIPTION 75% split keyboard
/* key matrix size */ /* key matrix size */
// Rows are doubled-up // Rows are doubled-up
#define MATRIX_ROWS 14 #define MATRIX_ROWS 14
#define MATRIX_COLS 8 #define MATRIX_COLS 8
// wiring of each half // wiring of each half
#define MATRIX_ROW_PINS { F4, F5, F6, F7, B1, B3, B2 } #define MATRIX_ROW_PINS { F4, F5, F6, F7, B1, B3, B2 }
#define MATRIX_COL_PINS { B6, B5, B4, E6, D7, C6, D4, D1} #define MATRIX_COL_PINS { B6, B5, B4, E6, D7, C6, D4, D1}
#define CATERINA_BOOTLOADER #define CATERINA_BOOTLOADER
/* COL2ROW or ROW2COL */ /* COL2ROW or ROW2COL */
#define DIODE_DIRECTION COL2ROW #define DIODE_DIRECTION COL2ROW
/* define if matrix has ghost */ /* define if matrix has ghost */
//#define MATRIX_HAS_GHOST //#define MATRIX_HAS_GHOST
/* number of backlight levels */ /* number of backlight levels */
// #define BACKLIGHT_LEVELS 3 // #define BACKLIGHT_LEVELS 3
/* Set 0 if debouncing isn't needed */ /* Set 0 if debouncing isn't needed */
#define DEBOUNCING_DELAY 5 #define DEBOUNCING_DELAY 5
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE #define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */ /* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE #define LOCKING_RESYNC_ENABLE
/* key combination for command */ /* key combination for command */
#define IS_COMMAND() ( \ #define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
) )
/* ws2812 RGB LED */ /* ws2812 RGB LED */
#define RGB_DI_PIN D3 #define RGB_DI_PIN D3
#define RGBLIGHT_TIMER #define RGBLIGHT_TIMER
#define RGBLED_NUM 12 // Number of LEDs #define RGBLED_NUM 12 // Number of LEDs
#define ws2812_PORTREG PORTD #define ws2812_PORTREG PORTD
#define ws2812_DDRREG DDRD #define ws2812_DDRREG DDRD
/* /*
* Feature disable options * Feature disable options
* These options are also useful to firmware size reduction. * These options are also useful to firmware size reduction.
*/ */
/* disable debug print */ /* disable debug print */
// #define NO_DEBUG // #define NO_DEBUG
/* disable print */ /* disable print */
// #define NO_PRINT // #define NO_PRINT
/* disable action features */ /* disable action features */
//#define NO_ACTION_LAYER //#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING //#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT //#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO //#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION //#define NO_ACTION_FUNCTION
#endif #endif

@ -117,18 +117,13 @@ void unregister_code16 (uint16_t code) {
} }
__attribute__ ((weak)) __attribute__ ((weak))
bool process_action_kb(keyrecord_t *record) { level_t process_kb(uint16_t keycode, keyrecord_t *record) {
return true; return CONTINUE;
} }
__attribute__ ((weak)) __attribute__ ((weak))
bool process_record_kb(uint16_t keycode, keyrecord_t *record) { level_t process_user(uint16_t keycode, keyrecord_t *record) {
return process_record_user(keycode, record); return CONTINUE;
}
__attribute__ ((weak))
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
} }
void reset_keyboard(void) { void reset_keyboard(void) {
@ -162,7 +157,8 @@ void reset_keyboard(void) {
static bool shift_interrupted[2] = {0, 0}; static bool shift_interrupted[2] = {0, 0};
static uint16_t scs_timer[2] = {0, 0}; static uint16_t scs_timer[2] = {0, 0};
bool process_record_quantum(keyrecord_t *record) { level_t process_quantum(keyrecord_t *record) {
level_t level = CONTINUE;
/* This gets the keycode from the key pressed */ /* This gets the keycode from the key pressed */
keypos_t key = record->event.key; keypos_t key = record->event.key;
@ -182,7 +178,7 @@ bool process_record_quantum(keyrecord_t *record) {
keycode = keymap_key_to_keycode(layer, key); keycode = keymap_key_to_keycode(layer, key);
} else } else
#endif #endif
keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key);
// This is how you use actions here // This is how you use actions here
// if (keycode == KC_LEAD) { // if (keycode == KC_LEAD) {
@ -192,47 +188,57 @@ bool process_record_quantum(keyrecord_t *record) {
// return false; // return false;
// } // }
if (!( level |= process_user(keycode, record);
process_record_kb(keycode, record) && if (!(level & STOP_KEYBOARD))
level |= process_kb(keycode, record);
#if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED) #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
process_midi(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_midi(keycode, record);
#endif #endif
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
process_audio(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_audio(keycode, record);
#endif #endif
#ifdef STENO_ENABLE #ifdef STENO_ENABLE
process_steno(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_steno(keycode, record);
#endif #endif
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
process_music(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_music(keycode, record);
#endif #endif
#ifdef TAP_DANCE_ENABLE #ifdef TAP_DANCE_ENABLE
process_tap_dance(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_tap_dance(keycode, record);
#endif #endif
#ifndef DISABLE_LEADER #ifndef DISABLE_LEADER
process_leader(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_leader(keycode, record);
#endif #endif
#ifndef DISABLE_CHORDING #ifndef DISABLE_CHORDING
process_chording(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_chording(keycode, record)
#endif #endif
#ifdef COMBO_ENABLE #ifdef COMBO_ENABLE
process_combo(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_combo(keycode, record);
#endif #endif
#ifdef UNICODE_ENABLE #ifdef UNICODE_ENABLE
process_unicode(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_unicode(keycode, record);
#endif #endif
#ifdef UCIS_ENABLE #ifdef UCIS_ENABLE
process_ucis(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_ucis(keycode, record);
#endif #endif
#ifdef PRINTING_ENABLE #ifdef PRINTING_ENABLE
process_printer(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_printer(keycode, record);
#endif #endif
#ifdef UNICODEMAP_ENABLE #ifdef UNICODEMAP_ENABLE
process_unicode_map(keycode, record) && if (!(level & STOP_FEATURES))
level |= process_unicode_map(keycode, record);
#endif #endif
true)) {
return false;
}
// Shift / paren setup // Shift / paren setup
@ -241,33 +247,33 @@ bool process_record_quantum(keyrecord_t *record) {
if (record->event.pressed) { if (record->event.pressed) {
reset_keyboard(); reset_keyboard();
} }
return false; return (level | STOP_ALL);
break; break;
case DEBUG: case DEBUG:
if (record->event.pressed) { if (record->event.pressed) {
print("\nDEBUG: enabled.\n"); print("\nDEBUG: enabled.\n");
debug_enable = true; debug_enable = true;
} }
return false; return (level | STOP_ALL);
break; break;
#ifdef FAUXCLICKY_ENABLE #ifdef FAUXCLICKY_ENABLE
case FC_TOG: case FC_TOG:
if (record->event.pressed) { if (record->event.pressed) {
FAUXCLICKY_TOGGLE; FAUXCLICKY_TOGGLE;
} }
return false; return (level | STOP_ALL);
break; break;
case FC_ON: case FC_ON:
if (record->event.pressed) { if (record->event.pressed) {
FAUXCLICKY_ON; FAUXCLICKY_ON;
} }
return false; return (level | STOP_ALL);
break; break;
case FC_OFF: case FC_OFF:
if (record->event.pressed) { if (record->event.pressed) {
FAUXCLICKY_OFF; FAUXCLICKY_OFF;
} }
return false; return (level | STOP_ALL);
break; break;
#endif #endif
#ifdef RGBLIGHT_ENABLE #ifdef RGBLIGHT_ENABLE
@ -275,49 +281,49 @@ bool process_record_quantum(keyrecord_t *record) {
if (record->event.pressed) { if (record->event.pressed) {
rgblight_toggle(); rgblight_toggle();
} }
return false; return (level | STOP_ALL);
break; break;
case RGB_MOD: case RGB_MOD:
if (record->event.pressed) { if (record->event.pressed) {
rgblight_step(); rgblight_step();
} }
return false; return (level | STOP_ALL);
break; break;
case RGB_HUI: case RGB_HUI:
if (record->event.pressed) { if (record->event.pressed) {
rgblight_increase_hue(); rgblight_increase_hue();
} }
return false; return (level | STOP_ALL);
break; break;
case RGB_HUD: case RGB_HUD:
if (record->event.pressed) { if (record->event.pressed) {
rgblight_decrease_hue(); rgblight_decrease_hue();
} }
return false; return (level | STOP_ALL);
break; break;
case RGB_SAI: case RGB_SAI:
if (record->event.pressed) { if (record->event.pressed) {
rgblight_increase_sat(); rgblight_increase_sat();
} }
return false; return (level | STOP_ALL);
break; break;
case RGB_SAD: case RGB_SAD:
if (record->event.pressed) { if (record->event.pressed) {
rgblight_decrease_sat(); rgblight_decrease_sat();
} }
return false; return (level | STOP_ALL);
break; break;
case RGB_VAI: case RGB_VAI:
if (record->event.pressed) { if (record->event.pressed) {
rgblight_increase_val(); rgblight_increase_val();
} }
return false; return (level | STOP_ALL);
break; break;
case RGB_VAD: case RGB_VAD:
if (record->event.pressed) { if (record->event.pressed) {
rgblight_decrease_val(); rgblight_decrease_val();
} }
return false; return (level | STOP_ALL);
break; break;
#endif #endif
#ifdef PROTOCOL_LUFA #ifdef PROTOCOL_LUFA
@ -325,20 +331,20 @@ bool process_record_quantum(keyrecord_t *record) {
if (record->event.pressed) { if (record->event.pressed) {
set_output(OUTPUT_AUTO); set_output(OUTPUT_AUTO);
} }
return false; return (level | STOP_ALL);
break; break;
case OUT_USB: case OUT_USB:
if (record->event.pressed) { if (record->event.pressed) {
set_output(OUTPUT_USB); set_output(OUTPUT_USB);
} }
return false; return (level | STOP_ALL);
break; break;
#ifdef BLUETOOTH_ENABLE #ifdef BLUETOOTH_ENABLE
case OUT_BT: case OUT_BT:
if (record->event.pressed) { if (record->event.pressed) {
set_output(OUTPUT_BLUETOOTH); set_output(OUTPUT_BLUETOOTH);
} }
return false; return (level | STOP_ALL);
break; break;
#endif #endif
#endif #endif
@ -423,7 +429,7 @@ bool process_record_quantum(keyrecord_t *record) {
eeconfig_update_keymap(keymap_config.raw); eeconfig_update_keymap(keymap_config.raw);
clear_keyboard(); // clear to prevent stuck keys clear_keyboard(); // clear to prevent stuck keys
return false; return (level | STOP_ALL);
} }
break; break;
case KC_LSPO: { case KC_LSPO: {
@ -445,7 +451,7 @@ bool process_record_quantum(keyrecord_t *record) {
} }
unregister_mods(MOD_BIT(KC_LSFT)); unregister_mods(MOD_BIT(KC_LSFT));
} }
return false; return (level | STOP_ALL);
// break; // break;
} }
@ -468,7 +474,7 @@ bool process_record_quantum(keyrecord_t *record) {
} }
unregister_mods(MOD_BIT(KC_RSFT)); unregister_mods(MOD_BIT(KC_RSFT));
} }
return false; return (level | STOP_ALL);
// break; // break;
} }
case GRAVE_ESC: { case GRAVE_ESC: {
@ -486,7 +492,7 @@ bool process_record_quantum(keyrecord_t *record) {
} }
} }
return process_action_kb(record); return level;
} }
__attribute__ ((weak)) __attribute__ ((weak))

@ -119,9 +119,29 @@ void matrix_init_kb(void);
void matrix_scan_kb(void); void matrix_scan_kb(void);
void matrix_init_user(void); void matrix_init_user(void);
void matrix_scan_user(void); void matrix_scan_user(void);
bool process_action_kb(keyrecord_t *record); bool process_action_kb(keyrecord_t *record);
bool process_record_kb(uint16_t keycode, keyrecord_t *record);
bool process_record_user(uint16_t keycode, keyrecord_t *record); typedef enum {
PL_STOP_SYSTEM,
PL_STOP_FEATURES,
PL_STOP_KEYBOARD
} process_level_t;
#define CONTINUE (0)
#define STOP_SYSTEM (1<<PL_STOP_SYSTEM)
#define STOP_FEAUTRES (1<<PL_STOP_FEAUTRES)
#define STOP_KEYBOARD (1<<PL_STOP_KEYBOARD)
#define STOP_ALL (STOP_SYSTEM|STOP_FEAUTRES|STOP_KEYBOARD)
// uint8_t supports up to 8 stops
#define level_t uint8_t
/* keyboard-specific key event (pre)processing */
level_t process_quantum(keyrecord_t *record);
level_t process_kb(uint16_t keycode, keyrecord_t *record);
level_t process_user(uint16_t keycode, keyrecord_t *record);
void reset_keyboard(void); void reset_keyboard(void);

@ -40,6 +40,8 @@ int tp_buttons;
#include <fauxclicky.h> #include <fauxclicky.h>
#endif #endif
#include "quantum.h"
void action_exec(keyevent_t event) void action_exec(keyevent_t event)
{ {
if (!IS_NOEVENT(event)) { if (!IS_NOEVENT(event)) {
@ -120,24 +122,21 @@ void process_record_nocache(keyrecord_t *record)
} }
#endif #endif
__attribute__ ((weak))
bool process_record_quantum(keyrecord_t *record) {
return true;
}
void process_record(keyrecord_t *record) void process_record(keyrecord_t *record)
{ {
if (IS_NOEVENT(record->event)) { return; } if (IS_NOEVENT(record->event)) { return; }
if(!process_record_quantum(record)) uint8_t level = process_quantum(record);
if (level & STOP_SYSTEM)
return; return;
action_t action = store_or_get_action(record->event.pressed, record->event.key); action_t action = store_or_get_action(record->event.pressed, record->event.key);
dprint("ACTION: "); debug_action(action); dprint("ACTION: "); debug_action(action);
#ifndef NO_ACTION_LAYER #ifndef NO_ACTION_LAYER
dprint(" layer_state: "); layer_debug(); dprint(" layer_state: "); layer_debug();
dprint(" default_layer_state: "); default_layer_debug(); dprint(" default_layer_state: "); default_layer_debug();
#endif #endif
dprintln(); dprintln();
process_action(record, action); process_action(record, action);

@ -58,9 +58,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);
/* user defined special function */ /* user defined special function */
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
/* keyboard-specific key event (pre)processing */
bool process_record_quantum(keyrecord_t *record);
/* Utilities for actions. */ /* Utilities for actions. */
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
extern bool disable_action_cache; extern bool disable_action_cache;

Loading…
Cancel
Save