diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/keymap_common.h | 10 | ||||
-rw-r--r-- | quantum/matrix.c | 6 | ||||
-rw-r--r-- | quantum/quantum.c | 168 | ||||
-rw-r--r-- | quantum/quantum.h | 11 | ||||
-rw-r--r-- | quantum/quantum.mk | 54 | ||||
-rw-r--r-- | quantum/template/Makefile | 53 | ||||
-rw-r--r-- | quantum/template/README.md | 2 | ||||
-rw-r--r-- | quantum/template/keymaps/default/keymap.c (renamed from quantum/template/keymaps/default.c) | 0 |
8 files changed, 185 insertions, 119 deletions
diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h index 91d5c09c1c..c72c0bc29d 100644 --- a/quantum/keymap_common.h +++ b/quantum/keymap_common.h @@ -88,10 +88,8 @@ extern const uint16_t fn_actions[]; #define KC_AT LSFT(KC_2) // @ - #define KC_HASH LSFT(KC_3) // # - #define KC_DLR LSFT(KC_4) // $ #define KC_DOLLAR KC_DLR @@ -113,13 +111,11 @@ extern const uint16_t fn_actions[]; #define KC_RPRN LSFT(KC_0) // ) #define KC_RIGHT_PAREN KC_RPRN - #define KC_UNDS LSFT(KC_MINS) // _ #define KC_UNDERSCORE KC_UNDS #define KC_PLUS LSFT(KC_EQL) // + - #define KC_LCBR LSFT(KC_LBRC) // { #define KC_LEFT_CURLY_BRACE KC_LCBR @@ -139,16 +135,14 @@ extern const uint16_t fn_actions[]; #define KC_LT LSFT(KC_COMM) // < - #define KC_GT LSFT(KC_DOT) // > - #define KC_QUES LSFT(KC_SLSH) // ? #define KC_QUESTION KC_QUES - #define KC_DQT LSFT(KC_QUOT) // " #define KC_DOUBLE_QUOTE KC_DQT +#define KC_DQUO KC_DQT #define KC_DELT KC_DELETE // Del key (four letter code) @@ -240,6 +234,8 @@ extern const uint16_t fn_actions[]; #define BL_TOGG 0x5082 #define BL_STEP 0x5083 +#define KC_LSPO 0x5084 // Left shift, open parens when tapped +#define KC_RSPC 0x5085 // Right shift, close parens when tapped // GOTO layer - 16 layers max // when: // ON_PRESS = 1 diff --git a/quantum/matrix.c b/quantum/matrix.c index d5fd7def8a..412662a794 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c @@ -68,8 +68,10 @@ uint8_t matrix_cols(void) { void matrix_init(void) { /* frees PORTF by setting the JTD bit twice within four cycles */ - MCUCR |= _BV(JTD); - MCUCR |= _BV(JTD); + #ifdef __AVR_ATmega32U4__ + MCUCR |= _BV(JTD); + MCUCR |= _BV(JTD); + #endif /* initializes the I/O pins */ #if DIODE_DIRECTION == COL2ROW for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) { diff --git a/quantum/quantum.c b/quantum/quantum.c index eb64a99a4d..bc63fb614b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -13,6 +13,16 @@ bool process_action_kb(keyrecord_t *record) { } __attribute__ ((weak)) +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + return process_record_user(keycode, record); +} + +__attribute__ ((weak)) +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + return true; +} + +__attribute__ ((weak)) void leader_start(void) {} __attribute__ ((weak)) @@ -21,6 +31,7 @@ void leader_end(void) {} uint8_t starting_note = 0x0C; int offset = 7; + #ifdef AUDIO_ENABLE bool music_activated = false; @@ -59,6 +70,8 @@ uint8_t chord_key_down = 0; static uint8_t input_mode; #endif +static bool shift_interrupted[2] = {0, 0}; + bool keys_chord(uint8_t keys[]) { uint8_t keys_size = sizeof(keys)/sizeof(keys[0]); bool pass = true; @@ -121,6 +134,9 @@ bool process_record_quantum(keyrecord_t *record) { keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); #endif + if (!process_record_kb(keycode, record)) + return false; + // This is how you use actions here // if (keycode == KC_LEAD) { // action_t action; @@ -271,14 +287,14 @@ bool process_record_quantum(keyrecord_t *record) { music_sequence_count = 0; return false; } - + if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing stop_all_notes(); music_sequence_recording = false; music_sequence_playing = false; return false; } - + if (keycode == KC_LGUI && record->event.pressed) { // Start playing stop_all_notes(); music_sequence_recording = false; @@ -293,7 +309,7 @@ bool process_record_quantum(keyrecord_t *record) { music_sequence_interval-=10; return false; } - + if (keycode == KC_DOWN) { if (record->event.pressed) music_sequence_interval+=10; @@ -415,9 +431,151 @@ bool process_record_quantum(keyrecord_t *record) { #endif + switch(keycode) { + case KC_LSPO: { + if (record->event.pressed) { + shift_interrupted[0] = false; + register_mods(MOD_BIT(KC_LSFT)); + } + else { + if (!shift_interrupted[0]) { + register_code(KC_9); + unregister_code(KC_9); + } + unregister_mods(MOD_BIT(KC_LSFT)); + } + return false; + break; + } + + case KC_RSPC: { + if (record->event.pressed) { + shift_interrupted[1] = false; + register_mods(MOD_BIT(KC_RSFT)); + } + else { + if (!shift_interrupted[1]) { + register_code(KC_0); + unregister_code(KC_0); + } + unregister_mods(MOD_BIT(KC_RSFT)); + } + return false; + break; + } + default: { + shift_interrupted[0] = true; + shift_interrupted[1] = true; + break; + } + } + return process_action_kb(record); } +const bool ascii_to_qwerty_shift_lut[0x80] PROGMEM = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 0 +}; + +const uint8_t ascii_to_qwerty_keycode_lut[0x80] PROGMEM = { + 0, 0, 0, 0, 0, 0, 0, 0, + KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, KC_ESC, 0, 0, 0, 0, + KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT, + KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH, + KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, + KC_8, KC_9, KC_SCLN, KC_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH, + KC_2, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, + KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O, + KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, + KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS, + KC_GRV, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, + KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O, + KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, + KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL +}; + +/* for users whose OSes are set to Colemak */ +#if 0 +#include "keymap_colemak.h" + +const bool ascii_to_colemak_shift_lut[0x80] PROGMEM = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 0 +}; + +const uint8_t ascii_to_colemak_keycode_lut[0x80] PROGMEM = { + 0, 0, 0, 0, 0, 0, 0, 0, + KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, KC_ESC, 0, 0, 0, 0, + KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT, + KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH, + KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, + KC_8, KC_9, CM_SCLN, CM_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH, + KC_2, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G, + CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O, + CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W, + CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS, + KC_GRV, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G, + CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O, + CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W, + CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL +}; + +#endif + +void send_string(const char *str) { + while (1) { + uint8_t keycode; + uint8_t ascii_code = pgm_read_byte(str); + if (!ascii_code) break; + keycode = pgm_read_byte(&ascii_to_qwerty_keycode_lut[ascii_code]); + if (pgm_read_byte(&ascii_to_qwerty_shift_lut[ascii_code])) { + register_code(KC_LSFT); + register_code(keycode); + unregister_code(keycode); + unregister_code(KC_LSFT); + } + else { + register_code(keycode); + unregister_code(keycode); + } + ++str; + } +} + + void matrix_init_quantum() { matrix_init_kb(); } @@ -463,7 +621,7 @@ void matrix_scan_quantum() { #endif //------------------------------------------------------------------------------ -// Override these functions in your keymap file to play different tunes on +// Override these functions in your keymap file to play different tunes on // different events such as startup and bootloader jump __attribute__ ((weak)) @@ -481,4 +639,4 @@ void audio_on_user() {} __attribute__ ((weak)) void music_scale_user() {} -//------------------------------------------------------------------------------
\ No newline at end of file +//------------------------------------------------------------------------------ diff --git a/quantum/quantum.h b/quantum/quantum.h index 69a0d8126a..69277b9e32 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -1,6 +1,7 @@ #ifndef QUANTUM_H #define QUANTUM_H +#include <avr/pgmspace.h> #include "matrix.h" #include "keymap_common.h" #ifdef BACKLIGHT_ENABLE @@ -23,6 +24,9 @@ #include "eeconfig.h" #include <stddef.h> #include <avr/io.h> +#include <util/delay.h> + +#define SEND_STRING(str) send_string(PSTR(str)) extern uint32_t default_layer_state; @@ -58,9 +62,14 @@ extern uint32_t default_layer_state; #define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT) #endif +void send_string(const char *str); + void matrix_init_kb(void); void matrix_scan_kb(void); bool process_action_kb(keyrecord_t *record); +bool process_record_kb(uint16_t keycode, keyrecord_t *record); +bool process_record_user(uint16_t keycode, keyrecord_t *record); + bool is_music_on(void); void music_toggle(void); @@ -73,4 +82,4 @@ void audio_on_user(void); void music_on_user(void); void music_scale_user(void); -#endif
\ No newline at end of file +#endif diff --git a/quantum/quantum.mk b/quantum/quantum.mk deleted file mode 100644 index c099d67939..0000000000 --- a/quantum/quantum.mk +++ /dev/null @@ -1,54 +0,0 @@ -QUANTUM_DIR = quantum - -# # project specific files -SRC += $(QUANTUM_DIR)/quantum.c \ - $(QUANTUM_DIR)/keymap_common.c \ - $(QUANTUM_DIR)/led.c - -# ifdef KEYMAP_FILE -# ifneq (,$(shell grep USING_MIDI '$(KEYMAP_FILE)')) -# MIDI_ENABLE=yes -# $(info * Overriding MIDI_ENABLE setting - $(KEYMAP_FILE) requires it) -# endif -# ifneq (,$(shell grep USING_UNICODE '$(KEYMAP_FILE)')) -# UNICODE_ENABLE=yes -# $(info * Overriding UNICODE_ENABLE setting - $(KEYMAP_FILE) requires it) -# endif -# ifneq (,$(shell grep USING_BACKLIGHT '$(KEYMAP_FILE)')) -# BACKLIGHT_ENABLE=yes -# $(info * Overriding BACKLIGHT_ENABLE setting - $(KEYMAP_FILE) requires it) -# endif -# endif - -ifndef CUSTOM_MATRIX - SRC += $(QUANTUM_DIR)/matrix.c -endif - -#ifeq ($(strip $(MIDI_ENABLE)), yes) -# SRC += $(QUANTUM_DIR)/keymap_midi.c -#endif - -ifeq ($(strip $(AUDIO_ENABLE)), yes) - SRC += $(QUANTUM_DIR)/audio/audio.c - SRC += $(QUANTUM_DIR)/audio/voices.c - SRC += $(QUANTUM_DIR)/audio/luts.c -endif - -ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) - SRC += $(QUANTUM_DIR)/light_ws2812.c - SRC += $(QUANTUM_DIR)/rgblight.c - OPT_DEFS += -DRGBLIGHT_ENABLE -endif - -# Optimize size but this may cause error "relocation truncated to fit" -#EXTRALDFLAGS = -Wl,--relax - -# Search Path -VPATH += $(TOP_DIR)/$(QUANTUM_DIR) -VPATH += $(TOP_DIR)/$(QUANTUM_DIR)/keymap_extras -VPATH += $(TOP_DIR)/$(QUANTUM_DIR)/audio - -include $(TMK_DIR)/protocol/lufa.mk - -include $(TMK_DIR)/common.mk -include $(TMK_DIR)/rules.mk diff --git a/quantum/template/Makefile b/quantum/template/Makefile index 1a535ef2cb..8772b09200 100644 --- a/quantum/template/Makefile +++ b/quantum/template/Makefile @@ -38,28 +38,6 @@ # To rebuild project do "make clean" then "make all". #---------------------------------------------------------------------------- -# Target file name (without extension). -TARGET = %KEYBOARD% - - -# Directory common source filess exist -TOP_DIR = ../.. -TMK_DIR = ../../tmk_core - -# Directory keyboard dependent files exist -TARGET_DIR = . - -# # project specific files -SRC = %KEYBOARD%.c - -ifdef KEYMAP - SRC := keymaps/$(KEYMAP).c $(SRC) -else - SRC := keymaps/default.c $(SRC) -endif - -CONFIG_H = config.h - # MCU name #MCU = at90usb1287 MCU = atmega32u4 @@ -113,46 +91,23 @@ OPT_DEFS += -DBOOTLOADER_SIZE=512 # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +BOOTMAGIC_ENABLE = no # 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 -KEYBOARD_LOCK_ENABLE = yes # Allow locking of keyboard via magic key # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work NKRO_ENABLE = no # USB Nkey Rollover -BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default MIDI_ENABLE = no # MIDI controls UNICODE_ENABLE = no # Unicode BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID AUDIO_ENABLE = no # Audio output on port C6 - -ifdef KEYMAP - -ifeq ("$(wildcard keymaps/$(KEYMAP).c)","") -ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","") - include keymaps/$(KEYMAP)/makefile.mk -endif -endif - -else - -ifneq ("$(wildcard keymaps/default/makefile.mk)","") - include keymaps/default/makefile.mk +ifndef QUANTUM_DIR + include ../../Makefile endif -endif - -# Optimize size but this may cause error "relocation truncated to fit" -#EXTRALDFLAGS = -Wl,--relax - -# Search Path -VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) -VPATH += $(TMK_DIR) - -include $(TOP_DIR)/quantum/quantum.mk diff --git a/quantum/template/README.md b/quantum/template/README.md index 39f9f59d10..baaeef4731 100644 --- a/quantum/template/README.md +++ b/quantum/template/README.md @@ -3,7 +3,7 @@ ## Quantum MK Firmware -For the full Quantum feature list, see [the parent README.md](/README.md). +For the full Quantum feature list, see [the parent README.md](/doc/README.md). ## Building diff --git a/quantum/template/keymaps/default.c b/quantum/template/keymaps/default/keymap.c index 4121fd860c..4121fd860c 100644 --- a/quantum/template/keymaps/default.c +++ b/quantum/template/keymaps/default/keymap.c |