]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - keyboard/planck/extended_keymap_common.c
Update for Atomic PCB Rev 0
[qmk_firmware.git] / keyboard / planck / extended_keymap_common.c
index 387ad43d3568f1c82cb6e112a06a88643b06a64a..841b24943123c965b7776c4bf4f57039e2831896 100644 (file)
@@ -22,6 +22,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "action.h"
 #include "action_macro.h"
 #include "debug.h"
+#include "backlight.h"
 
 
 static action_t keycode_to_action(uint16_t keycode);
@@ -30,16 +31,46 @@ static action_t keycode_to_action(uint16_t keycode);
 /* converts key to action */
 action_t action_for_key(uint8_t layer, keypos_t key)
 {
+       // 16bit keycodes - important
     uint16_t keycode = keymap_key_to_keycode(layer, key);
 
-    // Handle mods in keymap
-    if (keycode > 0x00FF && keycode < 0x2000) {
+    if (keycode >= 0x0100 && keycode < 0x2000) {
+       // Has a modifier
        action_t action;
+       // Split it up
        action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF);
        return action;
-       } else if (keycode > 0x1FFF && keycode < 0x3000) {
+       } else if (keycode >= 0x2000 && keycode < 0x3000) {
+               // Is a shortcut for function layer, pull last 12bits
         return keymap_func_to_action(keycode & 0xFFF);
-       }
+       } else if (keycode >= 0x3000 && keycode < 0x4000) {
+       action_t action;
+       action.code = ACTION_MACRO(keycode & 0xFF);
+       return action;
+       } else if (keycode >= BL_0 & keycode <= BL_15) {
+        action_t action;
+        action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F);
+        return action;
+    } else if (keycode == BL_DEC) {
+        action_t action;
+        action.code = ACTION_BACKLIGHT_DECREASE();
+        return action;
+    } else if (keycode == BL_INC) {
+        action_t action;
+        action.code = ACTION_BACKLIGHT_INCREASE();
+        return action;
+    } else if (keycode == BL_TOGG) {
+        action_t action;
+        action.code = ACTION_BACKLIGHT_TOGGLE();
+        return action;
+    } else if (keycode == BL_STEP) {
+        action_t action;
+        action.code = ACTION_BACKLIGHT_STEP();
+        return action;
+    } else if (keycode == RESET) {
+        bootloader_jump();
+        return;
+    }
 
     switch (keycode) {
         case KC_FN0 ... KC_FN31:
@@ -160,9 +191,7 @@ static action_t keycode_to_action(uint16_t keycode)
 /* translates key to keycode */
 uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
 {
-    // return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
-    // This limits it to a byte
-
+       // Read entire word (16bits)
     return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
 }
 
@@ -172,8 +201,8 @@ action_t keymap_fn_to_action(uint16_t keycode)
     return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
 }
 
-/* translates Fn keycode to action */
 action_t keymap_func_to_action(uint16_t keycode)
 {
+       // For FUNC without 8bit limit
     return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) };
-}
\ No newline at end of file
+}