summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/keymap_common.c30
-rw-r--r--quantum/keymap_common.h28
-rw-r--r--quantum/keymap_unicode.c49
3 files changed, 61 insertions, 46 deletions
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 94588ef41c..05e0831f02 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -25,17 +25,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "debug.h"
#include "backlight.h"
#include "keymap_midi.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(uint32_t keycode);
/* converts key to action */
action_t action_for_key(uint8_t layer, keypos_t key)
{
- // 16bit keycodes - important
+ // 32bit keycodes - important
uint32_t keycode = keymap_key_to_keycode(layer, key);
- dprintln();
- dprintf("keycode: %16X", keycode);
- dprintln();
+
if (keycode >= 0x0100 && keycode < 0x2000) {
// Has a modifier
action_t action;
@@ -49,7 +60,7 @@ action_t action_for_key(uint8_t layer, keypos_t key)
} else if (keycode >= 0x3000 && keycode < 0x4000) {
// When the code starts with 3, it's an action macro.
action_t action;
- action.code = ACTION_MACRO(keycode & 0xFF);
+ action.code = (0xC000 | (keycode & 0xFF));
return action;
#ifdef BACKLIGHT_ENABLE
} else if (keycode >= BL_0 & keycode <= BL_15) {
@@ -73,13 +84,15 @@ action_t action_for_key(uint8_t layer, keypos_t key)
action.code = ACTION_BACKLIGHT_STEP();
return action;
#endif
- } else if (keycode == RESET) { // RESET is 0x5000, which is why this is here
+ } else if (keycode == RESET) { // RESET is 0x5000
clear_keyboard();
+ #ifdef AUDIO_ENABLE
+ play_notes(&goodbye, 5, false);
+ #endif
_delay_ms(250);
bootloader_jump();
return;
} else if (keycode == DEBUG) { // DEBUG is 0x5001
- // TODO: Does this actually work?
print("\nDEBUG: enabled.\n");
debug_enable = true;
return;
@@ -128,10 +141,9 @@ action_t action_for_key(uint8_t layer, keypos_t key)
action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
return action;
#ifdef UNICODE_ENABLE
- } else if (keycode >= 0x9000) {
+ } else if (keycode >= 0x0000FFFF) {
action_t action;
action.code = keycode;
- action.custom.kind = 0x8;
return action;
#endif
} else {
diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h
index 396fead332..396230d88b 100644
--- a/quantum/keymap_common.h
+++ b/quantum/keymap_common.h
@@ -62,18 +62,18 @@ extern const uint32_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];
// Ability to use mods in layouts
-#define LCTL(kc) kc | 0x0100
-#define LSFT(kc) kc | 0x0200
-#define LALT(kc) kc | 0x0400
-#define LGUI(kc) kc | 0x0800
-#define HYPR(kc) kc | 0x0F00
-#define MEH(kc) kc | 0x0700
-#define LCAG(kc) kc | 0x0D00 // Modifier Ctrl Alt and GUI
-
-#define RCTL(kc) kc | 0x1100
-#define RSFT(kc) kc | 0x1200
-#define RALT(kc) kc | 0x1400
-#define RGUI(kc) kc | 0x1800
+#define LCTL(kc) (kc | 0x0100)
+#define LSFT(kc) (kc | 0x0200)
+#define LALT(kc) (kc | 0x0400)
+#define LGUI(kc) (kc | 0x0800)
+#define HYPR(kc) (kc | 0x0F00)
+#define MEH(kc) (kc | 0x0700)
+#define LCAG(kc) (kc | 0x0D00) // Modifier Ctrl Alt and GUI
+
+#define RCTL(kc) (kc | 0x1100)
+#define RSFT(kc) (kc | 0x1200)
+#define RALT(kc) (kc | 0x1400)
+#define RGUI(kc) (kc | 0x1800)
// Aliases for shifted symbols
// Each key has a 4-letter code, and some have longer aliases too.
@@ -129,13 +129,13 @@ extern const uint16_t fn_actions[];
#define KC_DELT KC_DELETE // Del key (four letter code)
// Alias for function layers than expand past FN31
-#define FUNC(kc) kc | 0x2000
+#define FUNC(kc) (kc | 0x2000)
// Aliases
#define S(kc) LSFT(kc)
#define F(kc) FUNC(kc)
-#define M(kc) kc | 0x3000
+#define M(kc) (kc | 0x00003000)
#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
diff --git a/quantum/keymap_unicode.c b/quantum/keymap_unicode.c
index 3a480878b7..cda167d2c1 100644
--- a/quantum/keymap_unicode.c
+++ b/quantum/keymap_unicode.c
@@ -16,6 +16,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "keymap_common.h"
+#include <math.h>
+
+#define UNICODE_OSX /* Mac with Unicode Hex Input */
uint16_t hextokeycode(int hex) {
if (hex == 0x0) {
@@ -29,33 +32,33 @@ uint16_t hextokeycode(int hex) {
void action_custom(keyrecord_t *record, uint32_t code)
{
-
// For more info on how this works per OS, see here: https://en.wikipedia.org/wiki/Unicode_input#Hexadecimal_code_input
if (record->event.pressed) {
+ #ifdef UNICODE_OSX
+ register_code(KC_LALT);
+ #endif
+
uint32_t unicode = code;
- // register_code(KC_LALT);
-
- register_code(hextokeycode((unicode & 0xF000) >> 12));
- unregister_code(hextokeycode((unicode & 0xF000) >> 12));
- register_code(hextokeycode((unicode & 0x0F00) >> 8));
- unregister_code(hextokeycode((unicode & 0x0F00) >> 8));
- register_code(hextokeycode((unicode & 0x00F0) >> 4));
- unregister_code(hextokeycode((unicode & 0x00F0) >> 4));
- register_code(hextokeycode((unicode & 0x000F)));
- unregister_code(hextokeycode((unicode & 0x000F)));
-
- /* Test 'a' */
- // register_code(hextokeycode(0x0));
- // unregister_code(hextokeycode(0x0));
- // register_code(hextokeycode(0x0));
- // unregister_code(hextokeycode(0x0));
- // register_code(hextokeycode(0x6));
- // unregister_code(hextokeycode(0x6));
- // register_code(hextokeycode(0x1));
- // unregister_code(hextokeycode(0x1));
-
- // unregister_code(KC_LALT);
+ bool leading_zero = false;
+ for(int i = 6; i >= 0; i--) {
+ uint8_t digit = ((unicode >> (int)(i*4)) & 0xF);
+ if (digit > 0 || leading_zero || (i < 4)) {
+ leading_zero = true;
+ register_code(hextokeycode(digit));
+ unregister_code(hextokeycode(digit));
+ if (i == 4) {
+ register_code(KC_LSFT);
+ register_code(KC_EQL);
+ unregister_code(KC_EQL);
+ unregister_code(KC_LSFT);
+ }
+ }
+ }
+
+ #ifdef UNICODE_OSX
+ unregister_code(KC_LALT);
+ #endif
}
return;
} \ No newline at end of file