Merge pull request #1 from jackhumbert/master

Catch up with jack's master
example_keyboards
TerryMathews 9 years ago committed by GitHub
commit 4decdd2b18

@ -78,6 +78,10 @@ ifndef QUANTUM_DIR
include ../../Makefile include ../../Makefile
endif endif
ifneq (, $(findstring yes, $(HHKB_JP)))
OPT_DEFS += -DHHKB_JP
endif
debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION
debug-on: all debug-on: all

@ -29,7 +29,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DESCRIPTION q.m.k keyboard firmware for HHKB #define DESCRIPTION q.m.k keyboard firmware for HHKB
/* key matrix size */ /* key matrix size */
#define MATRIX_ROWS 8 #ifdef HHKB_JP
# define MATRIX_ROWS 16
#else
# define MATRIX_ROWS 8
#endif
#define MATRIX_COLS 8 #define MATRIX_COLS 8
#define TAPPING_TERM 200 #define TAPPING_TERM 200

@ -21,4 +21,31 @@
{ K70, K71, K72, K73, K74, K75, K76, KC_NO } \ { K70, K71, K72, K73, K74, K75, K76, KC_NO } \
} }
#define KEYMAP_JP( \
K02, K32, K62, K22, K12, K52, K72, KA2, K92, K82, KB2, KE2, KF2, KD2, KC2, \
K03, K63, K23, K13, K53, K73, KA3, K93, K83, KB3, KE3, KF3, KD3, \
K06, K66, K26, K16, K56, K76, KA6, K96, K86, KB6, KE6, KF6, KD6, KC6, \
K05, K65, K25, K15, K55, K75, KA5, K95, K85, KB5, KE5, KF5, KD5, KC5, \
K04, K34, K64, K24, K14, K74, K94, K84, KB4, KE4, KF4, KD4, KC4) \
{ \
{ KC_NO, KC_NO, K02, K03, K04, K05, K06, KC_NO }, \
{ KC_NO, KC_NO, K12, K13, K14, K15, K16, KC_NO }, \
{ KC_NO, KC_NO, K22, K23, K24, K25, K26, KC_NO }, \
{ KC_NO, KC_NO, K32, KC_NO, K34, KC_NO, KC_NO, KC_NO }, \
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
{ KC_NO, KC_NO, K52, K53, KC_NO, K55, K56, KC_NO }, \
{ KC_NO, KC_NO, K62, K63, K64, K65, K66, KC_NO }, \
{ KC_NO, KC_NO, K72, K73, K74, K75, K76, KC_NO }, \
{ KC_NO, KC_NO, K82, K83, K84, K85, K86, KC_NO }, \
{ KC_NO, KC_NO, K92, K93, K94, K95, K96, KC_NO }, \
{ KC_NO, KC_NO, KA2, KA3, KC_NO, KA5, KA6, KC_NO }, \
{ KC_NO, KC_NO, KB2, KB3, KB4, KB5, KB6, KC_NO }, \
{ KC_NO, KC_NO, KC2, KC_NO, KC4, KC5, KC6, KC_NO }, \
{ KC_NO, KC_NO, KD2, KD3, KD4, KD5, KD6, KC_NO }, \
{ KC_NO, KC_NO, KE2, KE3, KE4, KE5, KE6, KC_NO }, \
{ KC_NO, KC_NO, KF2, KF3, KF4, KF5, KF6, KC_NO } \
}
#endif #endif

@ -0,0 +1,58 @@
#include "hhkb.h"
#define _______ KC_TRNS
/* Layer 0: HHKB JP
* ,-----------------------------------------------------------.
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| -| =|Yen|Bsp|
* |-----------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| |
* |------------------------------------------------------` Ent|
* |Ctrl | A| S| D| F| G| H| J| K| L| ;| '| `| |
* |-----------------------------------------------------------|
* |Shft | Z| X| C| V| B| N| M| ,| .| /| \| Up|Sft|
* |-----------------------------------------------------------|
* | ||Ctl|Alt|Cmd| | Spc |Bsp| | | ||Lft|Dwn|Rgh|
* `-----------------------------------------------------------'
*/
/* Layer 1: HHKB mode (HHKB Fn)
* ,-----------------------------------------------------------.
* |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Caps | | | | | | | |Psc|Slk|Pus|Up | | |
* |------------------------------------------------------` |
* | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig| | |
* |-----------------------------------------------------------|
* | | | | | | | +| -|End|PgD|Dow| | | |
* |-----------------------------------------------------------|
* | || | | | | | | | | || | | |
* `-----------------------------------------------------------'
*/
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = KEYMAP_JP(
KC_ESC, 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_JYEN, KC_BSPC,
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_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_BSLS, KC_ENT,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RO, KC_UP, KC_RSFT,
MO(1), KC_ZKHK, KC_LGUI, KC_LALT, KC_MHEN, KC_SPC, KC_HENK, KC_KANA, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RGHT
),
[1] = KEYMAP_JP(
KC_PWR, 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_INS, KC_DEL,
KC_CAPS, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, _______,
_______, KC_VOLD, KC_VOLU, KC_MUTE, KC_PWR, _______, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, _______, KC_PENT,
_______, _______, _______, _______, _______, _______, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, _______, _______, _______,
_______, _______, _______, _______, _______, _______ , _______, _______, _______, _______, _______, _______, _______
)
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t macro_id, uint8_t opt) {
return MACRO_NONE;
}
const uint16_t PROGMEM fn_actions[] = {
};

@ -0,0 +1,65 @@
#include "hhkb.h"
#define _______ KC_TRNS
enum {
ZER,
HDN,
OSY
};
#define CTL_ESC CTL_T(KC_ESC)
#define SFT_BSP SFT_T(KC_BSPC)
#define SCRNS3 LGUI(LCTL(LSFT(KC_3)))
#define SCRNS4 LGUI(LCTL(LSFT(KC_4)))
/* hhkb jp ~ layout
* ,-----------------------------------------------------------.
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| -| =|Yen|Bsp|
* |-----------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| |
* |------------------------------------------------------` Ent|
* |Ctrl | A| S| D| F| G| H| J| K| L| ;| '| `| |
* |-----------------------------------------------------------|
* |Shft | Z| X| C| V| B| N| M| ,| .| /| \| Up|Sft|
* |-----------------------------------------------------------|
* | ||Ctl|Alt|Cmd| | Spc |Bsp| | | ||Lft|Dwn|Rgh|
* `-----------------------------------------------------------'
*/
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[ZER] = KEYMAP_JP(
KC_ESC, 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_INS, KC_BSPC,
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,
CTL_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_GRV, KC_ENT,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_BSLS, KC_UP, KC_RSFT,
MO(HDN), KC_LCTL, KC_LALT, KC_LGUI, MO(HDN), KC_SPC, SFT_BSP, MO(HDN), MO(OSY), KC_NO, KC_LEFT, KC_DOWN, KC_RGHT
),
[HDN] = KEYMAP_JP(
KC_GRV, 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_DEL,
_______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, _______,
_______, KC_TILD, KC_GRV, KC_BSLS, KC_PIPE, KC_MINS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_TILD, KC_GRV, _______, _______,
_______, KC_VOLD, KC_VOLU, KC_MUTE, KC_PWR, _______, _______, KC_ENT, _______, _______, _______, _______, KC_PGUP, _______,
_______, _______, _______, _______, _______, KC_UNDS , KC_DEL, _______, _______, _______, KC_HOME, KC_PGDN, KC_END
),
[OSY] = KEYMAP_JP(
_______, _______, _______, SCRNS3, SCRNS4, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______ , _______, _______, _______, _______, _______, _______, _______
)
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t macro_id, uint8_t opt) {
return MACRO_NONE;
}
const uint16_t PROGMEM fn_actions[] = {
};

@ -353,6 +353,81 @@ void matrix_scan_user(void) {
As you can see, you have three function. you can use - `SEQ_ONE_KEY` for single-key sequences (Leader followed by just one key), and `SEQ_TWO_KEYS` and `SEQ_THREE_KEYS` for longer sequences. Each of these accepts one or more keycodes as arguments. This is an important point: You can use keycodes from **any layer on your keyboard**. That layer would need to be active for the leader macro to fire, obviously. As you can see, you have three function. you can use - `SEQ_ONE_KEY` for single-key sequences (Leader followed by just one key), and `SEQ_TWO_KEYS` and `SEQ_THREE_KEYS` for longer sequences. Each of these accepts one or more keycodes as arguments. This is an important point: You can use keycodes from **any layer on your keyboard**. That layer would need to be active for the leader macro to fire, obviously.
### Tap Dance: A single key can do 3, 5, or 100 different things
Hit the semicolon key once, send a semicolon. Hit it twice, rapidly -- send a colon. Hit it three times, and your keyboard's LEDs do a wild dance. That's just one example of what Tap Dance can do. It's one of the nicest community-contributed features in the firmware, conceived and created by [algernon](https://github.com/algernon) in [#451](https://github.com/jackhumbert/qmk_firmware/pull/451). Here's how Algernon describes the feature:
With this feature one can specify keys that behave differently, based on the amount of times they have been tapped, and when interrupted, they get handled before the interrupter.
To make it clear how this is different from `ACTION_FUNCTION_TAP`, lets explore a certain setup! We want one key to send `Space` on single tap, but `Enter` on double-tap.
With `ACTION_FUNCTION_TAP`, it is quite a rain-dance to set this up, and has the problem that when the sequence is interrupted, the interrupting key will be send first. Thus, `SPC a` will result in `a SPC` being sent, if they are typed within `TAPPING_TERM`. With the tap dance feature, that'll come out as `SPC a`, correctly.
The implementation hooks into two parts of the system, to achieve this: into `process_record_quantum()`, and the matrix scan. We need the latter to be able to time out a tap sequence even when a key is not being pressed, so `SPC` alone will time out and register after `TAPPING_TERM` time.
But lets start with how to use it, first!
First, you will need `TAP_DANCE_ENABLE=yes` in your `Makefile`, because the feature is disabled by default. This adds a little less than 1k to the firmware size. Next, you will want to define some tap-dance keys, which is easiest to do with the `TD()` macro, that - similar to `F()`, takes a number, which will later be used as an index into the `tap_dance_actions` array.
This array specifies what actions shall be taken when a tap-dance key is in action. Currently, there are two possible options:
* `ACTION_TAP_DANCE_DOUBLE(kc1, kc2)`: Sends the `kc1` keycode when tapped once, `kc2` otherwise.
* `ACTION_TAP_DANCE_FN(fn)`: Calls the specified function - defined in the user keymap - with the current state of the tap-dance action.
The first option is enough for a lot of cases, that just want dual roles. For example, `ACTION_TAP_DANCE(KC_SPC, KC_ENT)` will result in `Space` being sent on single-tap, `Enter` otherwise.
And that's the bulk of it!
Do note, however, that this implementation does have some consequences: keys do not register until either they reach the tapping ceiling, or they time out. This means that if you hold the key, nothing happens, no repeat, no nothing. It is possible to detect held state, and register an action then too, but that's not implemented yet. Keys also unregister immediately after being registered, so you can't even hold the second tap. This is intentional, to be consistent.
And now, on to the explanation of how it works!
The main entry point is `process_tap_dance()`, called from `process_record_quantum()`, which is run for every keypress, and our handler gets to run early. This function checks whether the key pressed is a tap-dance key. If it is not, and a tap-dance was in action, we handle that first, and enqueue the newly pressed key. If it is a tap-dance key, then we check if it is the same as the already active one (if there's one active, that is). If it is not, we fire off the old one first, then register the new one. If it was the same, we increment the counter and the timer.
This means that you have `TAPPING_TERM` time to tap the key again, you do not have to input all the taps within that timeframe. This allows for longer tap counts, with minimal impact on responsiveness.
Our next stop is `matrix_scan_tap_dance()`. This handles the timeout of tap-dance keys.
For the sake of flexibility, tap-dance actions can be either a pair of keycodes, or a user function. The latter allows one to handle higher tap counts, or do extra things, like blink the LEDs, fiddle with the backlighting, and so on. This is accomplished by using an union, and some clever macros.
In the end, let's see a full example!
```c
enum {
CT_SE = 0,
CT_CLN,
CT_EGG
};
/* Have the above three on the keymap, TD(CT_SE), etc... */
void dance_cln (qk_tap_dance_state_t *state) {
if (state->count == 1) {
register_code (KC_RSFT);
register_code (KC_SCLN);
unregister_code (KC_SCLN);
unregister_code (KC_RSFT);
} else {
register_code (KC_SCLN);
unregister_code (KC_SCLN);
reset_tap_dance (state);
}
}
void dance_egg (qk_tap_dance_state_t *state) {
if (state->count >= 100) {
SEND_STRING ("Safety dance!");
reset_tap_dance (state);
}
}
const qk_tap_dance_action_t tap_dance_actions[] = {
[CT_SE] = ACTION_TAP_DANCE_DOUBLE (KC_SPC, KC_ENT)
,[CT_CLN] = ACTION_TAP_DANCE_FN (dance_cln)
,[CT_EGG] = ACTION_TAP_DANCE_FN (dance_egg)
};
```
### Temporarily setting the default layer ### Temporarily setting the default layer
`DF(layer)` - sets default layer to *layer*. The default layer is the one at the "bottom" of the layer stack - the ultimate fallback layer. This currently does not persist over power loss. When you plug the keyboard back in, layer 0 will always be the default. It is theoretically possible to work around that, but that's not what `DF` does. `DF(layer)` - sets default layer to *layer*. The default layer is the one at the "bottom" of the layer stack - the ultimate fallback layer. This currently does not persist over power loss. When you plug the keyboard back in, layer 0 will always be the default. It is theoretically possible to work around that, but that's not what `DF` does.

@ -107,7 +107,7 @@ endif
# Version string # Version string
OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null) OPT_DEFS += -DVERSION=$(GIT_VERSION)
# Bootloader address # Bootloader address
ifdef STM32_BOOTLOADER_ADDRESS ifdef STM32_BOOTLOADER_ADDRESS

@ -260,7 +260,7 @@ LST = $(patsubst %.c,$(OBJDIR)/%.lst,$(patsubst %.cpp,$(OBJDIR)/%.lst,$(patsubst
# Compiler flags to generate dependency files. # Compiler flags to generate dependency files.
#GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d #GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
GENDEPFLAGS = -MMD -MP -MF $(BUILD_DIR)/.dep/$(subst /,_,$@).d GENDEPFLAGS = -MMD -MP -MF $(BUILD_DIR)/.dep/$(subst /,_,$(subst $(BUILD_DIR)/,,$@)).d
# Combine all necessary flags and optional flags. # Combine all necessary flags and optional flags.
@ -271,23 +271,10 @@ ALL_CPPFLAGS = $(MCUFLAGS) -x c++ $(CPPFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS)
ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS)
# Default target. # Default target.
all: all: build sizeafter
@$(MAKE) begin
@$(MAKE) gccversion
@$(MAKE) sizebefore
@$(MAKE) clean_list # force clean each time
@$(MAKE) build
@$(MAKE) sizeafter
@$(MAKE) end
# Quick make that doesn't clean # Quick make that doesn't clean
quick: quick: build sizeafter
@$(MAKE) begin
@$(MAKE) gccversion
@$(MAKE) sizebefore
@$(MAKE) build
@$(MAKE) sizeafter
@$(MAKE) end
# Change the build target to build a HEX file or a library. # Change the build target to build a HEX file or a library.
build: elf hex build: elf hex
@ -303,13 +290,7 @@ sym: $(BUILD_DIR)/$(TARGET).sym
LIBNAME=lib$(TARGET).a LIBNAME=lib$(TARGET).a
lib: $(LIBNAME) lib: $(LIBNAME)
check_submodule:
# Eye candy.
# AVR Studio 3.x does not check make's exit code but relies on
# the following magic strings to be generated by the compile job.
begin:
@$(SECHO) $(MSG_BEGIN)
git submodule status --recursive | \ git submodule status --recursive | \
while IFS= read -r x; do \ while IFS= read -r x; do \
case "$$x" in \ case "$$x" in \
@ -318,10 +299,6 @@ begin:
esac \ esac \
done done
end:
@$(SECHO) $(MSG_END)
# Display size of file. # Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
#ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf #ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
@ -331,7 +308,7 @@ sizebefore:
@if test -f $(TARGET).hex; then $(SECHO) $(MSG_SIZE_BEFORE); $(SILENT) || $(HEXSIZE); \ @if test -f $(TARGET).hex; then $(SECHO) $(MSG_SIZE_BEFORE); $(SILENT) || $(HEXSIZE); \
2>/dev/null; $(SECHO); fi 2>/dev/null; $(SECHO); fi
sizeafter: sizeafter: $(BUILD_DIR)/$(TARGET).hex
@if test -f $(TARGET).hex; then $(SECHO); $(SECHO) $(MSG_SIZE_AFTER); $(SILENT) || $(HEXSIZE); \ @if test -f $(TARGET).hex; then $(SECHO); $(SECHO) $(MSG_SIZE_AFTER); $(SILENT) || $(HEXSIZE); \
2>/dev/null; $(SECHO); fi 2>/dev/null; $(SECHO); fi
# test file sizes eventually # test file sizes eventually
@ -383,60 +360,55 @@ gccversion :
$(eval CMD=$(AR) $@ $(OBJ) ) $(eval CMD=$(AR) $@ $(OBJ) )
@$(BUILD_CMD) @$(BUILD_CMD)
BEGIN = gccversion check_submodule sizebefore
# Link: create ELF output file from object files. # Link: create ELF output file from object files.
.SECONDARY : $(BUILD_DIR)/$(TARGET).elf .SECONDARY : $(BUILD_DIR)/$(TARGET).elf
.PRECIOUS : $(OBJ) .PRECIOUS : $(OBJ)
%.elf: $(OBJ) %.elf: $(OBJ) | $(BEGIN)
@$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD) @$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD)
$(eval CMD=$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)) $(eval CMD=$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS))
@$(BUILD_CMD) @$(BUILD_CMD)
# Compile: create object files from C source files. # Compile: create object files from C source files.
$(OBJDIR)/%.o : %.c $(OBJDIR)/%.o : %.c | $(BEGIN)
@mkdir -p $(@D) @mkdir -p $(@D)
@$(SILENT) || printf "$(MSG_COMPILING) $<" | $(AWK_CMD) @$(SILENT) || printf "$(MSG_COMPILING) $<" | $(AWK_CMD)
$(eval CMD=$(CC) -c $(ALL_CFLAGS) $< -o $@) $(eval CMD=$(CC) -c $(ALL_CFLAGS) $< -o $@)
@$(BUILD_CMD) @$(BUILD_CMD)
# Compile: create object files from C++ source files. # Compile: create object files from C++ source files.
$(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.o : %.cpp | $(BEGIN)
@mkdir -p $(@D) @mkdir -p $(@D)
@$(SILENT) || printf "$(MSG_COMPILING_CPP) $<" | $(AWK_CMD) @$(SILENT) || printf "$(MSG_COMPILING_CPP) $<" | $(AWK_CMD)
$(eval CMD=$(CC) -c $(ALL_CPPFLAGS) $< -o $@) $(eval CMD=$(CC) -c $(ALL_CPPFLAGS) $< -o $@)
@$(BUILD_CMD) @$(BUILD_CMD)
# Compile: create assembler files from C source files. # Compile: create assembler files from C source files.
%.s : %.c %.s : %.c | $(BEGIN)
@$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD) @$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
$(eval CMD=$(CC) -S $(ALL_CFLAGS) $< -o $@) $(eval CMD=$(CC) -S $(ALL_CFLAGS) $< -o $@)
@$(BUILD_CMD) @$(BUILD_CMD)
# Compile: create assembler files from C++ source files. # Compile: create assembler files from C++ source files.
%.s : %.cpp %.s : %.cpp | $(BEGIN)
@$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD) @$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
$(eval CMD=$(CC) -S $(ALL_CPPFLAGS) $< -o $@) $(eval CMD=$(CC) -S $(ALL_CPPFLAGS) $< -o $@)
@$(BUILD_CMD) @$(BUILD_CMD)
# Assemble: create object files from assembler source files. # Assemble: create object files from assembler source files.
$(OBJDIR)/%.o : %.S $(OBJDIR)/%.o : %.S | $(BEGIN)
@mkdir -p $(@D) @mkdir -p $(@D)
@$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD) @$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
$(eval CMD=$(CC) -c $(ALL_ASFLAGS) $< -o $@) $(eval CMD=$(CC) -c $(ALL_ASFLAGS) $< -o $@)
@$(BUILD_CMD) @$(BUILD_CMD)
# Create preprocessed source for use in sending a bug report. # Create preprocessed source for use in sending a bug report.
%.i : %.c %.i : %.c | $(BEGIN)
$(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@ $(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@
# Target: clean project. # Target: clean project.
clean: begin clean_list end clean:
clean_list :
@$(REMOVE) -r $(BUILD_DIR)
@$(REMOVE) -r $(TOP_DIR)/$(BUILD_DIR)
@$(REMOVE) -r $(KEYBOARD_PATH)/$(BUILD_DIR)
@if $$SUBPROJECT; then $(REMOVE) -r $(SUBPROJECT_PATH)/$(BUILD_DIR); fi
@$(REMOVE) -r $(KEYMAP_PATH)/$(BUILD_DIR)
show_path: show_path:
@echo VPATH=$(VPATH) @echo VPATH=$(VPATH)
@ -496,6 +468,19 @@ all-keymaps-%:
all-keymaps: all-keymaps-all all-keymaps: all-keymaps-all
GOAL=$(MAKECMDGOALS)
ifeq ($(MAKECMDGOALS),)
GOAL = all
endif
CLEANING_GOALS=clean clean_list all
ifneq ($(findstring $(GOAL),$(CLEANING_GOALS)),)
$(shell $(REMOVE) -r $(BUILD_DIR) 2>/dev/null)
$(shell $(REMOVE) -r $(TOP_DIR)/$(BUILD_DIR))
$(shell $(REMOVE) -r $(KEYBOARD_PATH)/$(BUILD_DIR))
$(shell if $$SUBPROJECT; then $(REMOVE) -r $(SUBPROJECT_PATH)/$(BUILD_DIR); fi)
$(shell $(REMOVE) -r $(KEYMAP_PATH)/$(BUILD_DIR))
endif
# Create build directory # Create build directory
$(shell mkdir $(BUILD_DIR) 2>/dev/null) $(shell mkdir $(BUILD_DIR) 2>/dev/null)
@ -508,8 +493,8 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
# Listing of phony targets. # Listing of phony targets.
.PHONY : all quick begin finish end sizebefore sizeafter gccversion \ .PHONY : all quick finish sizebefore sizeafter gccversion \
build elf hex eep lss sym coff extcoff \ build elf hex eep lss sym coff extcoff check_submodule \
clean clean_list debug gdb-config show_path \ clean clean_list debug gdb-config show_path \
program teensy dfu flip dfu-ee flip-ee dfu-start \ program teensy dfu flip dfu-ee flip-ee dfu-start \
all-keyboards-defaults all-keyboards all-keymaps \ all-keyboards-defaults all-keyboards all-keymaps \

Loading…
Cancel
Save