summaryrefslogtreecommitdiff
path: root/keyboards/a_dux/keymaps/jcmkk3
diff options
context:
space:
mode:
authorAlbert Engelbrecht <me@albertengelbrecht.com>2021-09-24 02:30:52 -0500
committerGitHub <noreply@github.com>2021-09-24 00:30:52 -0700
commit77bb907feeb17f5a97544276d8a2e1b9cb512038 (patch)
tree3e475f505daabfd4a47fbbcad93672ca2e4aa5d4 /keyboards/a_dux/keymaps/jcmkk3
parentc6f92e37aad673e9f6bc7694d5f8829bbb8b87de (diff)
[Keyboard] Added A. Dux keyboard configurations (#14320)
Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'keyboards/a_dux/keymaps/jcmkk3')
-rw-r--r--keyboards/a_dux/keymaps/jcmkk3/keymap.c130
-rw-r--r--keyboards/a_dux/keymaps/jcmkk3/oneshot.c72
-rw-r--r--keyboards/a_dux/keymaps/jcmkk3/oneshot.h46
-rw-r--r--keyboards/a_dux/keymaps/jcmkk3/rules.mk1
4 files changed, 249 insertions, 0 deletions
diff --git a/keyboards/a_dux/keymaps/jcmkk3/keymap.c b/keyboards/a_dux/keymaps/jcmkk3/keymap.c
new file mode 100644
index 0000000000..608e0c522e
--- /dev/null
+++ b/keyboards/a_dux/keymaps/jcmkk3/keymap.c
@@ -0,0 +1,130 @@
+/* Copyright 2021 @jcmkk3
+ *
+ * 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 QMK_KEYBOARD_H
+
+#include "oneshot.h"
+
+#define LA_UPP OSL(UPP)
+#define LA_SYM OSL(SYM)
+#define LA_NAV MO(NAV)
+
+enum layers {
+ DEF,
+ UPP,
+ SYM,
+ NAV,
+ NUM,
+};
+
+enum keycodes {
+ // Custom oneshot mod implementation with no timers.
+ OS_SHFT = SAFE_RANGE,
+ OS_CTRL,
+ OS_ALT,
+ OS_GUI,
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [DEF] = LAYOUT(
+ KC_Y, KC_C, KC_L, KC_M, KC_K, KC_Z, KC_F, KC_U, KC_QUOT, KC_DQUO,
+ KC_I, KC_S, KC_R, KC_T, KC_G, KC_P, KC_N, KC_E, KC_A, KC_O,
+ KC_Q, KC_V, KC_W, KC_D, KC_J, KC_B, KC_H, KC_COMM, KC_DOT, KC_X,
+ LA_NAV, KC_SPC, LA_UPP, LA_SYM
+ ),
+
+ [UPP] = LAYOUT(
+ S(KC_Y), S(KC_C), S(KC_L), S(KC_M), S(KC_K), S(KC_Z), S(KC_F), S(KC_U), KC_EXLM, KC_QUES,
+ S(KC_I), S(KC_S), S(KC_R), S(KC_T), S(KC_G), S(KC_P), S(KC_N), S(KC_E), S(KC_A), S(KC_O),
+ S(KC_Q), S(KC_V), S(KC_W), S(KC_D), S(KC_J), S(KC_B), S(KC_H), KC_SCLN, KC_COLN, S(KC_X),
+ _______, _______, _______, _______
+ ),
+
+ [SYM] = LAYOUT(
+ KC_LABK, KC_LCBR, KC_LBRC, KC_LPRN, KC_CIRC, KC_DLR, KC_RPRN, KC_RBRC, KC_RCBR, KC_RABK,
+ KC_HASH, KC_UNDS, KC_EQL, KC_MINS, KC_PLUS, KC_AMPR, OS_CTRL, OS_SHFT, OS_ALT, OS_GUI,
+ KC_PERC, KC_GRV, KC_TILD, KC_SLSH, KC_ASTR, KC_PIPE, KC_BSLS, KC_SCLN, KC_COLN, KC_AT,
+ _______, _______, _______, _______
+ ),
+
+ [NAV] = LAYOUT(
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_TAB, KC_UP, KC_ENT, KC_DEL,
+ OS_GUI, OS_ALT, OS_SHFT, OS_CTRL, XXXXXXX, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END,
+ C(KC_Z), C(KC_X), C(KC_C), C(KC_V), XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ _______, _______, KC_BSPC, _______
+ ),
+
+ [NUM] = LAYOUT(
+ KC_7, KC_5, KC_3, KC_1, KC_9, KC_8, KC_0, KC_2, KC_4, KC_6,
+ OS_GUI, OS_ALT, OS_SHFT, OS_CTRL, XXXXXXX, XXXXXXX, OS_CTRL, OS_SHFT, OS_ALT, OS_GUI,
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_MINS, XXXXXXX, XXXXXXX, XXXXXXX, KC_COMM, KC_DOT, KC_SLSH,
+ _______, _______, KC_BSPC, _______
+ ),
+};
+
+bool is_oneshot_cancel_key(uint16_t keycode) {
+ switch (keycode) {
+ case LA_SYM:
+ case LA_NAV:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool is_oneshot_ignored_key(uint16_t keycode) {
+ switch (keycode) {
+ case LA_SYM:
+ case LA_NAV:
+ case KC_LSFT:
+ case OS_SHFT:
+ case OS_CTRL:
+ case OS_ALT:
+ case OS_GUI:
+ return true;
+ default:
+ return false;
+ }
+}
+
+oneshot_state os_shft_state = os_up_unqueued;
+oneshot_state os_ctrl_state = os_up_unqueued;
+oneshot_state os_alt_state = os_up_unqueued;
+oneshot_state os_gui_state = os_up_unqueued;
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ update_oneshot(
+ &os_shft_state, KC_LSFT, OS_SHFT,
+ keycode, record
+ );
+ update_oneshot(
+ &os_ctrl_state, KC_LCTL, OS_CTRL,
+ keycode, record
+ );
+ update_oneshot(
+ &os_alt_state, KC_LALT, OS_ALT,
+ keycode, record
+ );
+ update_oneshot(
+ &os_gui_state, KC_LGUI, OS_GUI,
+ keycode, record
+ );
+
+ return true;
+}
+
+layer_state_t layer_state_set_user(layer_state_t state) {
+ return update_tri_layer_state(state, SYM, NAV, NUM);
+}
diff --git a/keyboards/a_dux/keymaps/jcmkk3/oneshot.c b/keyboards/a_dux/keymaps/jcmkk3/oneshot.c
new file mode 100644
index 0000000000..e84b5a7b1d
--- /dev/null
+++ b/keyboards/a_dux/keymaps/jcmkk3/oneshot.c
@@ -0,0 +1,72 @@
+/* Copyright 2021 @jcmkk3
+ *
+ * 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 "oneshot.h"
+
+void update_oneshot(
+ oneshot_state *state,
+ uint16_t mod,
+ uint16_t trigger,
+ uint16_t keycode,
+ keyrecord_t *record
+) {
+ if (keycode == trigger) {
+ if (record->event.pressed) {
+ // Trigger keydown
+ if (*state == os_up_unqueued) {
+ register_code(mod);
+ }
+ *state = os_down_unused;
+ } else {
+ // Trigger keyup
+ switch (*state) {
+ case os_down_unused:
+ // If we didn't use the mod while trigger was held, queue it.
+ *state = os_up_queued;
+ break;
+ case os_down_used:
+ // If we did use the mod while trigger was held, unregister it.
+ *state = os_up_unqueued;
+ unregister_code(mod);
+ break;
+ default:
+ break;
+ }
+ }
+ } else {
+ if (record->event.pressed) {
+ if (is_oneshot_cancel_key(keycode) && *state != os_up_unqueued) {
+ // Cancel oneshot on designated cancel keydown.
+ *state = os_up_unqueued;
+ unregister_code(mod);
+ }
+ } else {
+ if (!is_oneshot_ignored_key(keycode)) {
+ // On non-ignored keyup, consider the oneshot used.
+ switch (*state) {
+ case os_down_unused:
+ *state = os_down_used;
+ break;
+ case os_up_queued:
+ *state = os_up_unqueued;
+ unregister_code(mod);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/keyboards/a_dux/keymaps/jcmkk3/oneshot.h b/keyboards/a_dux/keymaps/jcmkk3/oneshot.h
new file mode 100644
index 0000000000..b88e68d1d5
--- /dev/null
+++ b/keyboards/a_dux/keymaps/jcmkk3/oneshot.h
@@ -0,0 +1,46 @@
+/* Copyright 2021 @jcmkk3
+ *
+ * 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 QMK_KEYBOARD_H
+
+// Represents the four states a oneshot key can be in
+typedef enum {
+ os_up_unqueued,
+ os_up_queued,
+ os_down_unused,
+ os_down_used,
+} oneshot_state;
+
+// Custom oneshot mod implementation that doesn't rely on timers. If a mod is
+// used while it is held it will be unregistered on keyup as normal, otherwise
+// it will be queued and only released after the next non-mod keyup.
+void update_oneshot(
+ oneshot_state *state,
+ uint16_t mod,
+ uint16_t trigger,
+ uint16_t keycode,
+ keyrecord_t *record
+);
+
+// To be implemented by the consumer. Defines keys to cancel oneshot mods.
+bool is_oneshot_cancel_key(uint16_t keycode);
+
+// To be implemented by the consumer. Defines keys to ignore when determining
+// whether a oneshot mod has been used. Setting this to modifiers and layer
+// change keys allows stacking multiple oneshot modifiers, and carrying them
+// between layers.
+bool is_oneshot_ignored_key(uint16_t keycode);
diff --git a/keyboards/a_dux/keymaps/jcmkk3/rules.mk b/keyboards/a_dux/keymaps/jcmkk3/rules.mk
new file mode 100644
index 0000000000..b7dcd87b1e
--- /dev/null
+++ b/keyboards/a_dux/keymaps/jcmkk3/rules.mk
@@ -0,0 +1 @@
+SRC += oneshot.c