diff options
author | Alexander Fougner <fougner89@gmail.com> | 2018-03-14 21:55:34 +0100 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-03-16 16:41:32 -0400 |
commit | 3acaad66005718ab50a46ae375636f328a93b100 (patch) | |
tree | aa366acc271a7d685578e4fcf462c7a2a198c26d | |
parent | 00b4dce605bc44a2ee6babaf93dbe3640e735d2e (diff) | |
download | qmk_firmware-3acaad66005718ab50a46ae375636f328a93b100.tar.gz qmk_firmware-3acaad66005718ab50a46ae375636f328a93b100.zip |
Initial support for The Unloved Bastard
-rw-r--r-- | keyboards/unloved_bastard/config.h | 168 | ||||
-rw-r--r-- | keyboards/unloved_bastard/keymaps/default/config.h | 24 | ||||
-rw-r--r-- | keyboards/unloved_bastard/keymaps/default/keymap.c | 63 | ||||
-rw-r--r-- | keyboards/unloved_bastard/keymaps/default/readme.md | 1 | ||||
-rw-r--r-- | keyboards/unloved_bastard/matrix.c | 138 | ||||
-rw-r--r-- | keyboards/unloved_bastard/readme.md | 15 | ||||
-rw-r--r-- | keyboards/unloved_bastard/rules.mk | 71 | ||||
-rw-r--r-- | keyboards/unloved_bastard/unloved_bastard.c | 70 | ||||
-rw-r--r-- | keyboards/unloved_bastard/unloved_bastard.h | 42 |
9 files changed, 592 insertions, 0 deletions
diff --git a/keyboards/unloved_bastard/config.h b/keyboards/unloved_bastard/config.h new file mode 100644 index 000000000..d89e85862 --- /dev/null +++ b/keyboards/unloved_bastard/config.h | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | Copyright 2018 Alexander Fougner <fougner89 at gmail.com> | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along 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 0x1337 | ||
26 | #define DEVICE_VER 0x0001 | ||
27 | #define MANUFACTURER BathroomEpiphanies | ||
28 | #define PRODUCT Unloved Bastard | ||
29 | #define DESCRIPTION Unloved Bastard controller for CM Masterkeys S | ||
30 | |||
31 | /* key matrix size */ | ||
32 | #define MATRIX_ROWS 8 | ||
33 | #define MATRIX_COLS 18 | ||
34 | |||
35 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
36 | #define DEBOUNCING_DELAY 5 | ||
37 | |||
38 | /* define if matrix has ghost (lacks anti-ghosting diodes) */ | ||
39 | //#define MATRIX_HAS_GHOST | ||
40 | |||
41 | /* number of backlight levels */ | ||
42 | |||
43 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
44 | #define LOCKING_SUPPORT_ENABLE | ||
45 | /* Locking resynchronize hack */ | ||
46 | #define LOCKING_RESYNC_ENABLE | ||
47 | |||
48 | /* If defined, GRAVE_ESC will always act as ESC when CTRL is held. | ||
49 | * This is userful for the Windows task manager shortcut (ctrl+shift+esc). | ||
50 | */ | ||
51 | // #define GRAVE_ESC_CTRL_OVERRIDE | ||
52 | |||
53 | /* | ||
54 | * Force NKRO | ||
55 | * | ||
56 | * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved | ||
57 | * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the | ||
58 | * makefile for this to work.) | ||
59 | * | ||
60 | * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) | ||
61 | * until the next keyboard reset. | ||
62 | * | ||
63 | * NKRO may prevent your keystrokes from being detected in the BIOS, but it is | ||
64 | * fully operational during normal computer usage. | ||
65 | * | ||
66 | * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) | ||
67 | * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by | ||
68 | * bootmagic, NKRO mode will always be enabled until it is toggled again during a | ||
69 | * power-up. | ||
70 | * | ||
71 | */ | ||
72 | //#define FORCE_NKRO | ||
73 | |||
74 | /* | ||
75 | * Magic Key Options | ||
76 | * | ||
77 | * Magic keys are hotkey commands that allow control over firmware functions of | ||
78 | * the keyboard. They are best used in combination with the HID Listen program, | ||
79 | * found here: https://www.pjrc.com/teensy/hid_listen.html | ||
80 | * | ||
81 | * The options below allow the magic key functionality to be changed. This is | ||
82 | * useful if your keyboard/keypad is missing keys and you want magic key support. | ||
83 | * | ||
84 | */ | ||
85 | |||
86 | /* key combination for magic key command */ | ||
87 | #define IS_COMMAND() ( \ | ||
88 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
89 | ) | ||
90 | |||
91 | /* control how magic key switches layers */ | ||
92 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true | ||
93 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true | ||
94 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false | ||
95 | |||
96 | /* override magic key keymap */ | ||
97 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS | ||
98 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS | ||
99 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM | ||
100 | //#define MAGIC_KEY_HELP1 H | ||
101 | //#define MAGIC_KEY_HELP2 SLASH | ||
102 | //#define MAGIC_KEY_DEBUG D | ||
103 | //#define MAGIC_KEY_DEBUG_MATRIX X | ||
104 | //#define MAGIC_KEY_DEBUG_KBD K | ||
105 | //#define MAGIC_KEY_DEBUG_MOUSE M | ||
106 | //#define MAGIC_KEY_VERSION V | ||
107 | //#define MAGIC_KEY_STATUS S | ||
108 | //#define MAGIC_KEY_CONSOLE C | ||
109 | //#define MAGIC_KEY_LAYER0_ALT1 ESC | ||
110 | //#define MAGIC_KEY_LAYER0_ALT2 GRAVE | ||
111 | //#define MAGIC_KEY_LAYER0 0 | ||
112 | //#define MAGIC_KEY_LAYER1 1 | ||
113 | //#define MAGIC_KEY_LAYER2 2 | ||
114 | //#define MAGIC_KEY_LAYER3 3 | ||
115 | //#define MAGIC_KEY_LAYER4 4 | ||
116 | //#define MAGIC_KEY_LAYER5 5 | ||
117 | //#define MAGIC_KEY_LAYER6 6 | ||
118 | //#define MAGIC_KEY_LAYER7 7 | ||
119 | //#define MAGIC_KEY_LAYER8 8 | ||
120 | //#define MAGIC_KEY_LAYER9 9 | ||
121 | //#define MAGIC_KEY_BOOTLOADER PAUSE | ||
122 | //#define MAGIC_KEY_LOCK CAPS | ||
123 | //#define MAGIC_KEY_EEPROM E | ||
124 | //#define MAGIC_KEY_NKRO N | ||
125 | //#define MAGIC_KEY_SLEEP_LED Z | ||
126 | |||
127 | /* | ||
128 | * Feature disable options | ||
129 | * These options are also useful to firmware size reduction. | ||
130 | */ | ||
131 | |||
132 | /* disable debug print */ | ||
133 | //#define NO_DEBUG | ||
134 | |||
135 | /* disable print */ | ||
136 | //#define NO_PRINT | ||
137 | |||
138 | /* disable action features */ | ||
139 | //#define NO_ACTION_LAYER | ||
140 | //#define NO_ACTION_TAPPING | ||
141 | //#define NO_ACTION_ONESHOT | ||
142 | //#define NO_ACTION_MACRO | ||
143 | //#define NO_ACTION_FUNCTION | ||
144 | |||
145 | /* | ||
146 | * MIDI options | ||
147 | */ | ||
148 | |||
149 | /* Prevent use of disabled MIDI features in the keymap */ | ||
150 | //#define MIDI_ENABLE_STRICT 1 | ||
151 | |||
152 | /* enable basic MIDI features: | ||
153 | - MIDI notes can be sent when in Music mode is on | ||
154 | */ | ||
155 | //#define MIDI_BASIC | ||
156 | |||
157 | /* enable advanced MIDI features: | ||
158 | - MIDI notes can be added to the keymap | ||
159 | - Octave shift and transpose | ||
160 | - Virtual sustain, portamento, and modulation wheel | ||
161 | - etc. | ||
162 | */ | ||
163 | //#define MIDI_ADVANCED | ||
164 | |||
165 | /* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ | ||
166 | //#define MIDI_TONE_KEYCODE_OCTAVES 1 | ||
167 | |||
168 | #endif | ||
diff --git a/keyboards/unloved_bastard/keymaps/default/config.h b/keyboards/unloved_bastard/keymaps/default/config.h new file mode 100644 index 000000000..c55f7f9f7 --- /dev/null +++ b/keyboards/unloved_bastard/keymaps/default/config.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* Copyright 2018 Alexander Fougner <fougner89 at 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 | #ifndef CONFIG_USER_H | ||
18 | #define CONFIG_USER_H | ||
19 | |||
20 | #include "config_common.h" | ||
21 | |||
22 | // place overrides here | ||
23 | |||
24 | #endif | ||
diff --git a/keyboards/unloved_bastard/keymaps/default/keymap.c b/keyboards/unloved_bastard/keymaps/default/keymap.c new file mode 100644 index 000000000..f4dedc799 --- /dev/null +++ b/keyboards/unloved_bastard/keymaps/default/keymap.c | |||
@@ -0,0 +1,63 @@ | |||
1 | /* Copyright 2018 Alexander Fougner <fougner89 at 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 | #include "unloved_bastard.h" | ||
17 | |||
18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
19 | [0] = KEYMAP(\ | ||
20 | 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_PAUS, \ | ||
21 | 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, \ | ||
22 | 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, \ | ||
23 | 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, \ | ||
24 | KC_LSFT,KC_NUBS,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, KC_UP, \ | ||
25 | KC_LCTL,KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT ) | ||
26 | }; | ||
27 | |||
28 | |||
29 | const uint16_t PROGMEM fn_actions[] = { | ||
30 | |||
31 | }; | ||
32 | |||
33 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
34 | { | ||
35 | // MACRODOWN only works in this function | ||
36 | switch(id) { | ||
37 | case 0: | ||
38 | if (record->event.pressed) { | ||
39 | register_code(KC_RSFT); | ||
40 | } else { | ||
41 | unregister_code(KC_RSFT); | ||
42 | } | ||
43 | break; | ||
44 | } | ||
45 | return MACRO_NONE; | ||
46 | }; | ||
47 | |||
48 | |||
49 | void matrix_init_user(void) { | ||
50 | |||
51 | } | ||
52 | |||
53 | void matrix_scan_user(void) { | ||
54 | |||
55 | } | ||
56 | |||
57 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
58 | return true; | ||
59 | } | ||
60 | |||
61 | void led_set_user(uint8_t usb_led) { | ||
62 | |||
63 | } | ||
diff --git a/keyboards/unloved_bastard/keymaps/default/readme.md b/keyboards/unloved_bastard/keymaps/default/readme.md new file mode 100644 index 000000000..a2b5f1192 --- /dev/null +++ b/keyboards/unloved_bastard/keymaps/default/readme.md | |||
@@ -0,0 +1 @@ | |||
# The default keymap for unloved_bastard | |||
diff --git a/keyboards/unloved_bastard/matrix.c b/keyboards/unloved_bastard/matrix.c new file mode 100644 index 000000000..65773879b --- /dev/null +++ b/keyboards/unloved_bastard/matrix.c | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | Copyright 2017 Gabriel Young <gabeplaysdrums@live.com> | ||
3 | Copyright 2018 Alexander Fougner <fougner89 at gmail.com> | ||
4 | |||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation, either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #include <stdint.h> | ||
20 | #include <stdbool.h> | ||
21 | #include <avr/io.h> | ||
22 | #include <util/delay.h> | ||
23 | #include "print.h" | ||
24 | #include "debug.h" | ||
25 | #include "util.h" | ||
26 | #include "matrix.h" | ||
27 | |||
28 | #ifndef DEBOUNCING_DELAY | ||
29 | # define DEBOUNCING_DELAY 5 | ||
30 | #endif | ||
31 | static uint8_t debouncing = DEBOUNCING_DELAY; | ||
32 | |||
33 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
34 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
35 | |||
36 | static matrix_row_t scan_col(void) { | ||
37 | return ( | ||
38 | (PINC&(1<<7) ? 0 : ((matrix_row_t)1<<0)) | | ||
39 | (PINB&(1<<6) ? 0 : ((matrix_row_t)1<<1)) | | ||
40 | (PINB&(1<<1) ? 0 : ((matrix_row_t)1<<2)) | | ||
41 | (PINB&(1<<0) ? 0 : ((matrix_row_t)1<<3)) | | ||
42 | (PINB&(1<<5) ? 0 : ((matrix_row_t)1<<4)) | | ||
43 | (PINB&(1<<3) ? 0 : ((matrix_row_t)1<<5)) | | ||
44 | (PINB&(1<<4) ? 0 : ((matrix_row_t)1<<6)) | | ||
45 | (PINB&(1<<2) ? 0 : ((matrix_row_t)1<<7)) | ||
46 | ); | ||
47 | } | ||
48 | |||
49 | static void select_col(uint8_t col) { | ||
50 | switch (col) { | ||
51 | case 0: PORTD = (PORTD & ~0b00111111) | 0b00110011; break; | ||
52 | case 1: PORTD = (PORTD & ~0b00111111) | 0b00100011; break; | ||
53 | case 2: PORTD = (PORTD & ~0b00111111) | 0b00010111; break; | ||
54 | case 3: PORTD = (PORTD & ~0b00111111) | 0b00110011; break; | ||
55 | case 4: PORTD = (PORTD & ~0b00111111) | 0b00010011; break; | ||
56 | case 5: PORTD = (PORTD & ~0b00111111) | 0b00011011; break; | ||
57 | case 6: PORTD = (PORTD & ~0b00111111) | 0b00110100; break; | ||
58 | case 7: PORTD = (PORTD & ~0b00111111) | 0b00111010; break; | ||
59 | case 8: PORTD = (PORTD & ~0b00111111) | 0b00111000; break; | ||
60 | case 9: PORTD = (PORTD & ~0b00111111) | 0b00111100; break; | ||
61 | case 10: PORTD = (PORTD & ~0b00111111) | 0b00110010; break; | ||
62 | case 11: PORTD = (PORTD & ~0b00111111) | 0b00011111; break; | ||
63 | case 12: PORTD = (PORTD & ~0b00111111) | 0b00001111; break; | ||
64 | case 13: PORTD = (PORTD & ~0b00111111) | 0b00100111; break; | ||
65 | case 14: PORTD = (PORTD & ~0b00111111) | 0b00000111; break; | ||
66 | case 15: PORTD = (PORTD & ~0b00111111) | 0b00110110; break; | ||
67 | case 16: PORTD = (PORTD & ~0b00111111) | 0b00001011; break; | ||
68 | case 17: PORTD = (PORTD & ~0b00111111) | 0b00000011; break; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | void matrix_init(void) { | ||
73 | /* Row output pins */ | ||
74 | DDRD |= 0b00111111; | ||
75 | /* Column input pins */ | ||
76 | DDRC &= ~0b10000000; | ||
77 | DDRB &= ~0b01111111; | ||
78 | PORTC |= 0b10000000; | ||
79 | PORTB |= 0b01111111; | ||
80 | |||
81 | for (uint8_t i=0; i < MATRIX_ROWS; i++) | ||
82 | matrix[i] = matrix_debouncing[i] = 0; | ||
83 | |||
84 | matrix_init_quantum(); | ||
85 | } | ||
86 | |||
87 | uint8_t matrix_scan(void) { | ||
88 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
89 | select_col(col); | ||
90 | _delay_us(3); | ||
91 | matrix_row_t col_scan = scan_col(); | ||
92 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
93 | bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col); | ||
94 | bool curr_bit = col_scan & (1<<row); | ||
95 | if (prev_bit != curr_bit) { | ||
96 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); | ||
97 | debouncing = DEBOUNCING_DELAY; | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | |||
102 | if (debouncing) { | ||
103 | if (--debouncing) | ||
104 | _delay_ms(1); | ||
105 | else | ||
106 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) | ||
107 | matrix[i] = matrix_debouncing[i]; | ||
108 | } | ||
109 | |||
110 | matrix_scan_quantum(); | ||
111 | return 1; | ||
112 | } | ||
113 | |||
114 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
115 | return matrix[row]; | ||
116 | } | ||
117 | |||
118 | void matrix_print(void) { | ||
119 | #ifndef NO_PRINT | ||
120 | print("\nr\\c ABCDEFGHIJKLMNOPQR\n"); | ||
121 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
122 | matrix_row_t matrix_row = matrix_get_row(row); | ||
123 | xprintf("%02X: ", row); | ||
124 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
125 | bool curr_bit = matrix_row & (1<<col); | ||
126 | xprintf("%c", curr_bit ? '*' : '.'); | ||
127 | } | ||
128 | print("\n"); | ||
129 | } | ||
130 | #endif | ||
131 | } | ||
132 | |||
133 | uint8_t matrix_key_count(void) { | ||
134 | uint8_t count = 0; | ||
135 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) | ||
136 | count += bitpop32(matrix[row]); | ||
137 | return count; | ||
138 | } | ||
diff --git a/keyboards/unloved_bastard/readme.md b/keyboards/unloved_bastard/readme.md new file mode 100644 index 000000000..33c74d4b0 --- /dev/null +++ b/keyboards/unloved_bastard/readme.md | |||
@@ -0,0 +1,15 @@ | |||
1 | # unloved_bastard | ||
2 | |||
3 |  | ||
4 | |||
5 | A short description of the keyboard/project | ||
6 | |||
7 | Keyboard Maintainer: [Alexander Fougner](https://github.com/fougner) | ||
8 | Hardware Supported: CoolerMaster Masterkeys S PBT (Not the Pro versions with backlighting etc) | ||
9 | Hardware Availability: Pretty much anywhere | ||
10 | |||
11 | Make example for this keyboard (after setting up your build environment): | ||
12 | |||
13 | make unloved_bastard:default | ||
14 | |||
15 | See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. | ||
diff --git a/keyboards/unloved_bastard/rules.mk b/keyboards/unloved_bastard/rules.mk new file mode 100644 index 000000000..e15d61dda --- /dev/null +++ b/keyboards/unloved_bastard/rules.mk | |||
@@ -0,0 +1,71 @@ | |||
1 | # MCU name | ||
2 | #MCU = at90usb1286 | ||
3 | MCU = atmega32u2 | ||
4 | |||
5 | # Processor frequency. | ||
6 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
7 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
8 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
9 | # automatically to create a 32-bit value in your source code. | ||
10 | # | ||
11 | # This will be an integer division of F_USB below, as it is sourced by | ||
12 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
13 | # does not *change* the processor frequency - it should merely be updated to | ||
14 | # reflect the processor speed set externally so that the code can use accurate | ||
15 | # software delays. | ||
16 | F_CPU = 16000000 | ||
17 | |||
18 | |||
19 | # | ||
20 | # LUFA specific | ||
21 | # | ||
22 | # Target architecture (see library "Board Types" documentation). | ||
23 | ARCH = AVR8 | ||
24 | |||
25 | # Input clock frequency. | ||
26 | # This will define a symbol, F_USB, in all source code files equal to the | ||
27 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
28 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
29 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
30 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
31 | # at the end, this will be done automatically to create a 32-bit value in your | ||
32 | # source code. | ||
33 | # | ||
34 | # If no clock division is performed on the input clock inside the AVR (via the | ||
35 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
36 | F_USB = $(F_CPU) | ||
37 | |||
38 | # Interrupt driven control endpoint task(+60) | ||
39 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
40 | |||
41 | |||
42 | # Boot Section Size in *bytes* | ||
43 | # Teensy halfKay 512 | ||
44 | # Teensy++ halfKay 1024 | ||
45 | # Atmel DFU loader 4096 | ||
46 | # LUFA bootloader 4096 | ||
47 | # USBaspLoader 2048 | ||
48 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
49 | |||
50 | |||
51 | # Build Options | ||
52 | # change yes to no to disable | ||
53 | # | ||
54 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) | ||
55 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | ||
56 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
57 | CONSOLE_ENABLE = yes # Console for debug(+400) | ||
58 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
59 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
60 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | ||
61 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
62 | NKRO_ENABLE = no # USB Nkey Rollover | ||
63 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default | ||
64 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) | ||
65 | UNICODE_ENABLE = no # Unicode | ||
66 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
67 | AUDIO_ENABLE = no # Audio output on port C6 | ||
68 | FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches | ||
69 | |||
70 | CUSTOM_MATRIX = yes | ||
71 | SRC += matrix.c | ||
diff --git a/keyboards/unloved_bastard/unloved_bastard.c b/keyboards/unloved_bastard/unloved_bastard.c new file mode 100644 index 000000000..197593060 --- /dev/null +++ b/keyboards/unloved_bastard/unloved_bastard.c | |||
@@ -0,0 +1,70 @@ | |||
1 | /* Copyright 2018 Alexander Fougner <fougner89 at 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 | #include "unloved_bastard.h" | ||
17 | |||
18 | void 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 | |||
25 | void matrix_scan_kb(void) { | ||
26 | // put your looping keyboard code here | ||
27 | // runs every cycle (a lot) | ||
28 | |||
29 | matrix_scan_user(); | ||
30 | } | ||
31 | |||
32 | bool 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 | return process_record_user(keycode, record); | ||
36 | } | ||
37 | |||
38 | // C5 left | ||
39 | // C6 middle led | ||
40 | // B7 right led | ||
41 | void led_init_ports(void) { | ||
42 | DDRB |= (1<<7); | ||
43 | DDRC |= (1<<5); | ||
44 | DDRC |= (1<<6); | ||
45 | |||
46 | PORTB |= (1<<7); | ||
47 | PORTC |= (1<<5); | ||
48 | PORTC |= (1<<6); | ||
49 | } | ||
50 | |||
51 | |||
52 | void led_set_kb(uint8_t usb_led) { | ||
53 | |||
54 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) | ||
55 | PORTC &= ~(1<<5); | ||
56 | else | ||
57 | PORTC |= (1<<5); | ||
58 | |||
59 | if (usb_led & (1<<USB_LED_NUM_LOCK)) | ||
60 | PORTB &= ~(1<<7); | ||
61 | else | ||
62 | PORTB |= (1<<7); | ||
63 | |||
64 | if (usb_led & (1<<USB_LED_SCROLL_LOCK)) | ||
65 | PORTC &= ~(1<<6); | ||
66 | else | ||
67 | PORTC |= (1<<6); | ||
68 | |||
69 | led_set_user(usb_led); | ||
70 | } | ||
diff --git a/keyboards/unloved_bastard/unloved_bastard.h b/keyboards/unloved_bastard/unloved_bastard.h new file mode 100644 index 000000000..8a58b0bad --- /dev/null +++ b/keyboards/unloved_bastard/unloved_bastard.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /* Copyright 2017 REPLACE_WITH_YOUR_NAME | ||
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 UNLOVED_BASTARD_H | ||
17 | #define UNLOVED_BASTARD_H | ||
18 | |||
19 | #include "quantum.h" | ||
20 | |||
21 | #define KEYMAP( \ | ||
22 | KG6, KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0, KN5, KN7, KP7, \ | ||
23 | KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2, KR4, KC4, KE4, \ | ||
24 | KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3, KQ4, KC5, KE5, \ | ||
25 | KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6, KO1, \ | ||
26 | KB2, KH6, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0, KB3, KC6, \ | ||
27 | KP4, KN2, KN6, KQ6, KN0, KN3, KM0, KP1, KC0, KQ0, KR0 \ | ||
28 | ) \ | ||
29 | { \ | ||
30 | /* Columns and rows need to be swapped in the below definition */ \ | ||
31 | /* A B C D E F G H I J K L M N O P Q R */ \ | ||
32 | /* 0 */ { KC_NO, KC_NO, KC0, KC_NO, KC_NO, KF0, KC_NO, KC_NO, KC_NO, KJ0, KK0, KC_NO, KM0, KN0, KO0, KC_NO, KQ0, KR0 }, \ | ||
33 | /* 1 */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KG1, KH1, KI1, KJ1, KK1, KL1, KM1, KC_NO, KO1, KP1, KC_NO, KC_NO }, \ | ||
34 | /* 2 */ { KC_NO, KB2, KC_NO, KC_NO, KC_NO, KF2, KG2, KH2, KI2, KJ2, KK2, KL2, KM2, KN2, KO2, KC_NO, KC_NO, KC_NO }, \ | ||
35 | /* 3 */ { KC_NO, KB3, KC_NO, KC_NO, KC_NO, KF3, KG3, KH3, KI3, KJ3, KK3, KL3, KM3, KN3, KO3, KC_NO, KC_NO, KC_NO }, \ | ||
36 | /* 4 */ { KC_NO, KC_NO, KC4, KC_NO, KE4, KF4, KG4, KH4, KI4, KJ4, KK4, KL4, KM4, KC_NO, KO4, KP4, KQ4, KR4 }, \ | ||
37 | /* 5 */ { KC_NO, KC_NO, KC5, KC_NO, KE5, KF5, KG5, KH5, KI5, KJ5, KK5, KL5, KM5, KN5, KO5, KP5, KC_NO, KC_NO }, \ | ||
38 | /* 6 */ { KC_NO, KC_NO, KC6, KC_NO, KC_NO, KF6, KG6, KH6, KI6, KJ6, KK6, KL6, KC_NO,KN6, KO6, KC_NO, KQ6, KC_NO }, \ | ||
39 | /* 7 */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KF7, KG7, KH7, KI7, KJ7, KK7, KL7, KM7, KN7, KC_NO, KP7, KC_NO, KC_NO } \ | ||
40 | } | ||
41 | |||
42 | #endif | ||