From 3acaad66005718ab50a46ae375636f328a93b100 Mon Sep 17 00:00:00 2001 From: Alexander Fougner Date: Wed, 14 Mar 2018 21:55:34 +0100 Subject: Initial support for The Unloved Bastard --- keyboards/unloved_bastard/config.h | 168 +++++++++++++++++++++ keyboards/unloved_bastard/keymaps/default/config.h | 24 +++ keyboards/unloved_bastard/keymaps/default/keymap.c | 63 ++++++++ .../unloved_bastard/keymaps/default/readme.md | 1 + keyboards/unloved_bastard/matrix.c | 138 +++++++++++++++++ keyboards/unloved_bastard/readme.md | 15 ++ keyboards/unloved_bastard/rules.mk | 71 +++++++++ keyboards/unloved_bastard/unloved_bastard.c | 70 +++++++++ keyboards/unloved_bastard/unloved_bastard.h | 42 ++++++ 9 files changed, 592 insertions(+) create mode 100644 keyboards/unloved_bastard/config.h create mode 100644 keyboards/unloved_bastard/keymaps/default/config.h create mode 100644 keyboards/unloved_bastard/keymaps/default/keymap.c create mode 100644 keyboards/unloved_bastard/keymaps/default/readme.md create mode 100644 keyboards/unloved_bastard/matrix.c create mode 100644 keyboards/unloved_bastard/readme.md create mode 100644 keyboards/unloved_bastard/rules.mk create mode 100644 keyboards/unloved_bastard/unloved_bastard.c create mode 100644 keyboards/unloved_bastard/unloved_bastard.h (limited to 'keyboards/unloved_bastard') diff --git a/keyboards/unloved_bastard/config.h b/keyboards/unloved_bastard/config.h new file mode 100644 index 0000000000..d89e85862e --- /dev/null +++ b/keyboards/unloved_bastard/config.h @@ -0,0 +1,168 @@ +/* +Copyright 2018 Alexander Fougner + +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 . +*/ + +#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 index 0000000000..c55f7f9f7d --- /dev/null +++ b/keyboards/unloved_bastard/keymaps/default/config.h @@ -0,0 +1,24 @@ +/* Copyright 2018 Alexander Fougner + * + * 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 . + */ + +#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 index 0000000000..f4dedc7991 --- /dev/null +++ b/keyboards/unloved_bastard/keymaps/default/keymap.c @@ -0,0 +1,63 @@ +/* Copyright 2018 Alexander Fougner + * + * 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 . + */ +#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 index 0000000000..a2b5f1192f --- /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 0000000000..65773879bc --- /dev/null +++ b/keyboards/unloved_bastard/matrix.c @@ -0,0 +1,138 @@ +/* + Copyright 2017 Gabriel Young + Copyright 2018 Alexander Fougner + + 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 . +*/ + +#include +#include +#include +#include +#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< + * + * 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 . + */ +#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<. + */ +#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 -- cgit v1.2.3