Skip to content

Instantly share code, notes, and snippets.

@willwm
Last active November 11, 2022 13:29
Show Gist options
  • Save willwm/c59261c6f02d2e9ded3f986f6608d25d to your computer and use it in GitHub Desktop.
Save willwm/c59261c6f02d2e9ded3f986f6608d25d to your computer and use it in GitHub Desktop.
Vial QMK BrainDump

Vial QMK BrainDump

Code Snippets

Quantum - Progrramming the Behavior of Any Keycode

https://docs.qmk.fm/#/custom_quantum_functions?id=programming-the-behavior-of-any-keycode

// Quantum - Progrramming the Behavior of Any Keycode ===================== //
// https://docs.qmk.fm/#/custom_quantum_functions?id=custom-keycodes        //

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case FOO:
      if (record->event.pressed) {
        // Do something when pressed
      } else {
        // Do something else when release
      }
      return false; // Skip all further processing of this key
    case KC_ENTER:
      // Play a tone when enter is pressed
      if (record->event.pressed) {
        PLAY_SONG(tone_qwerty);
      }
      return true; // Let QMK send the enter press/release events
    default:
      return true; // Process all other keycodes normally
  }
}

Caps Word - Representing Caps Word state

https://docs.qmk.fm/#/feature_caps_word?id=representing-caps-word-state

// Caps Word - Representing Caps Word state =============================== //
// https://docs.qmk.fm/#/feature_caps_word?id=representing-caps-word-state  //

void caps_word_set_user(bool active) {
    if (active) {
        // Do something when Caps Word activates.
    } else {
        // Do something when Caps Word deactivates.
    }
}

RGB Matrix - Per-Layer Lighting (only keys mapped on layer)

void layer_indicator_only_configured(uint8_t led_min, uint8_t led_max) {
    uint8_t layer = get_highest_layer(layer_state);

    // Layer indicator only on keys with configured keycodes:
    if (layer > 0) {

        for (uint8_t row = 0; row < MATRIX_ROWS; ++row) {
            for (uint8_t col = 0; col < MATRIX_COLS; ++col) {
                uint8_t index = g_led_config.matrix_co[row][col];

                if (index >= led_min && index <= led_max && index != NO_LED &&
                keymap_key_to_keycode(layer, (keypos_t){col,row}) > KC_TRNS) {
                    set_layer_color(layer, index);
                }
            }
        }
    }
}

RGB Matrix - Per-Layer Lighting Modes

https://docs.qmk.fm/#/feature_rgb_matrix?id=functions

void set_layer_mode(uint8_t layer) {
    switch(layer) {
        case 3:
            rgb_matrix_mode(RGB_MATRIX_CYCLE_PINWHEEL);
            break;
        case 2:
            rgb_matrix_mode(RGB_MATRIX_SOLID_COLOR);
            break;
        case 1:
            rgb_matrix_mode(RGB_MATRIX_CYCLE_LEFT_RIGHT);
            break;
        default:
            rgb_matrix_mode(RGB_MATRIX_GRADIENT_LEFT_RIGHT);
            break;
    }
}

Unicode Map

https://docs.qmk.fm/#/feature_unicode?id=unicode-map

Note: Add UNICODEMAP_ENABLE=yes to rules.mk

// Unicode - Unicode Map ================================================= //
// https://docs.qmk.fm/#/feature_unicode?id=unicode-map                    //

enum unicode_names {
    ALL,
    EXST,
    ELEM,
    INF,
    EMPT
};

const uint32_t PROGMEM unicode_map[] = {
    [ALL]   = 0x2200,  // ∀
    [EXST]  = 0x2203,  // ∃
    [ELEM]  = 0x2208,  // ∈
    [INF]   = 0x221E,  // ∞
    [EMPT]  = 0x2205,  // ∅
};

vial-qmk Configuration

rules.mk

VIA_ENABLE=yes
VIAL_ENABLE=yes
VIALRGB_ENABLE=yes

ENCODER_MAP_ENABLE=yes
KEY_LOCK_ENABLE=yes

config.h

#pragma once

#include "config_common.h"

#define DRIVER_1_LED_TOTAL 66
#define DRIVER_2_LED_TOTAL 32
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)

// https://docs.qmk.fm/#/feature_leader_key?id=per-key-timing-on-leader-keys
#define LEADER_PER_KEY_TIMING
#define LEADER_TIMEOUT 250

//enable RGB Matrix Effects for Vial
#define RGB_MATRIX_KEYPRESSES           // reacts to keypresses
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS  // enable framebuffer effects
#define RGB_DISABLE_WHEN_USB_SUSPENDED  // turn off effects when suspended
#define RGB_TRIGGER_ON_KEYDOWN          // Triggers RGB keypress events on key down. This makes RGB control feel more responsive. This may cause RGB to not function properly on some boards

//Vial Keyboard UID
#define VIAL_KEYBOARD_UID {0x03, 0x75, 0x3D, 0xEC, 0x97, 0xC2, 0xE9, 0x9A}
#define VIAL_UNLOCK_COMBO_ROWS { 1, 10 }
#define VIAL_UNLOCK_COMBO_COLS { 3, 4 }

See Also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment