Beispiel #1
0
/*
 * Do keyboard routine jobs: scan mantrix, light LEDs, ...
 * This is repeatedly called as fast as possible.
 */
void keyboard_task(void)
{
    static matrix_col_t matrix_prev[MATRIX_COLS];
#ifdef MATRIX_HAS_GHOST
    static matrix_col_t matrix_ghost[MATRIX_COLS];
#endif
    static uint8_t led_status = 0;
    matrix_col_t matrix_col = 0;
    matrix_col_t matrix_change = 0;

    matrix_scan();
    for (uint8_t c = 0; c < MATRIX_COLS; c++) {
        matrix_col = matrix_get_col(c);
        matrix_change = matrix_col ^ matrix_prev[c];
        if (matrix_change) {
#ifdef MATRIX_HAS_GHOST
            if (has_ghost_in_col(c)) {
                /* Keep track of whether ghosted status has changed for
                 * debugging. But don't update matrix_prev until un-ghosted, or
                 * the last key would be lost.
                 */
                if (debug_matrix && matrix_ghost[c] != matrix_col) {
                    matrix_print();
                }
                matrix_ghost[c] = matrix_col;
                continue;
            }
            matrix_ghost[c] = matrix_col;
#endif
            if (debug_matrix) matrix_print();
            for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
                if (matrix_change & ((matrix_col_t)1<<r)) {
                    keyevent_t e = (keyevent_t){
                        .key = (keypos_t){ .row = r, .col = c },
                        .pressed = (matrix_col & ((matrix_col_t)1<<r)),
                        .time = (timer_read() | 1) /* time should not be 0 */
                    };
                    action_exec(e);
                    hook_matrix_change(e);
                    // record a processed key
                    matrix_prev[c] ^= ((matrix_col_t)1<<r);
                    // process a key per task call
                    goto MATRIX_LOOP_END;
                }
            }
        }
    }
Beispiel #2
0
void action_exec(keyevent_t event)
{
    if (!IS_NOEVENT(event)) {
        dprint("\n---- action_exec: start -----\n");
        dprint("EVENT: "); debug_event(event); dprintln();
        hook_matrix_change(event);
    }

    keyrecord_t record = { .event = event };

#ifndef NO_ACTION_TAPPING
    action_tapping_process(record);
#else
    process_action(&record);
    if (!IS_NOEVENT(record.event)) {
        dprint("processed: "); debug_record(record); dprintln();
    }
#endif
}