[Keyboard] Add userspace pdl and a handwired board (#14199)

Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Joel Challis <git@zvecr.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
This commit is contained in:
Daniel Perrett 2022-04-13 06:25:19 +01:00 committed by GitHub
parent 0524a82a88
commit a5e41615f7
Failed to generate hash of commit
25 changed files with 1104 additions and 0 deletions

216
users/pdl/pdl.c Normal file
View file

@ -0,0 +1,216 @@
/*
Copyright 2018-2021 Daniel Perrett
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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "pdl.h"
// unshifted
//
// regardless of current mods, send this character in an unshifted state
__attribute__ ((weak))
bool unshifted (uint16_t keycode, keyrecord_t *record) {
uint8_t mods;
if (record->event.pressed) {
mods = keyboard_report->mods & EITHER_SHIFT;
if (mods) {
unregister_mods(mods);
register_code(keycode);
register_mods(mods);
} else {
register_code(keycode);
}
return false;
} else {
return true;
}
}
/*
* update_punctn_coding_layer_state
*
* Check NAVIGN and NUMBRS layers. If one is activated, also activate PUNCTN. If both are activated, also activate CODING.
*/
__attribute__ ((weak))
uint32_t update_punctn_coding_layer_state(uint32_t state) {
uint32_t maskEither = (1UL << _NAVIGN) | (1UL << _NUMBRS);
uint32_t maskPunctn = 1UL << _PUNCTN;
uint32_t maskCoding = 1UL << _CODING;
#ifdef COMBO_PDL
return (
(state & maskEither)
? (state | maskPunctn) & ~maskCoding // either => punctn
: (state & ~maskCoding) & ~maskPunctn // neither => neither
);
#endif
return (
(state & maskEither)
? (state & maskEither) == maskEither
? (state & ~maskPunctn) | maskCoding // both => coding
: (state | maskPunctn) & ~maskCoding // either => punctn
: (state & ~maskCoding) & ~maskPunctn // neither => neither
);
}
__attribute__ ((weak))
uint32_t layer_state_set_user(uint32_t state) {
return update_punctn_coding_layer_state(state);
}
__attribute__ ((weak))
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
if (record->event.pressed) {
// ensure that the toggled layer is switched off by a single tap
layer_off(keycode & 0xFF);
}
break;
case QWERTY:
if (record->event.pressed) {
set_single_persistent_default_layer(_QWERTY);
}
return false;
break;
case PROXIM:
if (record->event.pressed) {
set_single_persistent_default_layer(_PROXIM);
}
return false;
break;
// KC_LBRC, KC_NUHS, KC_GRV, KC_RBRC [#`]
// These four keys are unshifted in the UK layout and should be sent as such.
case KU_LBRC:
return unshifted(KC_LBRC, record);
case KU_NUHS:
return unshifted(KC_NUHS, record);
case KU_GRV:
return unshifted(KC_GRV, record);
case KU_RBRC:
return unshifted(KC_RBRC, record);
case KC_ESC:
if (!record->event.pressed) {
layer_off(_NUMBRS);
layer_off(_NAVIGN);
layer_off(_PUNCTN);
layer_off(_CODING);
}
return true;
}
return true;
}
#ifdef COMBO_PDL
enum combos {
VCOMBO_PU,
VCOMBO_NU,
VCOMBO_EU,
VCOMBO_IU,
VCOMBO_LU,
VCOMBO_PD,
VCOMBO_ND,
VCOMBO_ED,
VCOMBO_ID,
VCOMBO_LD,
HCOMBO_JR,
HCOMBO_UR,
HCOMBO_PR,
HCOMBO_MR,
HCOMBO_HR,
XCOMBO_LEFT,
XCOMBO_RIGHT,
XCOMBO_UP,
XCOMBO_DOWN,
XCOMBO_ENTER,
XCOMBO_DEL,
XCOMBO_BKSP,
XCOMBO_MINS,
XCOMBO_TAB,
XCOMBO_UNDO,
XCOMBO_REDO,
XCOMBO_PGUP,
XCOMBO_PGDN
};
const uint16_t PROGMEM vcombo_pu[] = {KC_J, KC_P, COMBO_END};
const uint16_t PROGMEM vcombo_nu[] = {KC_Y, KC_N, COMBO_END};
const uint16_t PROGMEM vcombo_eu[] = {KC_O, KC_E, COMBO_END};
const uint16_t PROGMEM vcombo_iu[] = {KC_U, KC_I, COMBO_END};
const uint16_t PROGMEM vcombo_lu[] = {KC_QUOT, KC_L, COMBO_END};
const uint16_t PROGMEM vcombo_pd[] = {KC_M, KC_P, COMBO_END};
const uint16_t PROGMEM vcombo_nd[] = {KC_H, KC_N, COMBO_END};
const uint16_t PROGMEM vcombo_ed[] = {KC_COMM, KC_E, COMBO_END};
const uint16_t PROGMEM vcombo_id[] = {KC_DOT, KC_I, COMBO_END};
const uint16_t PROGMEM vcombo_ld[] = {KC_SLSH, KC_L, COMBO_END};
const uint16_t PROGMEM hcombo_jr[] = {KC_J, KC_Y, COMBO_END};
const uint16_t PROGMEM hcombo_ur[] = {KC_QUOT, KC_U, COMBO_END};
const uint16_t PROGMEM hcombo_pr[] = {KC_P, KC_N, COMBO_END};
const uint16_t PROGMEM hcombo_mr[] = {KC_M, KC_H, COMBO_END};
const uint16_t PROGMEM hcombo_hr[] = {KC_COMM, KC_H, COMBO_END};
const uint16_t PROGMEM xcombo_left[] = {KC_K, KC_P, COMBO_END};
const uint16_t PROGMEM xcombo_right[] = {KC_M, KC_G, COMBO_END};
const uint16_t PROGMEM xcombo_up[] = {KC_B, KC_J, COMBO_END};
const uint16_t PROGMEM xcombo_down[] = {KC_K, KC_M, COMBO_END};
const uint16_t PROGMEM xcombo_enter[] = {KC_G, KC_P, COMBO_END};
const uint16_t PROGMEM xcombo_del[] = {KC_M, KC_B, COMBO_END};
const uint16_t PROGMEM xcombo_bksp[] = {KC_K, KC_J, COMBO_END};
const uint16_t PROGMEM xcombo_mins[] = {KC_V, KC_H, COMBO_END};
const uint16_t PROGMEM xcombo_tab[] = {KC_V, KC_K, COMBO_END};
const uint16_t PROGMEM xcombo_undo[] = {KC_V, KC_J, COMBO_END};
const uint16_t PROGMEM xcombo_redo[] = {KC_B, KC_H, COMBO_END};
const uint16_t PROGMEM xcombo_pgup[] = {KC_G, KC_B, COMBO_END};
const uint16_t PROGMEM xcombo_pgdn[] = {KC_G, KC_K, COMBO_END};
combo_t key_combos[COMBO_COUNT] = {
[VCOMBO_PU] = COMBO(vcombo_pu, KC_CIRC),
[VCOMBO_NU] = COMBO(vcombo_nu, KC_LBRC),
[VCOMBO_EU] = COMBO(vcombo_eu, LSFT(KC_9)),
[VCOMBO_IU] = COMBO(vcombo_iu, LSFT(KC_0)),
[VCOMBO_LU] = COMBO(vcombo_lu, KC_RBRC),
[VCOMBO_PD] = COMBO(vcombo_pd, LSFT(KC_7)),
[VCOMBO_ND] = COMBO(vcombo_nd, KC_EQL),
[VCOMBO_ED] = COMBO(vcombo_ed, KC_MINS),
[VCOMBO_ID] = COMBO(vcombo_id, LSFT(KC_1)),
[VCOMBO_LD] = COMBO(vcombo_ld, LSFT(KC_5)),
[HCOMBO_JR] = COMBO(hcombo_jr, KC_GRV),
[HCOMBO_UR] = COMBO(hcombo_ur, LSFT(KC_2)),
[HCOMBO_PR] = COMBO(hcombo_pr, LSFT(KC_8)),
[HCOMBO_MR] = COMBO(hcombo_mr, KC_NUHS),
[HCOMBO_HR] = COMBO(hcombo_hr, KC_NUBS),
[XCOMBO_LEFT] = COMBO(xcombo_left, KC_LEFT),
[XCOMBO_RIGHT] = COMBO(xcombo_right, KC_RGHT),
[XCOMBO_UP] = COMBO(xcombo_up, KC_UP),
[XCOMBO_DOWN] = COMBO(xcombo_down, KC_DOWN),
[XCOMBO_ENTER] = COMBO(xcombo_enter, KC_ENT),
[XCOMBO_DEL] = COMBO(xcombo_del, KC_DEL),
[XCOMBO_BKSP] = COMBO(xcombo_bksp, KC_BSPC),
[XCOMBO_MINS] = COMBO(xcombo_mins, KC_MINS),
[XCOMBO_TAB] = COMBO(xcombo_tab, KC_TAB),
[XCOMBO_UNDO] = COMBO(xcombo_undo, LCTL(KC_Y)),
[XCOMBO_REDO] = COMBO(xcombo_redo, LCTL(KC_Z)),
[XCOMBO_PGUP] = COMBO(xcombo_pgup, KC_PGUP),
[XCOMBO_PGDN] = COMBO(xcombo_pgdn, KC_PGDN)
};
#endif

135
users/pdl/pdl.h Normal file
View file

@ -0,0 +1,135 @@
/*
Copyright 2018-2021 Daniel Perrett
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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "quantum.h"
enum userspace_layer_codes {
QWERTY = SAFE_RANGE,
PROXIM,
PUNCTN,
CODING,
KU_LBRC,
KU_NUHS,
KU_GRV,
KU_RBRC,
NEW_SAFE_RANGE
};
enum userspace_layers {
_PROXIM,
_QWERTY,
_NUMBRS,
_NAVIGN,
_PUNCTN,
_CODING,
_FUNCTN
};
#define MY_FESC LT(_FUNCTN, KC_ESC)
#define MY_SSPC MT(MOD_RSFT, KC_SPC)
#define MY_SESC MT(MOD_LSFT, KC_ESC)
#define MY_SBSL MT(MOD_LSFT, KC_NUBS)
#define MY_CBSL MT(MOD_LCTL, KC_NUBS)
#define MY_SSCL MT(MOD_RSFT, KC_SCLN)
#define MY_ASCL MT(MOD_LALT, KC_SCLN)
#define MY_SQUO MT(MOD_RSFT, KC_QUOT)
#define MY_CENT MT(MOD_RCTL, KC_ENT)
#define MY_SENT MT(MOD_RSFT, KC_ENT)
#define MY_AMNU MT(MOD_RALT, KC_APP)
#define MY_TILD S(KC_NUHS)
#define MY_SEQL MT(MOD_RALT, KC_PEQL)
#define MY_CMIN MT(MOD_RALT, KC_MINS)
#define MY_ASLS MT(MOD_RALT, KC_SLSH)
#define MY_UNDO LCTL(KC_Z)
#define MY_CUT LCTL(KC_X)
#define MY_COPY LCTL(KC_C)
#define MY_PASTE LCTL(KC_V)
#define MY_AF4 LALT(KC_F4)
#define MY_CF4 LCTL(KC_F4)
#define MY_CF5 LCTL(KC_F5)
#define MY_CAD LCTL(LALT(KC_DEL))
#define NUMBRS TT(_NUMBRS)
#define NAVIGN TT(_NAVIGN)
#define FUNCTN TT(_FUNCTN)
#define EITHER_SHIFT (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT))
// Cannot redefine this here
// #define TAPPING_TOGGLE 2
// Taken from drashna:
// Since our quirky block definitions are basically a list of comma separated
// arguments, we need a wrapper in order for these definitions to be
// expanded before being used as arguments to the LAYOUT_xxx macro.
#if !defined(LAYOUT)
#if defined(LAYOUT_ortho_4x12)
#define LAYOUT_wrapper_ortho_4x12(...) LAYOUT_ortho_4x12(__VA_ARGS__)
#define LAYOUT LAYOUT_ortho_4x12
#elif defined(KEYMAP)
#define LAYOUT KEYMAP
#endif
#endif
#define KEYMAP_wrapper(...) LAYOUT(__VA_ARGS__)
#define LAYOUT_wrapper(...) LAYOUT(__VA_ARGS__)
#define ___________________________________________ _______, _______, _______, _______, _______
#define _________________QWERTY_L1_________________ KC_Q, KC_W, KC_E, KC_R, KC_T
#define _________________QWERTY_L2_________________ KC_A, KC_S, KC_D, KC_F, KC_G
#define _________________QWERTY_L3_________________ KC_Z, KC_X, KC_C, KC_V, KC_B
#define _________________QWERTY_R1_________________ KC_Y, KC_U, KC_I, KC_O, KC_P
#define _________________QWERTY_R2_________________ KC_H, KC_J, KC_K, KC_L, KC_SCLN
#define _________________QWERTY_R3_________________ KC_N, KC_M, KC_COMM, KC_DOT, KC_SLASH
#define _________________PROXIM_L1_________________ KC_Q, KC_W, KC_F, KC_R, KC_B
#define _________________PROXIM_L2_________________ KC_A, KC_S, KC_D, KC_T, KC_G
#define _________________PROXIM_L3_________________ KC_Z, KC_X, KC_C, KC_V, KC_K
#define _________________PROXIM_R1_________________ KC_J, KC_Y, KC_O, KC_U, KC_QUOT
#define _________________PROXIM_R2_________________ KC_P, KC_N, KC_E, KC_I, KC_L
#define _________________PROXIM_R3_________________ KC_M, KC_H, KC_COMM, KC_DOT, KC_SLASH
#define _________________PUNCTN_R1_________________ KC_NUBS, KC_NUHS, KC_LPRN, KC_RPRN, _______
#define _________________PUNCTN_R2_________________ KC_GRV, KC_EQL, KC_MINS, KC_PLUS, KC_SLSH
#define _________________PUNCTN_R3_________________ KC_LBRC, KC_RBRC, _______, _______, _______
#define _________________CODING_R1_________________ KU_GRV, KC_PERC, KC_DLR, KC_AT, _______
#define _________________CODING_R2_________________ KC_CIRC, KC_UNDS, MY_TILD, KC_AMPR, KU_NUHS
#define _________________CODING_R3_________________ KU_LBRC, KU_RBRC, _______, _______, _______
#define _________________NAVIGN_L1_________________ KC_DEL, KC_PGUP, KC_UP, KC_PGDN, KC_BSPC
#define _________________NAVIGN_L2_________________ KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END
#define _________________NAVIGN_L3_________________ MY_UNDO, MY_CUT, MY_COPY, MY_PASTE, KC_ENT
#define _________________NUMBRS_L1_________________ KC_1, KC_2, KC_3, KC_4, KC_5
#define _________________NUMBRS_L2_________________ KC_6, KC_7, KC_8, KC_9, KC_0
#define _________________NUMBRS_L3_________________ KC_UNDO, KC_MINS, KC_EQL, KC_PDOT, KC_ENT
#define _________________FUNCTN_L1_________________ KC_ESC, KC_F1, KC_F2, KC_F3, MY_AF4
#define _________________FUNCTN_L2_________________ KC_APP, KC_F4, KC_F5, KC_F6, MY_CF5
#define _________________FUNCTN_L3_________________ RESET, KC_F7, KC_F8, KC_F9, MY_CF4
#define _________________FUNCTN_R1_________________ KC_VOLU, KC_F10, KC_F11, KC_F12, KC_INS
#define _________________FUNCTN_R2_________________ KC_VOLD, KC_MPRV, KC_MSTP, KC_MPLY, KC_MNXT
#define _________________FUNCTN_R3_________________ KC_MUTE, KC_PAUS, QWERTY, PROXIM, DEBUG

1
users/pdl/rules.mk Normal file
View file

@ -0,0 +1 @@
COMBO_ENABLE = yes