Jelajahi Sumber

Merge branch 'master' of https://github.com/jackhumbert/qmk_firmware

Stephan Bösebeck 9 tahun lalu
induk
melakukan
0befb25739

+ 21 - 0
README.md

@@ -98,6 +98,27 @@ We've added shortcuts to make common modifier/tap (mod-tap) mappings more compac
 
 `DF(layer)` - sets default layer to *layer*. The default layer is the one at the "bottom" of the layer stack - the ultimate fallback layer. This currently does not persist over power loss. When you plug the keyboard back in, layer 0 will always be the default. It is theoretically possible to work around that, but that's not what `DF` does.
 
+### Prevent stuck modifiers
+
+Consider the following scenario:
+
+1. Layer 0 has a key defined as Shift.
+2. The same key is defined on layer 1 as the letter A.
+3. User presses Shift.
+4. User switches to layer 1 for whatever reason.
+5. User releases Shift, or rather the letter A.
+6. User switches back to layer 0.
+
+Shift was actually never released and is still considered pressed.
+
+If such situation bothers you add this to your `config.h`:
+
+    #define PREVENT_STUCK_MODIFIERS
+
+This option uses 5 bytes of memory per every 8 keys on the keyboard
+rounded up (5 bits per key). For example on Planck (48 keys) it uses
+(48/8)\*5 = 30 bytes.
+
 ### Remember: These are just aliases
 
 These functions work the same way that their `ACTION_*` functions do - they're just quick aliases. To dig into all of the tmk ACTION_* functions, please see the [TMK documentation](https://github.com/jackhumbert/qmk_firmware/blob/master/tmk_core/doc/keymap.md#2-action).

+ 238 - 0
keyboard/ergodox_ez/keymaps/alexjj/keymap.c

@@ -0,0 +1,238 @@
+#include "ergodox_ez.h"
+#include "debug.h"
+#include "action_layer.h"
+
+#define BASE 0 // default layer
+#define SYMB 1 // symbols
+#define MDIA 2 // media keys
+#define UNIC 3 // unicode entry layer
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+/* Keymap 0: Basic layer
+ *
+ * ,--------------------------------------------------.           ,--------------------------------------------------.
+ * |   ESC  |  1!  |  2@  |  3#  |  4$  |  5%  |  6^  |           |  7&  |  8*  |  9(  |  0)  |  -_  |  +=  |  BkSp  |
+ * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
+ * | Tab    |   Q  |   W  |   E  |   R  |   T  |  {   |           |   }  |   Y  |   U  |   I  |   O  |   P  |  |\    |
+ * |--------+------+------+------+------+------|  [   |           |   ]  |------+------+------+------+------+--------|
+ * | Win    |   A  |   S  |   D  |   F  |   G  |------|           |------|   H  |   J  |   K  |   L  |  :;  |  '"    |
+ * |--------+------+------+------+------+------| Home |           | End  |------+------+------+------+------+--------|
+ * | LShift |Z/Alt |   X  |   C  |   V  |   B  |      |           |      |   N  |   M  |   ,  |   .  | Alt  | RShift |
+ * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
+ *   |LCtrl | COPY | PASTE| Left | Right|                                       | Down |  Up  |Hyper |  `~  | RCtrl |
+ *   `----------------------------------'                                       `----------------------------------'
+ *                                        ,-------------.       ,-------------.
+ *   Hyper = Ctrl+Super+Alt+Shift         | ~L3  |  F5  |       |  F2  | ~L2  |
+ *                                 ,------|------|------|       |------+------+------.
+ *                                 |      |      | PgUp |       | Ins  |      |      |
+ *                                 | Enter| BkSp |------|       |------| ~L1  |Space |
+ *                                 |      |      | PgDn |       | Del  |      |      |
+ *                                 `--------------------'       `--------------------'
+ */
+// If it accepts an argument (i.e, is a function), it doesn't need KC_.
+// Otherwise, it needs KC_*
+[BASE] = KEYMAP(  // layer 0 : default
+        // left hand
+        KC_ESC,         KC_1,         KC_2,   KC_3,   KC_4,   KC_5,   KC_6,
+        KC_TAB,         KC_Q,         KC_W,   KC_E,   KC_R,   KC_T,   KC_LBRC,
+        KC_LGUI,        KC_A,         KC_S,   KC_D,   KC_F,   KC_G,
+        KC_LSFT,        ALT_T(KC_Z),  KC_X,   KC_C,   KC_V,   KC_B,   KC_HOME,
+        KC_LCTRL,       LCTL(KC_C), LCTL(KC_V),  KC_LEFT,KC_RGHT,
+                                                      KC_FN3,  KC_F5,
+                                                              KC_PGUP,
+                                               KC_ENT,KC_BSPC,KC_PGDN,
+        // right hand
+             KC_7,     KC_8,   KC_9,   KC_0,   KC_MINS,   KC_EQL,        KC_BSPC,
+             KC_RBRC,  KC_Y,   KC_U,   KC_I,   KC_O,   KC_P,             KC_BSLS,
+                       KC_H,   KC_J,   KC_K,   KC_L,   KC_SCLN,KC_QUOT,
+             KC_END,   KC_N,   KC_M,   KC_COMM,KC_DOT, KC_SLSH,   KC_RSFT,
+             KC_DOWN,KC_UP, ALL_T(KC_NO),KC_GRV,   KC_RCTRL,
+             KC_F2, KC_FN2,
+             KC_INS,
+             KC_DELT,KC_FN1, KC_SPC
+    ),
+/* Keymap 1: Symbol Layer
+ *
+ * ,--------------------------------------------------.           ,--------------------------------------------------.
+ * |        |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |           |  F7  |  F8  |  F9  |  F10 |  F11 |  F12 |PrintScr|
+ * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
+ * |        |   !  |   @  |   {  |   }  |   |  |      |           |      |   Up |   7  |   8  |   9  |   *  |        |
+ * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+ * |        |   #  |   $  |   (  |   )  |   `  |------|           |------| Down |   4  |   5  |   6  |   +  |        |
+ * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+ * |        |   %  |   ^  |   [  |   ]  |   ~  |      |           |      |   &  |   1  |   2  |   3  |   \  |        |
+ * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
+ *   |      |   £  |      |      |      |                                       |      |    . |   0  |   =  |Alt+F4|
+ *   `----------------------------------'                                       `----------------------------------'
+ *              ↑                         ,-------------.       ,-------------.
+ *           THERE!                       |      |      |       |      |      |
+ *                                 ,------|------|------|       |------+------+------.
+ *    CAD = Ctrl + Alt + Delete    |      |      |      |       |      |      |      |
+ *                                 |      |      |------|       |------|      |      |
+ *                                 |      |      |      |       | CAD  |      |      |
+ *                                 `--------------------'       `--------------------'
+ */
+// SYMBOLS
+[SYMB] = KEYMAP(
+       // left hand
+       KC_TRNS,KC_F1,  KC_F2,  KC_F3,  KC_F4,  KC_F5,  KC_F6,
+       KC_TRNS,KC_EXLM,KC_AT,  KC_LCBR,KC_RCBR,KC_PIPE,KC_TRNS,
+       KC_TRNS,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV,
+       KC_TRNS,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,KC_TRNS,
+       KC_TRNS,M(3),KC_TRNS,KC_TRNS,KC_TRNS,
+                                       KC_TRNS,KC_TRNS,
+                                               KC_TRNS,
+                               KC_TRNS,KC_TRNS,KC_TRNS,
+       // right hand
+       KC_F7, KC_F8,   KC_F9,  KC_F10,   KC_F11,   KC_F12,  KC_PSCR,
+       KC_TRNS, KC_UP,   KC_7,   KC_8,    KC_9,    KC_ASTR, KC_TRNS,
+                KC_DOWN, KC_4,   KC_5,    KC_6,    KC_PLUS, KC_TRNS,
+       KC_TRNS, KC_AMPR, KC_1,   KC_2,    KC_3,    KC_BSLS, KC_TRNS,
+                         KC_TRNS,KC_DOT,  KC_0,    KC_EQL,  LALT(KC_F4),
+       KC_TRNS, KC_TRNS,
+       KC_TRNS,
+       LCTL(LALT(KC_DEL)), KC_TRNS, KC_TRNS
+),
+/* Keymap 2: Media and mouse keys
+ *
+ * ,--------------------------------------------------.           ,--------------------------------------------------.
+ * | TEENSY |      |      |      |      |      |      |           |      |      |      |      |      |      |        |
+ * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
+ * |        |      |      | MsUp |      |      |      |           |      |      |      |      |      |      |        |
+ * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+ * |        |      |MsLeft|MsDown|MsRght|      |------|           |------|      |      |      |      |      |  Play  |
+ * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+ * |        |      |      |      |      |      |      |           |      |      |      | Prev | Next |      |        |
+ * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
+ *   |      |      |      | Lclk | Rclk |                                       |VolDn |VolUp | Mute |      |      |
+ *   `----------------------------------'                                       `----------------------------------'
+ *                                        ,-------------.       ,-------------.
+ *                                        |      |      |       |      |      |
+ *                                 ,------|------|------|       |------+------+------.
+ *                                 |      |      |      |       |      |      |Brwser|
+ *                                 |      |      |------|       |------|      |Back  |
+ *                                 |      |      |      |       |      |      |      |
+ *                                 `--------------------'       `--------------------'
+ */
+// MEDIA AND MOUSE
+[MDIA] = KEYMAP(
+       RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+       KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS,
+       KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS,
+       KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+       KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2,
+                                           KC_TRNS, KC_TRNS,
+                                                    KC_TRNS,
+                                  KC_TRNS, KC_TRNS, KC_TRNS,
+    // right hand
+       KC_TRNS,  KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+       KC_TRNS,  KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+                 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY,
+       KC_TRNS,  KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS,
+                          KC_VOLD, KC_VOLU, KC_MUTE, KC_TRNS, KC_TRNS,
+       KC_TRNS, KC_TRNS,
+       KC_TRNS,
+       KC_TRNS, KC_TRNS, KC_WBAK
+),
+/* Keymap 3: Unicode Entry
+ *
+ * ,--------------------------------------------------.           ,--------------------------------------------------.
+ * |  Alt   |  1   |   2  |  3   |  4   |   5  |  6   |           |   7  |  8   |   9  |  0   |  +   |  +   |        |
+ * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
+ * |  Alt   |      |      |   E  |      |      |      |           |      |      |   7  |   8  |  9   |  +   |        |
+ * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+ * |  Alt   |   A  |      |   D  |   F  |      |------|           |------|      |   4  |   5  |  6   |  +   |        |
+ * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+ * |  Alt   |      |      |   C  |      |   B  |      |           |      |      |   1  |   2  |  3   |  +   |        |
+ * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
+ *   | Alt  |  Alt | Alt  |      |      |                                       |   0  |   0  |  0   |  +   |       |
+ *   `----------------------------------'                                       `----------------------------------'
+ *                                        ,-------------.       ,-------------.
+ *      WINDOWS ONLY SETUP!!              | ~L3  |      |       |      |      |
+ *                                 ,------|------|------|       |------+------+------.
+ *                                 |      |      |      |       |      |      |      |
+ *                                 |  Alt |  Alt |------|       |------|  Alt | Alt  |
+ *                                 |      |      |      |       |      |      |      |
+ *                                 `--------------------'       `--------------------'
+ */
+// If it accepts an argument (i.e, is a function), it doesn't need KC_.
+// Otherwise, it needs KC_*
+[UNIC] = KEYMAP(  // layer 3 : Unicode Entry
+        // left hand
+       KC_LALT,       KC_P1,      KC_P2,      KC_P3,  KC_P4,     KC_P5,   KC_P6,
+      KC_LALT,       KC_TRNS,    KC_TRNS,    KC_E,   KC_TRNS,   KC_TRNS, KC_TRNS,
+      KC_LALT,       KC_A,       KC_TRNS,    KC_D,   KC_F,      KC_TRNS,
+      KC_LALT,       KC_TRNS,    KC_TRNS,    KC_C,   KC_TRNS,   KC_B,    KC_TRNS,
+      KC_LALT,       KC_LALT,    KC_LALT,    KC_TRNS,KC_TRNS,
+                                                     KC_TRNS,   KC_TRNS,
+                                                                KC_TRNS,
+                                             KC_LALT,KC_LALT,   KC_TRNS,
+        // right hand
+           KC_P7,    KC_P8,     KC_P9,   KC_P0,   KC_PPLS,KC_PPLS,      KC_TRNS,
+           KC_TRNS,  KC_TRNS,   KC_P7,   KC_P8,   KC_P9,  KC_PPLS,      KC_TRNS,
+                     KC_TRNS,   KC_P4,   KC_P5,   KC_P6,  KC_PPLS,      KC_TRNS,
+           KC_TRNS,  KC_TRNS,   KC_P1,   KC_P2,   KC_P3,  KC_PPLS,      KC_TRNS,
+                                KC_P0,   KC_P0,   KC_P0,  KC_PPLS,      KC_TRNS,
+           KC_TRNS, KC_TRNS,
+           KC_TRNS,
+           KC_TRNS,KC_LALT, KC_LALT
+                  ),
+};
+
+
+const uint16_t PROGMEM fn_actions[] = {
+    [1] = ACTION_LAYER_TAP_TOGGLE(SYMB),                // FN1 - Momentary Layer 1 (Symbols)
+    [2] = ACTION_LAYER_TAP_TOGGLE(MDIA),                // FN2 - Momentary Layer 2 (Media)
+    [3] = ACTION_LAYER_TAP_TOGGLE(UNIC)                 // FN3 - Momentary Layer 3 (Unicode entry)
+}; 
+
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+  // MACRODOWN only works in this function
+      switch(id) {
+        case 0:
+        if (record->event.pressed) {
+          register_code(KC_RSFT);
+        } else {
+          unregister_code(KC_RSFT);
+        }
+      case 3: // this would trigger when you hit a key mapped as M(3)
+        if (record->event.pressed) {
+          return MACRO( I(255), D(LALT), T(P1), T(P5), T(P6), U(LALT), END  );
+      }
+        break;
+      }
+    return MACRO_NONE;
+};
+
+// Runs just one time when the keyboard initializes.
+void matrix_init_user(void) {
+
+};
+
+// Runs constantly in the background, in a loop.
+void matrix_scan_user(void) {
+
+    uint8_t layer = biton32(layer_state);
+
+    ergodox_board_led_off();
+    ergodox_right_led_1_off();
+    ergodox_right_led_2_off();
+    ergodox_right_led_3_off();
+    switch (layer) {
+      // TODO: Make this relevant to the ErgoDox EZ.
+        case 1:
+            ergodox_right_led_1_on();
+            break;
+        case 2:
+            ergodox_right_led_2_on();
+            break;
+        case 3:
+            ergodox_right_led_3_on();
+            break;
+        default:
+            // none
+            break;
+    }
+
+};

File diff ditekan karena terlalu besar
+ 1141 - 0
keyboard/ergodox_ez/keymaps/alexjj/keymap.hex


+ 179 - 0
keyboard/ergodox_ez/keymaps/alexjj/readme.md

@@ -0,0 +1,179 @@
+Englishman in New York
+===========================
+
+:microphone: :tea:
+
+About
+------
+
+After using the massdrop configurator to get the basics, I wanted to add a
+little extra to my ergodox. Notably the Hyper hotkey, the press and hold,
+and a way to have my beloved £ :pound: symbol available<sup>[1](#unicode)</sup>. Why not switch to a GB
+layout? Well the computers I use are US keymap'd and I can't always change
+that. Plus I've got used to 2/@ and 3/# and moving to the ergodox was hard
+enough. :sweat_smile:
+
+I started from the default and edited from there as I needed. It's somewhat
+similar to a regular layout, particularly R1 and shift/controls. I ended up
+with a few keys that were blank, so I'm testing out some shortcuts. Alt+F4 for
+quitting things in Windows, is one example, but I felt it was better placed on 
+the 1st layer - in case of fat fingers.
+
+Layout
+-------
+
+![Layout](rl-layout.jpg "Isn't it lovely")
+
+### Base Layer
+
+```
+,--------------------------------------------------.           ,--------------------------------------------------.
+|   ESC  |  1!  |  2@  |  3#  |  4$  |  5%  |  6^  |           |  7&  |  8*  |  9(  |  0)  |  -_  |  +=  |  BkSp  |
+|--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
+| Tab    |   Q  |   W  |   E  |   R  |   T  |  {   |           |   }  |   Y  |   U  |   I  |   O  |   P  |  |\    |
+|--------+------+------+------+------+------|  [   |           |   ]  |------+------+------+------+------+--------|
+| Win    |   A  |   S  |   D  |   F  |   G  |------|           |------|   H  |   J  |   K  |   L  |  :;  |  '"    |
+|--------+------+------+------+------+------| Home |           | End  |------+------+------+------+------+--------|
+| LShift |Z/Alt |   X  |   C  |   V  |   B  |      |           |      |   N  |   M  |   ,  |   .  | Alt  | RShift |
+`--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
+  |LCtrl | COPY | PASTE| Left | Right|                                       | Down |  Up  |Hyper |  `~  | RCtrl |
+  `----------------------------------'                                       `----------------------------------'
+                                       ,-------------.       ,-------------.
+  Hyper = Ctrl+Super+Alt+Shift         | ~L3  |  F5  |       |  F2  | ~L2  |
+                                ,------|------|------|       |------+------+------.
+                                |      |      | PgUp |       | Ins  |      |      |
+                                | Enter| BkSp |------|       |------| ~L1  |Space |
+                                |      |      | PgDn |       | Del  |      |      |
+                                `--------------------'       `--------------------'
+``` 
+
+### Symbol Layer
+
+```
+,--------------------------------------------------.           ,--------------------------------------------------.
+|        |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |           |  F7  |  F8  |  F9  |  F10 |  F11 |  F12 |PrintScr|
+|--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
+|        |   !  |   @  |   {  |   }  |   |  |      |           |      |   Up |   7  |   8  |   9  |   *  |        |
+|--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+|        |   #  |   $  |   (  |   )  |   `  |------|           |------| Down |   4  |   5  |   6  |   +  |        |
+|--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+|        |   %  |   ^  |   [  |   ]  |   ~  |      |           |      |   &  |   1  |   2  |   3  |   \  |        |
+`--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
+  |      |   £  |      |      |      |                                       |      |    . |   0  |   =  |Alt+F4|
+  `----------------------------------'                                       `----------------------------------'
+             ↑                         ,-------------.       ,-------------.
+          THERE!                       |      |      |       |      |      |
+                                ,------|------|------|       |------+------+------.
+   CAD = Ctrl + Alt + Delete    |      |      |      |       |      |      |      |
+                                |      |      |------|       |------|      |      |
+                                |      |      |      |       | CAD  |      |      |
+                                `--------------------'       `--------------------'
+```
+### Media Layer
+
+Not touched this, not used either.
+
+```
+,--------------------------------------------------.           ,--------------------------------------------------.
+| TEENSY |      |      |      |      |      |      |           |      |      |      |      |      |      |        |
+|--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
+|        |      |      | MsUp |      |      |      |           |      |      |      |      |      |      |        |
+|--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+|        |      |MsLeft|MsDown|MsRght|      |------|           |------|      |      |      |      |      |  Play  |
+|--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+|        |      |      |      |      |      |      |           |      |      |      | Prev | Next |      |        |
+`--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
+  |      |      |      | Lclk | Rclk |                                       |VolDn |VolUp | Mute |      |      |
+  `----------------------------------'                                       `----------------------------------'
+                                       ,-------------.       ,-------------.
+                                       |      |      |       |      |      |
+                                ,------|------|------|       |------+------+------.
+                                |      |      |      |       |      |      |Brwser|
+                                |      |      |------|       |------|      |Back  |
+                                |      |      |      |       |      |      |      |
+                                `--------------------'       `--------------------'
+```
+### Unicode Layer
+
+Used to enter/test unicode input on Windows. All numbers are numpad keys.
+
+```
+,--------------------------------------------------.           ,--------------------------------------------------.
+|  Alt   |  1   |   2  |  3   |  4   |   5  |  6   |           |   7  |  8   |   9  |  0   |  +   |  +   |        |
+|--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
+|  Alt   |      |      |   E  |      |      |      |           |      |      |   7  |   8  |  9   |  +   |        |
+|--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+|  Alt   |   A  |      |   D  |   F  |      |------|           |------|      |   4  |   5  |  6   |  +   |        |
+|--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
+|  Alt   |      |      |   C  |      |   B  |      |           |      |      |   1  |   2  |  3   |  +   |        |
+`--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
+  | Alt  |  Alt | Alt  |      |      |                                       |   0  |   0  |  0   |  +   |       |
+  `----------------------------------'                                       `----------------------------------'
+                                       ,-------------.       ,-------------.
+     WINDOWS ONLY SETUP!!              | ~L3  |      |       |      |      |
+                                ,------|------|------|       |------+------+------.
+                                |      |      |      |       |      |      |      |
+                                |  Alt |  Alt |------|       |------|  Alt | Alt  |
+                                |      |      |      |       |      |      |      |
+                                `--------------------'       `--------------------'
+```
+
+
+Usage
+------
+
+~L1 / L2 / L3 will momentarily switch to a layer if held and another key is pressed.
+If pressed and released will remain on layer until pressed again.
+
+### Unicode
+
+This layout is for Windows only. To enter a character Press and Hold Alt, type + and hex code then release Alt.
+
+Changelog
+-----------
+
+### [0.2.1] - 2016-04-05
+
+* Changed £ to alt code in Windows. Windows sucks at unicode.
+
+### [0.2.0] - 2016-03-27
+
+* Added unicode layer
+* Moved Copy/Paste to left hand side
+* Switched Enter and Space (again)
+* Added L3 (unicode layer) toggle
+* Removed Press and Hold for Alt on right hand size (/)
+* Swapped Volume Up/Down to match arrows
+* Tried fixing £ macro
+* Removed * in the matrix function things (upstream change)
+
+### [0.1.1] - 2016-03-23
+
+* Changed £ input to a macro
+
+
+### [0.1.0] - 2016-03-22
+
+After actually using the keyboard, I've made some changes:
+
+* Swapped Enter and Space
+* Moved backspace to thumb keys (top right still remains)
+* Added Ctrl+Alt+Delete
+* Added Teensy Reset on 2nd layer
+* Switched Up and Down
+* Changed copy/paste to be Ctrl+c and Ctrl+v as KC_COPY/PASTE didn't work (in Windows)
+* Moved ~L2 to replace +L1 after learning how the function works (notes above)
+* Hopefully fixed GBP symbol (unicode enabled in MakeFile)
+
+### [0.0.1] - 2016-03-21
+
+First version
+
+
+Issues
+-------
+
+Space for feedback and notes for future improvements
+
+----
+<sup><a name="unicode">1</a></sup>: For Windows only, and you have to edit the [registry](https://en.wikipedia.org/wiki/Unicode_input#Hexadecimal_code_input).

TEMPAT SAMPAH
keyboard/ergodox_ez/keymaps/alexjj/rl-layout.jpg


TEMPAT SAMPAH
keyboard/ergodox_ez/keymaps/ordinary/ordinary-base.png


+ 3 - 3
keyboard/ergodox_ez/keymaps/ordinary/ordinary-base.txt

@@ -1,8 +1,8 @@
 [{x:3.5},"#\n3",{x:10.5},"*\n8"],
 [{y:-0.875,x:2.5},"@\n2",{x:1},"$\n4",{x:8.5},"&\n7",{x:1},"(\n9"],
 [{y:-0.875,x:5.5},"%\n5",{c:"#ff4444"},"Esc",{x:4.5,c:"#cccccc"},"_\n\n\n\n\n\n-","^\n6"],
-[{y:-0.875,c:"#73ab6a",w:1.5},"~\n\n\n\n\n\n`",{c:"#cccccc"},"!\n1",{x:14.5},")\n0",{t:"#000000\n\n\n\n#0000ff",w:1.5},"+\n\n\n\n\n\n="],
-[{y:-0.375,x:3.5,t:"#000000"},"E",{x:10.5},"I"],
+[{y:-0.875,c:"#73ab6a",w:1.5},"~\n\n\n\n\n\n`",{c:"#cccccc"},"!\n1",{x:14.5},")\n0",{w:1.5},"+\n\n\n\n\n\n="],
+[{y:-0.375,x:3.5},"E",{x:10.5},"I"],
 [{y:-0.875,x:2.5},"W",{x:1},"R",{x:8.5},"U",{x:1},"O"],
 [{y:-0.875,x:5.5},"T",{h:1.5},"{\n\n\n\n\n\n[",{x:4.5,h:1.5},"}\n\n\n\n\n\n]","Y"],
 [{y:-0.875,c:"#73ab6a",w:1.5},"Tab",{c:"#cccccc"},"Q",{x:14.5},"P",{c:"#2277ff",fa:[0,0,0,1],w:1.5},"|\n\\\nMedia\nL2"],
@@ -14,7 +14,7 @@
 [{y:-0.75,x:3.5,c:"#cccccc"},"C",{x:10.5},"<\n,"],
 [{y:-0.875,x:2.5},"X",{x:1},"V",{x:8.5},"M",{x:1},">\n."],
 [{y:-0.875,x:5.5},"B",{x:6.5},"N"],
-[{y:-0.875,c:"#2277ff",w:1.5},"Capitals\n\n\nShift",{c:"#cccccc"},"Z\n\nCtrl",{x:14.5},"?\n/\nCtrl",{c:"#2277ff",w:1.5},"\n\nCapitals\nShift"],
+[{y:-0.875,c:"#2277ff",w:1.5},"Capitals\n\n\nShift",{c:"#cccccc"},"Z",{x:14.5},"?\n/",{c:"#2277ff",w:1.5},"\n\nCapitals\nShift"],
 [{y:-0.375,x:3.5,c:"#77aaff"},"Option\n\n\nLAlt",{x:10.5},"Option\n\n\nRAlt"],
 [{y:-0.875,x:2.5},"Hyper",{x:1},"Cmd\n\n\nSuper",{x:8.5},"Cmd\n\n\nSuper",{x:1},"Hyper"],
 [{y:-0.75,x:0.5},"Ctrl\n\n\nLCtrl","Meh",{x:14.5},"Meh","Ctrl\n\n\nRCtrl"],

File diff ditekan karena terlalu besar
+ 57 - 3
keyboard/ergodox_ez/keymaps/ordinary/readme.md


+ 1 - 5
keyboard/preonic/keymaps/default/keymap.c

@@ -60,13 +60,9 @@ const uint16_t PROGMEM fn_actions[] = {
 
 float start_up[][2] = {
   {440.0*pow(2.0,(67)/12.0), 600},
-  {0, 50},
   {440.0*pow(2.0,(64)/12.0), 400},
-  {0, 50},
   {440.0*pow(2.0,(55)/12.0), 400},
-  {0, 50},
   {440.0*pow(2.0,(60)/12.0), 400},
-  {0, 50},
   {440.0*pow(2.0,(64)/12.0), 1000},
 };
 
@@ -91,6 +87,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
 void matrix_init_user(void) {
 #ifdef AUDIO_ENABLE
     init_notes();
-    play_notes(&start_up, 9, false);
+    play_notes(&start_up, 5, false);
 #endif
 }

+ 34 - 0
keyboard/preonic/keymaps/nerdgasm/README.md

@@ -0,0 +1,34 @@
+# The Default Planck Layout
+
+    const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [_QW] = { /* Qwerty */
+      {KC_TAB,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_BSPC},
+      {KC_ESC,  KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT},
+      {KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_ENT },
+      {M(0),    KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC,  KC_SPC,  MO(_RS), KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT}
+    },
+    [_CM] = { /* Colemak */
+      {KC_TAB,  KC_Q,    KC_W,    KC_F,    KC_P,    KC_G,    KC_J,    KC_L,    KC_U,    KC_Y,    KC_SCLN, KC_BSPC},
+      {KC_ESC,  KC_A,    KC_R,    KC_S,    KC_T,    KC_D,    KC_H,    KC_N,    KC_E,    KC_I,    KC_O,    KC_QUOT},
+      {KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_K,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_ENT },
+      {M(0),    KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC,  KC_SPC,  MO(_RS), KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT}
+    },
+    [_DV] = { /* Dvorak */
+      {KC_TAB,  KC_QUOT, KC_COMM, KC_DOT,  KC_P,    KC_Y,    KC_F,    KC_G,    KC_C,    KC_R,    KC_L,    KC_BSPC},
+      {KC_ESC,  KC_A,    KC_O,    KC_E,    KC_U,    KC_I,    KC_D,    KC_H,    KC_T,    KC_N,    KC_S,    KC_SLSH},
+      {KC_LSFT, KC_SCLN, KC_Q,    KC_J,    KC_K,    KC_X,    KC_B,    KC_M,    KC_W,    KC_V,    KC_Z,    KC_ENT },
+      {M(0),    KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC,  KC_SPC,  MO(_RS), KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT}
+    },
+    [_RS] = { /* RAISE */
+      {KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC},
+      {KC_TRNS, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_MINS, KC_EQL,  KC_LBRC, KC_RBRC, KC_BSLS},
+      {KC_TRNS, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  DF(_QW), DF(_CM), DF(_DV), RESET,   KC_TRNS},
+      {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
+    },
+    [_LW] = { /* LOWER */
+      {KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC},
+      {KC_TRNS, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE},
+      {KC_TRNS, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  DF(_QW), DF(_CM), DF(_DV), RESET,   KC_TRNS},
+      {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
+    }
+    };

+ 117 - 0
keyboard/preonic/keymaps/nerdgasm/keymap.c

@@ -0,0 +1,117 @@
+// This is the canonical layout file for the Quantum project. If you want to add another keyboard,
+// this is the style you want to emulate.
+
+#include "preonic.h"
+#ifdef BACKLIGHT_ENABLE
+  #include "backlight.h"
+#endif
+
+// Each layer gets a name for readability, which is then used in the keymap matrix below.
+// The underscores don't mean anything - you can have a layer called STUFF or any other name.
+// Layer names don't all need to be of the same length, obviously, and you can also skip them
+// entirely and just use numbers.
+#define _QW 0
+#define _CM 1
+#define _DV 2
+#define _LW 3
+#define _RS 4
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[_QW] = { /* Qwerty */
+  {KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC},
+  {KC_TAB,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_BSPC},
+  {KC_ESC,  KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT},
+  {KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_ENT },
+  {M(0),    KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC,  KC_SPC,  MO(_RS), KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT}
+},
+[_CM] = { /* Colemak */
+  {KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC},
+  {KC_TAB,  KC_Q,    KC_W,    KC_F,    KC_P,    KC_G,    KC_J,    KC_L,    KC_U,    KC_Y,    KC_SCLN, KC_BSPC},
+  {KC_ESC,  KC_A,    KC_R,    KC_S,    KC_T,    KC_D,    KC_H,    KC_N,    KC_E,    KC_I,    KC_O,    KC_QUOT},
+  {KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_K,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_ENT },
+  {M(0),    KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC,  KC_SPC,  MO(_RS), KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT}
+},
+[_DV] = { /* Dvorak */
+  {KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC},
+  {KC_TAB,  KC_QUOT, KC_COMM, KC_DOT,  KC_P,    KC_Y,    KC_F,    KC_G,    KC_C,    KC_R,    KC_L,    KC_BSPC},
+  {KC_ESC,  KC_A,    KC_O,    KC_E,    KC_U,    KC_I,    KC_D,    KC_H,    KC_T,    KC_N,    KC_S,    KC_SLSH},
+  {KC_LSFT, KC_SCLN, KC_Q,    KC_J,    KC_K,    KC_X,    KC_B,    KC_M,    KC_W,    KC_V,    KC_Z,    KC_ENT },
+  {M(0),    KC_LCTL, KC_LALT, KC_LGUI, MO(_LW), KC_SPC,  KC_SPC,  MO(_RS), KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT}
+},
+[_RS] = { /* RAISE */
+  {KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC},
+  {KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC},
+  {KC_TRNS, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_MINS, KC_EQL,  KC_LBRC, KC_RBRC, KC_BSLS},
+  {KC_TRNS, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  DF(_QW), DF(_CM), DF(_DV), RESET,   KC_TRNS},
+  {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
+},
+[_LW] = { /* LOWER */
+  {KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC},
+  {KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC},
+  {KC_TRNS, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE},
+  {KC_TRNS, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  DF(_QW), DF(_CM), DF(_DV), RESET,   KC_TRNS},
+  {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
+}
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+
+};
+
+// Guitar Notes
+#define N_E 13180.5
+#define N_B 9870.8
+#define N_G 15680.0
+#define N_D 11740.7
+#define N_E 13180.5
+
+float start_up[][2] = {
+ { N_E, 500 },
+ { 0, 50 },
+ { N_E, 500 },
+ { 0, 50 },
+ { N_E, 500 },
+ { 0, 50 },
+ { N_B, 500 },
+ { 0, 50 },
+ { N_E, 1000 },
+ { 0, 50 },
+ { N_G, 1500 },
+ { 0, 50 },
+};
+
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+  // MACRODOWN only works in this function
+      switch(id) {
+        case 0:
+          if (record->event.pressed) {
+            register_code(KC_RSFT);
+            #ifdef BACKLIGHT_ENABLE
+              backlight_step();
+            #endif
+          } else {
+            unregister_code(KC_RSFT);
+          }
+        break;
+      }
+    return MACRO_NONE;
+};
+
+void matrix_init_user(void) {
+#ifdef AUDIO_ENABLE
+    init_notes();
+    play_notes(&start_up, 12, false);
+#endif
+}
+
+void process_action_user(keyrecord_t *record) {
+#ifdef AUDIO_ENABLE
+  if (record->event.pressed) {
+    float keypress[][2] = {
+      {440.0*pow(2.0,(record->event.key.col*7)/12.0), 600}
+    };
+    play_notes(&keypress, 1, false);
+  }
+#endif
+}

+ 9 - 0
keyboard/preonic/preonic.c

@@ -10,6 +10,11 @@ void matrix_scan_user(void) {
 
 };
 
+__attribute__ ((weak))
+void process_action_user(keyrecord_t *record) {
+
+};
+
 void matrix_init_kb(void) {
 	#ifdef BACKLIGHT_ENABLE
     	backlight_init_ports();
@@ -30,3 +35,7 @@ void matrix_init_kb(void) {
 void matrix_scan_kb(void) {
 	matrix_scan_user();
 };
+
+void process_action_kb(keyrecord_t *record) {
+	process_action_user(record);
+}

+ 1 - 0
keyboard/preonic/preonic.h

@@ -46,5 +46,6 @@
 
 void matrix_init_user(void);
 void matrix_scan_user(void);
+void process_action_kb(keyrecord_t *record);
 
 #endif

+ 3 - 0
quantum/audio.c

@@ -247,6 +247,9 @@ ISR(TIMER3_COMPA_vect) {
             if (note_frequency > 0) {
                 ICR3 = (int)(((double)F_CPU) / note_frequency); // Set max to the period
                 OCR3A = (int)(((double)F_CPU) / note_frequency) >> 1; // Set compare to half the period
+            } else {
+                ICR3 = 0;
+                OCR3A = 0;
             }
         #endif
 

+ 29 - 3
tmk_core/common/action.c

@@ -53,6 +53,22 @@ void action_exec(keyevent_t event)
 #endif
 }
 
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+bool disable_action_cache = false;
+
+void process_action_nocache(keyrecord_t *record)
+{
+    disable_action_cache = true;
+    process_action(record);
+    disable_action_cache = false;
+}
+#else
+void process_action_nocache(keyrecord_t *record)
+{
+    process_action(record);
+}
+#endif
+
 __attribute__ ((weak))
 void process_action_kb(keyrecord_t *record) {}
 
@@ -67,7 +83,7 @@ void process_action(keyrecord_t *record)
 
     process_action_kb(record);
 
-    action_t action = layer_switch_get_action(event.key);
+    action_t action = store_or_get_action(event.pressed, event.key);
     dprint("ACTION: "); debug_action(action);
 #ifndef NO_ACTION_LAYER
     dprint(" layer_state: "); layer_debug();
@@ -88,14 +104,24 @@ void process_action(keyrecord_t *record)
                                                                 action.key.mods<<4;
                 if (event.pressed) {
                     if (mods) {
-                        add_weak_mods(mods);
+                        if (IS_MOD(action.key.code)) {
+                            // e.g. LSFT(KC_LGUI): we don't want the LSFT to be weak as it would make it useless.
+                            // this also makes LSFT(KC_LGUI) behave exactly the same as LGUI(KC_LSFT)
+                            add_mods(mods);
+                        } else {
+                            add_weak_mods(mods);
+                        }
                         send_keyboard_report();
                     }
                     register_code(action.key.code);
                 } else {
                     unregister_code(action.key.code);
                     if (mods) {
-                        del_weak_mods(mods);
+                        if (IS_MOD(action.key.code)) {
+                            del_mods(mods);
+                        } else {
+                            del_weak_mods(mods);
+                        }
                         send_keyboard_report();
                     }
                 }

+ 4 - 0
tmk_core/common/action.h

@@ -62,6 +62,10 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
 void process_action_kb(keyrecord_t *record);
 
 /* Utilities for actions.  */
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+extern bool disable_action_cache;
+#endif
+void process_action_nocache(keyrecord_t *record);
 void process_action(keyrecord_t *record);
 void register_code(uint8_t code);
 void unregister_code(uint8_t code);

+ 71 - 6
tmk_core/common/action_layer.c

@@ -110,9 +110,71 @@ void layer_debug(void)
 }
 #endif
 
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+uint8_t source_layers_cache[MAX_LAYER_BITS][(MATRIX_ROWS * MATRIX_COLS + 7) / 8] = {0};
 
+void update_source_layers_cache(keypos_t key, uint8_t layer)
+{
+    const uint8_t key_number = key.col + (key.row * MATRIX_COLS);
+    const uint8_t storage_row = key_number / 8;
+    const uint8_t storage_bit = key_number % 8;
 
-action_t layer_switch_get_action(keypos_t key)
+    for (uint8_t bit_number = 0; bit_number < MAX_LAYER_BITS; bit_number++) {
+        source_layers_cache[bit_number][storage_row] ^=
+            (-((layer & (1U << bit_number)) != 0)
+             ^ source_layers_cache[bit_number][storage_row])
+            & (1U << storage_bit);
+    }
+}
+
+uint8_t read_source_layers_cache(keypos_t key)
+{
+    const uint8_t key_number = key.col + (key.row * MATRIX_COLS);
+    const uint8_t storage_row = key_number / 8;
+    const uint8_t storage_bit = key_number % 8;
+    uint8_t layer = 0;
+
+    for (uint8_t bit_number = 0; bit_number < MAX_LAYER_BITS; bit_number++) {
+        layer |=
+            ((source_layers_cache[bit_number][storage_row]
+              & (1U << storage_bit)) != 0)
+            << bit_number;
+    }
+
+    return layer;
+}
+#endif
+
+/*
+ * Make sure the action triggered when the key is released is the same
+ * one as the one triggered on press. It's important for the mod keys
+ * when the layer is switched after the down event but before the up
+ * event as they may get stuck otherwise.
+ */
+action_t store_or_get_action(bool pressed, keypos_t key)
+{
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+    if (disable_action_cache) {
+        return layer_switch_get_action(key);
+    }
+
+    uint8_t layer;
+
+    if (pressed) {
+        layer = layer_switch_get_layer(key);
+        update_source_layers_cache(key, layer);
+    }
+    else {
+        layer = read_source_layers_cache(key);
+    }
+    return action_for_key(layer, key);
+#else
+    return layer_switch_get_action(key);
+#endif
+}
+
+
+int8_t layer_switch_get_layer(keypos_t key)
 {
     action_t action;
     action.code = ACTION_TRANSPARENT;
@@ -124,15 +186,18 @@ action_t layer_switch_get_action(keypos_t key)
         if (layers & (1UL<<i)) {
             action = action_for_key(i, key);
             if (action.code != ACTION_TRANSPARENT) {
-                return action;
+                return i;
             }
         }
     }
     /* fall back to layer 0 */
-    action = action_for_key(0, key);
-    return action;
+    return 0;
 #else
-    action = action_for_key(biton32(default_layer_state), key);
-    return action;
+    return biton32(default_layer_state);
 #endif
 }
+
+action_t layer_switch_get_action(keypos_t key)
+{
+    return action_for_key(layer_switch_get_layer(key), key);
+}

+ 11 - 0
tmk_core/common/action_layer.h

@@ -70,6 +70,17 @@ void layer_xor(uint32_t state);
 #define layer_debug()
 #endif
 
+/* pressed actions cache */
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+/* The number of bits needed to represent the layer number: log2(32). */
+#define MAX_LAYER_BITS 5
+void update_source_layers_cache(keypos_t key, uint8_t layer);
+uint8_t read_source_layers_cache(keypos_t key);
+#endif
+action_t store_or_get_action(bool pressed, keypos_t key);
+
+/* return the topmost non-transparent layer currently associated with key */
+int8_t layer_switch_get_layer(keypos_t key);
 
 /* return action depending on current layer status */
 action_t layer_switch_get_action(keypos_t key);