Add support for KMAC

This commit is contained in:
Mathias Andersson 2017-06-04 22:13:17 +02:00
parent 00d9416626
commit 1b02b2006e
16 changed files with 1219 additions and 0 deletions

18
keyboards/kmac/Makefile Normal file
View File

@ -0,0 +1,18 @@
# Copyright 2013 Jun Wako <wakojun@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
ifndef MAKEFILE_INCLUDED
include ../../Makefile
endif

178
keyboards/kmac/config.h Normal file
View File

@ -0,0 +1,178 @@
/*
Copyright 2017 Mathias Andersson <wraul@dbox.se>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_H
#define CONFIG_H
#include "config_common.h"
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6050
#define DEVICE_VER 0x0104
#define MANUFACTURER KBDMania
#define PRODUCT KMAC
#define DESCRIPTION QMK keyboard firmware for KMAC
/* key matrix size */
#define MATRIX_ROWS 6
#define MATRIX_COLS 17
/*
* Keyboard Matrix Assignments
* The KMAC uses demultiplexers for the cols, they are only included here as documentation.
* See matrix.c for more details.
*/
#define MATRIX_ROW_PINS { D0, D1, D2, D3, D5, B7 }
#define MATRIX_COL_PINS { C6, B6, F0, F1, C7, B5 }
#define UNUSED_PINS
/* COL2ROW, ROW2COL, or CUSTOM_MATRIX */
#define DIODE_DIRECTION CUSTOM_MATRIX
/* number of backlight levels */
#define BACKLIGHT_LEVELS 3
// #define BACKLIGHT_PIN B7
// #define BACKLIGHT_BREATHING
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCING_DELAY 5
/* define if matrix has ghost (lacks anti-ghosting diodes) */
//#define MATRIX_HAS_GHOST
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
/*
* Force NKRO
*
* Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
* state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
* makefile for this to work.)
*
* If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
* until the next keyboard reset.
*
* NKRO may prevent your keystrokes from being detected in the BIOS, but it is
* fully operational during normal computer usage.
*
* For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
* or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
* bootmagic, NKRO mode will always be enabled until it is toggled again during a
* power-up.
*
*/
//#define FORCE_NKRO
/*
* Magic Key Options
*
* Magic keys are hotkey commands that allow control over firmware functions of
* the keyboard. They are best used in combination with the HID Listen program,
* found here: https://www.pjrc.com/teensy/hid_listen.html
*
* The options below allow the magic key functionality to be changed. This is
* useful if your keyboard/keypad is missing keys and you want magic key support.
*
*/
/* key combination for magic key command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
/* control how magic key switches layers */
//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
/* override magic key keymap */
//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
//#define MAGIC_KEY_HELP1 H
//#define MAGIC_KEY_HELP2 SLASH
//#define MAGIC_KEY_DEBUG D
//#define MAGIC_KEY_DEBUG_MATRIX X
//#define MAGIC_KEY_DEBUG_KBD K
//#define MAGIC_KEY_DEBUG_MOUSE M
//#define MAGIC_KEY_VERSION V
//#define MAGIC_KEY_STATUS S
//#define MAGIC_KEY_CONSOLE C
//#define MAGIC_KEY_LAYER0_ALT1 ESC
//#define MAGIC_KEY_LAYER0_ALT2 GRAVE
//#define MAGIC_KEY_LAYER0 0
//#define MAGIC_KEY_LAYER1 1
//#define MAGIC_KEY_LAYER2 2
//#define MAGIC_KEY_LAYER3 3
//#define MAGIC_KEY_LAYER4 4
//#define MAGIC_KEY_LAYER5 5
//#define MAGIC_KEY_LAYER6 6
//#define MAGIC_KEY_LAYER7 7
//#define MAGIC_KEY_LAYER8 8
//#define MAGIC_KEY_LAYER9 9
//#define MAGIC_KEY_BOOTLOADER PAUSE
//#define MAGIC_KEY_LOCK CAPS
//#define MAGIC_KEY_EEPROM E
//#define MAGIC_KEY_NKRO N
//#define MAGIC_KEY_SLEEP_LED Z
/*
* Feature disable options
* These options are also useful to firmware size reduction.
*/
/* disable debug print */
//#define NO_DEBUG
/* disable print */
//#define NO_PRINT
/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
/*
* MIDI options
*/
/* Prevent use of disabled MIDI features in the keymap */
//#define MIDI_ENABLE_STRICT 1
/* enable basic MIDI features:
- MIDI notes can be sent when in Music mode is on
*/
//#define MIDI_BASIC
/* enable advanced MIDI features:
- MIDI notes can be added to the keymap
- Octave shift and transpose
- Virtual sustain, portamento, and modulation wheel
- etc.
*/
//#define MIDI_ADVANCED
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
//#define MIDI_TONE_KEYCODE_OCTAVES 1
#endif

View File

@ -0,0 +1,37 @@
# Copyright 2013 Jun Wako <wakojun@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# QMK Build Options
# change to "no" to disable the options, or define them in the Makefile in
# the appropriate keymap folder that will get included automatically
#
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
AUDIO_ENABLE = no # Audio output on port C6
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
ifndef QUANTUM_DIR
include ../../../../Makefile
endif

View File

@ -0,0 +1,24 @@
/* Copyright 2017 Mathias Andersson <wraul@dbox.se>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_USER_H
#define CONFIG_USER_H
#include "../../config.h"
// place overrides here
#endif

View File

@ -0,0 +1,97 @@
/* Copyright 2017 Mathias Andersson <wraul@dbox.se>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "kmac.h"
// Helpful defines
#define _______ KC_TRNS
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _BL 0
#define _FL 1
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_BL] = KEYMAP(
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, \
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, \
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, \
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, \
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, \
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(_FL), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT \
),
[_FL] = KEYMAP(
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), _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
),
};
const uint16_t PROGMEM fn_actions[] = {
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
// MACRODOWN only works in this function
switch(id) {
case 0:
if (record->event.pressed) {
SEND_STRING("The");
return false;
}
break;
case 1:
if (record->event.pressed) {
SEND_STRING("Custom");
return false;
}
break;
case 2:
if (record->event.pressed) {
SEND_STRING("Keyboard");
return false;
}
break;
case 3:
if (record->event.pressed) {
return MACRO( D(LCTL), T(C), U(LCTL), T(RGHT), D(LCTL), T(V), U(LCTL), END );
}
break;
}
return MACRO_NONE;
};
void matrix_init_user(void) {
}
void matrix_scan_user(void) {
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}
void led_set_user(uint8_t usb_led) {
}

View File

@ -0,0 +1,56 @@
# Keymap for the winkey version of KMAC
This is the default keymap for the winkey version of the PCB. It implements the same features as the official default KMAC firmware.
See [keymap.c](keymap.c) for details.
## Layers
The keymap have two layers. To access the functions on the second layer, hold down caps lock and press the corresponding key.
### Layer 1: Default Layer
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
`---' `---------------' `---------------' `---------------' `-----------'
,-----------------------------------------------------------. ,-----------.
|~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|-----------------------------------------------------------| |-----------|
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
|-----------------------------------------------------------| '-----------'
|Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|-----------------------------------------------------------| ,---.
|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|-----------------------------------------------------------| ,-----------.
|Ctl|Gui|Alt| Space |Alt|Gui|Fn |Ctl| |Lef|Dow|Rig|
`-----------------------------------------------------------' `-----------'
### Layer 2: Function Layer
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|Led| |M1 |M2 |M3 |M4 | |M5 |M6 |M7 |M8 | |M9 |M10|M11|M12| | | | |
`---' `---------------' `---------------' `---------------' `-----------'
,-----------------------------------------------------------. ,-----------.
| | | | | | | | | | | | | | | | | | |
|-----------------------------------------------------------| |-----------|
| | | | | | | | | | | | | | | | | | |
|-----------------------------------------------------------| '-----------'
| | | | | | | | | | | | | |
|-----------------------------------------------------------| ,---.
| | | | | | | | | | | | | | |
|-----------------------------------------------------------| ,-----------.
| | | | | | | | | | | | |
`-----------------------------------------------------------' `-----------'
## Macros
These are mostly useless and serve more like examples I guess.
| Macro | Action |
|:-----:| -------------------------------------- |
| 1 | Types `The` |
| 2 | Types `Custom` |
| 3 | Types `Keyboard` |
| 4 | Inputs `<Ctrl+c>` `<Right>` `<Ctrl+v>` |
## Building
To build the firmware with the default keymap, run `make default`.

View File

@ -0,0 +1,37 @@
# Copyright 2013 Jun Wako <wakojun@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# QMK Build Options
# change to "no" to disable the options, or define them in the Makefile in
# the appropriate keymap folder that will get included automatically
#
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
AUDIO_ENABLE = no # Audio output on port C6
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
ifndef QUANTUM_DIR
include ../../../../Makefile
endif

View File

@ -0,0 +1,24 @@
/* Copyright 2017 Mathias Andersson <wraul@dbox.se>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_USER_H
#define CONFIG_USER_H
#include "../../config.h"
// place overrides here
#endif

View File

@ -0,0 +1,97 @@
/* Copyright 2017 Mathias Andersson <wraul@dbox.se>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "kmac.h"
// Helpful defines
#define _______ KC_TRNS
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _BL 0
#define _FL 1
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_BL] = KEYMAP_WINKEYLESS(
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, \
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, \
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, \
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, \
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, \
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FL), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT \
),
[_FL] = KEYMAP_WINKEYLESS(
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), _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
),
};
const uint16_t PROGMEM fn_actions[] = {
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
// MACRODOWN only works in this function
switch(id) {
case 0:
if (record->event.pressed) {
SEND_STRING("The");
return false;
}
break;
case 1:
if (record->event.pressed) {
SEND_STRING("Custom");
return false;
}
break;
case 2:
if (record->event.pressed) {
SEND_STRING("Keyboard");
return false;
}
break;
case 3:
if (record->event.pressed) {
return MACRO( D(LCTL), T(C), U(LCTL), T(RGHT), D(LCTL), T(V), U(LCTL), END );
}
break;
}
return MACRO_NONE;
};
void matrix_init_user(void) {
}
void matrix_scan_user(void) {
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}
void led_set_user(uint8_t usb_led) {
}

View File

@ -0,0 +1,57 @@
# Keymap for the winkeyless version of KMAC
This is the default keymap for the winkeyless version of the PCB. It implements the same features as the official default KMAC firmware.
See [keymap.c](keymap.c) for details.
## Layers
The keymap have two layers. To access the functions on the second layer, hold down caps lock and press the corresponding key.
### Layer 1: Default Layer
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
`---' `---------------' `---------------' `---------------' `-----------'
,-----------------------------------------------------------. ,-----------.
|~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|-----------------------------------------------------------| |-----------|
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
|-----------------------------------------------------------| '-----------'
|Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|-----------------------------------------------------------| ,---.
|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|-----------------------------------------------------------| ,-----------.
|Ctl|Gui|Alt| Space |Alt|Fn |Ctl| |Lef|Dow|Rig|
`-----------------------------------------------------------' `-----------'
### Layer 2: Function Layer
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|Led| |M1 |M2 |M3 |M4 | |M5 |M6 |M7 |M8 | |M9 |M10|M11|M12| | | | |
`---' `---------------' `---------------' `---------------' `-----------'
,-----------------------------------------------------------. ,-----------.
| | | | | | | | | | | | | | | | | | |
|-----------------------------------------------------------| |-----------|
| | | | | | | | | | | | | | | | | | |
|-----------------------------------------------------------| '-----------'
| | | | | | | | | | | | | |
|-----------------------------------------------------------| ,---.
| | | | | | | | | | | | | | |
|-----------------------------------------------------------| ,-----------.
| | | | | | | | | | | |
`-----------------------------------------------------------' `-----------'
## Macros
These are mostly useless and serve more like examples I guess.
| Macro | Action |
|:-----:| -------------------------------------- |
| 1 | Types `The` |
| 2 | Types `Custom` |
| 3 | Types `Keyboard` |
| 4 | Inputs `<Ctrl+c>` `<Right>` `<Ctrl+v>` |
## Building
To build the firmware with the keymap for the winkeyless version, run `make winkeyless`.

109
keyboards/kmac/kmac.c Normal file
View File

@ -0,0 +1,109 @@
/* Copyright 2017 Mathias Andersson <wraul@dbox.se>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "kmac.h"
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
led_init_ports();
matrix_init_user();
}
void matrix_scan_kb(void) {
// put your looping keyboard code here
// runs every cycle (a lot)
matrix_scan_user();
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
// put your per-action keyboard code here
// runs for every action, just before processing by the firmware
return process_record_user(keycode, record);
}
void led_init_ports(void) {
DDRB |= (1<<0); // OUT
DDRE |= (1<<6); // OUT
}
/* LED pin configuration
* Scroll Lock: Low PE6
* Caps Lock: Low PB0
*/
void led_set_kb(uint8_t usb_led) {
if (usb_led & (1<<USB_LED_CAPS_LOCK))
{
PORTB &= ~(1<<0); // LO
}
else
{
PORTB |= (1<<0); // HI
}
if (usb_led & (1<<USB_LED_SCROLL_LOCK))
{
PORTE &= ~(1<<6); // LO
}
else
{
PORTE |= (1<<6); // HI
}
led_set_user(usb_led);
}
void backlight_init_ports(void) {
DDRB |= (1<<1) | (1<<2) | (1<<3) | (1<<4); // OUT
DDRD |= (1<<7); // OUT
}
/* Backlight pin configuration
* F-row: High PB1
* W: Low PB4
* A: Low PB2
* S: Low PB3
* D: Low PD7
*/
void backlight_set(uint8_t level)
{
// F-row
if(level & (1<<0))
{
PORTB |= (1<<1); // HI
}
else
{
PORTB &= ~(1<<1); // LO
}
// WASD
if(level & (1<<1))
{
PORTB &= ~(1<<4); // LO
PORTB &= ~(1<<2); // LO
PORTB &= ~(1<<3); // LO
PORTD &= ~(1<<7); // LO
}
else
{
PORTB |= (1<<4); // HI
PORTB |= (1<<2); // HI
PORTB |= (1<<3); // HI
PORTD |= (1<<7); // HI
}
}

56
keyboards/kmac/kmac.h Normal file
View File

@ -0,0 +1,56 @@
/* Copyright 2017 Mathias Andersson <wraul@dbox.se>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KMAC_H
#define KMAC_H
#include "quantum.h"
// Keymap for the winkey version of the PCB.
#define KEYMAP( \
K00, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \
K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4D, K4F, \
K50, K51, K52, K55, K58, K5A, K5C, K5D, K5E, K5F, K5G \
) { \
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F G */ \
/* 0 */ { K00, KC_NO, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G }, \
/* 1 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G }, \
/* 2 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G }, \
/* 3 */ { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, KC_NO, K3D, KC_NO, KC_NO, KC_NO }, \
/* 4 */ { K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, KC_NO, KC_NO, K4D, KC_NO, K4F, KC_NO }, \
/* 5 */ { K50, K51, K52, KC_NO, KC_NO, K55, KC_NO, KC_NO, K58, KC_NO, K5A, KC_NO, K5C, K5D, K5E, K5F, K5G } \
}
// Keymap for the winkeyless version of the PCB.
#define KEYMAP_WINKEYLESS( \
K00, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \
K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4D, K4F, \
K50, K51, K52, K55, K58, K5A, K5D, K5E, K5F, K5G \
) KEYMAP( \
K00, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \
K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4D, K4F, \
K50, K51, K52, K55, K58, K5A, KC_NO, K5D, K5E, K5F, K5G \
)
#endif

311
keyboards/kmac/matrix.c Normal file
View File

@ -0,0 +1,311 @@
/*
Copyright 2017 Mathias Andersson <wraul@dbox.se>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdbool.h>
#if defined(__AVR__)
#include <avr/io.h>
#endif
#include "wait.h"
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"
#include "timer.h"
/* Set 0 if debouncing isn't needed */
#ifndef DEBOUNCING_DELAY
# define DEBOUNCING_DELAY 5
#endif
#define COL_SHIFTER ((uint32_t)1)
static uint16_t debouncing_time;
static bool debouncing = false;
static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static void init_rows(void);
static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col);
static void unselect_cols(void);
static void select_col(uint8_t col);
inline
uint8_t matrix_rows(void) {
return MATRIX_ROWS;
}
inline
uint8_t matrix_cols(void) {
return MATRIX_COLS;
}
void matrix_init(void) {
unselect_cols();
init_rows();
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
matrix_debouncing[i] = 0;
}
matrix_init_quantum();
}
uint8_t matrix_scan(void)
{
// Set col, read rows
for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
bool matrix_changed = read_rows_on_col(matrix_debouncing, current_col);
if (matrix_changed) {
debouncing = true;
debouncing_time = timer_read();
}
}
if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) {
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = matrix_debouncing[i];
}
debouncing = false;
}
matrix_scan_quantum();
return 1;
}
inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & ((matrix_row_t)1<col));
}
inline
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row];
}
void matrix_print(void)
{
print("\nr/c 0123456789ABCDEFGHIJKLMNOPQRSTUV\n");
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
phex(row); print(": ");
print_bin_reverse32(matrix_get_row(row));
print("\n");
}
}
uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop32(matrix[i]);
}
return count;
}
static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
{
bool matrix_changed = false;
// Select col and wait for col selecton to stabilize
select_col(current_col);
wait_us(30);
// For each row...
for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++)
{
// Store last value of row prior to reading
matrix_row_t last_row_value = current_matrix[row_index];
// Check row pin state
// Use the otherwise unused row: 3, col: 0 for caps lock
if (row_index == 3 && current_col == 0) {
// Pin E2 uses active low
if ((_SFR_IO8(E2 >> 4) & _BV(E2 & 0xF)) == 0)
{
// Pin LO, set col bit
current_matrix[row_index] |= (COL_SHIFTER << current_col);
}
else
{
// Pin HI, clear col bit
current_matrix[row_index] &= ~(COL_SHIFTER << current_col);
}
}
else {
if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)))
{
// Pin HI, set col bit
current_matrix[row_index] |= (COL_SHIFTER << current_col);
}
else
{
// Pin LO, clear col bit
current_matrix[row_index] &= ~(COL_SHIFTER << current_col);
}
}
// Determine if the matrix changed state
if ((last_row_value != current_matrix[row_index]) && !(matrix_changed))
{
matrix_changed = true;
}
}
// Unselect cols
unselect_cols();
return matrix_changed;
}
/* Row pin configuration
* row: 0 1 2 3 4 5
* pin: D0 D1 D2 D3 D5 B7
*
* Caps lock uses its own pin E2
*/
static void init_rows(void)
{
DDRD &= ~((1<<0)| (1<<1) | (1<<2) | (1<<3) | (1<<5)); // IN
PORTD &= ~((1<<0)| (1<<1) | (1<<2) | (1<<3) | (1<<5)); // LO
DDRB &= ~(1<<7); // IN
PORTB &= ~(1<<7); // LO
DDRE &= ~(1<<2); // IN
PORTE |= (1<<2); // HI
}
/* Columns 0 - 15
* These columns uses two 74HC237D 3 to 8 bit demultiplexers.
* col / pin: PC6 PB6 PF0 PF1 PC7
* 0: 1 0 0 0 0
* 1: 1 0 1 0 0
* 2: 1 0 0 1 0
* 3: 1 0 1 1 0
* 4: 1 0 0 0 1
* 5: 1 0 1 0 1
* 6: 1 0 0 1 1
* 7: 1 0 1 1 1
* 8: 0 1 0 0 0
* 9: 0 1 1 0 0
* 10: 0 1 0 1 0
* 11: 0 1 1 1 0
* 12: 0 1 0 0 1
* 13: 0 1 1 0 1
* 14: 0 1 0 1 1
* 15: 0 1 1 1 1
*
* col: 16
* pin: PB5
*/
static void unselect_cols(void)
{
DDRB |= (1<<5) | (1<<6); // OUT
PORTB &= ~((1<<5) | (1<<6)); // LO
DDRC |= (1<<6) | (1<<7); // OUT
PORTC &= ~((1<<6) | (1<<7)); // LO
DDRF |= (1<<0) | (1<<1); // OUT
PORTF &= ~((1<<0) | (1<<1)); // LO
}
static void select_col(uint8_t col)
{
switch (col) {
case 0:
PORTC |= (1<<6); // HI
break;
case 1:
PORTC |= (1<<6); // HI
PORTF |= (1<<0); // HI
break;
case 2:
PORTC |= (1<<6); // HI
PORTF |= (1<<1); // HI
break;
case 3:
PORTC |= (1<<6); // HI
PORTF |= (1<<0) | (1<<1); // HI
break;
case 4:
PORTC |= (1<<6); // HI
PORTC |= (1<<7); // HI
break;
case 5:
PORTC |= (1<<6); // HI
PORTF |= (1<<0); // HI
PORTC |= (1<<7); // HI
break;
case 6:
PORTC |= (1<<6); // HI
PORTF |= (1<<1); // HI
PORTC |= (1<<7); // HI
break;
case 7:
PORTC |= (1<<6); // HI
PORTF |= (1<<0) | (1<<1); // HI
PORTC |= (1<<7); // HI
break;
case 8:
PORTB |= (1<<6); // HI
break;
case 9:
PORTB |= (1<<6); // HI
PORTF |= (1<<0); // HI
break;
case 10:
PORTB |= (1<<6); // HI
PORTF |= (1<<1); // HI
break;
case 11:
PORTB |= (1<<6); // HI
PORTF |= (1<<0) | (1<<1); // HI
break;
case 12:
PORTB |= (1<<6); // HI
PORTC |= (1<<7); // HI
break;
case 13:
PORTB |= (1<<6); // HI
PORTF |= (1<<0); // HI
PORTC |= (1<<7); // HI
break;
case 14:
PORTB |= (1<<6); // HI
PORTF |= (1<<1); // HI
PORTC |= (1<<7); // HI
break;
case 15:
PORTB |= (1<<6); // HI
PORTF |= (1<<0) | (1<<1); // HI
PORTC |= (1<<7); // HI
break;
case 16:
PORTB |= (1<<5); // HI
break;
}
}

45
keyboards/kmac/readme.md Normal file
View File

@ -0,0 +1,45 @@
KMAC keyboard firmware
======================
A Korean custom keyboard designed by Byungho Kim and the KBDMania community.
## Supported models
All the tenkeyless models should be supported.
## Bootloader
The PCB is hardwired to run the bootloader if the key at the `Caps Lock` position is held down when connecting the keyboard.
It is also possible to use Boot Magic and Command to access the bootloader.
## Quantum MK Firmware
For the full Quantum feature list, see the [documentation](https://docs.qmk.fm).
## Building
The 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.
Depending 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.
### Winkey keymap
The [default keymap](keymaps/default) are designed for the winkey version of the PCB.
### Winkeyless Keymap
A [keymap](keymaps/winkeyless) for the winkeyless version of the PCB are also provided.
### Custom keymaps
To 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.
To make it easy to define keymaps for the different versions of the PCB two macros are provided.
| PCB | Macro |
| -------------- | --------------------- |
| Winkey PCB | `KEYMAP()` |
| Winkeyless PCB | `KEYMAP_WINKEYLESS()` |
To build the firmware with a custom keymap, run `make <keymap name>`

72
keyboards/kmac/rules.mk Normal file
View File

@ -0,0 +1,72 @@
# Project specific files
SRC = matrix.c
# MCU name
#MCU = at90usb1287
MCU = atmega32u4
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
#
# This will be an integer division of F_USB below, as it is sourced by
# F_USB after it has run through any CPU prescalers. Note that this value
# does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate
# software delays.
F_CPU = 8000000
#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# Input clock frequency.
# This will define a symbol, F_USB, in all source code files equal to the
# input clock frequency (before any prescaling is performed) in Hz. This value may
# differ from F_CPU if prescaling is used on the latter, and is required as the
# raw input clock is fed directly to the PLL sections of the AVR for high speed
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
# at the end, this will be done automatically to create a 32-bit value in your
# source code.
#
# If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)
# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in *bytes*
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096
# LUFA bootloader 4096
# USBaspLoader 2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Build Options
# change yes to no to disable
#
BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
CONSOLE_ENABLE ?= yes # Console for debug(+400)
COMMAND_ENABLE ?= yes # Commands for debug and configuration
CUSTOM_MATRIX ?= yes # Custom matrix file
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE ?= yes # USB Nkey Rollover
BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality
MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config)
UNICODE_ENABLE ?= no # Unicode
BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
AUDIO_ENABLE ?= no # Audio output on port C6
FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches

View File

@ -45,6 +45,7 @@ These keyboards are part of the QMK repository, but their manufacturers are not
* [JD45](/keyboards/jd45) &mdash; Another Geekhack community project, designed by jdcarpe.
* [KC60](/keyboards/kc60) &mdash; A programmable Chinese-made keyboard, lost in the mists of time.
* [Kinesis Advantage](/keyboards/kinesis) &mdash; Contoured ergonomic keyboard by Kinesis Computer Ergonomics.
* [KMAC](/keyboards/kmac) &mdash; Korean custom keyboard.
* [The Kitten Paw](/keyboards/kitten_paw) &mdash; A replacement controller (2016 revision) for the Filco Majestouch by [Bathroom Epiphanies](https://github.com/BathroomEpiphanies).
* [Lets Split](/keyboards/lets_split) - Split ortholinear 40% keyboard.
* [Phantom](/keyboards/phantom) &mdash; A tenkeyless kit by Teel, also from Geekhack.