]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - quantum/keymap_common.c
changing up the makefile a bit
[qmk_firmware.git] / quantum / keymap_common.c
index 5c00c0afa2216a8d9d159b821b1accff1aff8bcf..ae6cddb343c63f3752cbe4ef5bb20e1c713a6f6e 100644 (file)
@@ -19,11 +19,27 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "report.h"
 #include "keycode.h"
 #include "action_layer.h"
+#include <util/delay.h>
 #include "action.h"
 #include "action_macro.h"
 #include "debug.h"
 #include "backlight.h"
 #include "keymap_midi.h"
+#include "bootloader.h"
+
+#include <stdio.h>
+#include <inttypes.h>
+#ifdef AUDIO_ENABLE
+    #include "audio.h"
+
+    float goodbye[][2] = {
+        {440.0*pow(2.0,(67)/12.0), 400},
+        {0, 50},
+        {440.0*pow(2.0,(60)/12.0), 400},
+        {0, 50},
+        {440.0*pow(2.0,(55)/12.0), 600},
+    };
+#endif
 
 static action_t keycode_to_action(uint16_t keycode);
 
@@ -49,7 +65,7 @@ action_t action_for_key(uint8_t layer, keypos_t key)
        action.code = ACTION_MACRO(keycode & 0xFF);
        return action;
 #ifdef BACKLIGHT_ENABLE
-       } else if (keycode >= BL_0 & keycode <= BL_15) {
+       } else if (keycode >= BL_0 && keycode <= BL_15) {
         action_t action;
         action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F);
         return action;
@@ -71,14 +87,24 @@ action_t action_for_key(uint8_t layer, keypos_t key)
         return action;
 #endif
     } else if (keycode == RESET) { // RESET is 0x5000, which is why this is here
+       action_t action;
+        clear_keyboard();
+        #ifdef AUDIO_ENABLE
+            play_notes(&goodbye, 5, false);
+        #endif
+        _delay_ms(250);
+        #ifdef ATREUS_ASTAR
+            *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
+        #endif
         bootloader_jump();
-        return;
+        return action;
     } else if (keycode == DEBUG) { // DEBUG is 0x5001
       // TODO: Does this actually work?
+        action_t action;
         print("\nDEBUG: enabled.\n");
         debug_enable = true;
-        return;
-    } else if (keycode >= 0x5000 && keycode < 0x6000) { 
+        return action;
+    } else if (keycode >= 0x5000 && keycode < 0x6000) {
         // Layer movement shortcuts
         // See .h to see constraints/usage
         int type = (keycode >> 0x8) & 0xF;
@@ -101,6 +127,12 @@ action_t action_for_key(uint8_t layer, keypos_t key)
             action_t action;
             action.code = ACTION_DEFAULT_LAYER_SET(layer);
             return action;
+        } else if (type == 0x4) {
+            // Set default layer
+            int layer = keycode & 0xFF;
+            action_t action;
+            action.code = ACTION_LAYER_TOGGLE(layer);
+            return action;
         }
 #ifdef MIDI_ENABLE
     } else if (keycode >= 0x6000 && keycode < 0x7000) {
@@ -108,8 +140,16 @@ action_t action_for_key(uint8_t layer, keypos_t key)
         action.code =  ACTION_FUNCTION_OPT(keycode & 0xFF, (keycode & 0x0F00) >> 8);
         return action;
 #endif
+    } else if (keycode >= 0x7000 && keycode < 0x8000) {
+        action_t action;
+        action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
+        return action;
+    } else if (keycode >= 0x8000 && keycode < 0x9000) {
+        action_t action;
+        action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
+        return action;
 #ifdef UNICODE_ENABLE
-    } else if (keycode >= 0x8000) {
+    } else if (keycode >= 0x8000000) {
         action_t action;
         uint16_t unicode = keycode & ~(0x8000);
         action.code =  ACTION_FUNCTION_OPT(unicode & 0xFF, (unicode & 0xFF00) >> 8);