aboutsummaryrefslogtreecommitdiff
path: root/users/badger
diff options
context:
space:
mode:
authorDan White <BlueTufa@users.noreply.github.com>2020-09-16 22:03:28 -0600
committerGitHub <noreply@github.com>2020-09-16 21:03:28 -0700
commitf650b03fb77530eb6aa7eab541f6a28c98e0ced6 (patch)
treeb5f034ed0d01ab27aaef9b5137dcdcbc548951b1 /users/badger
parent410d09675a58f1890c24068066bb8eace21c2416 (diff)
downloadqmk_firmware-f650b03fb77530eb6aa7eab541f6a28c98e0ced6.tar.gz
qmk_firmware-f650b03fb77530eb6aa7eab541f6a28c98e0ced6.zip
[Keymap] Badger keymaps/userspace (#10239)
* Badger keymaps * bug fix - linter * code review feedback and ortholinear bugs * cleanup * backing out suspect bug after doing additional research * code review feedback * code review feedback * changing default badger keymap and small bugfix
Diffstat (limited to 'users/badger')
-rw-r--r--users/badger/README.md31
-rw-r--r--users/badger/badger.c49
-rw-r--r--users/badger/badger.h109
-rw-r--r--users/badger/ortho.c151
-rw-r--r--users/badger/ortho.h58
-rw-r--r--users/badger/rules.mk2
6 files changed, 400 insertions, 0 deletions
diff --git a/users/badger/README.md b/users/badger/README.md
new file mode 100644
index 000000000..fca1028a5
--- /dev/null
+++ b/users/badger/README.md
@@ -0,0 +1,31 @@
1# A multi-OS keyboard layout with support for both Linux (KDE) and MacOS-specific QWERTY layouts for many 60-ish% keyboards (
2
3## Author: [BlueTufa](https://github.com/BlueTufa)
4
5> Supported Keyboards: 1up RGB and HTE, Clueboard 66, dztech 60 RGB, and partial support for Preonic and Planck ortholinear keyboards.
6
7## Layouts
8
9### QWERTY
10Default layer: Standard QWERTY layer with CAPS lock mapped to ESC. ESC is a Layer toggle, when held down it maps to KDE-specific MOVE layer. Dedicated Function key for ADJUST layer. I also take advantage of the AG_SWAP when using this keyboard on Linux, which swaps between ALT and GUI on both sides.
11
12Mac layer: Mostly the same as the default layer, except that the ESC key maps to a MacOS specific set of MOVE layer shortcuts. These leverage a piece of software called Rectangle, which makes up for some of the tiling shortcomings of MacOS.
13
14### MOVE layer
15OS-specific convenience shortcuts. Macros are defined to make it easier to adapt these to other operating systems. The macros also help maintain the spacing that helps with the readability of the layers in source control.
16
17The main goal of the MOVE layer is to manage window move and resize, and jump to a specific virtual desktop. The other function is to expose VIM-style move keys as arrow keys to other applications. Some keys from ADJUST layer are also redefined here.
18
19Care was taken to keep the tiling and virtual desktop shortcuts as similar as possible between Linux and MacOS in this MOVE layer. The most notable difference is that I haven't found a good way to do corner tiling in Linux the way that it's supported in MacOS Rectangle.
20
21REMINDER: The 9-key left-hand pattern requires the installation of the MacOS rectangle app:
22
23```bash
24brew cask install rectangle
25```
26
27### ADJUST layer
28Access to function keys as well as media controls and keyboard settings. Some useful OS action keys are defined here as well.
29
30### Config layer
31Access to Quantum keyboard controls as well as RGB configuration. If audio is supported it would belong in this layer as well.
diff --git a/users/badger/badger.c b/users/badger/badger.c
new file mode 100644
index 000000000..455184061
--- /dev/null
+++ b/users/badger/badger.c
@@ -0,0 +1,49 @@
1/*
2Copyright 2020 Dan White <opensource@bluetufa.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12You should have received a copy of the GNU General Public License
13along with this program. If not, see <http://www.gnu.org/licenses/>.
14*/
15#include "badger.h"
16
17bool _capsLockState;
18
19__attribute__ ((weak))
20void keyboard_post_init_user(void) {
21 _capsLockState = false;
22}
23
24__attribute__ ((weak))
25bool process_record_user(uint16_t keycode, keyrecord_t *record) {
26 switch (keycode) {
27 case CS_RIGHT:
28 if (record->event.pressed) {
29 SEND_STRING(SS_LALT(SS_TAP(X_B)SS_TAP(X_ENTER)));
30 return false;
31 }
32 break;
33 case CS_DOWN:
34 if (record->event.pressed) {
35 SEND_STRING(SS_LALT(SS_TAP(X_V)SS_TAP(X_ENTER)));
36 return false;
37 }
38 break;
39 case KC_CAPS:
40 if (record->event.pressed) {
41 _capsLockState = !_capsLockState;
42 return true;
43 }
44 break;
45 default:
46 return true;
47 }
48 return true;
49}
diff --git a/users/badger/badger.h b/users/badger/badger.h
new file mode 100644
index 000000000..bb2dcd0bd
--- /dev/null
+++ b/users/badger/badger.h
@@ -0,0 +1,109 @@
1/*
2Copyright 2020 Dan White <opensource@bluetufa.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12You should have received a copy of the GNU General Public License
13along with this program. If not, see <http://www.gnu.org/licenses/>.
14*/
15#pragma once
16
17#include QMK_KEYBOARD_H
18
19enum layers {
20 _QWERTY_MAC,
21 _MOVE_MAC,
22 _QWERTY_LINUX,
23 _MOVE_LINUX,
24 _ADJUST,
25 _CONFIG
26};
27
28enum CustomKeys {
29 CS_RIGHT = SAFE_RANGE,
30 CS_DOWN
31};
32
33#define OS_POP LCTL(KC_F10)
34#define MAC_POP LCTL(KC_UP)
35#define MAC_FRC LGUI(LALT(KC_ESC))
36#define OS_COPY LSFT(LCTL(KC_C))
37#define OS_PAST LSFT(LCTL(KC_V))
38#define MAC_PST LGUI(KC_V)
39#define MAC_CPY LGUI(KC_C)
40#define KC_BACK LCTL(LSFT(KC_LBRC))
41#define KC_NEXT LCTL(LSFT(KC_RBRC))
42
43#define MOVE LT(_MOVE_LINUX, KC_ESC)
44#define MOVE_MAC LT(_MOVE_MAC, KC_ESC)
45#define ADJUST MO(_ADJUST)
46#define CFG_MAC LT(_CONFIG, MAC_POP)
47#define CFG_LNX LT(_CONFIG, OS_POP)
48
49#define WD_BACK LALT(KC_LEFT)
50#define WD_FRWD LALT(KC_RIGHT)
51
52#define VD_1 LCTL(KC_F1)
53#define VD_2 LCTL(KC_F2)
54#define VD_3 LCTL(KC_F3)
55
56#define WM_UH LGUI(KC_UP)
57#define WM_BH LGUI(KC_DOWN)
58#define WM_LH LGUI(KC_LEFT)
59#define WM_RH LGUI(KC_RIGHT)
60#define WM_MAX LGUI(KC_PGUP)
61
62#define CM_RIGHT LGUI(KC_D)
63#define CM_DOWN LGUI(LSFT(KC_D))
64
65/* THESE are not defaults in KDE and must be set manually */
66#define WM_VD1 HYPR(KC_1)
67#define WM_VD2 HYPR(KC_2)
68#define WM_VD3 HYPR(KC_3)
69
70/* IntelliJ / JetBrains shortcuts with Mac keymap */
71#define IJ_BACK LGUI(LALT(KC_LEFT))
72#define IJ_FWD LGUI(LALT(KC_RIGHT))
73#define IJ_UP LGUI(LALT(KC_UP))
74#define IJ_DOWN LGUI(LALT(KC_DOWN))
75#define IJ_IMPL LGUI(LALT(KC_B))
76#define IJ_DECL LGUI(KC_B)
77#define IJ_REN LSFT(KC_F6)
78#define IJ_USAG LALT(KC_F7)
79#define IJ_RUN KC_F9
80#define IJ_STEP KC_F8
81#define IJ_INTO LSFT(KC_F7)
82#define IJ_OUT LSFT(KC_F8)
83#define IJ_STOP LGUI(KC_F2)
84#define IJ_IMPS LCTL(LALT(LSFT(KC_EQUAL)))
85#define IJ_IMPH LCTL(LALT(LSFT(KC_MINUS)))
86#define IJ_TOP LGUI(KC_HOME)
87#define IJ_BOTT LGUI(KC_END)
88#define IJ_FIND LGUI(LSFT(KC_F))
89
90/* MacOS virtual desktop shortcuts */
91#define M_VD1 LCTL(KC_1)
92#define M_VD2 LCTL(KC_2)
93#define M_VD3 LCTL(KC_3)
94
95/* rectangle shortcuts */
96#define MM_ULCN LCTL(LGUI(KC_LEFT))
97#define MM_URCN LCTL(LGUI(KC_RIGHT))
98#define MM_LLCN LCTL(LSFT(LGUI(KC_LEFT)))
99#define MM_LRCN LCTL(LSFT(LGUI(KC_RIGHT)))
100#define MM_MAX LALT(LGUI(KC_F))
101#define MM_LH HYPR(KC_LBRC)
102#define MM_RH HYPR(KC_RBRC)
103#define MM_UH LALT(LGUI(KC_UP))
104#define MM_BH LALT(LGUI(KC_DOWN))
105#define MM_LEFT LCTL(LALT(LGUI(KC_LEFT)))
106#define MM_RGHT LCTL(LALT(LGUI(KC_RIGHT)))
107
108#define DF_1 DF(_QWERTY_MAC)
109#define DF_2 DF(_QWERTY_LINUX)
diff --git a/users/badger/ortho.c b/users/badger/ortho.c
new file mode 100644
index 000000000..ff84e1706
--- /dev/null
+++ b/users/badger/ortho.c
@@ -0,0 +1,151 @@
1/*
2Copyright 2020 Dan White <opensource@bluetufa.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12You should have received a copy of the GNU General Public License
13along with this program. If not, see <http://www.gnu.org/licenses/>.
14*/
15#include "ortho.h"
16#include "badger.h"
17
18int _currentLayer;
19bool _capsLock;
20
21#ifdef AUDIO_ENABLE
22float capsOnSong[][2] = SONG(CAPS_ON);
23float capsOffSong[][2] = SONG(CAPS_OFF);
24float defaultLayerSong[][2] = SONG(QWERTY_LAYER_SONG);
25float moveLayerSong[][2] = SONG(MOVE_LAYER_SONG);
26float macLayerSong[][2] = SONG(MAC_LAYER_SONG);
27float raiseLayerSong[][2] = SONG(RAISE_LAYER_SONG);
28float lowerLayerSong[][2] = SONG(LOWER_LAYER_SONG);
29float agSwapSong[][2] = SONG(LONG_AG_SWAP);
30float agNormSong[][2] = SONG(LONG_AG_NORM);
31#endif
32
33__attribute__ ((weak))
34void keyboard_post_init_user(void) {
35 _capsLock = false;
36 _currentLayer = _QWERTY_MAC_ORTHO;
37 layer_on(_currentLayer);
38}
39
40__attribute__ ((weak))
41bool process_record_user(uint16_t keycode, keyrecord_t *record) {
42 dprintf("Key event recorded. KEYCODE: %u , event: %u\n", keycode, record->event.pressed);
43 switch (keycode) {
44 case CS_RIGHT:
45 if (record->event.pressed) {
46 SEND_STRING(SS_LALT(SS_TAP(X_B)SS_TAP(X_ENTER)));
47 return false;
48 }
49 break;
50 case CS_DOWN:
51 if (record->event.pressed) {
52 SEND_STRING(SS_LALT(SS_TAP(X_V)SS_TAP(X_ENTER)));
53 return false;
54 }
55 break;
56 case KC_CAPS:
57 if (record->event.pressed) {
58 dprintf("CAPS_LOCK state: %u\n", _capsLock);
59 _capsLock = !_capsLock;
60 #ifdef AUDIO_ENABLE
61 _capsLock ? PLAY_SONG(capsOnSong) : PLAY_SONG(capsOffSong);
62 #endif
63 return true;
64 }
65 break;
66 case AG_SWAP:
67 #ifdef AUDIO_ENABLE
68 PLAY_SONG(agSwapSong);
69 #endif
70 return true;
71 break;
72 case AG_NORM:
73 #ifdef AUDIO_ENABLE
74 PLAY_SONG(agNormSong);
75 #endif
76 return true;
77 break;
78 case KC_MAC2:
79 if (record->event.pressed) {
80 SEND_STRING("ll\n");
81 return false;
82 }
83 break;
84 case KC_MAC1:
85 if (record->event.pressed) {
86 SEND_STRING("open https://www.reddit.com/r/mechanicalkeyboards\n");
87 return false;
88 }
89 break;
90 case KC_FIRST:
91 if (record->event.pressed) {
92 // don't turn off the QWERTY layer
93 if (_currentLayer != _QWERTY_MAC_ORTHO) {
94 layer_off(_currentLayer);
95 }
96 _currentLayer = _QWERTY_MAC_ORTHO;
97 layer_on(_currentLayer);
98 playSongForLayer(_currentLayer);
99 return false;
100 }
101 break;
102 case KC_LYRC:
103 if (record->event.pressed) {
104 dprintf("LYR CYCLE pressed %u, CURRENT_LAYER: %u\n", keycode, _currentLayer);
105 // don't turn off the QWERTY layer or the ADJUST layer
106 if (_currentLayer != _QWERTY_MAC_ORTHO) {
107 layer_off(_currentLayer);
108 }
109 // don't lock the ADJUST layer
110 // since this key is accessible via the ADJUST
111 // layer, as it will require tricky state management
112 if (++_currentLayer == _ADJUST_ORTHO) {
113 _currentLayer = _QWERTY_MAC_ORTHO;
114 } else {
115 layer_on(_currentLayer);
116 }
117
118 playSongForLayer(_currentLayer);
119 return false;
120 }
121 break;
122 }
123 return true;
124}
125
126void playSongForLayer(int currentLayer) {
127 #ifdef AUDIO_ENABLE
128 switch (currentLayer) {
129 case _QWERTY_LINUX:
130 PLAY_SONG(defaultLayerSong);
131 break;
132 case _MOVE_LINUX:
133 PLAY_SONG(moveLayerSong);
134 break;
135 case _QWERTY_MAC:
136 PLAY_SONG(macLayerSong);
137 break;
138 case _MOVE_MAC:
139 PLAY_SONG(moveLayerSong);
140 break;
141 case _RAISE:
142 PLAY_SONG(raiseLayerSong);
143 break;
144 case _LOWER:
145 PLAY_SONG(lowerLayerSong);
146 break;
147 default:
148 break;
149 }
150 #endif
151} \ No newline at end of file
diff --git a/users/badger/ortho.h b/users/badger/ortho.h
new file mode 100644
index 000000000..207f2e282
--- /dev/null
+++ b/users/badger/ortho.h
@@ -0,0 +1,58 @@
1/*
2Copyright 2020 Dan White <opensource@bluetufa.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12You should have received a copy of the GNU General Public License
13along with this program. If not, see <http://www.gnu.org/licenses/>.
14*/
15#pragma once
16
17#include "badger.h"
18
19enum OrthoLayers {
20 _QWERTY_MAC_ORTHO,
21 _MOVE_MAC_ORTHO,
22 _QWERTY_LINUX_ORTHO,
23 _MOVE_LINUX_ORTHO,
24 _RAISE,
25 _LOWER,
26 _ADJUST_ORTHO
27};
28
29enum OrthoKeys {
30 KC_MAC1 = CS_DOWN + 1,
31 KC_MAC2,
32 KC_LYRC,
33 KC_FIRST
34};
35
36#define P_ADJ LT(_ADJUST_ORTHO, KC_BSPC)
37#define RAISE MO(_RAISE)
38#define LOWER MO(_LOWER)
39#define MOMAC LT(_MOVE_MAC_ORTHO, KC_ESC)
40#define MOLNX LT(_MOVE_LINUX_ORTHO, KC_ESC)
41
42void playSongForLayer(int currentLayer);
43
44#ifdef AUDIO_ENABLE
45#define QWERTY_LAYER_SONG H__NOTE(_G6), H__NOTE(_D6), Q__NOTE(_A5), Q__NOTE(_E5),
46#define MAC_LAYER_SONG H__NOTE(_E5), H__NOTE(_A5), Q__NOTE(_D6), Q__NOTE(_G6), \
47 ED_NOTE(_E7), E__NOTE(_CS7), E__NOTE(_E6), E__NOTE(_A6), M__NOTE(_CS7, 20),
48#define LONG_AG_SWAP Q__NOTE(_G5), Q__NOTE(_D6), Q__NOTE(_A6), Q__NOTE(_E7), \
49 SD_NOTE(_B5), SD_NOTE(_A5), SD_NOTE(_B5), SD_NOTE(_A5),
50#define LONG_AG_NORM Q__NOTE(_DS4), Q__NOTE(_DS4), B__NOTE(_C5),
51#define MOVE_LAYER_SONG E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), ED_NOTE(_E7), \
52 S__NOTE(_REST), ED_NOTE(_GS7),
53#define RAISE_LAYER_SONG W__NOTE(_BF5), Q__NOTE(_A5), W__NOTE(_BF5), Q__NOTE(_A5), W__NOTE(_E6), Q__NOTE(_B5),
54#define LOWER_LAYER_SONG Q__NOTE(_DS4), E__NOTE(_DS4), E__NOTE(_DS6), Q__NOTE(_DS5), \
55 E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_E5), E__NOTE(_E5), E__NOTE(_DS6), Q__NOTE(_DS5),
56#define CAPS_ON W__NOTE(_E5), Q__NOTE(_BF5), W__NOTE(_E5), Q__NOTE(_BF5), W__NOTE(_E5), Q__NOTE(_BF5),
57#define CAPS_OFF W__NOTE(_E5), Q__NOTE(_BF5),
58#endif
diff --git a/users/badger/rules.mk b/users/badger/rules.mk
new file mode 100644
index 000000000..4f1507b8f
--- /dev/null
+++ b/users/badger/rules.mk
@@ -0,0 +1,2 @@
1SRC += badger.c
2SRC += ortho.c