summaryrefslogtreecommitdiff
path: root/keyboards/atreus62/keymaps/mneme/keymap.c
diff options
context:
space:
mode:
authorDavid Olsson <david.olsson@softhouse.se>2017-01-11 23:00:34 +0100
committerDavid Olsson <david.olsson@softhouse.se>2017-01-11 23:00:34 +0100
commit3a453a03ed5f029bb9cf23955e87789245d39a22 (patch)
tree5e8422ad9ef92e7ad5e10765c64921c413fd49e2 /keyboards/atreus62/keymaps/mneme/keymap.c
parent176b93d08eb5cc0c65a6d571fc2c1fec5f575854 (diff)
Atreus62 first semi-final draft
Diffstat (limited to 'keyboards/atreus62/keymaps/mneme/keymap.c')
-rw-r--r--keyboards/atreus62/keymaps/mneme/keymap.c316
1 files changed, 316 insertions, 0 deletions
diff --git a/keyboards/atreus62/keymaps/mneme/keymap.c b/keyboards/atreus62/keymaps/mneme/keymap.c
new file mode 100644
index 0000000000..8c3f8aa435
--- /dev/null
+++ b/keyboards/atreus62/keymaps/mneme/keymap.c
@@ -0,0 +1,316 @@
+#include <stdarg.h>
+#include "atreus62.h"
+#include "led.h"
+#include "action_layer.h"
+#include "action_util.h"
+
+//avrdude -p atmega32u4 -P /dev/tty.usbmodem1411 -c avr109 -U flash:w:atreus63_default.hex
+/*
+ *WINDOWS SWEDISH
+ */
+#define KN_HALF KC_GRV // 1/2
+#define KN_PLUS KC_MINS // +
+#define KN_ACUT KC_EQL // ´
+#define KN_AO KC_LBRC // Å
+#define KN_UMLA KC_RBRC // ¨
+#define KN_OE KC_SCLN // Ö
+#define KN_AE KC_QUOT // Ä
+#define KN_QUOT KC_NUHS // '
+#define KN_LABK KC_NUBS // <
+#define KN_MINS KC_SLSH // -
+#define KN_EXLM LSFT(KC_1) // !
+#define KN_DQT LSFT(KC_2) // "
+#define KN_AT RALT(KC_2) // @
+#define KN_HASH LSFT(KC_3) // #
+#define KN_DLR RALT(KC_4) // $
+#define KN_PERC LSFT(KC_5) // %
+#define KN_AMPR LSFT(KC_6) // &
+#define KN_SLSH LSFT(KC_7) // /
+#define KN_LPRN LSFT(KC_8) // (
+#define KN_RPRN LSFT(KC_9) // )
+#define KN_EQL LSFT(KC_0) // =
+#define KN_UNDS LSFT(KN_MINS) // _
+#define KN_QUES LSFT(KN_PLUS) // ?
+#define KN_GRAV LSFT(KN_ACUT) // `
+#define KN_LCBR RALT(KC_7) // {
+#define KN_RCBR RALT(KC_0) // }
+#define KN_LBRC RALT(KC_8) // [
+#define KN_RBRC RALT(KC_9) // ]
+#define KN_RABK LSFT(KN_LABK) // <
+#define KN_COLN LSFT(KC_DOT) // :
+#define KN_SCLN LSFT(KC_COMM) // :
+#define KN_PIPE RALT(KN_LABK) // |
+#define KN_QUES LSFT(KN_PLUS) // ?
+#define KN_CIRC LSFT(KN_UMLA) // ^
+#define KN_ASTR LSFT(KN_QUOT) // *
+#define KN_TILD RALT(KN_UMLA) // ~
+#define KN_BSLS RALT(KN_PLUS) //
+
+#define OSM_LCTL OSM(MOD_LCTL)
+#define OSM_LALT OSM(MOD_LALT)
+#define OSM_LSFT OSM(MOD_LSFT)
+
+#define KC_HYP LSFT(LALT(LCTL(KC_LGUI)))
+
+#define KC_COPY LCTL(KC_C)
+#define KC_PASTE LCTL(KC_V)
+#define KC_UNDO LCTL(KC_Z)
+#define KC_REDO LCTL(LSFT(KC_Z))
+
+// Layers
+enum {
+ BASE = 0,
+ NAV,
+ SYM
+};
+
+//Macros
+enum {
+ KF_1 = 0, // 1, F1
+ KF_2, // ...
+ KF_3,
+ KF_4,
+ KF_5,
+ KF_6,
+ KF_7,
+ KF_8,
+ KF_9,
+ KF_10,
+ KF_11,
+ KF_12
+};
+
+// Tapdance
+enum {
+ TD_FUN = 0,
+ TD_EQ
+};
+
+//Custom keycodes
+enum {
+ PLACEHOLDER = SAFE_RANGE
+};
+
+//State and timers
+uint16_t kf_timers[12];
+
+
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+ [BASE] = {
+
+ { M(KF_11) ,M(KF_1) ,M(KF_2) ,M(KF_3) ,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,KC_F12 ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_VOLD ,KC_VOLU }
+
+ },
+ [SYM] = {
+
+ { KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,TD(TD_EQ) ,KC_NO ,TD(TD_FUN) ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS },
+ { KC_TRNS ,KN_LABK ,KN_RABK ,KN_LCBR ,KN_RCBR ,KN_PLUS ,KC_NO ,KN_AT ,KN_DQT ,KN_QUOT ,KN_GRAV ,KN_SLSH ,KC_TRNS },
+ { KC_TRNS ,KN_EXLM ,KN_EQL ,KN_LPRN ,KN_RPRN ,KN_MINS ,KC_NO ,KN_UNDS ,KN_SCLN ,KN_COLN ,KN_AMPR ,KN_PIPE ,KC_TRNS },
+ { KC_TRNS ,KN_DLR ,KN_PERC ,KN_LBRC ,KN_RBRC ,KN_ASTR ,KC_TRNS ,KN_HASH ,KC_COMM ,KC_DOT ,KN_QUES ,KN_BSLS ,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 }
+
+ }
+};
+
+#define TAP_ONCE(code) \
+ register_code (code); \
+ unregister_code (code)
+
+static void m_tapn (uint8_t code, ...) {
+ uint8_t kc = code;
+ va_list ap;
+
+ va_start(ap, code);
+ do {
+ register_code(kc);
+ unregister_code(kc);
+ wait_ms(50);
+ kc = va_arg(ap, int);
+ } while (kc != 0);
+ va_end(ap);
+}
+
+static void m_handle_kf (keyrecord_t *record, uint8_t id) {
+ uint8_t code = id - KF_1;
+
+ if (record->event.pressed) {
+ kf_timers[code] = timer_read ();
+ } else {
+ uint8_t kc_base;
+ uint8_t long_press = (kf_timers[code] && timer_elapsed (kf_timers[code]) > TAPPING_TERM);
+
+ kf_timers[code] = 0;
+
+ switch(id){
+ case KF_1 ... KF_10:
+ if (long_press) {
+ // Long press
+ kc_base = KC_F1;
+ } else {
+ kc_base = KC_1;
+ }
+ code += kc_base;
+ break;
+ case KF_11:
+ code = long_press ? KC_F11 : KC_ESC;
+ break;
+ case KF_12:
+ code = long_press ? KC_F12 : KC_PLUS;
+ break;
+ }
+ register_code (code);
+ unregister_code (code);
+ }
+}
+
+const uint16_t PROGMEM fn_actions[] = {
+
+};
+
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+ switch (id) {
+ case KF_1 ... KF_12:
+ m_handle_kf(record, id);
+ break;
+ }
+ return MACRO_NONE;
+};
+
+// Custom keycodes
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ bool queue = true;
+
+ //Cancle one-shot mods.
+ switch (keycode) {
+ case KC_ESC:
+ if (record->event.pressed && get_oneshot_mods() && !has_oneshot_mods_timed_out()) {
+ clear_oneshot_mods();
+ queue = false;
+ }
+ break;
+ }
+ return queue;
+}
+
+// TAP DANCE SETTINGS
+void dance_eq (qk_tap_dance_state_t *state, void *user_data) {
+ switch (state->count) {
+ case 1: // ===
+ register_code(KC_LSHIFT);
+ m_tapn(KC_0, KC_0, KC_0, 0);
+ unregister_code(KC_LSHIFT);
+ break;
+ case 2:
+ register_code(KC_LSHIFT);
+ m_tapn(KC_1, KC_0, KC_0, 0);
+ unregister_code(KC_LSHIFT);
+ break;
+ default:
+ reset_tap_dance(state);
+ }
+}
+
+void dance_fun (qk_tap_dance_state_t *state, void *user_data) {
+ switch (state->count) {
+ case 1: // =>
+ register_code(KC_LSHIFT);
+ m_tapn(KC_0, KN_LABK, 0);
+ unregister_code(KC_LSHIFT);
+ break;
+ case 2: // () => {}
+ register_code(KC_LSHIFT);
+ m_tapn(KC_8, KC_9, KC_SPC, KC_0, KN_LABK, KC_SPC, 0);
+ unregister_code(KC_LSHIFT);
+ register_code(KC_RALT);
+ m_tapn(KC_7, 0);
+ unregister_code(KC_RALT);
+ TAP_ONCE(KC_ENT);
+ break;
+ default:
+ reset_tap_dance(state);
+ }
+}
+
+qk_tap_dance_action_t tap_dance_actions[] = {
+ [TD_FUN] = ACTION_TAP_DANCE_FN (dance_fun)
+ ,[TD_EQ] = ACTION_TAP_DANCE_FN (dance_eq)
+};
+
+// Runs just one time when the keyboard initializes.
+void matrix_init_user(void) {
+ set_unicode_input_mode(UC_WINC);
+};
+
+LEADER_EXTERNS();
+// Runs constantly in the background, in a loop.
+void matrix_scan_user(void) {
+ LEADER_DICTIONARY() {
+ leading = false;
+ leader_end();
+ SEQ_ONE_KEY(KC_L){
+ register_code(KC_RGUI);
+ TAP_ONCE(KC_L);
+ unregister_code(KC_RGUI);
+ }; // Todo
+
+ SEQ_TWO_KEYS(KC_F, KC_S){
+ register_code(KC_LCTRL);
+ TAP_ONCE(KC_S);
+ unregister_code(KC_LCTRL);
+ }; // Todo
+
+ SEQ_TWO_KEYS(KC_B, KC_D){
+ register_code(KC_LCTRL);
+ TAP_ONCE(KC_W);
+ unregister_code(KC_LCTRL);
+ }; // Todo
+
+ SEQ_ONE_KEY(KC_SLSH){
+ register_code(KC_LCTRL);
+ TAP_ONCE(KC_F);
+ unregister_code(KC_LCTRL);
+ }
+
+ SEQ_TWO_KEYS (KC_S, KC_S) {
+ // ¯\_(ツ)_/¯
+ unicode_input_start(); register_hex(0xaf); unicode_input_finish();
+ register_code (KC_RALT); TAP_ONCE (KN_PLUS); unregister_code (KC_RALT);
+ register_code (KC_RSFT); TAP_ONCE (KC_8); unregister_code (KC_RSFT);
+ unicode_input_start (); register_hex(0x30c4); unicode_input_finish();
+ register_code (KC_RSFT); TAP_ONCE (KC_9); TAP_ONCE(KC_7); unregister_code (KC_RSFT);
+ unicode_input_start (); register_hex(0xaf); unicode_input_finish();
+ }
+
+ SEQ_TWO_KEYS (KC_S, KC_F) {
+ // 凸(ツ)凸
+ unicode_input_start(); register_hex(0x51F8); unicode_input_finish();
+ register_code (KC_RSFT); TAP_ONCE (KC_8); unregister_code (KC_RSFT);
+ unicode_input_start (); register_hex(0x30c4); unicode_input_finish();
+ register_code (KC_RSFT); TAP_ONCE (KC_9); unregister_code (KC_RSFT);
+ unicode_input_start (); register_hex(0x51F8); unicode_input_finish();
+ }
+
+ SEQ_TWO_KEYS (KC_S, KC_L) {
+ // λ
+ unicode_input_start();
+ register_hex(0x03bb);
+ unicode_input_finish();
+ }
+ };
+};