Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //key_overrides.h
- #pragma once
- #include QMK_KEYBOARD_H
- extern const key_override_t *key_overrides[];
- //socd.h
- #pragma once
- #include QMK_KEYBOARD_H
- enum jamies_keycodes {
- SOCD_W = SAFE_RANGE,
- SOCD_A,
- SOCD_S,
- SOCD_D,
- COLEMAK_TG // New keycode for Colemak toggle
- };
- bool process_record_user(uint16_t keycode, keyrecord_t *record);
- //layers.h
- #pragma once
- enum layer_names {
- _QWERTY,
- _SYM,
- _NUM,
- _GAME,
- _COLEMAK
- };
- //key_overrides.c
- #include "key_overrides.h"
- const key_override_t delete_key_override = ko_make_basic(MOD_MASK_SHIFT, KC_BSPC, KC_DEL);
- const key_override_t bspc_key_override = ko_make_basic(MOD_MASK_ALT,KC_BSPC, KC_BSLS);
- const key_override_t right_parenthesis_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_RPRN, KC_0);
- const key_override_t exclamation_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_EXLM, KC_1);
- const key_override_t at_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_AT, KC_2);
- const key_override_t hash_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_HASH, KC_3);
- const key_override_t dollar_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_DLR, KC_4);
- const key_override_t percentage_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_PERC, KC_5);
- const key_override_t circ_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_CIRC, KC_6);
- const key_override_t ampr_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_AMPR, KC_7);
- const key_override_t astr_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_ASTR, KC_8);
- const key_override_t lprn_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_LPRN, KC_9);
- const key_override_t mins_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_MINS, KC_UNDS);
- const key_override_t eql_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_EQL,KC_PLUS);
- const key_override_t lbrc_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_LBRC,KC_LCBR);
- const key_override_t rbrc_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_RBRC,KC_RCBR);
- const key_override_t bsls_key_override = ko_make_basic(MOD_MASK_SHIFT,KC_BSLS, KC_PIPE);
- const key_override_t *key_overrides[] = {
- &delete_key_override,
- &right_parenthesis_key_override,
- &exclamation_key_override,
- &at_key_override,
- &hash_key_override,
- &dollar_key_override,
- &percentage_key_override,
- &circ_key_override,
- &r_key_override,
- &astr_key_override,
- &lprn_key_override,
- &mins_key_override,
- &eql_key_override,
- &lbrc_key_override,
- &rbrc_key_override,
- &bsls_key_override,
- &bspc_key_override,
- NULL
- };
- //socd.c
- #include "socd.h"
- #include "layers.h"
- static bool w_down = false;
- static bool a_down = false;
- static bool s_down = false;
- static bool d_down = false;
- bool process_record_user(uint16_t keycode, keyrecord_t *record) {
- switch (keycode) {
- case COLEMAK_TG:
- if (record->event.pressed) {
- if (get_highest_layer(layer_state) == _COLEMAK) {
- layer_clear(); // Return to base layer
- } else {
- layer_move(_COLEMAK);
- }
- }
- return false;
- case SOCD_W:
- if (record->event.pressed) {
- if (s_down) {
- unregister_code(KC_S);
- }
- register_code(KC_W);
- w_down = true;
- } else {
- unregister_code(KC_W);
- w_down = false;
- if (s_down) {
- register_code(KC_S);
- }
- }
- return false;
- break;
- case SOCD_A:
- if (record->event.pressed) {
- if (d_down) {
- unregister_code(KC_D);
- }
- register_code(KC_A);
- a_down = true;
- } else {
- unregister_code(KC_A);
- a_down = false;
- if (d_down) {
- register_code(KC_D);
- }
- }
- return false;
- break;
- case SOCD_S:
- if (record->event.pressed) {
- if (w_down) {
- unregister_code(KC_W);
- }
- register_code(KC_S);
- s_down = true;
- } else {
- unregister_code(KC_S);
- s_down = false;
- if (w_down) {
- register_code(KC_W);
- }
- }
- return false;
- break;
- case SOCD_D:
- if (record->event.pressed) {
- if (a_down) {
- unregister_code(KC_A);
- }
- register_code(KC_D);
- d_down = true;
- } else {
- unregister_code(KC_D);
- d_down = false;
- if (a_down) {
- register_code(KC_A);
- }
- }
- return false;
- break;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement