summaryrefslogtreecommitdiff
path: root/keyboards/bajjak
diff options
context:
space:
mode:
authorGary Kong <kongkm88@gmail.com>2022-08-14 10:08:46 +0900
committerGitHub <noreply@github.com>2022-08-13 18:08:46 -0700
commit28b05d15ffb1e724addde3b8929ecb21284a8195 (patch)
treee3b381769a9883b0cc1305bbe3b376581c2c592e /keyboards/bajjak
parent86261bfd8e7c5e5a4993186afdc26f07914edbe5 (diff)
[Keyboard] add bajjak keyboard (#12377)
Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: peepeetee <43021794+peepeetee@users.noreply.github.com> Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
Diffstat (limited to 'keyboards/bajjak')
-rw-r--r--keyboards/bajjak/bajjak.c227
-rw-r--r--keyboards/bajjak/bajjak.h165
-rw-r--r--keyboards/bajjak/config.h117
-rw-r--r--keyboards/bajjak/info.json31
-rw-r--r--keyboards/bajjak/keymaps/5x6/keymap.c187
-rw-r--r--keyboards/bajjak/keymaps/default/keymap.c193
-rw-r--r--keyboards/bajjak/matrix.c253
-rw-r--r--keyboards/bajjak/readme.md23
-rw-r--r--keyboards/bajjak/rules.mk37
9 files changed, 1233 insertions, 0 deletions
diff --git a/keyboards/bajjak/bajjak.c b/keyboards/bajjak/bajjak.c
new file mode 100644
index 0000000000..74e2b2aa8c
--- /dev/null
+++ b/keyboards/bajjak/bajjak.c
@@ -0,0 +1,227 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
4Copyright 2015 ZSA Technology Labs Inc (@zsa)
5Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
6Copyright 2021 Gary Kong <kongkm88@gmail.com> (@garykong)
7
8This program is free software: you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "bajjak.h"
23
24extern inline void bajjak_board_led_on(void);
25extern inline void bajjak_right_led_1_on(void);
26extern inline void bajjak_right_led_2_on(void);
27extern inline void bajjak_right_led_3_on(void);
28extern inline void bajjak_right_led_on(uint8_t led);
29
30extern inline void bajjak_board_led_off(void);
31extern inline void bajjak_right_led_1_off(void);
32extern inline void bajjak_right_led_2_off(void);
33extern inline void bajjak_right_led_3_off(void);
34extern inline void bajjak_right_led_off(uint8_t led);
35
36extern inline void bajjak_led_all_on(void);
37extern inline void bajjak_led_all_off(void);
38
39extern inline void bajjak_right_led_1_set(uint8_t n);
40extern inline void bajjak_right_led_2_set(uint8_t n);
41extern inline void bajjak_right_led_3_set(uint8_t n);
42extern inline void bajjak_right_led_set(uint8_t led, uint8_t n);
43
44extern inline void bajjak_led_all_set(uint8_t n);
45
46keyboard_config_t keyboard_config;
47
48bool i2c_initialized = 0;
49i2c_status_t mcp23018_status = 0x20;
50
51void matrix_init_kb(void) {
52 // keyboard LEDs (see "PWM on ports OC1(A|B|C)" in "teensy-2-0.md")
53 TCCR1A = 0b10101001; // set and configure fast PWM
54 TCCR1B = 0b00001001; // set and configure fast PWM
55
56 // (tied to Vcc for hardware convenience)
57 DDRB &= ~(1<<4); // set B(4) as input
58 PORTB &= ~(1<<4); // set B(4) internal pull-up disabled
59
60 // unused pins - D4, D5, E6
61 // set as input with internal pull-up enabled
62 DDRD &= ~(1<<5 | 1<<4);
63 DDRE &= ~(1<<6);
64 PORTD |= (1<<5 | 1<<4);
65 PORTE |= (1<<6);
66
67 keyboard_config.raw = eeconfig_read_kb();
68 bajjak_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4 );
69 bajjak_blink_all_leds();
70
71 matrix_init_user();
72}
73
74void bajjak_blink_all_leds(void)
75{
76 bajjak_led_all_off();
77 bajjak_led_all_set(LED_BRIGHTNESS_DEFAULT);
78 bajjak_right_led_1_on();
79 wait_ms(50);
80 bajjak_right_led_2_on();
81 wait_ms(50);
82 bajjak_right_led_3_on();
83 wait_ms(50);
84#ifdef LEFT_LEDS
85 bajjak_left_led_1_on();
86 wait_ms(50);
87 if (!mcp23018_status) {
88 mcp23018_status = bajjak_left_leds_update();
89 }
90 bajjak_left_led_2_on();
91 wait_ms(50);
92 if (!mcp23018_status) {
93 mcp23018_status = bajjak_left_leds_update();
94 }
95#endif
96 bajjak_right_led_1_off();
97 wait_ms(50);
98 bajjak_right_led_2_off();
99 wait_ms(50);
100 bajjak_right_led_3_off();
101#ifdef LEFT_LEDS
102 wait_ms(50);
103 bajjak_left_led_1_off();
104 if (!mcp23018_status) {
105 mcp23018_status = bajjak_left_leds_update();
106 }
107 wait_ms(50);
108 bajjak_left_led_2_off();
109 if (!mcp23018_status) {
110 mcp23018_status = bajjak_left_leds_update();
111 }
112#endif
113
114 //bajjak_led_all_on();
115 //wait_ms(333);
116 bajjak_led_all_off();
117}
118
119uint8_t init_mcp23018(void) {
120 mcp23018_status = 0x20;
121
122 // I2C subsystem
123
124 // uint8_t sreg_prev;
125 // sreg_prev=SREG;
126 // cli();
127
128 if (i2c_initialized == 0) {
129 i2c_init(); // on pins D(1,0)
130 i2c_initialized = true;
131 wait_ms(1000);
132 }
133 // i2c_init(); // on pins D(1,0)
134 // wait_ms(1000);
135
136 // set pin direction
137 // - unused : input : 1
138 // - input : input : 1
139 // - driving : output : 0
140 mcp23018_status = i2c_start(I2C_ADDR_WRITE, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
141 mcp23018_status = i2c_write(IODIRA, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
142 mcp23018_status = i2c_write(0b00000000, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
143 mcp23018_status = i2c_write(0b00111111, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
144 i2c_stop();
145
146 // set pull-up
147 // - unused : on : 1
148 // - input : on : 1
149 // - driving : off : 0
150 mcp23018_status = i2c_start(I2C_ADDR_WRITE, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
151 mcp23018_status = i2c_write(GPPUA, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
152 mcp23018_status = i2c_write(0b00000000, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
153 mcp23018_status = i2c_write(0b01111111, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
154
155out:
156 i2c_stop();
157
158#ifdef LEFT_LEDS
159 if (!mcp23018_status) mcp23018_status = bajjak_left_leds_update();
160#endif // LEFT_LEDS
161
162 // SREG=sreg_prev;
163
164 return mcp23018_status;
165}
166
167#ifdef LEFT_LEDS
168uint8_t bajjak_left_leds_update(void) {
169 if (mcp23018_status) { // if there was an error
170 return mcp23018_status;
171 }
172#define LEFT_LED_1_SHIFT 7 // in MCP23018 port A
173#define LEFT_LED_2_SHIFT 7 // in MCP23018 port B
174
175 // set logical value (doesn't matter on inputs)
176 // - unused : hi-Z : 1
177 // - input : hi-Z : 1
178 // - driving : hi-Z : 1
179 mcp23018_status = i2c_start(I2C_ADDR_WRITE, BAJJAK_EZ_I2C_TIMEOUT);
180 if (mcp23018_status) goto out;
181 mcp23018_status = i2c_write(OLATA, BAJJAK_EZ_I2C_TIMEOUT);
182 if (mcp23018_status) goto out;
183 mcp23018_status = i2c_write(0b11111111
184 & ~(bajjak_left_led_1<<LEFT_LED_1_SHIFT),
185 BAJJAK_EZ_I2C_TIMEOUT);
186 if (mcp23018_status) goto out;
187 mcp23018_status = i2c_write(0b11111111
188 & ~(bajjak_left_led_2<<LEFT_LED_2_SHIFT),
189 BAJJAK_EZ_I2C_TIMEOUT);
190 if (mcp23018_status) goto out;
191
192 out:
193 i2c_stop();
194 return mcp23018_status;
195}
196#endif
197
198
199#ifdef SWAP_HANDS_ENABLE
200__attribute__ ((weak))
201// swap-hands action needs a matrix to define the swap
202const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
203 /* Left hand, matrix positions */
204 {{0, 13}, {1, 13}, {2, 13}, {3, 13}, {4, 13}, {5, 13}, {6, 13}},
205 {{0, 12}, {1, 12}, {2, 12}, {3, 12}, {4, 12}, {5, 12}, {6, 12}},
206 {{0, 11}, {1, 11}, {2, 11}, {3, 11}, {4, 11}, {5, 11}, {6, 11}},
207 {{0, 10}, {1, 10}, {2, 10}, {3, 10}, {4, 10}, {5, 10}, {6, 10}},
208 {{0, 9}, {1, 9}, {2, 9}, {3, 9}, {4, 9}, {5, 9}, {6, 9}},
209 {{0, 8}, {1, 8}, {2, 8}, {3, 8}, {4, 8}, {5, 8}, {6, 8}},
210 {{0, 7}, {1, 7}, {2, 7}, {3, 7}, {4, 7}, {5, 7}, {6, 7}},
211 /* Right hand, matrix positions */
212 {{0, 6}, {1, 6}, {2, 6}, {3, 6}, {4, 6}, {5, 6}, {6, 6}},
213 {{0, 5}, {1, 5}, {2, 5}, {3, 5}, {4, 5}, {5, 5}, {6, 5}},
214 {{0, 4}, {1, 4}, {2, 4}, {3, 4}, {4, 4}, {5, 4}, {6, 4}},
215 {{0, 3}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3}, {6, 3}},
216 {{0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, {5, 2}, {6, 2}},
217 {{0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}},
218 {{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}},
219};
220#endif
221
222void eeconfig_init_kb(void) { // EEPROM is getting reset!
223 keyboard_config.raw = 0;
224 keyboard_config.led_level = 4;
225 eeconfig_update_kb(keyboard_config.raw);
226 eeconfig_init_user();
227}
diff --git a/keyboards/bajjak/bajjak.h b/keyboards/bajjak/bajjak.h
new file mode 100644
index 0000000000..126df7932c
--- /dev/null
+++ b/keyboards/bajjak/bajjak.h
@@ -0,0 +1,165 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
4Copyright 2015 ZSA Technology Labs Inc (@zsa)
5Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
6Copyright 2021 Gary Kong <kongkm88@gmail.com> (@garykong)
7
8This program is free software: you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#pragma once
23
24#include "quantum.h"
25#include <stdint.h>
26#include <stdbool.h>
27#include "i2c_master.h"
28
29// I2C aliases and register addresses (see "mcp23018.md")
30#define I2C_ADDR 0b0100000
31#define I2C_ADDR_WRITE ( (I2C_ADDR<<1) | I2C_WRITE )
32#define I2C_ADDR_READ ( (I2C_ADDR<<1) | I2C_READ )
33#define IODIRA 0x00 // i/o direction register
34#define IODIRB 0x01
35#define GPPUA 0x0C // GPIO pull-up resistor register
36#define GPPUB 0x0D
37#define GPIOA 0x12 // general purpose i/o port register (write modifies OLAT)
38#define GPIOB 0x13
39#define OLATA 0x14 // output latch register
40#define OLATB 0x15
41
42extern i2c_status_t mcp23018_status;
43#define BAJJAK_EZ_I2C_TIMEOUT 100
44
45void init_bajjak(void);
46void bajjak_blink_all_leds(void);
47uint8_t init_mcp23018(void);
48uint8_t bajjak_left_leds_update(void);
49
50#ifndef LED_BRIGHTNESS_LO
51#define LED_BRIGHTNESS_LO 15
52#endif
53#ifndef LED_BRIGHTNESS_HI
54#define LED_BRIGHTNESS_HI 255
55#endif
56
57
58inline void bajjak_board_led_on(void) { setPinOutput(D6); writePinHigh(D6); }
59inline void bajjak_right_led_1_on(void) { setPinOutput(B5); writePinHigh(B5); }
60inline void bajjak_right_led_2_on(void) { setPinOutput(B6); writePinHigh(B6); }
61inline void bajjak_right_led_3_on(void) { setPinOutput(B7); writePinHigh(B7); }
62inline void bajjak_right_led_on(uint8_t led) { setPinOutput(led+4); writePinHigh(led+4); }
63
64inline void bajjak_board_led_off(void) { setPinInput(D6); writePinLow(D6); }
65inline void bajjak_right_led_1_off(void) { setPinInput(B5); writePinLow(B5); }
66inline void bajjak_right_led_2_off(void) { setPinInput(B6); writePinLow(B6); }
67inline void bajjak_right_led_3_off(void) { setPinInput(B7); writePinLow(B7); }
68inline void bajjak_right_led_off(uint8_t led) { setPinInput(led+4); writePinLow(led+4); }
69
70#ifdef LEFT_LEDS
71bool bajjak_left_led_1;
72bool bajjak_left_led_2;
73bool bajjak_left_led_3;
74
75inline void bajjak_left_led_1_on(void) { bajjak_left_led_1 = 1; }
76inline void bajjak_left_led_2_on(void) { bajjak_left_led_2 = 1; }
77
78inline void bajjak_left_led_1_off(void) { bajjak_left_led_1 = 0; }
79inline void bajjak_left_led_2_off(void) { bajjak_left_led_2 = 0; }
80#endif // LEFT_LEDS
81
82inline void bajjak_led_all_on(void) {
83 bajjak_board_led_on();
84 bajjak_right_led_1_on();
85 bajjak_right_led_2_on();
86 bajjak_right_led_3_on();
87#ifdef LEFT_LEDS
88 bajjak_left_led_1_on();
89 bajjak_left_led_2_on();
90#endif // LEFT_LEDS
91}
92
93inline void bajjak_led_all_off(void)
94{
95 bajjak_board_led_off();
96 bajjak_right_led_1_off();
97 bajjak_right_led_2_off();
98 bajjak_right_led_3_off();
99#ifdef LEFT_LEDS
100 bajjak_left_led_1_off();
101 bajjak_left_led_2_off();
102#endif // LEFT_LEDS
103}
104
105inline void bajjak_right_led_1_set(uint8_t n) { OCR1A = n; }
106inline void bajjak_right_led_2_set(uint8_t n) { OCR1B = n; }
107inline void bajjak_right_led_3_set(uint8_t n) { OCR1C = n; }
108inline void bajjak_right_led_set(uint8_t led, uint8_t n) {
109 (led == 1) ? (OCR1A = n) :
110 (led == 2) ? (OCR1B = n) :
111 (OCR1C = n);
112}
113
114inline void bajjak_led_all_set(uint8_t n) {
115 bajjak_right_led_1_set(n);
116 bajjak_right_led_2_set(n);
117 bajjak_right_led_3_set(n);
118}
119
120enum BAJJAK_ez_keycodes {
121 LED_LEVEL = SAFE_RANGE,
122 TOGGLE_LAYER_COLOR,
123 EZ_SAFE_RANGE,
124};
125
126#ifndef WEBUSB_ENABLE
127# define WEBUSB_PAIR KC_NO
128#endif
129
130typedef union {
131 uint32_t raw;
132 struct {
133 uint8_t led_level :3;
134 bool disable_layer_led :1;
135 };
136} keyboard_config_t;
137
138extern keyboard_config_t keyboard_config;
139
140#define LAYOUT_6x7( \
141 L00, L01, L02, L03, L04, L05, L06, R00, R01, R02, R03, R04, R05, R06, \
142 L10, L11, L12, L13, L14, L15, L16, R10, R11, R12, R13, R14, R15, R16, \
143 L20, L21, L22, L23, L24, L25, L26, R20, R21, R22, R23, R24, R25, R26, \
144 L30, L31, L32, L33, L34, L35, L36, R30, R31, R32, R33, R34, R35, R36, \
145 L40, L41, L42, L43, L44, L45, R41, R42, R43, R44, R45, R46, \
146 L50, L51, L52, L53, L54, R52, R53, R54, R55, R56, \
147 L65, L66, R60, R61, \
148 L64, R62, \
149 L63, L62, L61, R65, R64, R63 \
150 ) { \
151 { L00, L10, L20, L30, L40, L50, KC_NO }, \
152 { L01, L11, L21, L31, L41, L51, L61 }, \
153 { L02, L12, L22, L32, L42, L52, L62 }, \
154 { L03, L13, L23, L33, L43, L53, L63 }, \
155 { L04, L14, L24, L34, L44, L54, L64 }, \
156 { L05, L15, L25, L35, L45, KC_NO, L65 }, \
157 { L06, L16, L26, L36, KC_NO, KC_NO, L66 }, \
158 { R00, R10, R20, R30, KC_NO, KC_NO, R60 }, \
159 { R01, R11, R21, R31, R41, KC_NO, R61 }, \
160 { R02, R12, R22, R32, R42, R52, R62 }, \
161 { R03, R13, R23, R33, R43, R53, R63 }, \
162 { R04, R14, R24, R34, R44, R54, R64 }, \
163 { R05, R15, R25, R35, R45, R55, R65 },\
164 { R06, R16, R26, R36, R46, R56, KC_NO } \
165 }
diff --git a/keyboards/bajjak/config.h b/keyboards/bajjak/config.h
new file mode 100644
index 0000000000..344bc9040e
--- /dev/null
+++ b/keyboards/bajjak/config.h
@@ -0,0 +1,117 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
4Copyright 2015 ZSA Technology Labs Inc (@zsa)
5Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
6Copyright 2021 Gary Kong <kongkm88@gmail.com> (@garykong)
7
8This program is free software: you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#pragma once
23
24#include "config_common.h"
25
26/* USB Device descriptor parameter */
27#define VENDOR_ID 0x1209
28#define PRODUCT_ID 0x0002
29#define DEVICE_VER 0x0001
30#define PRODUCT BAJJAK
31
32/* key matrix size */
33#define MATRIX_ROWS 14
34#define MATRIX_ROWS_PER_SIDE (MATRIX_ROWS / 2)
35#define MATRIX_COLS 7
36
37#define COL_EXPANDED { true, true, true, true, true, true, true, false, false, false, false, false, false, false }
38#define MATRIX_ONBOARD_ROW_PINS { 0, 0, 0, 0, 0, 0, 0, B0, B1, B2, B3, D2, D3, C6 }
39#define MATRIX_ONBOARD_COL_PINS { F0, F1, F4, F5, F6, F7, D7 }
40#define DIODE_DIRECTION COL2ROW
41#define EXPANDER_COL_REGISTER GPIOB
42#define EXPANDER_ROW_REGISTER GPIOA
43#define MATRIX_EXPANDER_COL_PINS { 6, 5, 4, 3, 2, 1, 0 }
44#define MATRIX_EXPANDER_ROW_PINS { 0, 1, 2, 3, 4, 5, 6 }
45
46
47#define MOUSEKEY_INTERVAL 20
48#define MOUSEKEY_DELAY 0
49#define MOUSEKEY_TIME_TO_MAX 60
50#define MOUSEKEY_MAX_SPEED 7
51#define MOUSEKEY_WHEEL_DELAY 0
52
53#define DEBOUNCE 30
54
55#define TAPPING_TOGGLE 1
56
57/* define if matrix has ghost */
58//#define MATRIX_HAS_GHOST
59
60#define TAPPING_TERM 200
61#define IGNORE_MOD_TAP_INTERRUPT // this makes it possible to do rolling combos (zx) with keys that convert to other keys on hold (z becomes ctrl when you hold it, and when this option isn't enabled, z rapidly followed by x actually sends Ctrl-x. That's bad.)
62
63/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
64#define LOCKING_SUPPORT_ENABLE
65/* Locking resynchronize hack */
66#define LOCKING_RESYNC_ENABLE
67
68/* key combination for command */
69#define IS_COMMAND() ( \
70 get_mods() == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) || \
71 get_mods() == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \
72)
73
74/* number of backlight levels */
75#define BACKLIGHT_LEVELS 3
76
77#ifndef LED_BRIGHTNESS_LO
78#define LED_BRIGHTNESS_LO 15
79#endif
80#ifndef LED_BRIGHTNESS_HI
81#define LED_BRIGHTNESS_HI 255
82#endif
83#define LED_BRIGHTNESS_DEFAULT (LED_BRIGHTNESS_HI)
84
85/* fix space cadet rollover issue */
86#define DISABLE_SPACE_CADET_ROLLOVER
87
88/*
89 * The debounce filtering reports a key/switch change directly,
90 * without any extra delay. After that the debounce logic will filter
91 * all further changes, until the key/switch reports the same state for
92 * the given count of scans.
93 * So a perfect switch will get a short debounce period and
94 * a bad key will get a much longer debounce period.
95 * The result is an adaptive debouncing period for each switch.
96 *
97 * If you don't define it here, the matrix code will default to
98 * 5, which is now closer to 10ms, but still plenty according to
99 * manufacturer specs.
100 */
101
102/*
103 * Feature disable options
104 * These options are also useful to firmware size reduction.
105 */
106
107/* disable debug print */
108// #define NO_DEBUG
109
110/* disable print */
111// #define NO_PRINT
112
113/* disable action features */
114//#define NO_ACTION_LAYER
115//#define NO_ACTION_TAPPING
116//#define NO_ACTION_ONESHOT
117//#define DEBUG_MATRIX_SCAN_RATE
diff --git a/keyboards/bajjak/info.json b/keyboards/bajjak/info.json
new file mode 100644
index 0000000000..072ca33f5b
--- /dev/null
+++ b/keyboards/bajjak/info.json
@@ -0,0 +1,31 @@
1{
2 "keyboard_name": "bajjak",
3 "maintainer": "garykong",
4 "layouts": {
5 "LAYOUT_6x7": {
6 "layout": [
7 {"x":0, "y":0.375, "w":1.5}, {"x":1.5, "y":0.375}, {"x":2.5, "y":0.125}, {"x":3.5, "y":0}, {"x":4.5, "y":0.125}, {"x":5.5, "y":0.25}, {"x":6.5, "y":0.25},
8 {"x":9.5, "y":0.25}, {"x":10.5, "y":0.25}, {"x":11.5, "y":0.125}, {"x":12.5, "y":0}, {"x":13.5, "y":0.125}, {"x":14.5, "y":0.375}, {"x":15.5, "y":0.375, "w":1.5},
9
10 {"x":0, "y":1.375, "w":1.5}, {"x":1.5, "y":1.375}, {"x":2.5, "y":1.125}, {"x":3.5, "y":1}, {"x":4.5, "y":1.125}, {"x":5.5, "y":1.25}, {"x":6.5, "y":1.25},
11 {"x":9.5, "y":1.25}, {"x":10.5, "y":1.25}, {"x":11.5, "y":1.125}, {"x":12.5, "y":1}, {"x":13.5, "y":1.125}, {"x":14.5, "y":1.375}, {"x":15.5, "y":1.375, "w":1.5},
12
13 {"x":0, "y":2.375, "w":1.5}, {"x":1.5, "y":2.375}, {"x":2.5, "y":2.125}, {"x":3.5, "y":2}, {"x":4.5, "y":2.125}, {"x":5.5, "y":2.25}, {"x":6.5, "y":2.25},
14 {"x":9.5, "y":2.25}, {"x":10.5, "y":2.25}, {"x":11.5, "y":2.125}, {"x":12.5, "y":2}, {"x":13.5, "y":2.125}, {"x":14.5, "y":2.375}, {"x":15.5, "y":2.375, "w":1.5},
15
16 {"x":0, "y":3.375, "w":1.5}, {"x":1.5, "y":3.375}, {"x":2.5, "y":3.125}, {"x":3.5, "y":3}, {"x":4.5, "y":3.125}, {"x":5.5, "y":3.25}, {"x":6.5, "y":3.25},
17 {"x":9.5, "y":3.25}, {"x":10.5, "y":3.25}, {"x":11.5, "y":3.125}, {"x":12.5, "y":3}, {"x":13.5, "y":3.125}, {"x":14.5, "y":3.375}, {"x":15.5, "y":3.375, "w":1.5},
18
19 {"x":0, "y":4.375, "w":1.5}, {"x":1.5, "y":4.375}, {"x":2.5, "y":4.125}, {"x":3.5, "y":4}, {"x":4.5, "y":4.125}, {"x":5.5, "y":4.25},
20 {"x":10.5, "y":4.25}, {"x":11.5, "y":4.125}, {"x":12.5, "y":4}, {"x":13.5, "y":4.125}, {"x":14.5, "y":4.375}, {"x":15.5, "y":4.375, "w":1.5},
21
22 {"x":0, "y":5.375, "w":1.5}, {"x":1.5, "y":5.375}, {"x":2.5, "y":5.125}, {"x":3.5, "y":5}, {"x":4.5, "y":5.125},
23 {"x":11.5, "y":5.125}, {"x":12.5, "y":5}, {"x":13.5, "y":5.125}, {"x":14.5, "y":5.375}, {"x":15.5, "y":5.375, "w":1.5},
24
25 {"x":6, "y":6}, {"x":7, "y":6}, {"x":9, "y":6}, {"x":10, "y":6},
26 {"x":7, "y":7}, {"x":9, "y":7},
27 {"x":5, "y":7, "h":2}, {"x":6, "y":7, "h":2}, {"x":7, "y":8}, {"x":9, "y":8}, {"x":10, "y":7, "h":2}, {"x":11, "y":7, "h":2}
28 ]
29 }
30 }
31}
diff --git a/keyboards/bajjak/keymaps/5x6/keymap.c b/keyboards/bajjak/keymaps/5x6/keymap.c
new file mode 100644
index 0000000000..e97d0360b7
--- /dev/null
+++ b/keyboards/bajjak/keymaps/5x6/keymap.c
@@ -0,0 +1,187 @@
1/* Copyright 2021 Gary Kong
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#include QMK_KEYBOARD_H
18#include "version.h"
19
20enum layers {
21 BASE, // default layer
22 SYMB, // symbols
23 MDIA, // media keys
24};
25
26enum custom_keycodes {
27 VRSN = SAFE_RANGE,
28};
29
30const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
31/* Keymap 0: Basic layer
32 *
33 * ------------------------------------------- -------------------------------------------
34 * | = | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - |
35 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
36 * | Tab | Q | W | E | R | T | | Y | U | I | O | P | \ |
37 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
38 * | Caps | A | S | D | F | G | | H | J | K | L | ; | ' |
39 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
40 * | LShift | Z | X | C | V | B | | N | M | , | . | / | RShift |
41 * ------------------------------------------- -------------------------------------------
42 * | CTRL |GUI\` |ALT \ | Left |Right | | Up | Down | [ | ] | L1 |
43 * ---------------------------------- ----------------------------------
44 * ------------- ---------------
45 * |Ctrl/ESC|LALT| | RGUI |Ctrl/Alt|
46 * ------|------|------| |------+--------+------
47 * | | | Home | | PgUp | | |
48 * |Back | Del |------| |------| Enter |Space |
49 * |Space | | End | | PgDn | | |
50 * -------------------- ----------------------
51 *
52 */
53[BASE] = LAYOUT_6x7(
54// Left hand Right hand
55 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
56 KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, XXXXXXX, XXXXXXX, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
57 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, XXXXXXX, XXXXXXX, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
58 KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, XXXXXXX, XXXXXXX, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
59 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
60 KC_LCTRL, GUI_T(KC_GRV), ALT_T(KC_BSLS), KC_LEFT, KC_RGHT, KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, DF(SYMB),
61 CTL_T(KC_ESC), KC_LALT, KC_RGUI, CTL_T(KC_HAEN),
62 KC_HOME, KC_PGUP,
63 KC_BSPC, KC_DEL, KC_END, KC_PGDN, KC_ENT, KC_SPC
64),
65/* Keymap 1: Sybol layer
66 *
67 * ------------------------------------------- -------------------------------------------
68 * | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 |
69 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
70 * | Tab | ! | @ | { | } | | |NUMLCK| 7 | 8 | 9 | - | / |
71 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
72 * | | # | $ | ( | ) | | | | 4 | 5 | 6 | + | * |
73 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
74 * | LShift | % | ^ | [ | ] | | | L2 | 1 | 2 | 3 | = | RShift |
75 * ------------------------------------------- -------------------------------------------
76 * | CTRL |GUI\~`|ALT \ | Left | Right| | Up | Down | . | 0 | |
77 * ---------------------------------- ----------------------------------
78 * ------------- ---------------
79 * |Ctrl/ESC|LALT| | RGUI |Ctrl/Alt|
80 * ------|------|------| |------+--------+------
81 * | | | Home | | PgUp | | |
82 * |BackSp| Del |------| |------| Enter |Space |
83 * | | | End | | PgDn | | |
84 * -------------------- ----------------------
85 *
86 */
87[SYMB] = LAYOUT_6x7(
88// Left hand Right hand
89 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
90 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, XXXXXXX, XXXXXXX, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
91 _______, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, XXXXXXX, XXXXXXX, XXXXXXX, KC_NLCK, KC_P7 , KC_P8 , KC_P9, KC_MINS, KC_PSLS,
92 XXXXXXX, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_P4 , KC_P5 , KC_P6, KC_PLUS, KC_PAST,
93 _______, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, XXXXXXX, DF(MDIA), KC_P1 , KC_P2 , KC_P3, KC_PEQL, _______,
94 _______, _______, _______, _______, _______, _______, _______, KC_PDOT, KC_P0, DF(BASE),
95 _______, _______, _______, _______,
96 _______, _______,
97 _______, _______, _______, _______, _______, _______
98),
99/* Keymap 2: Media and mouse keys
100 *
101 * ------------------------------------------- -------------------------------------------
102 * | SLEEP |BR_Up |BR_Dn | | |Eject | | Prev | Play | Next | Mute |Vol_Up| Vol_Dn |
103 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
104 * | | | Lclk | MsUp | Rclk |MsWhUp| | | | | | | |
105 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
106 * | RESET | |MsLeft|MsDown|MsRght|MsWhDw| | | | | | | |
107 * |--------+------+------+------+------+------| |------|------+------+------+------+--------|
108 * | LShift | |MsWhL | |MsWhR | | | | | | | | RShift |
109 * ------------------------------------------- -------------------------------------------
110 * | CTRL |GUI\~`|ALT \ | Left | Right| | Up | Down | | | L0 |
111* ---------------------------------- -----------------------------------
112 * ------------- ---------------
113 * |Ctrl/ESC|LALT| | RGUI |Ctrl/Alt|
114 * ------|------|------| |------+--------+------
115 * | | | Home | | PgUp | | |
116 * |BackSp| Del |------| |------| Enter |Space |
117 * | | | End | | PgDn | | |
118 * -------------------- ----------------------
119 *
120 */
121[MDIA] = LAYOUT_6x7(
122// Left hand Right hand
123 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
124 KC_SLEP, KC_BRID, KC_BRIU, XXXXXXX, XXXXXXX, XXXXXXX, KC_EJCT, XXXXXXX, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU,
125 XXXXXXX, XXXXXXX, KC_BTN1, KC_MS_U, KC_BTN2, KC_WH_U, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
126 RESET, XXXXXXX, KC_MS_L, KC_MS_D, KC_MS_R, KC_WH_D, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
127 _______, XXXXXXX, KC_WH_L, XXXXXXX, KC_WH_R, XXXXXXX, DF(SYMB), XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
128 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, DF(BASE),
129 _______, _______, _______, _______,
130 _______, _______,
131 _______, _______, _______, _______, _______, _______
132),
133};
134
135bool process_record_user(uint16_t keycode, keyrecord_t *record) {
136 if (record->event.pressed) {
137 switch (keycode) {
138 case VRSN:
139 SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
140 return false;
141 }
142 }
143 return true;
144}
145
146// Runs whenever there is a layer state change.
147layer_state_t layer_state_set_user(layer_state_t state) {
148 bajjak_right_led_1_off();
149 bajjak_right_led_2_off();
150 bajjak_right_led_3_off();
151
152 uint8_t layer = get_highest_layer(state);
153 switch (layer) {
154 case 0:
155 break;
156 case 1:
157 bajjak_right_led_1_on();
158 break;
159 case 2:
160 bajjak_right_led_2_on();
161 break;
162 case 3:
163 bajjak_right_led_3_on();
164 break;
165 case 4:
166 bajjak_right_led_1_on();
167 bajjak_right_led_2_on();
168 break;
169 case 5:
170 bajjak_right_led_1_on();
171 bajjak_right_led_3_on();
172 break;
173 case 6:
174 bajjak_right_led_2_on();
175 bajjak_right_led_3_on();
176 break;
177 case 7:
178 bajjak_right_led_1_on();
179 bajjak_right_led_2_on();
180 bajjak_right_led_3_on();
181 break;
182 default:
183 break;
184 }
185
186 return state;
187};
diff --git a/keyboards/bajjak/keymaps/default/keymap.c b/keyboards/bajjak/keymaps/default/keymap.c
new file mode 100644
index 0000000000..4c79261307
--- /dev/null
+++ b/keyboards/bajjak/keymaps/default/keymap.c
@@ -0,0 +1,193 @@
1/* Copyright 2021 Gary Kong
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#include QMK_KEYBOARD_H
18#include "version.h"
19
20enum layers {
21 BASE, // default layer
22 SYMB, // symbols
23 MDIA, // media keys
24};
25
26enum custom_keycodes {
27 VRSN = SAFE_RANGE,
28};
29
30const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
31/* Keymap 0: Basic layer
32 *
33 * ,--------------------------------------------------. ,--------------------------------------------------.
34 * | ESC | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | Eject |
35 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
36 * | = | 1 | 2 | 3 | 4 | 5 | | | | 6 | 7 | 8 | 9 | 0 | - |
37 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
38 * | Tab | Q | W | E | R | T | | | | Y | U | I | O | P | \ |
39 * |--------+------+------+------+------+------+------| |------+------+------+------+------+------+--------|
40 * | Caps | A | S | D | F | G | L2 | | L1 | H | J | K | L | ; | ' |
41 * |--------+------+------+------+------+------+------' `------+------+------+------+------+------+--------|
42 * | LShift | Z | X | C | V | B | | N | M | , | . | / | RShift |
43 * `--------+------+------+------+------+------' `-----+------+------+------+------+-------'
44 * | CTRL |iGUI\'"|ALT \ | Left | Right| | Up | Down | [ | ] | ~L1 |
45 * `----------------------------------' `----------------------------------'
46 * ,-------------. ,-------------.
47 * |Ctrl/ESC|LALT| | RGUI |Ctrl/Alt|
48 * ,------|------|------| |------+--------+------.
49 * | | | Home | | PgUp | | |
50 * |BackSp| Del |------| |------| Enter |Space |
51 * | | | End | | PgDn | | |
52 * `--------------------' `----------------------'
53 *
54 */
55[BASE] = LAYOUT_6x7(
56// Left hand Right hand
57 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_EJCT,
58 KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, _______, _______, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
59 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, _______, _______, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
60 KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, TG(MDIA), TG(SYMB), KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
61 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
62 KC_LCTRL, GUI_T(KC_GRV), ALT_T(KC_BSLS), KC_LEFT, KC_RGHT, KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, TT(SYMB),
63 CTL_T(KC_ESC), KC_LALT, KC_RGUI, CTL_T(KC_RALT),
64 KC_HOME, KC_PGUP,
65 KC_BSPC, KC_DEL, KC_END, KC_PGDN, KC_ENT, KC_SPC
66),
67/* Keymap 1: Sybol layer
68 *
69 * ,--------------------------------------------------. ,--------------------------------------------------.
70 * | ESC | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | Eject |
71 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
72 * | | | | | | | | | | |NUMLCK| = | \ | * |PSCREEN |
73 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
74 * | Tab | ! | @ | { | } | | | | | | | 7 | 8 | 9 | - | SLCK |
75 * |--------+------+------+------+------+------+------| |------+------+------+------+------+------+--------|
76 * | Caps | # | $ | ( | ) | ` | | | | | 4 | 5 | 6 | + | PAUSE |
77 * |--------+------+------+------+------+------+------' `------+------+------+------+------+------+--------|
78 * | LShift | % | ^ | [ | ] | ~ | | | 1 | 2 | 3 |Enter | RShift |
79 * `--------+------+------+------+------+------' `-----+------+------+------+------+-------'
80 * | CTRL |GUI\'"|ALT \ | Left | Right| | Up | Down | . | 0 | |
81 * `----------------------------------' `----------------------------------'
82 * ,-------------. ,-------------.
83 * |Ctrl/ESC|LALT| | RGUI |Ctrl/Alt|
84 * ,------|------|------| |------+--------+------.
85 * | | | Home | | PgUp | | |
86 * |BackSp| Del |------| |------| Enter |Space |
87 * | | | End | | PgDn | | |
88 * `--------------------' `----------------------'
89 *
90 */
91[SYMB] = LAYOUT_6x7(
92// Left hand Right hand
93 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_EJCT,
94 _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_NLCK, KC_PEQL, KC_PSLS, KC_PAST, KC_PSCR,
95 KC_TAB, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, _______, _______, _______, KC_P7 , KC_P8 , KC_P9, KC_MINS, KC_SLCK,
96 KC_CAPS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, _______, _______, _______, KC_P4 , KC_P5 , KC_P6, KC_PLUS, KC_PAUS,
97 KC_LSFT, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, _______, KC_P1 , KC_P2 , KC_P3, KC_PENT, KC_RSFT,
98 KC_LCTRL, KC_LGUI, ALT_T(KC_INSERT), KC_LEFT, KC_RGHT, KC_UP, KC_DOWN, KC_PDOT, KC_P0, _______,
99 CTL_T(KC_ESC), KC_LALT, KC_RGUI, CTL_T(KC_RALT),
100 KC_HOME, KC_PGUP,
101 KC_BSPC, KC_DEL, KC_END, KC_PGDN, KC_ENT, KC_SPC
102),
103/* Keymap 2: Media and mouse keys
104 *
105 * ,--------------------------------------------------. ,--------------------------------------------------.
106 * | SLEEP |BR_Up |BR_Dn | | | | | | Prev | Play | Next | Mute |Vol_Up|Vol_Dn| Eject |
107 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
108 * | | | | | | | | | | | | | | | |
109 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
110 * | Tab | | Lclk | MsUp | Rclk |MsWhUp| | | | | | | | | |
111 * |--------+------+------+------+------+------+------| |------+------+------+------+------+------+--------|
112 * | Caps | |MsLeft|MsDown|MsRght|MsWhDw| | | | | | | | | |
113 * |--------+------+------+------+------+------+------' `------+------+------+------+------+------+--------|
114 * | LShift | |MsWhL | |MsWhR | | | | | | | | |
115 * `--------+------+------+------+------+------' `-----+------+------+------+------+-------'
116 * | CTRL |GUI\'"|ALT \ | Left | Right| | Up | Down | | | RESET |
117 * `----------------------------------' `----------------------------------'
118 * ,-------------. ,-------------.
119 * |Ctrl/ESC|LALT| | RGUI |Ctrl/Alt|
120 * ,------|------|------| |------+--------+------.
121 * | | | Home | | PgUp | | |
122 * |BackSp| Del |------| |------| Enter |Space |
123 * | | | End | | PgDn | | |
124 * `--------------------' `----------------------'
125 *
126 */
127[MDIA] = LAYOUT_6x7(
128// Left hand Right hand
129 KC_SLEP, KC_BRID, KC_BRIU, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_EJCT,
130 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
131 KC_TAB, _______, KC_BTN1, KC_MS_U, KC_BTN2, KC_WH_U, _______, _______, _______, _______, _______, _______, _______, _______,
132 KC_CAPS, _______, KC_MS_L, KC_MS_D, KC_MS_R, KC_WH_D, _______, _______, _______, _______, _______, _______, _______, _______,
133 KC_LSFT, _______, KC_WH_L, _______, KC_WH_R, _______, _______, _______, _______, _______, _______, _______,
134 KC_LCTRL, KC_LGUI, ALT_T(KC_INSERT), KC_LEFT, KC_RGHT, KC_UP, KC_DOWN, _______, _______, RESET,
135 CTL_T(KC_ESC), KC_LALT, KC_RGUI, CTL_T(KC_RALT),
136 KC_HOME, KC_PGUP,
137 KC_BSPC, KC_DEL, KC_END, KC_PGDN, KC_ENT, KC_SPC
138),
139};
140
141bool process_record_user(uint16_t keycode, keyrecord_t *record) {
142 if (record->event.pressed) {
143 switch (keycode) {
144 case VRSN:
145 SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
146 return false;
147 }
148 }
149 return true;
150}
151
152// Runs whenever there is a layer state change.
153layer_state_t layer_state_set_user(layer_state_t state) {
154 bajjak_right_led_1_off();
155 bajjak_right_led_2_off();
156 bajjak_right_led_3_off();
157
158 uint8_t layer = get_highest_layer(state);
159 switch (layer) {
160 case 0:
161 break;
162 case 1:
163 bajjak_right_led_1_on();
164 break;
165 case 2:
166 bajjak_right_led_2_on();
167 break;
168 case 3:
169 bajjak_right_led_3_on();
170 break;
171 case 4:
172 bajjak_right_led_1_on();
173 bajjak_right_led_2_on();
174 break;
175 case 5:
176 bajjak_right_led_1_on();
177 bajjak_right_led_3_on();
178 break;
179 case 6:
180 bajjak_right_led_2_on();
181 bajjak_right_led_3_on();
182 break;
183 case 7:
184 bajjak_right_led_1_on();
185 bajjak_right_led_2_on();
186 bajjak_right_led_3_on();
187 break;
188 default:
189 break;
190 }
191
192 return state;
193};
diff --git a/keyboards/bajjak/matrix.c b/keyboards/bajjak/matrix.c
new file mode 100644
index 0000000000..20fc3c8f23
--- /dev/null
+++ b/keyboards/bajjak/matrix.c
@@ -0,0 +1,253 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
4Copyright 2015 ZSA Technology Labs Inc (@zsa)
5Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
6Copyright 2021 Gary Kong <kongkm88@gmail.com> (@garykong)
7
8This program is free software: you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22
23/*
24 * scan matrix
25 */
26#include <stdint.h>
27#include <stdbool.h>
28#include <avr/io.h>
29#include "wait.h"
30#include "action_layer.h"
31#include "print.h"
32#include "debug.h"
33#include "util.h"
34#include "matrix.h"
35#include "debounce.h"
36#include "bajjak.h"
37
38
39/*
40 * This constant define not debouncing time in msecs, assuming eager_pr.
41 *
42 * On BAJJAK matrix scan rate is relatively low, because of slow I2C.
43 * Now it's only 317 scans/second, or about 3.15 msec/scan.
44 * According to Cherry specs, debouncing time is 5 msec.
45 *
46 * However, some switches seem to have higher debouncing requirements, or
47 * something else might be wrong. (Also, the scan speed has improved since
48 * that comment was written.)
49 */
50
51/* matrix state(1:on, 0:off) */
52extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
53extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
54
55static matrix_row_t read_cols(uint8_t row);
56static void init_cols(void);
57static void unselect_rows(void);
58static void select_row(uint8_t row);
59
60static uint8_t mcp23018_reset_loop;
61
62void matrix_init_custom(void) {
63 // initialize row and col
64
65 mcp23018_status = init_mcp23018();
66
67 unselect_rows();
68 init_cols();
69}
70
71// Reads and stores a row, returning
72// whether a change occurred.
73static inline bool store_raw_matrix_row(uint8_t index) {
74 matrix_row_t temp = read_cols(index);
75 if (raw_matrix[index] != temp) {
76 raw_matrix[index] = temp;
77 return true;
78 }
79 return false;
80}
81
82bool matrix_scan_custom(matrix_row_t current_matrix[]) {
83 if (mcp23018_status) { // if there was an error
84 if (++mcp23018_reset_loop == 0) {
85 print("trying to reset mcp23018\n");
86 mcp23018_status = init_mcp23018();
87 if (mcp23018_status) {
88 print("left side not responding\n");
89 } else {
90 print("left side attached\n");
91 bajjak_blink_all_leds();
92 }
93 }
94 }
95
96#ifdef LEFT_LEDS
97 mcp23018_status = bajjak_left_leds_update();
98#endif // LEFT_LEDS
99 bool changed = false;
100 for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
101 // select rows from left and right hands
102 uint8_t left_index = i;
103 uint8_t right_index = i + MATRIX_ROWS_PER_SIDE;
104 select_row(left_index);
105 select_row(right_index);
106
107 changed |= store_raw_matrix_row(left_index);
108 changed |= store_raw_matrix_row(right_index);
109
110 unselect_rows();
111 }
112
113 return changed;
114}
115
116/* Column pin configuration
117 *
118 * Teensy
119 * col: 0 1 2 3 4 5
120 * pin: F0 F1 F4 F5 F6 F7
121 *
122 * MCP23018
123 * col: 0 1 2 3 4 5
124 * pin: B5 B4 B3 B2 B1 B0
125 */
126static void init_cols(void) {
127 // init on mcp23018
128 // not needed, already done as part of init_mcp23018()
129
130 // init on teensy
131 setPinInputHigh(F0);
132 setPinInputHigh(F1);
133 setPinInputHigh(F4);
134 setPinInputHigh(F5);
135 setPinInputHigh(F6);
136 setPinInputHigh(F7);
137 setPinInputHigh(D7);
138}
139
140static matrix_row_t read_cols(uint8_t row) {
141 if (row < 7) {
142 if (mcp23018_status) { // if there was an error
143 return 0;
144 } else {
145 uint8_t data = 0;
146 // reading GPIOB (column port) since in mcp23018's sequential mode
147 // it is addressed directly after writing to GPIOA in select_row()
148 mcp23018_status = i2c_start(I2C_ADDR_READ, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
149 mcp23018_status = i2c_read_nack(BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status < 0) goto out;
150 data = ~((uint8_t)mcp23018_status);
151 mcp23018_status = I2C_STATUS_SUCCESS;
152 out:
153 i2c_stop();
154 return data;
155 }
156 } else {
157 /* read from teensy
158 * bitmask is 0b11110011, but we want those all
159 * in the lower six bits.
160 * we'll return 1s for the top two, but that's harmless.
161 */
162
163 return ~( (PINF & 0x03) | ((PINF & 0xF0) >> 2) | ((PIND & 0x80) >> 1) );
164 }
165}
166
167/* Row pin configuration
168 *
169 * Teensy
170 * row: 7 8 9 10 11 12 13
171 * pin: B0 B1 B2 B3 D2 D3 C6
172 *
173 * MCP23018
174 * row: 0 1 2 3 4 5 6
175 * pin: A0 A1 A2 A3 A4 A5 A6
176 */
177static void unselect_rows(void) {
178 // no need to unselect on mcp23018, because the select step sets all
179 // the other row bits high, and it's not changing to a different
180 // direction
181
182 // unselect on teensy
183 setPinInput(B0);
184 setPinInput(B1);
185 setPinInput(B2);
186 setPinInput(B3);
187 setPinInput(D2);
188 setPinInput(D3);
189 setPinInput(C6);
190}
191
192static void select_row(uint8_t row) {
193 if (row < 7) {
194 // select on mcp23018
195 if (!mcp23018_status) {
196 // set active row low : 0
197 // set other rows hi-Z : 1
198 mcp23018_status = i2c_start(I2C_ADDR_WRITE, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
199 mcp23018_status = i2c_write(GPIOA, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
200 mcp23018_status = i2c_write(0xFF & ~(1 << row), BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
201 out:
202 i2c_stop();
203 }
204 } else {
205 // select on teensy
206 // Output low(DDR:1, PORT:0) to select
207 switch (row) {
208 case 7:
209 setPinOutput(B0);
210 writePinLow(B0);
211 break;
212 case 8:
213 setPinOutput(B1);
214 writePinLow(B1);
215 break;
216 case 9:
217 setPinOutput(B2);
218 writePinLow(B2);
219 break;
220 case 10:
221 setPinOutput(B3);
222 writePinLow(B3);
223 break;
224 case 11:
225 setPinOutput(D2);
226 writePinLow(D2);
227 break;
228 case 12:
229 setPinOutput(D3);
230 writePinLow(D3);
231 break;
232 case 13:
233 setPinOutput(C6);
234 writePinLow(C6);
235 break;
236 }
237 }
238}
239
240// DO NOT REMOVE
241// Needed for proper wake/sleep
242void matrix_power_up(void) {
243 mcp23018_status = init_mcp23018();
244
245 unselect_rows();
246 init_cols();
247
248 // initialize matrix state: all keys off
249 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
250 matrix[i] = 0;
251 }
252
253}
diff --git a/keyboards/bajjak/readme.md b/keyboards/bajjak/readme.md
new file mode 100644
index 0000000000..7e86d0243d
--- /dev/null
+++ b/keyboards/bajjak/readme.md
@@ -0,0 +1,23 @@
1# bajjak
2
3This keyboard is a 6x7 array keyboard, similar in design to the Ergodox EZ.
4
5* Keyboard Maintainer: [Gary Kong](https://github.com/garykong)
6* Hardware Supported: bajjak keyboard (ATmega32U4)
7
8Make example for this keyboard (after setting up your build environment):
9
10 make bajjak:default
11
12Flashing example for this keyboard:
13
14 make bajjak:default:flash
15
16## Bootloader
17
18Enter the bootloader in 2 ways:
19
20* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead
21* **Keycode in layout**: Press the key mapped to `RESET` if it is available
22
23See 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).
diff --git a/keyboards/bajjak/rules.mk b/keyboards/bajjak/rules.mk
new file mode 100644
index 0000000000..6bbe7e3b28
--- /dev/null
+++ b/keyboards/bajjak/rules.mk
@@ -0,0 +1,37 @@
1# MCU name
2MCU = atmega32u4
3
4# Bootloader selection
5BOOTLOADER = halfkay
6
7# If you have Left LEDs (see
8# https://geekhack.org/index.php?topic=22780.msg873819#msg873819 for
9# details), include the following define:
10OPT_DEFS += -DLEFT_LEDS
11
12# Build Options
13# change yes to no to disable
14#
15BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
16MOUSEKEY_ENABLE = yes # Mouse keys
17EXTRAKEY_ENABLE = yes # Audio control and System control
18CONSOLE_ENABLE = no # Console for debug
19COMMAND_ENABLE = yes # Commands for debug and configuration
20NKRO_ENABLE = yes # Enable N-Key Rollover
21BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
22RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
23AUDIO_ENABLE = no # Audio output
24
25CUSTOM_MATRIX = lite # Custom matrix file for the BAJJAK
26UNICODE_ENABLE = yes # Unicode
27SWAP_HANDS_ENABLE = yes # Allow swapping hands of keyboard
28
29# Disable unsupported hardware
30BACKLIGHT_SUPPORTED = no
31AUDIO_SUPPORTED = no
32
33DEBOUNCE_TYPE = sym_eager_pr
34
35# project specific files
36SRC += matrix.c
37QUANTUM_LIB_SRC += i2c_master.c