aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Andersson <wraul@dbox.se>2019-06-26 09:32:03 +0200
committerDrashna Jaelre <drashna@live.com>2019-06-26 00:32:03 -0700
commit3483c51f62640c83d35a0b4c4636a5939f2c3898 (patch)
treebf4d0a94104a5e883c7b0f9d9b53aad982627a0c
parent8fd3f42281885346f93fff2f122569c002071c67 (diff)
downloadqmk_firmware-3483c51f62640c83d35a0b4c4636a5939f2c3898.tar.gz
qmk_firmware-3483c51f62640c83d35a0b4c4636a5939f2c3898.zip
[Keyboard] Modernize KMAC (#6131)
* [Keyboard] Modernize the KMAC implementation This brings the matrix implementation more in line with the current default matrix code. It also simplifies the implementation quite a bit. * [Keyboard] Add layout support to KMAC
-rw-r--r--keyboards/kmac/config.h23
-rw-r--r--keyboards/kmac/info.json9
-rw-r--r--keyboards/kmac/keymaps/default/config.h2
-rw-r--r--keyboards/kmac/keymaps/default/keymap.c126
-rw-r--r--keyboards/kmac/keymaps/default/readme.md6
-rw-r--r--keyboards/kmac/keymaps/default/rules.mk34
-rw-r--r--keyboards/kmac/keymaps/default_tkl_ansi/config.h (renamed from keyboards/kmac/keymaps/winkeyless/config.h)9
-rw-r--r--keyboards/kmac/keymaps/default_tkl_ansi/keymap.c87
-rw-r--r--keyboards/kmac/keymaps/default_tkl_ansi/readme.md50
-rw-r--r--keyboards/kmac/keymaps/default_tkl_ansi_wkl/config.h19
-rw-r--r--keyboards/kmac/keymaps/default_tkl_ansi_wkl/keymap.c87
-rw-r--r--keyboards/kmac/keymaps/default_tkl_ansi_wkl/readme.md (renamed from keyboards/kmac/keymaps/winkeyless/readme.md)15
-rw-r--r--keyboards/kmac/keymaps/winkeyless/keymap.c93
-rw-r--r--keyboards/kmac/keymaps/winkeyless/rules.mk34
-rw-r--r--keyboards/kmac/kmac.c100
-rw-r--r--keyboards/kmac/kmac.h73
-rw-r--r--keyboards/kmac/matrix.c359
-rw-r--r--keyboards/kmac/readme.md43
-rw-r--r--keyboards/kmac/rules.mk20
19 files changed, 569 insertions, 620 deletions
diff --git a/keyboards/kmac/config.h b/keyboards/kmac/config.h
index 110a7ac0f..652263d2b 100644
--- a/keyboards/kmac/config.h
+++ b/keyboards/kmac/config.h
@@ -15,17 +15,16 @@ You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>. 15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#ifndef CONFIG_H 18#pragma once
19#define CONFIG_H
20 19
21#include "config_common.h" 20#include "config_common.h"
22 21
23/* USB Device descriptor parameter */ 22/* USB Device descriptor parameter */
24#define VENDOR_ID 0xFEED 23#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x6050 24#define PRODUCT_ID 0x6050
26#define DEVICE_VER 0x0104 25#define DEVICE_VER 0x0104
27#define MANUFACTURER KBDMania 26#define MANUFACTURER KBDMania
28#define PRODUCT KMAC 27#define PRODUCT KMAC
29#define DESCRIPTION QMK keyboard firmware for KMAC 28#define DESCRIPTION QMK keyboard firmware for KMAC
30 29
31/* key matrix size */ 30/* key matrix size */
@@ -36,9 +35,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
36 * Keyboard Matrix Assignments 35 * Keyboard Matrix Assignments
37 * The KMAC uses demultiplexers for the cols, they are only included here as documentation. 36 * The KMAC uses demultiplexers for the cols, they are only included here as documentation.
38 * See matrix.c for more details. 37 * See matrix.c for more details.
39*/ 38 */
40#define MATRIX_ROW_PINS { D0, D1, D2, D3, D5, B7 } 39#define MATRIX_ROW_PINS \
41#define MATRIX_COL_PINS { C6, B6, F0, F1, C7, B5 } 40 { D0, D1, D2, D3, D5, B7 }
41#define MATRIX_COL_PINS \
42 { B6, C6, C7, F1, F0, B5 }
42#define UNUSED_PINS 43#define UNUSED_PINS
43 44
44/* COL2ROW, ROW2COL*/ 45/* COL2ROW, ROW2COL*/
@@ -169,5 +170,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
169 170
170/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ 171/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
171//#define MIDI_TONE_KEYCODE_OCTAVES 1 172//#define MIDI_TONE_KEYCODE_OCTAVES 1
172
173#endif
diff --git a/keyboards/kmac/info.json b/keyboards/kmac/info.json
index f86cfdde5..2fe0ef269 100644
--- a/keyboards/kmac/info.json
+++ b/keyboards/kmac/info.json
@@ -6,7 +6,8 @@
6 "width": 18.25, 6 "width": 18.25,
7 "height": 6.5, 7 "height": 6.5,
8 "layouts": { 8 "layouts": {
9 "LAYOUT": { 9 "LAYOUT_tkl_ansi": {
10 "key_count": 87,
10 "layout": [ 11 "layout": [
11 { "label": "Esc", "x": 0, "y": 0 }, 12 { "label": "Esc", "x": 0, "y": 0 },
12 { "label": "F1", "x": 2, "y": 0 }, 13 { "label": "F1", "x": 2, "y": 0 },
@@ -97,8 +98,8 @@
97 { "label": "\u2192", "x": 17.25, "y": 5.5 } 98 { "label": "\u2192", "x": 17.25, "y": 5.5 }
98 ] 99 ]
99 }, 100 },
100 101 "LAYOUT_tkl_ansi_wkl": {
101 "LAYOUT_WKL": { 102 "key_count": 84,
102 "layout": [ 103 "layout": [
103 { "label": "Esc", "x": 0, "y": 0 }, 104 { "label": "Esc", "x": 0, "y": 0 },
104 { "label": "F1", "x": 2, "y": 0 }, 105 { "label": "F1", "x": 2, "y": 0 },
@@ -177,11 +178,9 @@
177 { "label": "Shift", "x": 12.25, "y": 4.5, "w": 2.75 }, 178 { "label": "Shift", "x": 12.25, "y": 4.5, "w": 2.75 },
178 { "label": "\u2191", "x": 16.25, "y": 4.5 }, 179 { "label": "\u2191", "x": 16.25, "y": 4.5 },
179 { "label": "Ctrl", "x": 0, "y": 5.5, "w": 1.5 }, 180 { "label": "Ctrl", "x": 0, "y": 5.5, "w": 1.5 },
180 { "label": "Win", "x": 1.5, "y": 5.5 },
181 { "label": "Alt", "x": 2.5, "y": 5.5, "w": 1.5 }, 181 { "label": "Alt", "x": 2.5, "y": 5.5, "w": 1.5 },
182 { "x": 4, "y": 5.5, "w": 7 }, 182 { "x": 4, "y": 5.5, "w": 7 },
183 { "label": "Alt", "x": 11, "y": 5.5, "w": 1.5 }, 183 { "label": "Alt", "x": 11, "y": 5.5, "w": 1.5 },
184 { "label": "Win", "x": 12.5, "y": 5.5 },
185 { "label": "Ctrl", "x": 13.5, "y": 5.5, "w": 1.5 }, 184 { "label": "Ctrl", "x": 13.5, "y": 5.5, "w": 1.5 },
186 { "label": "\u2190", "x": 15.25, "y": 5.5 }, 185 { "label": "\u2190", "x": 15.25, "y": 5.5 },
187 { "label": "\u2193", "x": 16.25, "y": 5.5 }, 186 { "label": "\u2193", "x": 16.25, "y": 5.5 },
diff --git a/keyboards/kmac/keymaps/default/config.h b/keyboards/kmac/keymaps/default/config.h
index 09b8f1bc7..14b43132a 100644
--- a/keyboards/kmac/keymaps/default/config.h
+++ b/keyboards/kmac/keymaps/default/config.h
@@ -1,4 +1,4 @@
1/* Copyright 2017 Mathias Andersson <wraul@dbox.se> 1/* Copyright 2019 Mathias Andersson <wraul@dbox.se>
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
diff --git a/keyboards/kmac/keymaps/default/keymap.c b/keyboards/kmac/keymaps/default/keymap.c
index 3444f3cd5..05ccd1bcb 100644
--- a/keyboards/kmac/keymaps/default/keymap.c
+++ b/keyboards/kmac/keymaps/default/keymap.c
@@ -1,4 +1,4 @@
1/* Copyright 2017 Mathias Andersson <wraul@dbox.se> 1/* Copyright 2017-2019 Mathias Andersson <wraul@dbox.se>
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
@@ -15,79 +15,73 @@
15 */ 15 */
16#include QMK_KEYBOARD_H 16#include QMK_KEYBOARD_H
17 17
18// Each layer gets a name for readability, which is then used in the keymap matrix below. 18enum layer_names {
19// The underscores don't mean anything - you can have a layer called STUFF or any other name. 19 _QW,
20// Layer names don't all need to be of the same length, obviously, and you can also skip them 20 _FN,
21// entirely and just use numbers. 21};
22#define _BL 0 22
23#define _FL 1 23// Defines the keycodes used by our macros in process_record_user
24enum custom_keycodes {
25 MCR_01 = SAFE_RANGE,
26 MCR_02,
27 MCR_03,
28 MCR_04,
29 MCR_05,
30 MCR_06,
31 MCR_07,
32 MCR_08,
33 MCR_09,
34 MCR_10,
35 MCR_11,
36};
24 37
38// clang-format off
25const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 39const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
26 [_BL] = LAYOUT( 40 [_QW] = LAYOUT_tkl_ansi(
27 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_BRK, 41 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_BRK,
28 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, KC_HOME, KC_PGUP, 42 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, KC_HOME, KC_PGUP,
29 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, KC_END, KC_PGDN, 43 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, KC_END, KC_PGDN,
30 KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, 44 KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
31 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, 45 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP,
32 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(_FL), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), 46 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
33 [_FL] = LAYOUT( 47 [_FN] = LAYOUT_tkl_ansi(
34 BL_STEP, M(0), M(1), M(2), M(3), M(4), M(5), M(6), M(7), M(8), M(9), M(10), M(11), _______, _______, _______, 48 BL_STEP, MCR_01, MCR_02, MCR_03, MCR_03, MCR_04, MCR_05, MCR_06, MCR_07, MCR_08, MCR_09, MCR_10, MCR_11, _______, _______, _______,
35 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, 49 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
36 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, 50 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
37 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, 51 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
38 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, 52 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
39 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), 53 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
40}; 54};
55// clang-format on
41 56
42const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) 57bool process_record_user(uint16_t keycode, keyrecord_t *record) {
43{ 58 switch (keycode) {
44 // MACRODOWN only works in this function 59 case MCR_01:
45 switch (id) 60 if (record->event.pressed) {
46 { 61 SEND_STRING("The");
47 case 0: 62 }
48 if (record->event.pressed) 63 break;
49 { 64 case MCR_02:
50 SEND_STRING("The"); 65 if (record->event.pressed) {
51 return false; 66 SEND_STRING("Custom");
52 } 67 }
53 break; 68 break;
54 case 1: 69 case MCR_03:
55 if (record->event.pressed) 70 if (record->event.pressed) {
56 { 71 SEND_STRING("Keyboard");
57 SEND_STRING("Custom"); 72 }
58 return false; 73 break;
59 } 74 case MCR_04:
60 break; 75 if (record->event.pressed) {
61 case 2: 76 SEND_STRING(SS_LCTRL("c") SS_TAP(X_RIGHT) SS_LCTRL("v"));
62 if (record->event.pressed) 77 }
63 { 78 break;
64 SEND_STRING("Keyboard");
65 return false;
66 }
67 break;
68 case 3:
69 if (record->event.pressed)
70 {
71 return MACRO(D(LCTL), T(C), U(LCTL), T(RGHT), D(LCTL), T(V), U(LCTL), END);
72 }
73 break;
74 } 79 }
75 return MACRO_NONE; 80 return true;
76}; 81};
77 82
78void matrix_init_user(void) 83void matrix_init_user(void) {}
79{
80}
81
82void matrix_scan_user(void)
83{
84}
85 84
86bool process_record_user(uint16_t keycode, keyrecord_t *record) 85void matrix_scan_user(void) {}
87{
88 return true;
89}
90 86
91void led_set_user(uint8_t usb_led) 87void led_set_user(uint8_t usb_led) {}
92{
93}
diff --git a/keyboards/kmac/keymaps/default/readme.md b/keyboards/kmac/keymaps/default/readme.md
index aaa6f9bf2..a60840375 100644
--- a/keyboards/kmac/keymaps/default/readme.md
+++ b/keyboards/kmac/keymaps/default/readme.md
@@ -2,8 +2,6 @@
2 2
3This is the default keymap for the winkey version of the PCB. It implements the same features as the official default KMAC firmware. 3This is the default keymap for the winkey version of the PCB. It implements the same features as the official default KMAC firmware.
4 4
5See [keymap.c](keymap.c) for details.
6
7## Layers 5## Layers
8 6
9The keymap have two layers. To access the functions on the second layer, hold down `Fn` and press the corresponding key. 7The keymap have two layers. To access the functions on the second layer, hold down `Fn` and press the corresponding key.
@@ -50,7 +48,3 @@ These are mostly useless and serve more like examples I guess.
50| 2 | Types `Custom` | 48| 2 | Types `Custom` |
51| 3 | Types `Keyboard` | 49| 3 | Types `Keyboard` |
52| 4 | Inputs `<Ctrl+c>` `<Right>` `<Ctrl+v>` | 50| 4 | Inputs `<Ctrl+c>` `<Right>` `<Ctrl+v>` |
53
54## Building
55
56To build the firmware with the default keymap, run `make default`.
diff --git a/keyboards/kmac/keymaps/default/rules.mk b/keyboards/kmac/keymaps/default/rules.mk
deleted file mode 100644
index 128487947..000000000
--- a/keyboards/kmac/keymaps/default/rules.mk
+++ /dev/null
@@ -1,34 +0,0 @@
1# Copyright 2013 Jun Wako <wakojun@gmail.com>
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16
17# QMK Build Options
18# change to "no" to disable the options, or define them in the Makefile in
19# the appropriate keymap folder that will get included automatically
20#
21BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
22MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
23EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
24CONSOLE_ENABLE = no # Console for debug(+400)
25COMMAND_ENABLE = yes # Commands for debug and configuration
26NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
27BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
28MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
29AUDIO_ENABLE = no # Audio output on port C6
30UNICODE_ENABLE = no # Unicode
31BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
32RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
33SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
34
diff --git a/keyboards/kmac/keymaps/winkeyless/config.h b/keyboards/kmac/keymaps/default_tkl_ansi/config.h
index a3828f7d5..14b43132a 100644
--- a/keyboards/kmac/keymaps/winkeyless/config.h
+++ b/keyboards/kmac/keymaps/default_tkl_ansi/config.h
@@ -1,4 +1,4 @@
1/* Copyright 2017 Mathias Andersson <wraul@dbox.se> 1/* Copyright 2019 Mathias Andersson <wraul@dbox.se>
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
@@ -14,11 +14,6 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#ifndef CONFIG_USER_H 17#pragma once
18#define CONFIG_USER_H
19
20#include "../../config.h"
21 18
22// place overrides here 19// place overrides here
23
24#endif
diff --git a/keyboards/kmac/keymaps/default_tkl_ansi/keymap.c b/keyboards/kmac/keymaps/default_tkl_ansi/keymap.c
new file mode 100644
index 000000000..05ccd1bcb
--- /dev/null
+++ b/keyboards/kmac/keymaps/default_tkl_ansi/keymap.c
@@ -0,0 +1,87 @@
1/* Copyright 2017-2019 Mathias Andersson <wraul@dbox.se>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include QMK_KEYBOARD_H
17
18enum layer_names {
19 _QW,
20 _FN,
21};
22
23// Defines the keycodes used by our macros in process_record_user
24enum custom_keycodes {
25 MCR_01 = SAFE_RANGE,
26 MCR_02,
27 MCR_03,
28 MCR_04,
29 MCR_05,
30 MCR_06,
31 MCR_07,
32 MCR_08,
33 MCR_09,
34 MCR_10,
35 MCR_11,
36};
37
38// clang-format off
39const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
40 [_QW] = LAYOUT_tkl_ansi(
41 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_BRK,
42 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, KC_HOME, KC_PGUP,
43 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, KC_END, KC_PGDN,
44 KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
45 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP,
46 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
47 [_FN] = LAYOUT_tkl_ansi(
48 BL_STEP, MCR_01, MCR_02, MCR_03, MCR_03, MCR_04, MCR_05, MCR_06, MCR_07, MCR_08, MCR_09, MCR_10, MCR_11, _______, _______, _______,
49 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
50 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
51 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
52 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
53 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
54};
55// clang-format on
56
57bool process_record_user(uint16_t keycode, keyrecord_t *record) {
58 switch (keycode) {
59 case MCR_01:
60 if (record->event.pressed) {
61 SEND_STRING("The");
62 }
63 break;
64 case MCR_02:
65 if (record->event.pressed) {
66 SEND_STRING("Custom");
67 }
68 break;
69 case MCR_03:
70 if (record->event.pressed) {
71 SEND_STRING("Keyboard");
72 }
73 break;
74 case MCR_04:
75 if (record->event.pressed) {
76 SEND_STRING(SS_LCTRL("c") SS_TAP(X_RIGHT) SS_LCTRL("v"));
77 }
78 break;
79 }
80 return true;
81};
82
83void matrix_init_user(void) {}
84
85void matrix_scan_user(void) {}
86
87void led_set_user(uint8_t usb_led) {}
diff --git a/keyboards/kmac/keymaps/default_tkl_ansi/readme.md b/keyboards/kmac/keymaps/default_tkl_ansi/readme.md
new file mode 100644
index 000000000..a60840375
--- /dev/null
+++ b/keyboards/kmac/keymaps/default_tkl_ansi/readme.md
@@ -0,0 +1,50 @@
1# Keymap for the winkey version of KMAC
2
3This is the default keymap for the winkey version of the PCB. It implements the same features as the official default KMAC firmware.
4
5## Layers
6
7The keymap have two layers. To access the functions on the second layer, hold down `Fn` and press the corresponding key.
8
9### Layer 1: Default Layer
10 ,---. ,---------------. ,---------------. ,---------------. ,-----------.
11 |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
12 `---' `---------------' `---------------' `---------------' `-----------'
13 ,-----------------------------------------------------------. ,-----------.
14 |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
15 |-----------------------------------------------------------| |-----------|
16 |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
17 |-----------------------------------------------------------| '-----------'
18 |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
19 |-----------------------------------------------------------| ,---.
20 |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
21 |-----------------------------------------------------------| ,-----------.
22 |Ctl|Gui|Alt| Space |Alt|Gui|Fn |Ctl| |Lef|Dow|Rig|
23 `-----------------------------------------------------------' `-----------'
24
25### Layer 2: Function Layer
26 ,---. ,---------------. ,---------------. ,---------------. ,-----------.
27 |Led| |M1 |M2 |M3 |M4 | |M5 |M6 |M7 |M8 | |M9 |M10|M11|M12| | | | |
28 `---' `---------------' `---------------' `---------------' `-----------'
29 ,-----------------------------------------------------------. ,-----------.
30 | | | | | | | | | | | | | | | | | | |
31 |-----------------------------------------------------------| |-----------|
32 | | | | | | | | | | | | | | | | | | |
33 |-----------------------------------------------------------| '-----------'
34 | | | | | | | | | | | | | |
35 |-----------------------------------------------------------| ,---.
36 | | | | | | | | | | | | | | |
37 |-----------------------------------------------------------| ,-----------.
38 | | | | | | | | | | | | |
39 `-----------------------------------------------------------' `-----------'
40
41## Macros
42
43These are mostly useless and serve more like examples I guess.
44
45| Macro | Action |
46|:-----:| -------------------------------------- |
47| 1 | Types `The` |
48| 2 | Types `Custom` |
49| 3 | Types `Keyboard` |
50| 4 | Inputs `<Ctrl+c>` `<Right>` `<Ctrl+v>` |
diff --git a/keyboards/kmac/keymaps/default_tkl_ansi_wkl/config.h b/keyboards/kmac/keymaps/default_tkl_ansi_wkl/config.h
new file mode 100644
index 000000000..14b43132a
--- /dev/null
+++ b/keyboards/kmac/keymaps/default_tkl_ansi_wkl/config.h
@@ -0,0 +1,19 @@
1/* Copyright 2019 Mathias Andersson <wraul@dbox.se>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19// place overrides here
diff --git a/keyboards/kmac/keymaps/default_tkl_ansi_wkl/keymap.c b/keyboards/kmac/keymaps/default_tkl_ansi_wkl/keymap.c
new file mode 100644
index 000000000..42be54764
--- /dev/null
+++ b/keyboards/kmac/keymaps/default_tkl_ansi_wkl/keymap.c
@@ -0,0 +1,87 @@
1/* Copyright 2017-2019 Mathias Andersson <wraul@dbox.se>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include QMK_KEYBOARD_H
17
18enum layer_names {
19 _QW,
20 _FN,
21};
22
23// Defines the keycodes used by our macros in process_record_user
24enum custom_keycodes {
25 MCR_01 = SAFE_RANGE,
26 MCR_02,
27 MCR_03,
28 MCR_04,
29 MCR_05,
30 MCR_06,
31 MCR_07,
32 MCR_08,
33 MCR_09,
34 MCR_10,
35 MCR_11,
36};
37
38// clang-format off
39const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
40 [_QW] = LAYOUT_tkl_ansi_wkl(
41 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_BRK,
42 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, KC_HOME, KC_PGUP,
43 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, KC_END, KC_PGDN,
44 KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
45 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP,
46 KC_LCTL, KC_LALT, KC_SPC, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
47 [_FN] = LAYOUT_tkl_ansi_wkl(
48 BL_STEP, MCR_01, MCR_02, MCR_03, MCR_03, MCR_04, MCR_05, MCR_06, MCR_07, MCR_08, MCR_09, MCR_10, MCR_11, _______, _______, _______,
49 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
50 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
51 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
52 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
53 _______, _______, _______, _______, _______, _______, _______, _______),
54};
55// clang-format on
56
57bool process_record_user(uint16_t keycode, keyrecord_t *record) {
58 switch (keycode) {
59 case MCR_01:
60 if (record->event.pressed) {
61 SEND_STRING("The");
62 }
63 break;
64 case MCR_02:
65 if (record->event.pressed) {
66 SEND_STRING("Custom");
67 }
68 break;
69 case MCR_03:
70 if (record->event.pressed) {
71 SEND_STRING("Keyboard");
72 }
73 break;
74 case MCR_04:
75 if (record->event.pressed) {
76 SEND_STRING(SS_LCTRL("c") SS_TAP(X_RIGHT) SS_LCTRL("v"));
77 }
78 break;
79 }
80 return true;
81};
82
83void matrix_init_user(void) {}
84
85void matrix_scan_user(void) {}
86
87void led_set_user(uint8_t usb_led) {}
diff --git a/keyboards/kmac/keymaps/winkeyless/readme.md b/keyboards/kmac/keymaps/default_tkl_ansi_wkl/readme.md
index 9c579e9f5..a66ed1090 100644
--- a/keyboards/kmac/keymaps/winkeyless/readme.md
+++ b/keyboards/kmac/keymaps/default_tkl_ansi_wkl/readme.md
@@ -2,9 +2,6 @@
2 2
3This is the default keymap for the winkeyless version of the PCB. It implements the same features as the official default KMAC firmware. 3This is the default keymap for the winkeyless version of the PCB. It implements the same features as the official default KMAC firmware.
4 4
5
6See [keymap.c](keymap.c) for details.
7
8## Layers 5## Layers
9 6
10The keymap have two layers. To access the functions on the second layer, hold down `Fn` and press the corresponding key. 7The keymap have two layers. To access the functions on the second layer, hold down `Fn` and press the corresponding key.
@@ -22,8 +19,8 @@ The keymap have two layers. To access the functions on the second layer, hold do
22 |-----------------------------------------------------------| ,---. 19 |-----------------------------------------------------------| ,---.
23 |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up | 20 |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
24 |-----------------------------------------------------------| ,-----------. 21 |-----------------------------------------------------------| ,-----------.
25 |Ctl|Gui|Alt| Space |Alt|Fn |Ctl| |Lef|Dow|Rig| 22 |Ctl | |Alt | Space |Fn | |Ctl | |Lef|Dow|Rig|
26 `-----------------------------------------------------------' `-----------' 23 `----' `-----------------------------------------' `----' `-----------'
27 24
28### Layer 2: Function Layer 25### Layer 2: Function Layer
29 ,---. ,---------------. ,---------------. ,---------------. ,-----------. 26 ,---. ,---------------. ,---------------. ,---------------. ,-----------.
@@ -38,8 +35,8 @@ The keymap have two layers. To access the functions on the second layer, hold do
38 |-----------------------------------------------------------| ,---. 35 |-----------------------------------------------------------| ,---.
39 | | | | | | | | | | | | | | | 36 | | | | | | | | | | | | | | |
40 |-----------------------------------------------------------| ,-----------. 37 |-----------------------------------------------------------| ,-----------.
41 | | | | | | | | | | | | 38 | | | | | | | | | | | |
42 `-----------------------------------------------------------' `-----------' 39 `----' `-----------------------------------------' `----' `-----------'
43 40
44## Macros 41## Macros
45 42
@@ -51,7 +48,3 @@ These are mostly useless and serve more like examples I guess.
51| 2 | Types `Custom` | 48| 2 | Types `Custom` |
52| 3 | Types `Keyboard` | 49| 3 | Types `Keyboard` |
53| 4 | Inputs `<Ctrl+c>` `<Right>` `<Ctrl+v>` | 50| 4 | Inputs `<Ctrl+c>` `<Right>` `<Ctrl+v>` |
54
55## Building
56
57To build the firmware with the keymap for the winkeyless version, run `make winkeyless`.
diff --git a/keyboards/kmac/keymaps/winkeyless/keymap.c b/keyboards/kmac/keymaps/winkeyless/keymap.c
deleted file mode 100644
index 0df0aaf42..000000000
--- a/keyboards/kmac/keymaps/winkeyless/keymap.c
+++ /dev/null
@@ -1,93 +0,0 @@
1/* Copyright 2017 Mathias Andersson <wraul@dbox.se>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include QMK_KEYBOARD_H
17
18// Each layer gets a name for readability, which is then used in the keymap matrix below.
19// The underscores don't mean anything - you can have a layer called STUFF or any other name.
20// Layer names don't all need to be of the same length, obviously, and you can also skip them
21// entirely and just use numbers.
22#define _BL 0
23#define _FL 1
24
25const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
26 [_BL] = LAYOUT_WKL(
27 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_BRK,
28 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, KC_HOME, KC_PGUP,
29 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, KC_END, KC_PGDN,
30 KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
31 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP,
32 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FL), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
33 [_FL] = LAYOUT_WKL(
34 BL_STEP, M(0), M(1), M(2), M(3), M(4), M(5), M(6), M(7), M(8), M(9), M(10), M(11), _______, _______, _______,
35 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
36 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
37 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
38 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
39 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
40};
41
42const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
43{
44 // MACRODOWN only works in this function
45 switch (id)
46 {
47 case 0:
48 if (record->event.pressed)
49 {
50 SEND_STRING("The");
51 return false;
52 }
53 break;
54 case 1:
55 if (record->event.pressed)
56 {
57 SEND_STRING("Custom");
58 return false;
59 }
60 break;
61 case 2:
62 if (record->event.pressed)
63 {
64 SEND_STRING("Keyboard");
65 return false;
66 }
67 break;
68 case 3:
69 if (record->event.pressed)
70 {
71 return MACRO(D(LCTL), T(C), U(LCTL), T(RGHT), D(LCTL), T(V), U(LCTL), END);
72 }
73 break;
74 }
75 return MACRO_NONE;
76};
77
78void matrix_init_user(void)
79{
80}
81
82void matrix_scan_user(void)
83{
84}
85
86bool process_record_user(uint16_t keycode, keyrecord_t *record)
87{
88 return true;
89}
90
91void led_set_user(uint8_t usb_led)
92{
93}
diff --git a/keyboards/kmac/keymaps/winkeyless/rules.mk b/keyboards/kmac/keymaps/winkeyless/rules.mk
deleted file mode 100644
index 128487947..000000000
--- a/keyboards/kmac/keymaps/winkeyless/rules.mk
+++ /dev/null
@@ -1,34 +0,0 @@
1# Copyright 2013 Jun Wako <wakojun@gmail.com>
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16
17# QMK Build Options
18# change to "no" to disable the options, or define them in the Makefile in
19# the appropriate keymap folder that will get included automatically
20#
21BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
22MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
23EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
24CONSOLE_ENABLE = no # Console for debug(+400)
25COMMAND_ENABLE = yes # Commands for debug and configuration
26NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
27BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
28MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
29AUDIO_ENABLE = no # Audio output on port C6
30UNICODE_ENABLE = no # Unicode
31BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
32RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
33SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
34
diff --git a/keyboards/kmac/kmac.c b/keyboards/kmac/kmac.c
index 6b54294b4..dcbbc2f17 100644
--- a/keyboards/kmac/kmac.c
+++ b/keyboards/kmac/kmac.c
@@ -1,4 +1,4 @@
1/* Copyright 2017 Mathias Andersson <wraul@dbox.se> 1/* Copyright 2017-2019 Mathias Andersson <wraul@dbox.se>
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
@@ -15,61 +15,68 @@
15 */ 15 */
16#include "kmac.h" 16#include "kmac.h"
17 17
18#define CAPS_PIN B0
19#define SCROLL_PIN E6
20#define F_ROW_MASK 0b01
21#define WASD_MASK 0b10
22
23// Optional override functions below.
24// You can leave any or all of these undefined.
25// These are only required if you want to perform custom actions.
26
18void matrix_init_kb(void) { 27void matrix_init_kb(void) {
19 // put your keyboard start-up code here 28 // put your keyboard start-up code here
20 // runs once when the firmware starts up 29 // runs once when the firmware starts up
21 led_init_ports(); 30 setPinOutput(CAPS_PIN);
31 setPinOutput(SCROLL_PIN);
32
22 matrix_init_user(); 33 matrix_init_user();
23} 34}
24 35
36/*
37
25void matrix_scan_kb(void) { 38void matrix_scan_kb(void) {
26 // put your looping keyboard code here 39 // put your looping keyboard code here
27 // runs every cycle (a lot) 40 // runs every cycle (a lot)
28 41
29 matrix_scan_user(); 42 matrix_scan_user();
30} 43}
31 44
32bool process_record_kb(uint16_t keycode, keyrecord_t *record) { 45bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
33 // put your per-action keyboard code here 46 // put your per-action keyboard code here
34 // runs for every action, just before processing by the firmware 47 // runs for every action, just before processing by the firmware
35 48
36 return process_record_user(keycode, record); 49 return process_record_user(keycode, record);
37} 50}
38 51
39void led_init_ports(void) { 52*/
40 DDRB |= (1<<0); // OUT
41 DDRE |= (1<<6); // OUT
42}
43 53
44/* LED pin configuration 54/* LED pin configuration
45 * Scroll Lock: Low PE6 55 * Scroll Lock: Low PE6
46 * Caps Lock: Low PB0 56 * Caps Lock: Low PB0
47 */ 57 */
48void led_set_kb(uint8_t usb_led) { 58void led_set_kb(uint8_t usb_led) {
49 if (usb_led & (1<<USB_LED_CAPS_LOCK)) 59 if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
50 { 60 writePinLow(CAPS_PIN);
51 PORTB &= ~(1<<0); // LO 61 } else {
52 } 62 writePinHigh(CAPS_PIN);
53 else
54 {
55 PORTB |= (1<<0); // HI
56 } 63 }
57 64
58 if (usb_led & (1<<USB_LED_SCROLL_LOCK)) 65 if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
59 { 66 writePinLow(SCROLL_PIN);
60 PORTE &= ~(1<<6); // LO 67 } else {
61 } 68 writePinHigh(SCROLL_PIN);
62 else
63 {
64 PORTE |= (1<<6); // HI
65 } 69 }
66 70
67 led_set_user(usb_led); 71 led_set_user(usb_led);
68} 72}
69 73
70void backlight_init_ports(void) { 74void backlight_init_ports(void) {
71 DDRB |= (1<<1) | (1<<2) | (1<<3) | (1<<4); // OUT 75 setPinOutput(B1);
72 DDRD |= (1<<7); // OUT 76 setPinOutput(B2);
77 setPinOutput(B3);
78 setPinOutput(B4);
79 setPinOutput(D7);
73} 80}
74 81
75/* Backlight pin configuration 82/* Backlight pin configuration
@@ -79,31 +86,24 @@ void backlight_init_ports(void) {
79 * S: Low PB3 86 * S: Low PB3
80 * D: Low PD7 87 * D: Low PD7
81 */ 88 */
82void backlight_set(uint8_t level) 89void backlight_set(uint8_t level) {
83{
84 // F-row 90 // F-row
85 if(level & (1<<0)) 91 if (level & F_ROW_MASK) {
86 { 92 writePinHigh(B1);
87 PORTB |= (1<<1); // HI 93 } else {
88 } 94 writePinLow(B1);
89 else
90 {
91 PORTB &= ~(1<<1); // LO
92 } 95 }
93 96
94 // WASD 97 // WASD
95 if(level & (1<<1)) 98 if (level & WASD_MASK) {
96 { 99 writePinLow(B2);
97 PORTB &= ~(1<<4); // LO 100 writePinLow(B3);
98 PORTB &= ~(1<<2); // LO 101 writePinLow(B4);
99 PORTB &= ~(1<<3); // LO 102 writePinLow(D7);
100 PORTD &= ~(1<<7); // LO 103 } else {
101 } 104 writePinHigh(B2);
102 else 105 writePinHigh(B3);
103 { 106 writePinHigh(B4);
104 PORTB |= (1<<4); // HI 107 writePinHigh(D7);
105 PORTB |= (1<<2); // HI
106 PORTB |= (1<<3); // HI
107 PORTD |= (1<<7); // HI
108 } 108 }
109} 109}
diff --git a/keyboards/kmac/kmac.h b/keyboards/kmac/kmac.h
index 44de8914a..edeb63583 100644
--- a/keyboards/kmac/kmac.h
+++ b/keyboards/kmac/kmac.h
@@ -1,4 +1,4 @@
1/* Copyright 2017 Mathias Andersson <wraul@dbox.se> 1/* Copyright 2017-2019 Mathias Andersson <wraul@dbox.se>
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
@@ -13,41 +13,44 @@
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16#ifndef KMAC_H 16#pragma once
17#define KMAC_H
18 17
19#include "quantum.h" 18#include "quantum.h"
20 19
21// Keymap for the winkey version of the PCB. 20// clang-format off
22#define LAYOUT( \ 21#define LAYOUT_tkl_ansi( \
23 K00, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, \ 22 k00, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E, k0F, k0G, \
24 K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, \ 23 k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, k1F, k1G, \
25 K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, \ 24 k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E, k2F, k2G, \
26 K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \ 25 k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3D, \
27 K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4D, K4F, \ 26 k40, k41, k42, k43, k44, k45, k46, k47, k48, k49, k4A, k4D, k4F, \
28 K50, K51, K52, K55, K58, K5A, K5C, K5D, K5E, K5F, K5G) \ 27 k50, k51, k52, k55, k58, k5A, k5C, k5D, k5E, k5F, k5G \
29 { \ 28) \
30 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F G */ \ 29{ \
31 /* 0 */ {K00, KC_NO, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G}, \ 30 {k00, KC_NO, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E, k0F, k0G}, \
32 /* 1 */ {K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G}, \ 31 {k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, k1F, k1G}, \
33 /* 2 */ {K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G}, \ 32 {k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E, k2F, k2G}, \
34 /* 3 */ {K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, KC_NO, K3D, KC_NO, KC_NO, KC_NO}, \ 33 {k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, KC_NO, k3D, KC_NO, KC_NO, KC_NO}, \
35 /* 4 */ {K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, KC_NO, KC_NO, K4D, KC_NO, K4F, KC_NO}, \ 34 {k40, k41, k42, k43, k44, k45, k46, k47, k48, k49, k4A, KC_NO, KC_NO, k4D, KC_NO, k4F, KC_NO}, \
36 /* 5 */ { K50, K51, K52, KC_NO, KC_NO, K55, KC_NO, KC_NO, K58, KC_NO, K5A, KC_NO, K5C, K5D, K5E, K5F, K5G } \ 35 {k50, k51, k52, KC_NO, KC_NO, k55, KC_NO, KC_NO, k58, KC_NO, k5A, KC_NO, k5C, k5D, k5E, k5F, k5G } \
37 } 36}
37// clang-format on
38 38
39// Keymap for the winkeyless version of the PCB. 39// clang-format off
40#define LAYOUT_WKL( \ 40#define LAYOUT_tkl_ansi_wkl( \
41 K00, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, \ 41 k00, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E, k0F, k0G, \
42 K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, \ 42 k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, k1F, k1G, \
43 K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, \ 43 k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E, k2F, k2G, \
44 K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \ 44 k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3D, \
45 K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4D, K4F, \ 45 k40, k41, k42, k43, k44, k45, k46, k47, k48, k49, k4A, k4D, k4F, \
46 K50, K51, K52, K55, K58, K5A, K5D, K5E, K5F, K5G) LAYOUT(K00, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, \ 46 k50, k52, k55, k58, k5D, k5E, k5F, k5G \
47 K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, \ 47) \
48 K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, \ 48{ \
49 K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \ 49 {k00, KC_NO, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E, k0F, k0G}, \
50 K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4D, K4F, \ 50 {k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, k1F, k1G}, \
51 K50, K51, K52, K55, K58, K5A, KC_NO, K5D, K5E, K5F, K5G) 51 {k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E, k2F, k2G}, \
52 52 {k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, KC_NO, k3D, KC_NO, KC_NO, KC_NO}, \
53#endif 53 {k40, k41, k42, k43, k44, k45, k46, k47, k48, k49, k4A, KC_NO, KC_NO, k4D, KC_NO, k4F, KC_NO}, \
54 {k50, KC_NO, k52, KC_NO, KC_NO, k55, KC_NO, KC_NO, k58, KC_NO, KC_NO, KC_NO, KC_NO, k5D, k5E, k5F, k5G } \
55}
56// clang-format on
diff --git a/keyboards/kmac/matrix.c b/keyboards/kmac/matrix.c
index 00da96604..2212ee076 100644
--- a/keyboards/kmac/matrix.c
+++ b/keyboards/kmac/matrix.c
@@ -1,5 +1,5 @@
1/* 1/*
2Copyright 2017 Mathias Andersson <wraul@dbox.se> 2Copyright 2017-2019 Mathias Andersson <wraul@dbox.se>
3 3
4This program is free software: you can redistribute it and/or modify 4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by 5it under the terms of the GNU General Public License as published by
@@ -16,118 +16,137 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17#include <stdint.h> 17#include <stdint.h>
18#include <stdbool.h> 18#include <stdbool.h>
19#if defined(__AVR__)
20#include <avr/io.h>
21#endif
22#include "wait.h" 19#include "wait.h"
23#include "print.h" 20#include "print.h"
24#include "debug.h" 21#include "debug.h"
25#include "util.h" 22#include "util.h"
26#include "matrix.h" 23#include "matrix.h"
27#include "timer.h" 24#include "debounce.h"
28 25#include "quantum.h"
29 26
30/* Set 0 if debouncing isn't needed */ 27#if (MATRIX_COLS <= 8)
31#ifndef DEBOUNCE 28# define print_matrix_header() print("\nr/c 01234567\n")
32# define DEBOUNCE 5 29# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
30# define matrix_bitpop(i) bitpop(matrix[i])
31# define ROW_SHIFTER ((uint8_t)1)
32#elif (MATRIX_COLS <= 16)
33# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
34# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
35# define matrix_bitpop(i) bitpop16(matrix[i])
36# define ROW_SHIFTER ((uint16_t)1)
37#elif (MATRIX_COLS <= 32)
38# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
39# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
40# define matrix_bitpop(i) bitpop32(matrix[i])
41# define ROW_SHIFTER ((uint32_t)1)
33#endif 42#endif
34 43
35#define COL_SHIFTER ((uint32_t)1) 44static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
36 45static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
37static uint16_t debouncing_time;
38static bool debouncing = false;
39
40
41static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
42 46
43/* matrix state(1:on, 0:off) */ 47/* matrix state(1:on, 0:off) */
44static matrix_row_t matrix[MATRIX_ROWS]; 48static matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
45static matrix_row_t matrix_debouncing[MATRIX_ROWS]; 49static matrix_row_t matrix[MATRIX_ROWS]; // debounced values
46 50
47static void init_rows(void); 51__attribute__((weak)) void matrix_init_quantum(void) { matrix_init_kb(); }
48static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col);
49static void unselect_cols(void);
50static void select_col(uint8_t col);
51 52
52inline 53__attribute__((weak)) void matrix_scan_quantum(void) { matrix_scan_kb(); }
53uint8_t matrix_rows(void) {
54 return MATRIX_ROWS;
55}
56 54
57inline 55__attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); }
58uint8_t matrix_cols(void) {
59 return MATRIX_COLS;
60}
61 56
62void matrix_init(void) { 57__attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); }
63 unselect_cols();
64 init_rows();
65 58
66 // initialize matrix state: all keys off 59__attribute__((weak)) void matrix_init_user(void) {}
67 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
68 matrix[i] = 0;
69 matrix_debouncing[i] = 0;
70 }
71 60
72 matrix_init_quantum(); 61__attribute__((weak)) void matrix_scan_user(void) {}
73}
74 62
75uint8_t matrix_scan(void) 63inline uint8_t matrix_rows(void) { return MATRIX_ROWS; }
76{
77 // Set col, read rows
78 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
79 bool matrix_changed = read_rows_on_col(matrix_debouncing, current_col);
80 if (matrix_changed) {
81 debouncing = true;
82 debouncing_time = timer_read();
83 }
84 }
85
86 if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCE)) {
87 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
88 matrix[i] = matrix_debouncing[i];
89 }
90 debouncing = false;
91 }
92 64
93 matrix_scan_quantum(); 65inline uint8_t matrix_cols(void) { return MATRIX_COLS; }
94 return 1;
95}
96 66
97inline 67inline bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & ((matrix_row_t)1 << col)); }
98bool matrix_is_on(uint8_t row, uint8_t col)
99{
100 return (matrix[row] & ((matrix_row_t)1<<col));
101}
102 68
103inline 69inline matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; }
104matrix_row_t matrix_get_row(uint8_t row)
105{
106 return matrix[row];
107}
108 70
109void matrix_print(void) 71void matrix_print(void) {
110{ 72 print_matrix_header();
111 print("\nr/c 0123456789ABCDEFGHIJKLMNOPQRSTUV\n");
112 73
113 for (uint8_t row = 0; row < MATRIX_ROWS; row++) { 74 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
114 phex(row); print(": "); 75 phex(row);
115 print_bin_reverse32(matrix_get_row(row)); 76 print(": ");
77 print_matrix_row(row);
116 print("\n"); 78 print("\n");
117 } 79 }
118} 80}
119 81
120uint8_t matrix_key_count(void) 82uint8_t matrix_key_count(void) {
121{
122 uint8_t count = 0; 83 uint8_t count = 0;
123 for (uint8_t i = 0; i < MATRIX_ROWS; i++) { 84 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
124 count += bitpop32(matrix[i]); 85 count += matrix_bitpop(i);
125 } 86 }
126 return count; 87 return count;
127} 88}
128 89
129static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) 90/* Columns 0 - 15
130{ 91 * These columns uses two 74HC237D 3 to 8 bit demultiplexers.
92 * col / pin: PB6 PC6 PC7 PF1 PF0
93 * 0: 0 1 0 0 0
94 * 1: 0 1 0 0 1
95 * 2: 0 1 0 1 0
96 * 3: 0 1 0 1 1
97 * 4: 0 1 1 0 0
98 * 5: 0 1 1 0 1
99 * 6: 0 1 1 1 0
100 * 7: 0 1 1 1 1
101 * 8: 1 0 0 0 0
102 * 9: 1 0 0 0 1
103 * 10: 1 0 0 1 0
104 * 11: 1 0 0 1 1
105 * 12: 1 0 1 0 0
106 * 13: 1 0 1 0 1
107 * 14: 1 0 1 1 0
108 * 15: 1 0 1 1 1
109 *
110 * col: 16
111 * pin: PB5
112 */
113static void unselect_cols(void) {
114 for (uint8_t x = 0; x < 6; x++) {
115 setPinOutput(col_pins[x]);
116 writePinLow(col_pins[x]);
117 }
118}
119
120static void select_col(uint8_t col) {
121 if (col < 16) {
122 uint8_t c = col + 8;
123
124 writePin(B6, c & 0b10000);
125 writePin(C6, c & 0b01000);
126 writePin(C7, c & 0b00100);
127 writePin(F1, c & 0b00010);
128 writePin(F0, c & 0b00001);
129 } else {
130 writePinHigh(B5);
131 }
132}
133
134/* Row pin configuration
135 * row: 0 1 2 3 4 5
136 * pin: D0 D1 D2 D3 D5 B7
137 *
138 * Caps lock uses its own pin E2
139 */
140static void init_pins(void) {
141 unselect_cols();
142 for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
143 setPinInput(row_pins[x]);
144 }
145
146 setPinInputHigh(E2);
147}
148
149static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
131 bool matrix_changed = false; 150 bool matrix_changed = false;
132 151
133 // Select col and wait for col selecton to stabilize 152 // Select col and wait for col selecton to stabilize
@@ -135,42 +154,32 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
135 wait_us(30); 154 wait_us(30);
136 155
137 // For each row... 156 // For each row...
138 for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) 157 for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
139 {
140 // Store last value of row prior to reading 158 // Store last value of row prior to reading
141 matrix_row_t last_row_value = current_matrix[row_index]; 159 matrix_row_t last_row_value = current_matrix[row_index];
142 160
143 // Check row pin state 161 // Check row pin state
144 // Use the otherwise unused row: 3, col: 0 for caps lock 162 // Use the otherwise unused row: 3, col: 0 for caps lock
145 if (row_index == 3 && current_col == 0) { 163 if (row_index == 3 && current_col == 0) {
146 // Pin E2 uses active low 164 if (readPin(E2) == 0) {
147 if ((_SFR_IO8(E2 >> 4) & _BV(E2 & 0xF)) == 0)
148 {
149 // Pin LO, set col bit 165 // Pin LO, set col bit
150 current_matrix[row_index] |= (COL_SHIFTER << current_col); 166 current_matrix[row_index] |= (ROW_SHIFTER << current_col);
151 } 167 } else {
152 else
153 {
154 // Pin HI, clear col bit 168 // Pin HI, clear col bit
155 current_matrix[row_index] &= ~(COL_SHIFTER << current_col); 169 current_matrix[row_index] &= ~(ROW_SHIFTER << current_col);
156 } 170 }
157 } 171 } else {
158 else { 172 if (readPin(row_pins[row_index]) == 0) {
159 if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF))) 173 // Pin HI, clear col bit
160 { 174 current_matrix[row_index] &= ~(ROW_SHIFTER << current_col);
161 // Pin HI, set col bit 175 } else {
162 current_matrix[row_index] |= (COL_SHIFTER << current_col); 176 // Pin LO, set col bit
163 } 177 current_matrix[row_index] |= (ROW_SHIFTER << current_col);
164 else
165 {
166 // Pin LO, clear col bit
167 current_matrix[row_index] &= ~(COL_SHIFTER << current_col);
168 } 178 }
169 } 179 }
170 180
171 // Determine if the matrix changed state 181 // Determine if the matrix changed state
172 if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) 182 if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) {
173 {
174 matrix_changed = true; 183 matrix_changed = true;
175 } 184 }
176 } 185 }
@@ -181,131 +190,31 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
181 return matrix_changed; 190 return matrix_changed;
182} 191}
183 192
184/* Row pin configuration 193void matrix_init(void) {
185 * row: 0 1 2 3 4 5 194 // initialize key pins
186 * pin: D0 D1 D2 D3 D5 B7 195 init_pins();
187 *
188 * Caps lock uses its own pin E2
189 */
190static void init_rows(void)
191{
192 DDRD &= ~((1<<0)| (1<<1) | (1<<2) | (1<<3) | (1<<5)); // IN
193 PORTD &= ~((1<<0)| (1<<1) | (1<<2) | (1<<3) | (1<<5)); // LO
194 DDRB &= ~(1<<7); // IN
195 PORTB &= ~(1<<7); // LO
196
197 DDRE &= ~(1<<2); // IN
198 PORTE |= (1<<2); // HI
199}
200 196
201/* Columns 0 - 15 197 // initialize matrix state: all keys off
202 * These columns uses two 74HC237D 3 to 8 bit demultiplexers. 198 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
203 * col / pin: PC6 PB6 PF0 PF1 PC7 199 raw_matrix[i] = 0;
204 * 0: 1 0 0 0 0 200 matrix[i] = 0;
205 * 1: 1 0 1 0 0 201 }
206 * 2: 1 0 0 1 0
207 * 3: 1 0 1 1 0
208 * 4: 1 0 0 0 1
209 * 5: 1 0 1 0 1
210 * 6: 1 0 0 1 1
211 * 7: 1 0 1 1 1
212 * 8: 0 1 0 0 0
213 * 9: 0 1 1 0 0
214 * 10: 0 1 0 1 0
215 * 11: 0 1 1 1 0
216 * 12: 0 1 0 0 1
217 * 13: 0 1 1 0 1
218 * 14: 0 1 0 1 1
219 * 15: 0 1 1 1 1
220 *
221 * col: 16
222 * pin: PB5
223 */
224static void unselect_cols(void)
225{
226 DDRB |= (1<<5) | (1<<6); // OUT
227 PORTB &= ~((1<<5) | (1<<6)); // LO
228 202
229 DDRC |= (1<<6) | (1<<7); // OUT 203 debounce_init(MATRIX_ROWS);
230 PORTC &= ~((1<<6) | (1<<7)); // LO
231 204
232 DDRF |= (1<<0) | (1<<1); // OUT 205 matrix_init_quantum();
233 PORTF &= ~((1<<0) | (1<<1)); // LO
234} 206}
235 207
236static void select_col(uint8_t col) 208uint8_t matrix_scan(void) {
237{ 209 bool changed = false;
238 switch (col) { 210
239 case 0: 211 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
240 PORTC |= (1<<6); // HI 212 changed |= read_rows_on_col(raw_matrix, current_col);
241 break;
242 case 1:
243 PORTC |= (1<<6); // HI
244 PORTF |= (1<<0); // HI
245 break;
246 case 2:
247 PORTC |= (1<<6); // HI
248 PORTF |= (1<<1); // HI
249 break;
250 case 3:
251 PORTC |= (1<<6); // HI
252 PORTF |= (1<<0) | (1<<1); // HI
253 break;
254 case 4:
255 PORTC |= (1<<6); // HI
256 PORTC |= (1<<7); // HI
257 break;
258 case 5:
259 PORTC |= (1<<6); // HI
260 PORTF |= (1<<0); // HI
261 PORTC |= (1<<7); // HI
262 break;
263 case 6:
264 PORTC |= (1<<6); // HI
265 PORTF |= (1<<1); // HI
266 PORTC |= (1<<7); // HI
267 break;
268 case 7:
269 PORTC |= (1<<6); // HI
270 PORTF |= (1<<0) | (1<<1); // HI
271 PORTC |= (1<<7); // HI
272 break;
273 case 8:
274 PORTB |= (1<<6); // HI
275 break;
276 case 9:
277 PORTB |= (1<<6); // HI
278 PORTF |= (1<<0); // HI
279 break;
280 case 10:
281 PORTB |= (1<<6); // HI
282 PORTF |= (1<<1); // HI
283 break;
284 case 11:
285 PORTB |= (1<<6); // HI
286 PORTF |= (1<<0) | (1<<1); // HI
287 break;
288 case 12:
289 PORTB |= (1<<6); // HI
290 PORTC |= (1<<7); // HI
291 break;
292 case 13:
293 PORTB |= (1<<6); // HI
294 PORTF |= (1<<0); // HI
295 PORTC |= (1<<7); // HI
296 break;
297 case 14:
298 PORTB |= (1<<6); // HI
299 PORTF |= (1<<1); // HI
300 PORTC |= (1<<7); // HI
301 break;
302 case 15:
303 PORTB |= (1<<6); // HI
304 PORTF |= (1<<0) | (1<<1); // HI
305 PORTC |= (1<<7); // HI
306 break;
307 case 16:
308 PORTB |= (1<<5); // HI
309 break;
310 } 213 }
214
215 debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
216
217 matrix_scan_quantum();
218
219 return (uint8_t)changed;
311} 220}
diff --git a/keyboards/kmac/readme.md b/keyboards/kmac/readme.md
index cd181a5f6..47dbaa847 100644
--- a/keyboards/kmac/readme.md
+++ b/keyboards/kmac/readme.md
@@ -1,44 +1,21 @@
1# KMAC keyboard firmware 1# KMAC
2 2
3A Korean custom keyboard designed by Byungho Kim and the KBDMania community. 3A Korean custom keyboard designed by Byungho Kim and the KBDMania community.
4 4
5## Supported models 5Keyboard Maintainer: [Mathias Andersson](https://github.com/wraul)
6Hardware Supported: KMAC & KMAC 2
7Hardware Availability: http://www.kbdmania.net/xe/news/5232321
6 8
7All the tenkeyless models should be supported. 9Make example for this keyboard (after setting up your build environment):
8 10
9## Bootloader 11 make kmac:default
10
11The PCB is hardwired to run the bootloader if the key at the `Caps Lock` position is held down when connecting the keyboard.
12 12
13It is also possible to use Boot Magic and Command to access the bootloader. 13See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
14 14
15## Quantum MK Firmware 15## Bootloader
16 16
17For the full Quantum feature list, see the [documentation](https://docs.qmk.fm). 17The PCB is hardwired to run the bootloader if the key at the `Caps Lock` position is held down when connecting the keyboard.
18 18
19## Building 19## PCB versions
20 20
21The KMAC are available with two different PCB layouts, a winkey version and a winkeyless version. A default keymap are provided for each versions of the PCB. 21The KMAC are available with two different PCB layouts, a winkey version and a winkeyless version. A default keymap are provided for each versions of the PCB.
22
23Depending on which PCB and keymap you would like to use, you will have to compile the firmware slightly differently. All of the commands should be run in the [qmk root](https://github.com/qmk/qmk_firmware/) folder.
24
25### Winkey keymap
26
27The [default keymap](keymaps/default) are designed for the winkey version of the PCB.
28
29### Winkeyless Keymap
30
31A [keymap](keymaps/winkeyless) for the winkeyless version of the PCB are also provided.
32
33### Custom keymaps
34
35To define your own keymap, copy one of the [existing keymap](keymaps) folders and give it the name of your keymap. Then check the [keymap documentation](https://docs.qmk.fm/faq_keymap.html) for details on how to modify the keymap.
36
37To make it easy to define keymaps for the different versions of the PCB two macros are provided.
38
39| PCB | Macro |
40| -------------- | -------------- |
41| Winkey PCB | `LAYOUT()` |
42| Winkeyless PCB | `LAYOUT_WKL()` |
43
44To build the firmware with a custom keymap, run `make <keymap name>`
diff --git a/keyboards/kmac/rules.mk b/keyboards/kmac/rules.mk
index 41b16979d..dbcf540bd 100644
--- a/keyboards/kmac/rules.mk
+++ b/keyboards/kmac/rules.mk
@@ -1,5 +1,5 @@
1# Project specific files 1# Project specific files
2SRC = matrix.c 2SRC += matrix.c
3 3
4# MCU name 4# MCU name
5#MCU = at90usb1287 5#MCU = at90usb1287
@@ -42,15 +42,19 @@ F_USB = $(F_CPU)
42OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT 42OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
43 43
44 44
45# Boot Section Size in *bytes* 45# Bootloader selection
46# Teensy halfKay 512 46# Teensy halfkay
47# Teensy++ halfKay 1024 47# Pro Micro caterina
48# Atmel DFU loader 4096 48# Atmel DFU atmel-dfu
49# LUFA bootloader 4096 49# LUFA DFU lufa-dfu
50# USBaspLoader 2048 50# QMK DFU qmk-dfu
51OPT_DEFS += -DBOOTLOADER_SIZE=4096 51# atmega32a bootloadHID
52BOOTLOADER = atmel-dfu
52 53
53 54
55# Supported layouts
56LAYOUTS = tkl_ansi
57
54# Build Options 58# Build Options
55# change yes to no to disable 59# change yes to no to disable
56# 60#