introduces new format [broken] [skip ci]

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

@ -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;
@ -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