aboutsummaryrefslogtreecommitdiff
path: root/keyboards/kmac
diff options
context:
space:
mode:
authorMathias Andersson <wraul@dbox.se>2017-06-04 22:13:17 +0200
committerMathias Andersson <wraul@dbox.se>2017-06-08 19:35:27 +0200
commit1b02b2006e61f55fa7a38b929e6d604d0f6504e8 (patch)
tree0379f7d46ae68f313b8c37a19a4f69f912475d46 /keyboards/kmac
parent00d94166267f3ef9f514234ad877470b74b30601 (diff)
downloadqmk_firmware-1b02b2006e61f55fa7a38b929e6d604d0f6504e8.tar.gz
qmk_firmware-1b02b2006e61f55fa7a38b929e6d604d0f6504e8.zip
Add support for KMAC
Diffstat (limited to 'keyboards/kmac')
-rw-r--r--keyboards/kmac/Makefile18
-rw-r--r--keyboards/kmac/config.h178
-rw-r--r--keyboards/kmac/keymaps/default/Makefile37
-rw-r--r--keyboards/kmac/keymaps/default/config.h24
-rw-r--r--keyboards/kmac/keymaps/default/keymap.c97
-rw-r--r--keyboards/kmac/keymaps/default/readme.md56
-rw-r--r--keyboards/kmac/keymaps/winkeyless/Makefile37
-rw-r--r--keyboards/kmac/keymaps/winkeyless/config.h24
-rw-r--r--keyboards/kmac/keymaps/winkeyless/keymap.c97
-rw-r--r--keyboards/kmac/keymaps/winkeyless/readme.md57
-rw-r--r--keyboards/kmac/kmac.c109
-rw-r--r--keyboards/kmac/kmac.h56
-rw-r--r--keyboards/kmac/matrix.c311
-rw-r--r--keyboards/kmac/readme.md45
-rw-r--r--keyboards/kmac/rules.mk72
15 files changed, 1218 insertions, 0 deletions
diff --git a/keyboards/kmac/Makefile b/keyboards/kmac/Makefile
new file mode 100644
index 000000000..840dc9a28
--- /dev/null
+++ b/keyboards/kmac/Makefile
@@ -0,0 +1,18 @@
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
16ifndef MAKEFILE_INCLUDED
17 include ../../Makefile
18endif
diff --git a/keyboards/kmac/config.h b/keyboards/kmac/config.h
new file mode 100644
index 000000000..5c164bfc1
--- /dev/null
+++ b/keyboards/kmac/config.h
@@ -0,0 +1,178 @@
1/*
2Copyright 2017 Mathias Andersson <wraul@dbox.se>
3
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
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21#include "config_common.h"
22
23/* USB Device descriptor parameter */
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x6050
26#define DEVICE_VER 0x0104
27#define MANUFACTURER KBDMania
28#define PRODUCT KMAC
29#define DESCRIPTION QMK keyboard firmware for KMAC
30
31/* key matrix size */
32#define MATRIX_ROWS 6
33#define MATRIX_COLS 17
34
35/*
36 * Keyboard Matrix Assignments
37 * The KMAC uses demultiplexers for the cols, they are only included here as documentation.
38 * See matrix.c for more details.
39*/
40#define MATRIX_ROW_PINS { D0, D1, D2, D3, D5, B7 }
41#define MATRIX_COL_PINS { C6, B6, F0, F1, C7, B5 }
42#define UNUSED_PINS
43
44/* COL2ROW, ROW2COL, or CUSTOM_MATRIX */
45#define DIODE_DIRECTION CUSTOM_MATRIX
46
47/* number of backlight levels */
48#define BACKLIGHT_LEVELS 3
49// #define BACKLIGHT_PIN B7
50// #define BACKLIGHT_BREATHING
51
52/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
53#define DEBOUNCING_DELAY 5
54
55/* define if matrix has ghost (lacks anti-ghosting diodes) */
56//#define MATRIX_HAS_GHOST
57
58/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
59#define LOCKING_SUPPORT_ENABLE
60/* Locking resynchronize hack */
61#define LOCKING_RESYNC_ENABLE
62
63/*
64 * Force NKRO
65 *
66 * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
67 * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
68 * makefile for this to work.)
69 *
70 * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
71 * until the next keyboard reset.
72 *
73 * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
74 * fully operational during normal computer usage.
75 *
76 * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
77 * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
78 * bootmagic, NKRO mode will always be enabled until it is toggled again during a
79 * power-up.
80 *
81 */
82//#define FORCE_NKRO
83
84/*
85 * Magic Key Options
86 *
87 * Magic keys are hotkey commands that allow control over firmware functions of
88 * the keyboard. They are best used in combination with the HID Listen program,
89 * found here: https://www.pjrc.com/teensy/hid_listen.html
90 *
91 * The options below allow the magic key functionality to be changed. This is
92 * useful if your keyboard/keypad is missing keys and you want magic key support.
93 *
94 */
95
96/* key combination for magic key command */
97#define IS_COMMAND() ( \
98 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
99)
100
101/* control how magic key switches layers */
102//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
103//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
104//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
105
106/* override magic key keymap */
107//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
108//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
109//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
110//#define MAGIC_KEY_HELP1 H
111//#define MAGIC_KEY_HELP2 SLASH
112//#define MAGIC_KEY_DEBUG D
113//#define MAGIC_KEY_DEBUG_MATRIX X
114//#define MAGIC_KEY_DEBUG_KBD K
115//#define MAGIC_KEY_DEBUG_MOUSE M
116//#define MAGIC_KEY_VERSION V
117//#define MAGIC_KEY_STATUS S
118//#define MAGIC_KEY_CONSOLE C
119//#define MAGIC_KEY_LAYER0_ALT1 ESC
120//#define MAGIC_KEY_LAYER0_ALT2 GRAVE
121//#define MAGIC_KEY_LAYER0 0
122//#define MAGIC_KEY_LAYER1 1
123//#define MAGIC_KEY_LAYER2 2
124//#define MAGIC_KEY_LAYER3 3
125//#define MAGIC_KEY_LAYER4 4
126//#define MAGIC_KEY_LAYER5 5
127//#define MAGIC_KEY_LAYER6 6
128//#define MAGIC_KEY_LAYER7 7
129//#define MAGIC_KEY_LAYER8 8
130//#define MAGIC_KEY_LAYER9 9
131//#define MAGIC_KEY_BOOTLOADER PAUSE
132//#define MAGIC_KEY_LOCK CAPS
133//#define MAGIC_KEY_EEPROM E
134//#define MAGIC_KEY_NKRO N
135//#define MAGIC_KEY_SLEEP_LED Z
136
137/*
138 * Feature disable options
139 * These options are also useful to firmware size reduction.
140 */
141
142/* disable debug print */
143//#define NO_DEBUG
144
145/* disable print */
146//#define NO_PRINT
147
148/* disable action features */
149//#define NO_ACTION_LAYER
150//#define NO_ACTION_TAPPING
151//#define NO_ACTION_ONESHOT
152//#define NO_ACTION_MACRO
153//#define NO_ACTION_FUNCTION
154
155/*
156 * MIDI options
157 */
158
159/* Prevent use of disabled MIDI features in the keymap */
160//#define MIDI_ENABLE_STRICT 1
161
162/* enable basic MIDI features:
163 - MIDI notes can be sent when in Music mode is on
164*/
165//#define MIDI_BASIC
166
167/* enable advanced MIDI features:
168 - MIDI notes can be added to the keymap
169 - Octave shift and transpose
170 - Virtual sustain, portamento, and modulation wheel
171 - etc.
172*/
173//#define MIDI_ADVANCED
174
175/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
176//#define MIDI_TONE_KEYCODE_OCTAVES 1
177
178#endif
diff --git a/keyboards/kmac/keymaps/default/Makefile b/keyboards/kmac/keymaps/default/Makefile
new file mode 100644
index 000000000..a8a44889d
--- /dev/null
+++ b/keyboards/kmac/keymaps/default/Makefile
@@ -0,0 +1,37 @@
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 = yes # 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
35ifndef QUANTUM_DIR
36 include ../../../../Makefile
37endif
diff --git a/keyboards/kmac/keymaps/default/config.h b/keyboards/kmac/keymaps/default/config.h
new file mode 100644
index 000000000..a3828f7d5
--- /dev/null
+++ b/keyboards/kmac/keymaps/default/config.h
@@ -0,0 +1,24 @@
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
17#ifndef CONFIG_USER_H
18#define CONFIG_USER_H
19
20#include "../../config.h"
21
22// place overrides here
23
24#endif
diff --git a/keyboards/kmac/keymaps/default/keymap.c b/keyboards/kmac/keymaps/default/keymap.c
new file mode 100644
index 000000000..3553e8492
--- /dev/null
+++ b/keyboards/kmac/keymaps/default/keymap.c
@@ -0,0 +1,97 @@
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 "kmac.h"
17
18// Helpful defines
19#define _______ KC_TRNS
20
21// Each layer gets a name for readability, which is then used in the keymap matrix below.
22// The underscores don't mean anything - you can have a layer called STUFF or any other name.
23// Layer names don't all need to be of the same length, obviously, and you can also skip them
24// entirely and just use numbers.
25#define _BL 0
26#define _FL 1
27
28const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
29 [_BL] = KEYMAP(
30 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, \
31 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, \
32 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, \
33 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, \
34 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, \
35 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(_FL), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT \
36 ),
37 [_FL] = KEYMAP(
38 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), _______, _______, _______, \
39 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
40 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
41 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
42 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
43 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
44 ),
45};
46
47const uint16_t PROGMEM fn_actions[] = {
48
49};
50
51const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
52{
53 // MACRODOWN only works in this function
54 switch(id) {
55 case 0:
56 if (record->event.pressed) {
57 SEND_STRING("The");
58 return false;
59 }
60 break;
61 case 1:
62 if (record->event.pressed) {
63 SEND_STRING("Custom");
64 return false;
65 }
66 break;
67 case 2:
68 if (record->event.pressed) {
69 SEND_STRING("Keyboard");
70 return false;
71 }
72 break;
73 case 3:
74 if (record->event.pressed) {
75 return MACRO( D(LCTL), T(C), U(LCTL), T(RGHT), D(LCTL), T(V), U(LCTL), END );
76 }
77 break;
78 }
79 return MACRO_NONE;
80};
81
82
83void matrix_init_user(void) {
84
85}
86
87void matrix_scan_user(void) {
88
89}
90
91bool process_record_user(uint16_t keycode, keyrecord_t *record) {
92 return true;
93}
94
95void led_set_user(uint8_t usb_led) {
96
97}
diff --git a/keyboards/kmac/keymaps/default/readme.md b/keyboards/kmac/keymaps/default/readme.md
new file mode 100644
index 000000000..d384e0d6a
--- /dev/null
+++ b/keyboards/kmac/keymaps/default/readme.md
@@ -0,0 +1,56 @@
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
5See [keymap.c](keymap.c) for details.
6
7## Layers
8
9The keymap have two layers. To access the functions on the second layer, hold down caps lock and press the corresponding key.
10
11### Layer 1: Default Layer
12 ,---. ,---------------. ,---------------. ,---------------. ,-----------.
13 |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
14 `---' `---------------' `---------------' `---------------' `-----------'
15 ,-----------------------------------------------------------. ,-----------.
16 |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
17 |-----------------------------------------------------------| |-----------|
18 |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
19 |-----------------------------------------------------------| '-----------'
20 |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
21 |-----------------------------------------------------------| ,---.
22 |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
23 |-----------------------------------------------------------| ,-----------.
24 |Ctl|Gui|Alt| Space |Alt|Gui|Fn |Ctl| |Lef|Dow|Rig|
25 `-----------------------------------------------------------' `-----------'
26
27### Layer 2: Function Layer
28 ,---. ,---------------. ,---------------. ,---------------. ,-----------.
29 |Led| |M1 |M2 |M3 |M4 | |M5 |M6 |M7 |M8 | |M9 |M10|M11|M12| | | | |
30 `---' `---------------' `---------------' `---------------' `-----------'
31 ,-----------------------------------------------------------. ,-----------.
32 | | | | | | | | | | | | | | | | | | |
33 |-----------------------------------------------------------| |-----------|
34 | | | | | | | | | | | | | | | | | | |
35 |-----------------------------------------------------------| '-----------'
36 | | | | | | | | | | | | | |
37 |-----------------------------------------------------------| ,---.
38 | | | | | | | | | | | | | | |
39 |-----------------------------------------------------------| ,-----------.
40 | | | | | | | | | | | | |
41 `-----------------------------------------------------------' `-----------'
42
43## Macros
44
45These are mostly useless and serve more like examples I guess.
46
47| Macro | Action |
48|:-----:| -------------------------------------- |
49| 1 | Types `The` |
50| 2 | Types `Custom` |
51| 3 | Types `Keyboard` |
52| 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/winkeyless/Makefile b/keyboards/kmac/keymaps/winkeyless/Makefile
new file mode 100644
index 000000000..a8a44889d
--- /dev/null
+++ b/keyboards/kmac/keymaps/winkeyless/Makefile
@@ -0,0 +1,37 @@
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 = yes # 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
35ifndef QUANTUM_DIR
36 include ../../../../Makefile
37endif
diff --git a/keyboards/kmac/keymaps/winkeyless/config.h b/keyboards/kmac/keymaps/winkeyless/config.h
new file mode 100644
index 000000000..a3828f7d5
--- /dev/null
+++ b/keyboards/kmac/keymaps/winkeyless/config.h
@@ -0,0 +1,24 @@
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
17#ifndef CONFIG_USER_H
18#define CONFIG_USER_H
19
20#include "../../config.h"
21
22// place overrides here
23
24#endif
diff --git a/keyboards/kmac/keymaps/winkeyless/keymap.c b/keyboards/kmac/keymaps/winkeyless/keymap.c
new file mode 100644
index 000000000..f986dec27
--- /dev/null
+++ b/keyboards/kmac/keymaps/winkeyless/keymap.c
@@ -0,0 +1,97 @@
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 "kmac.h"
17
18// Helpful defines
19#define _______ KC_TRNS
20
21// Each layer gets a name for readability, which is then used in the keymap matrix below.
22// The underscores don't mean anything - you can have a layer called STUFF or any other name.
23// Layer names don't all need to be of the same length, obviously, and you can also skip them
24// entirely and just use numbers.
25#define _BL 0
26#define _FL 1
27
28const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
29 [_BL] = KEYMAP_WINKEYLESS(
30 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, \
31 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, \
32 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, \
33 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, \
34 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, \
35 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FL), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT \
36 ),
37 [_FL] = KEYMAP_WINKEYLESS(
38 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), _______, _______, _______, \
39 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
40 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
41 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
42 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
43 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
44 ),
45};
46
47const uint16_t PROGMEM fn_actions[] = {
48
49};
50
51const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
52{
53 // MACRODOWN only works in this function
54 switch(id) {
55 case 0:
56 if (record->event.pressed) {
57 SEND_STRING("The");
58 return false;
59 }
60 break;
61 case 1:
62 if (record->event.pressed) {
63 SEND_STRING("Custom");
64 return false;
65 }
66 break;
67 case 2:
68 if (record->event.pressed) {
69 SEND_STRING("Keyboard");
70 return false;
71 }
72 break;
73 case 3:
74 if (record->event.pressed) {
75 return MACRO( D(LCTL), T(C), U(LCTL), T(RGHT), D(LCTL), T(V), U(LCTL), END );
76 }
77 break;
78 }
79 return MACRO_NONE;
80};
81
82
83void matrix_init_user(void) {
84
85}
86
87void matrix_scan_user(void) {
88
89}
90
91bool process_record_user(uint16_t keycode, keyrecord_t *record) {
92 return true;
93}
94
95void led_set_user(uint8_t usb_led) {
96
97}
diff --git a/keyboards/kmac/keymaps/winkeyless/readme.md b/keyboards/kmac/keymaps/winkeyless/readme.md
new file mode 100644
index 000000000..b921f7b0f
--- /dev/null
+++ b/keyboards/kmac/keymaps/winkeyless/readme.md
@@ -0,0 +1,57 @@
1# Keymap for the winkeyless version of KMAC
2
3This is the default keymap for the winkeyless version of the PCB. It implements the same features as the official default KMAC firmware.
4
5
6See [keymap.c](keymap.c) for details.
7
8## Layers
9
10The keymap have two layers. To access the functions on the second layer, hold down caps lock and press the corresponding key.
11
12### Layer 1: Default Layer
13 ,---. ,---------------. ,---------------. ,---------------. ,-----------.
14 |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
15 `---' `---------------' `---------------' `---------------' `-----------'
16 ,-----------------------------------------------------------. ,-----------.
17 |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
18 |-----------------------------------------------------------| |-----------|
19 |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
20 |-----------------------------------------------------------| '-----------'
21 |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
22 |-----------------------------------------------------------| ,---.
23 |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
24 |-----------------------------------------------------------| ,-----------.
25 |Ctl|Gui|Alt| Space |Alt|Fn |Ctl| |Lef|Dow|Rig|
26 `-----------------------------------------------------------' `-----------'
27
28### Layer 2: Function Layer
29 ,---. ,---------------. ,---------------. ,---------------. ,-----------.
30 |Led| |M1 |M2 |M3 |M4 | |M5 |M6 |M7 |M8 | |M9 |M10|M11|M12| | | | |
31 `---' `---------------' `---------------' `---------------' `-----------'
32 ,-----------------------------------------------------------. ,-----------.
33 | | | | | | | | | | | | | | | | | | |
34 |-----------------------------------------------------------| |-----------|
35 | | | | | | | | | | | | | | | | | | |
36 |-----------------------------------------------------------| '-----------'
37 | | | | | | | | | | | | | |
38 |-----------------------------------------------------------| ,---.
39 | | | | | | | | | | | | | | |
40 |-----------------------------------------------------------| ,-----------.
41 | | | | | | | | | | | |
42 `-----------------------------------------------------------' `-----------'
43
44## Macros
45
46These are mostly useless and serve more like examples I guess.
47
48| Macro | Action |
49|:-----:| -------------------------------------- |
50| 1 | Types `The` |
51| 2 | Types `Custom` |
52| 3 | Types `Keyboard` |
53| 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/kmac.c b/keyboards/kmac/kmac.c
new file mode 100644
index 000000000..34647e81a
--- /dev/null
+++ b/keyboards/kmac/kmac.c
@@ -0,0 +1,109 @@
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 "kmac.h"
17
18void matrix_init_kb(void) {
19 // put your keyboard start-up code here
20 // runs once when the firmware starts up
21 led_init_ports();
22 matrix_init_user();
23}
24
25void matrix_scan_kb(void) {
26 // put your looping keyboard code here
27 // runs every cycle (a lot)
28
29 matrix_scan_user();
30}
31
32bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
33 // put your per-action keyboard code here
34 // runs for every action, just before processing by the firmware
35
36 return process_record_user(keycode, record);
37}
38
39void led_init_ports(void) {
40 DDRB |= (1<<0); // OUT
41 DDRE |= (1<<6); // OUT
42}
43
44/* LED pin configuration
45 * Scroll Lock: Low PE6
46 * Caps Lock: Low PB0
47 */
48void led_set_kb(uint8_t usb_led) {
49 if (usb_led & (1<<USB_LED_CAPS_LOCK))
50 {
51 PORTB &= ~(1<<0); // LO
52 }
53 else
54 {
55 PORTB |= (1<<0); // HI
56 }
57
58 if (usb_led & (1<<USB_LED_SCROLL_LOCK))
59 {
60 PORTE &= ~(1<<6); // LO
61 }
62 else
63 {
64 PORTE |= (1<<6); // HI
65 }
66
67 led_set_user(usb_led);
68}
69
70void backlight_init_ports(void) {
71 DDRB |= (1<<1) | (1<<2) | (1<<3) | (1<<4); // OUT
72 DDRD |= (1<<7); // OUT
73}
74
75/* Backlight pin configuration
76 * F-row: High PB1
77 * W: Low PB4
78 * A: Low PB2
79 * S: Low PB3
80 * D: Low PD7
81 */
82void backlight_set(uint8_t level)
83{
84 // F-row
85 if(level & (1<<0))
86 {
87 PORTB |= (1<<1); // HI
88 }
89 else
90 {
91 PORTB &= ~(1<<1); // LO
92 }
93
94 // WASD
95 if(level & (1<<1))
96 {
97 PORTB &= ~(1<<4); // LO
98 PORTB &= ~(1<<2); // LO
99 PORTB &= ~(1<<3); // LO
100 PORTD &= ~(1<<7); // LO
101 }
102 else
103 {
104 PORTB |= (1<<4); // HI
105 PORTB |= (1<<2); // HI
106 PORTB |= (1<<3); // HI
107 PORTD |= (1<<7); // HI
108 }
109}
diff --git a/keyboards/kmac/kmac.h b/keyboards/kmac/kmac.h
new file mode 100644
index 000000000..1d9d8e36b
--- /dev/null
+++ b/keyboards/kmac/kmac.h
@@ -0,0 +1,56 @@
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#ifndef KMAC_H
17#define KMAC_H
18
19#include "quantum.h"
20
21// Keymap for the winkey version of the PCB.
22#define KEYMAP( \
23 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, \
25 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, \
27 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 \
29) { \
30/* 0 1 2 3 4 5 6 7 8 9 A B C D E F G */ \
31/* 0 */ { 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 }, \
33/* 2 */ { 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 }, \
35/* 4 */ { 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 } \
37}
38
39// Keymap for the winkeyless version of the PCB.
40#define KEYMAP_WINKEYLESS( \
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, \
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, \
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 \
47) KEYMAP( \
48 K00, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, \
49 K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, \
50 K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, \
51 K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \
52 K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4D, K4F, \
53 K50, K51, K52, K55, K58, K5A, KC_NO, K5D, K5E, K5F, K5G \
54)
55
56#endif
diff --git a/keyboards/kmac/matrix.c b/keyboards/kmac/matrix.c
new file mode 100644
index 000000000..bab638bdf
--- /dev/null
+++ b/keyboards/kmac/matrix.c
@@ -0,0 +1,311 @@
1/*
2Copyright 2017 Mathias Andersson <wraul@dbox.se>
3
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
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include <stdint.h>
18#include <stdbool.h>
19#if defined(__AVR__)
20#include <avr/io.h>
21#endif
22#include "wait.h"
23#include "print.h"
24#include "debug.h"
25#include "util.h"
26#include "matrix.h"
27#include "timer.h"
28
29
30/* Set 0 if debouncing isn't needed */
31#ifndef DEBOUNCING_DELAY
32# define DEBOUNCING_DELAY 5
33#endif
34
35#define COL_SHIFTER ((uint32_t)1)
36
37static uint16_t debouncing_time;
38static bool debouncing = false;
39
40
41static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
42
43/* matrix state(1:on, 0:off) */
44static matrix_row_t matrix[MATRIX_ROWS];
45static matrix_row_t matrix_debouncing[MATRIX_ROWS];
46
47static void init_rows(void);
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
52inline
53uint8_t matrix_rows(void) {
54 return MATRIX_ROWS;
55}
56
57inline
58uint8_t matrix_cols(void) {
59 return MATRIX_COLS;
60}
61
62void matrix_init(void) {
63 unselect_cols();
64 init_rows();
65
66 // initialize matrix state: all keys off
67 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
68 matrix[i] = 0;
69 matrix_debouncing[i] = 0;
70 }
71
72 matrix_init_quantum();
73}
74
75uint8_t matrix_scan(void)
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) > DEBOUNCING_DELAY)) {
87 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
88 matrix[i] = matrix_debouncing[i];
89 }
90 debouncing = false;
91 }
92
93 matrix_scan_quantum();
94 return 1;
95}
96
97inline
98bool matrix_is_on(uint8_t row, uint8_t col)
99{
100 return (matrix[row] & ((matrix_row_t)1<col));
101}
102
103inline
104matrix_row_t matrix_get_row(uint8_t row)
105{
106 return matrix[row];
107}
108
109void matrix_print(void)
110{
111 print("\nr/c 0123456789ABCDEFGHIJKLMNOPQRSTUV\n");
112
113 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
114 phex(row); print(": ");
115 print_bin_reverse32(matrix_get_row(row));
116 print("\n");
117 }
118}
119
120uint8_t matrix_key_count(void)
121{
122 uint8_t count = 0;
123 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
124 count += bitpop32(matrix[i]);
125 }
126 return count;
127}
128
129static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
130{
131 bool matrix_changed = false;
132
133 // Select col and wait for col selecton to stabilize
134 select_col(current_col);
135 wait_us(30);
136
137 // For each row...
138 for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++)
139 {
140 // Store last value of row prior to reading
141 matrix_row_t last_row_value = current_matrix[row_index];
142
143 // Check row pin state
144 // Use the otherwise unused row: 3, col: 0 for caps lock
145 if (row_index == 3 && current_col == 0) {
146 // Pin E2 uses active low
147 if ((_SFR_IO8(E2 >> 4) & _BV(E2 & 0xF)) == 0)
148 {
149 // Pin LO, set col bit
150 current_matrix[row_index] |= (COL_SHIFTER << current_col);
151 }
152 else
153 {
154 // Pin HI, clear col bit
155 current_matrix[row_index] &= ~(COL_SHIFTER << current_col);
156 }
157 }
158 else {
159 if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)))
160 {
161 // Pin HI, set col bit
162 current_matrix[row_index] |= (COL_SHIFTER << current_col);
163 }
164 else
165 {
166 // Pin LO, clear col bit
167 current_matrix[row_index] &= ~(COL_SHIFTER << current_col);
168 }
169 }
170
171 // Determine if the matrix changed state
172 if ((last_row_value != current_matrix[row_index]) && !(matrix_changed))
173 {
174 matrix_changed = true;
175 }
176 }
177
178 // Unselect cols
179 unselect_cols();
180
181 return matrix_changed;
182}
183
184/* Row pin configuration
185 * row: 0 1 2 3 4 5
186 * pin: D0 D1 D2 D3 D5 B7
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
201/* Columns 0 - 15
202 * These columns uses two 74HC237D 3 to 8 bit demultiplexers.
203 * col / pin: PC6 PB6 PF0 PF1 PC7
204 * 0: 1 0 0 0 0
205 * 1: 1 0 1 0 0
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
229 DDRC |= (1<<6) | (1<<7); // OUT
230 PORTC &= ~((1<<6) | (1<<7)); // LO
231
232 DDRF |= (1<<0) | (1<<1); // OUT
233 PORTF &= ~((1<<0) | (1<<1)); // LO
234}
235
236static void select_col(uint8_t col)
237{
238 switch (col) {
239 case 0:
240 PORTC |= (1<<6); // HI
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 }
311}
diff --git a/keyboards/kmac/readme.md b/keyboards/kmac/readme.md
new file mode 100644
index 000000000..e7d97778f
--- /dev/null
+++ b/keyboards/kmac/readme.md
@@ -0,0 +1,45 @@
1KMAC keyboard firmware
2======================
3
4A Korean custom keyboard designed by Byungho Kim and the KBDMania community.
5
6## Supported models
7
8All the tenkeyless models should be supported.
9
10## Bootloader
11
12The PCB is hardwired to run the bootloader if the key at the `Caps Lock` position is held down when connecting the keyboard.
13
14It is also possible to use Boot Magic and Command to access the bootloader.
15
16## Quantum MK Firmware
17
18For the full Quantum feature list, see the [documentation](https://docs.qmk.fm).
19
20## Building
21
22The 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.
23
24Depending 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 [keyboards/kmac](/keyboards/kmac) folder.
25
26### Winkey keymap
27
28The [default keymap](keymaps/default) are designed for the winkey version of the PCB.
29
30### Winkeyless Keymap
31
32A [keymap](keymaps/winkeyless) for the winkeyless version of the PCB are also provided.
33
34### Custom keymaps
35
36To 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/Keymap.html) for details on how to modify the keymap.
37
38To make it easy to define keymaps for the different versions of the PCB two macros are provided.
39
40| PCB | Macro |
41| -------------- | --------------------- |
42| Winkey PCB | `KEYMAP()` |
43| Winkeyless PCB | `KEYMAP_WINKEYLESS()` |
44
45To build the firmware with a custom keymap, run `make <keymap name>`
diff --git a/keyboards/kmac/rules.mk b/keyboards/kmac/rules.mk
new file mode 100644
index 000000000..54c9aa256
--- /dev/null
+++ b/keyboards/kmac/rules.mk
@@ -0,0 +1,72 @@
1# Project specific files
2SRC = matrix.c
3
4# MCU name
5#MCU = at90usb1287
6MCU = atmega32u4
7
8# Processor frequency.
9# This will define a symbol, F_CPU, in all source code files equal to the
10# processor frequency in Hz. You can then use this symbol in your source code to
11# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
12# automatically to create a 32-bit value in your source code.
13#
14# This will be an integer division of F_USB below, as it is sourced by
15# F_USB after it has run through any CPU prescalers. Note that this value
16# does not *change* the processor frequency - it should merely be updated to
17# reflect the processor speed set externally so that the code can use accurate
18# software delays.
19F_CPU = 8000000
20
21
22#
23# LUFA specific
24#
25# Target architecture (see library "Board Types" documentation).
26ARCH = AVR8
27
28# Input clock frequency.
29# This will define a symbol, F_USB, in all source code files equal to the
30# input clock frequency (before any prescaling is performed) in Hz. This value may
31# differ from F_CPU if prescaling is used on the latter, and is required as the
32# raw input clock is fed directly to the PLL sections of the AVR for high speed
33# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
34# at the end, this will be done automatically to create a 32-bit value in your
35# source code.
36#
37# If no clock division is performed on the input clock inside the AVR (via the
38# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
39F_USB = $(F_CPU)
40
41# Interrupt driven control endpoint task(+60)
42OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
43
44
45# Boot Section Size in *bytes*
46# Teensy halfKay 512
47# Teensy++ halfKay 1024
48# Atmel DFU loader 4096
49# LUFA bootloader 4096
50# USBaspLoader 2048
51OPT_DEFS += -DBOOTLOADER_SIZE=4096
52
53
54# Build Options
55# change yes to no to disable
56#
57BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration(+1000)
58MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
59EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
60CONSOLE_ENABLE ?= yes # Console for debug(+400)
61COMMAND_ENABLE ?= yes # Commands for debug and configuration
62CUSTOM_MATRIX ?= yes # Custom matrix file
63# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
64SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
65# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
66NKRO_ENABLE ?= yes # USB Nkey Rollover
67BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality
68MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config)
69UNICODE_ENABLE ?= no # Unicode
70BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
71AUDIO_ENABLE ?= no # Audio output on port C6
72FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches