12 // Fillers to make layering more clear
13 #define XXXXXXX KC_NO // No-op (no key in this location on Mitosis' fake matrix)
14 #define _______ KC_TRNS // Transparent, because I haven't decided a mapping yet
15 #define ___M___ KC_TRNS // Transparent, as required by modifier key on another layer
16 #define KC_LMTA KC_LALT // For fun, name the mods like the space cadet keyboard does
17 #define KC_RMTA KC_RALT // META
18 #define KC_LSUP KC_LGUI // SUPER
19 #define KC_RSUP KC_RGUI //
20 #define KC_RHYP KC_INT4 // HYPER (actually muhenkan 無変換 and henkan 変換)
21 #define KC_LHYP KC_INT5 // or NFER/XFER.
23 // Momentary tri-state layers. Mitosis default keymap does this too but employs
24 // new keymappings and a bunch of conditional code. This simpler keymap
25 // accomplishes it, but with a small quirk: triggering both layers then
26 // releasing one out-of-order will leave the tri-state triggered until the
27 // other is released. Which doesn't bother me.
29 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
31 {KC_Q, KC_D, KC_R, KC_W, KC_B, KC_J, KC_F, KC_U, KC_P, KC_SCLN},
32 {KC_A, KC_S, KC_H, KC_T, KC_G, KC_Y, KC_N, KC_E, KC_O, KC_I},
33 {KC_Z, KC_X, KC_M, KC_C, KC_V, KC_K, KC_L, KC_COMM, KC_DOT, KC_QUOT},
34 {XXXXXXX, KC_LSUP, KC_LCTL, MO(_xN), KC_LSFT, KC_RSFT, MO(_xN), KC_RCTL, KC_RSUP, XXXXXXX},
35 {XXXXXXX, KC_LHYP, KC_LMTA, MO(_xS), KC_BSPC, KC_SPC, MO(_xS), KC_RMTA, KC_RHYP, XXXXXXX}
38 {KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P},
39 {KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN},
40 {KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_QUOT},
41 {XXXXXXX, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX},
42 {XXXXXXX, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX}
45 {KC_ESC, _______, KC_UP, _______, _______, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_TILD},
46 {KC_TAB, KC_LEFT, KC_DOWN, KC_RGHT, _______, KC_CIRC, KC_AMPR, KC_PIPE, KC_GRV, KC_UNDS},
47 {KC_BSLS, KC_RPRN, KC_RCBR, KC_RBRC, KC_RABK, KC_LABK, KC_LBRC, KC_LCBR, KC_LPRN, KC_SLSH},
48 {XXXXXXX, _______, _______, MO(_xF), _______, _______, MO(_xF), _______, _______, XXXXXXX},
49 {XXXXXXX, _______, _______, ___M___, KC_DEL, KC_ENT, ___M___, _______, _______, XXXXXXX},
52 {_______, _______, _______, _______, _______, KC_PSLS, KC_P7, KC_P8, KC_P9, KC_P0},
53 {_______, _______, _______, _______, _______, KC_PAST, KC_P4, KC_P5, KC_P6, KC_PPLS},
54 {_______, _______, _______, _______, _______, KC_PMNS, KC_P1, KC_P2, KC_P3, KC_PEQL},
55 {XXXXXXX, _______, _______, ___M___, _______, _______, ___M___, _______, _______, XXXXXXX},
56 {XXXXXXX, _______, _______, MO(_xF), _______, KC_PENT, MO(_xF), _______, _______, XXXXXXX},
59 {_______, _______, KC_PGUP, _______, KC_VOLU, KC_F13, KC_F7, KC_F8, KC_F9, KC_F10},
60 {_______, KC_HOME, KC_PGDN, KC_END, KC_VOLD, KC_F14, KC_F4, KC_F5, KC_F6, KC_F11},
61 {TG(_xQ), KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_F15, KC_F1, KC_F2, KC_F3, KC_F12},
62 {XXXXXXX, _______, _______, ___M___, _______, _______, ___M___, _______, _______, XXXXXXX},
63 {XXXXXXX, _______, _______, _______, ___M___, ___M___, _______, _______, _______, XXXXXXX},
67 // This is a hack to place <question mark> on <shift-comma> and <exclaimation
68 // mark> on <shift-period>, when using an operating system configured for a
70 bool comm_shifted = false;
71 bool ques_shifted = false;
72 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
80 k_shifted = &comm_shifted;
84 k_shifted = &ques_shifted;
90 shifted = get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT));
92 // Keydown. If shift is currently pressed, register its alternate keycode.
93 if (record->event.pressed && shifted) {
95 register_code(s_keycode);
97 // Keyup. If shift was pressed back when the key was pressed, unregister
98 // its alternate keycode.
99 } else if (!(record->event.pressed) && *k_shifted) {
101 unregister_code(s_keycode);
103 // Otherwise, behave as normal.
109 // Set the bits of A selected by MASK to the corresponding bits of B
110 #define setbits(A, B, MASK) A = (A & (B | ~MASK)) | (B & MASK)
111 void matrix_scan_user(void) {
113 // Bit # 7 6 5 4 3 2 1 0
114 // layer_state: [ | | | _xF | _xN | _xS | _xQ | _xW ]
115 // usb_led [ | | |kana |cmps |scrl |caps | num ]
116 // PORTB: [ NC | 10 | 9 | 8 | 14 | 16 | 15 |rxled]
117 // PORTC: [ NC | 5 | | | | | | ]
118 // PORTD: [ 6 | NC |txled| 4 | tx* | rx* | grn | p29 ]
119 // PORTE: [ | 7 | | | | | | ]
120 // PORTF: [ a0 | a1 | red | blu | | | NC | NC ]
122 // PD0 is connected to the pairing switch and p29 on the wireless module.
123 // PF0,PF1,PB7,PC7,PD6 are not broken out by the pro micro board. I don't understand why.
124 // PB1-PB6,PD4,PD5,PD6,PF6,PF7 are not connected to the Mitosis receiver
125 // board. Each may be connected to an LED by way of a resistor (4.7k to
126 // match the others) for a total of 14 additional indicators.
128 // A simple (but technically inaccurate) model of the momentary layer state:
129 // Fn1 key makes _xS active; indicator = red
130 // Fn2 key makes _xN active; indicator = blue
131 // Both keys make _xF active; indicator = purple
132 // Toggling QWERTY mode makes indicator include green, so (red/blue/purple becomes yellow/cyan/white)
134 // negated because for ports 0=LED on.
135 uint32_t portf_bits = ~(layer_state|layer_state<<1|(layer_state&0b100)<<3);
136 setbits(PORTF, portf_bits, 0b00110000);
137 setbits(PORTD, ~layer_state, 0b00000010);