]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Initial support for The Unloved Bastard
authorAlexander Fougner <fougner89@gmail.com>
Wed, 14 Mar 2018 20:55:34 +0000 (21:55 +0100)
committerJack Humbert <jack.humb@gmail.com>
Fri, 16 Mar 2018 20:41:32 +0000 (16:41 -0400)
keyboards/unloved_bastard/config.h [new file with mode: 0644]
keyboards/unloved_bastard/keymaps/default/config.h [new file with mode: 0644]
keyboards/unloved_bastard/keymaps/default/keymap.c [new file with mode: 0644]
keyboards/unloved_bastard/keymaps/default/readme.md [new file with mode: 0644]
keyboards/unloved_bastard/matrix.c [new file with mode: 0644]
keyboards/unloved_bastard/readme.md [new file with mode: 0644]
keyboards/unloved_bastard/rules.mk [new file with mode: 0644]
keyboards/unloved_bastard/unloved_bastard.c [new file with mode: 0644]
keyboards/unloved_bastard/unloved_bastard.h [new file with mode: 0644]

diff --git a/keyboards/unloved_bastard/config.h b/keyboards/unloved_bastard/config.h
new file mode 100644 (file)
index 0000000..d89e858
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+Copyright 2018 Alexander Fougner <fougner89 at 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 CONFIG_H
+#define CONFIG_H
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID       0xFEED
+#define PRODUCT_ID      0x1337
+#define DEVICE_VER      0x0001
+#define MANUFACTURER    BathroomEpiphanies
+#define PRODUCT         Unloved Bastard
+#define DESCRIPTION     Unloved Bastard controller for CM Masterkeys S
+
+/* key matrix size */
+#define MATRIX_ROWS 8
+#define MATRIX_COLS 18
+
+/* 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
+
+/* number of backlight levels */
+
+/* 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
+
+/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
+ * This is userful for the Windows task manager shortcut (ctrl+shift+esc).
+ */
+// #define GRAVE_ESC_CTRL_OVERRIDE
+
+/*
+ * 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
diff --git a/keyboards/unloved_bastard/keymaps/default/config.h b/keyboards/unloved_bastard/keymaps/default/config.h
new file mode 100644 (file)
index 0000000..c55f7f9
--- /dev/null
@@ -0,0 +1,24 @@
+/* Copyright 2018 Alexander Fougner <fougner89 at 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 CONFIG_USER_H
+#define CONFIG_USER_H
+
+#include "config_common.h"
+
+// place overrides here
+
+#endif
diff --git a/keyboards/unloved_bastard/keymaps/default/keymap.c b/keyboards/unloved_bastard/keymaps/default/keymap.c
new file mode 100644 (file)
index 0000000..f4dedc7
--- /dev/null
@@ -0,0 +1,63 @@
+/* Copyright 2018 Alexander Fougner <fougner89 at 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/>.
+ */
+#include "unloved_bastard.h"
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = 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_PAUS, \
+                 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_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, \
+                 KC_LCTL,KC_LGUI,KC_LALT,                KC_SPC,                                 KC_RALT,KC_RGUI, KC_APP,  KC_RCTL,   KC_LEFT, KC_DOWN, KC_RGHT  )
+};
+
+
+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) {
+            register_code(KC_RSFT);
+          } else {
+            unregister_code(KC_RSFT);
+          }
+        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) {
+
+}
diff --git a/keyboards/unloved_bastard/keymaps/default/readme.md b/keyboards/unloved_bastard/keymaps/default/readme.md
new file mode 100644 (file)
index 0000000..a2b5f11
--- /dev/null
@@ -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 (file)
index 0000000..6577387
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+  Copyright 2017 Gabriel Young <gabeplaysdrums@live.com>
+  Copyright 2018 Alexander Fougner <fougner89 at 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/>.
+*/
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/io.h>
+#include <util/delay.h>
+#include "print.h"
+#include "debug.h"
+#include "util.h"
+#include "matrix.h"
+
+#ifndef DEBOUNCING_DELAY
+#   define DEBOUNCING_DELAY 5
+#endif
+static uint8_t debouncing = DEBOUNCING_DELAY;
+
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
+static matrix_row_t scan_col(void) {
+    return (
+        (PINC&(1<<7) ? 0 : ((matrix_row_t)1<<0)) |
+        (PINB&(1<<6) ? 0 : ((matrix_row_t)1<<1)) |
+        (PINB&(1<<1) ? 0 : ((matrix_row_t)1<<2)) |
+        (PINB&(1<<0) ? 0 : ((matrix_row_t)1<<3)) |
+        (PINB&(1<<5) ? 0 : ((matrix_row_t)1<<4)) |
+        (PINB&(1<<3) ? 0 : ((matrix_row_t)1<<5)) |
+        (PINB&(1<<4) ? 0 : ((matrix_row_t)1<<6)) |
+        (PINB&(1<<2) ? 0 : ((matrix_row_t)1<<7))
+    );
+}
+
+static void select_col(uint8_t col) {
+    switch (col) {
+        case 0: PORTD = (PORTD & ~0b00111111) | 0b00110011; break;
+        case 1: PORTD = (PORTD & ~0b00111111) | 0b00100011; break;
+        case 2: PORTD = (PORTD & ~0b00111111) | 0b00010111; break;
+        case 3: PORTD = (PORTD & ~0b00111111) | 0b00110011; break;
+        case 4: PORTD = (PORTD & ~0b00111111) | 0b00010011; break;
+        case 5: PORTD = (PORTD & ~0b00111111) | 0b00011011; break;
+        case 6: PORTD = (PORTD & ~0b00111111) | 0b00110100; break;
+        case 7: PORTD = (PORTD & ~0b00111111) | 0b00111010; break;
+        case 8: PORTD = (PORTD & ~0b00111111) | 0b00111000; break;
+        case 9: PORTD = (PORTD & ~0b00111111) | 0b00111100; break;
+        case 10: PORTD = (PORTD & ~0b00111111) | 0b00110010; break;
+        case 11: PORTD = (PORTD & ~0b00111111) | 0b00011111; break;
+        case 12: PORTD = (PORTD & ~0b00111111) | 0b00001111; break;
+        case 13: PORTD = (PORTD & ~0b00111111) | 0b00100111; break;
+        case 14: PORTD = (PORTD & ~0b00111111) | 0b00000111; break;
+        case 15: PORTD = (PORTD & ~0b00111111) | 0b00110110; break;
+        case 16: PORTD = (PORTD & ~0b00111111) | 0b00001011; break;
+        case 17: PORTD = (PORTD & ~0b00111111) | 0b00000011; break;
+    }
+}
+
+void matrix_init(void) {
+    /* Row output pins */
+    DDRD  |=  0b00111111;
+    /* Column input pins */
+    DDRC  &= ~0b10000000;
+    DDRB  &= ~0b01111111;
+    PORTC |=  0b10000000;
+    PORTB |=  0b01111111;
+
+    for (uint8_t i=0; i < MATRIX_ROWS; i++)
+        matrix[i] = matrix_debouncing[i] = 0;
+
+    matrix_init_quantum();
+}
+
+uint8_t matrix_scan(void) {
+    for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+        select_col(col);
+        _delay_us(3);
+        matrix_row_t col_scan = scan_col();
+        for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+            bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
+            bool curr_bit = col_scan & (1<<row);
+            if (prev_bit != curr_bit) {
+                matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
+                debouncing = DEBOUNCING_DELAY;
+            }
+        }
+    }
+
+    if (debouncing) {
+        if (--debouncing)
+            _delay_ms(1);
+        else
+            for (uint8_t i = 0; i < MATRIX_ROWS; i++)
+                matrix[i] = matrix_debouncing[i];
+    }
+
+    matrix_scan_quantum();
+    return 1;
+}
+
+inline matrix_row_t matrix_get_row(uint8_t row) {
+    return matrix[row];
+}
+
+void matrix_print(void) {
+#ifndef NO_PRINT
+    print("\nr\\c ABCDEFGHIJKLMNOPQR\n");
+    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+        matrix_row_t matrix_row = matrix_get_row(row);
+        xprintf("%02X: ", row);
+        for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+            bool curr_bit = matrix_row & (1<<col);
+            xprintf("%c", curr_bit ? '*' : '.');
+        }
+        print("\n");
+    }
+#endif
+}
+
+uint8_t matrix_key_count(void) {
+    uint8_t count = 0;
+    for (uint8_t row = 0; row < MATRIX_ROWS; row++)
+        count += bitpop32(matrix[row]);
+    return count;
+}
diff --git a/keyboards/unloved_bastard/readme.md b/keyboards/unloved_bastard/readme.md
new file mode 100644 (file)
index 0000000..33c74d4
--- /dev/null
@@ -0,0 +1,15 @@
+# unloved_bastard
+
+![unloved_bastard](imgur.com image replace me!)
+
+A short description of the keyboard/project
+
+Keyboard Maintainer: [Alexander Fougner](https://github.com/fougner)  
+Hardware Supported: CoolerMaster Masterkeys S PBT (Not the Pro versions with backlighting etc)  
+Hardware Availability: Pretty much anywhere
+
+Make example for this keyboard (after setting up your build environment):
+
+    make unloved_bastard:default
+
+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 (file)
index 0000000..e15d61d
--- /dev/null
@@ -0,0 +1,71 @@
+# MCU name
+#MCU = at90usb1286
+MCU = atmega32u2
+
+# 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 = 16000000
+
+
+#
+# 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
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = yes      # 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 = no            # USB Nkey Rollover
+BACKLIGHT_ENABLE = no       # Enable keyboard backlight functionality on B7 by default
+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
+
+CUSTOM_MATRIX = yes
+SRC += matrix.c
diff --git a/keyboards/unloved_bastard/unloved_bastard.c b/keyboards/unloved_bastard/unloved_bastard.c
new file mode 100644 (file)
index 0000000..1975930
--- /dev/null
@@ -0,0 +1,70 @@
+/* Copyright 2018 Alexander Fougner <fougner89 at 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/>.
+ */
+#include "unloved_bastard.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);
+}
+
+// C5 left
+// C6 middle led
+// B7 right led
+void led_init_ports(void) {
+    DDRB |= (1<<7);
+    DDRC |= (1<<5);
+    DDRC |= (1<<6);
+
+    PORTB |= (1<<7);
+    PORTC |= (1<<5);
+    PORTC |= (1<<6);
+}
+
+
+void led_set_kb(uint8_t usb_led) {
+
+    if (usb_led & (1<<USB_LED_CAPS_LOCK))
+        PORTC &= ~(1<<5);
+    else
+        PORTC |=  (1<<5);
+
+    if (usb_led & (1<<USB_LED_NUM_LOCK))
+        PORTB &= ~(1<<7);
+    else
+        PORTB |=  (1<<7);
+
+    if (usb_led & (1<<USB_LED_SCROLL_LOCK))
+        PORTC &= ~(1<<6);
+    else
+        PORTC |=  (1<<6);
+
+    led_set_user(usb_led);
+}
diff --git a/keyboards/unloved_bastard/unloved_bastard.h b/keyboards/unloved_bastard/unloved_bastard.h
new file mode 100644 (file)
index 0000000..8a58b0b
--- /dev/null
@@ -0,0 +1,42 @@
+/* Copyright 2017 REPLACE_WITH_YOUR_NAME
+ *
+ * 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 UNLOVED_BASTARD_H
+#define UNLOVED_BASTARD_H
+
+#include "quantum.h"
+
+#define KEYMAP( \
+  KG6,      KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0,   KN5, KN7, KP7, \
+  KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2,   KR4, KC4, KE4, \
+  KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3,   KQ4, KC5, KE5, \
+  KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6,      KO1,                  \
+  KB2, KH6, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0,      KB3,        KC6,      \
+  KP4, KN2, KN6,                KQ6,                KN0, KN3, KM0, KP1,   KC0, KQ0, KR0  \
+) \
+{ \
+/* Columns and rows need to be swapped in the below definition */ \
+/*          A       B       C       D       E       F       G       H       I       J       K       L       M       N       O       P       Q       R       */ \
+/* 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     }, \
+/* 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   }, \
+/* 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   }, \
+/* 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   }, \
+/* 4 */ {   KC_NO,  KC_NO,  KC4,    KC_NO,  KE4,    KF4,    KG4,    KH4,    KI4,    KJ4,    KK4,  KL4,   KM4,  KC_NO,  KO4,    KP4,    KQ4,    KR4     }, \
+/* 5 */ {   KC_NO,  KC_NO,  KC5,    KC_NO,  KE5,    KF5,    KG5,    KH5,    KI5,    KJ5,    KK5,  KL5,   KM5,  KN5,    KO5,    KP5,    KC_NO,  KC_NO   }, \
+/* 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   }, \
+/* 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   }  \
+}
+
+#endif