summaryrefslogtreecommitdiffstats
path: root/tmk_core
diff options
context:
space:
mode:
authorDamien <Dbroqua@users.noreply.github.com>2017-05-26 15:57:08 +0200
committerGitHub <noreply@github.com>2017-05-26 15:57:08 +0200
commit0a4a966c6648e66a1129ae3af36639054d3e0ed3 (patch)
treeec50b19b9031b1f3f24e003879f95cf9690d61af /tmk_core
parent7180e195e84aabf252fcadb2852644417ac1d663 (diff)
parent7a4ec3bd926865e490fbf7c5ec68d762e998683f (diff)
downloadqmk_firmware-0a4a966c6648e66a1129ae3af36639054d3e0ed3.tar.gz
qmk_firmware-0a4a966c6648e66a1129ae3af36639054d3e0ed3.tar.xz
Merge pull request #22 from qmk/master
Merge from QMK
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/avr.mk42
-rw-r--r--tmk_core/chibios.mk4
-rw-r--r--tmk_core/common/action.c19
-rw-r--r--tmk_core/common/keyboard.c58
-rw-r--r--tmk_core/common/keyboard.h1
5 files changed, 88 insertions, 36 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index 5df539def..ccecdb192 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -89,9 +89,9 @@ DEBUG_HOST = localhost
#============================================================================
# Autodecct teensy loader
ifneq (, $(shell which teensy-loader-cli 2>/dev/null))
- TEENSY_LOADER_CLI = teensy-loader-cli
+ TEENSY_LOADER_CLI ?= teensy-loader-cli
else
- TEENSY_LOADER_CLI = teensy_loader_cli
+ TEENSY_LOADER_CLI ?= teensy_loader_cli
endif
# Program the device.
@@ -100,43 +100,47 @@ program: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
teensy: $(BUILD_DIR)/$(TARGET).hex
$(TEENSY_LOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex
+
+BATCHISP ?= batchisp
flip: $(BUILD_DIR)/$(TARGET).hex
- batchisp -hardware usb -device $(MCU) -operation erase f
- batchisp -hardware usb -device $(MCU) -operation loadbuffer $(BUILD_DIR)/$(TARGET).hex program
- batchisp -hardware usb -device $(MCU) -operation start reset 0
+ $(BATCHISP) -hardware usb -device $(MCU) -operation erase f
+ $(BATCHISP) -hardware usb -device $(MCU) -operation loadbuffer $(BUILD_DIR)/$(TARGET).hex program
+ $(BATCHISP) -hardware usb -device $(MCU) -operation start reset 0
+
+DFU_PROGRAMMER ?= dfu-programmer
dfu: $(BUILD_DIR)/$(TARGET).hex sizeafter
- until dfu-programmer $(MCU) get bootloader-version; do\
+ until $(DFU_PROGRAMMER) $(MCU) get bootloader-version; do\
echo "Error: Bootloader not found. Trying again in 5s." ;\
sleep 5 ;\
done
-ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
- dfu-programmer $(MCU) erase --force
+ifneq (, $(findstring 0.7, $(shell $(DFU_PROGRAMMER) --version 2>&1)))
+ $(DFU_PROGRAMMER) $(MCU) erase --force
else
- dfu-programmer $(MCU) erase
+ $(DFU_PROGRAMMER) $(MCU) erase
endif
- dfu-programmer $(MCU) flash $(BUILD_DIR)/$(TARGET).hex
- dfu-programmer $(MCU) reset
+ $(DFU_PROGRAMMER) $(MCU) flash $(BUILD_DIR)/$(TARGET).hex
+ $(DFU_PROGRAMMER) $(MCU) reset
dfu-start:
- dfu-programmer $(MCU) reset
- dfu-programmer $(MCU) start
+ $(DFU_PROGRAMMER) $(MCU) reset
+ $(DFU_PROGRAMMER) $(MCU) start
flip-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
$(COPY) $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET)eep.hex
- batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
- batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(BUILD_DIR)/$(TARGET)eep.hex program
- batchisp -hardware usb -device $(MCU) -operation start reset 0
+ $(BATCHISP) -hardware usb -device $(MCU) -operation memory EEPROM erase
+ $(BATCHISP) -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(BUILD_DIR)/$(TARGET)eep.hex program
+ $(BATCHISP) -hardware usb -device $(MCU) -operation start reset 0
$(REMOVE) $(BUILD_DIR)/$(TARGET)eep.hex
dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
- dfu-programmer $(MCU) flash --eeprom $(BUILD_DIR)/$(TARGET).eep
+ $(DFU_PROGRAMMER) $(MCU) flash --eeprom $(BUILD_DIR)/$(TARGET).eep
else
- dfu-programmer $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep
+ $(DFU_PROGRAMMER) $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep
endif
- dfu-programmer $(MCU) reset
+ $(DFU_PROGRAMMER) $(MCU) reset
# Convert hex to bin.
flashbin: $(BUILD_DIR)/$(TARGET).hex
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index eb0c40138..2a8d32fb9 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -151,5 +151,7 @@ endif
# List any extra directories to look for libraries here.
EXTRALIBDIRS = $(RULESPATH)/ld
+DFU_UTIL ?= dfu-util
+
dfu-util: $(BUILD_DIR)/$(TARGET).bin sizeafter
- dfu-util $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
+ $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 4ba1cc251..a534f818e 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_macro.h"
#include "action_util.h"
#include "action.h"
+#include "wait.h"
#ifdef DEBUG_ACTION
#include "debug.h"
@@ -438,6 +439,9 @@ void process_action(keyrecord_t *record, action_t action)
} else {
if (tap_count > 0) {
dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n");
+ if (action.layer_tap.code == KC_CAPS) {
+ wait_ms(80);
+ }
unregister_code(action.layer_tap.code);
} else {
dprint("KEYMAP_TAP_KEY: No tap: Off on release\n");
@@ -537,6 +541,21 @@ void process_action(keyrecord_t *record, action_t action)
break;
}
+#ifndef NO_ACTION_LAYER
+ // if this event is a layer action, update the leds
+ switch (action.kind.id) {
+ case ACT_LAYER:
+ #ifndef NO_ACTION_TAPPING
+ case ACT_LAYER_TAP:
+ case ACT_LAYER_TAP_EXT:
+ #endif
+ led_set(host_keyboard_leds());
+ break;
+ default:
+ break;
+ }
+#endif
+
#ifndef NO_ACTION_ONESHOT
/* Because we switch layers after a oneshot event, we need to release the
* key before we leave the layer or no key up event will be generated.
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index eac1f1dd8..97a8f1cd8 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -61,23 +61,51 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "visualizer/visualizer.h"
#endif
+#ifdef MATRIX_HAS_GHOST
+extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
+static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata){
+ matrix_row_t out = 0;
+ for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+ //read each key in the row data and check if the keymap defines it as a real key
+ if (pgm_read_byte(&keymaps[0][row][col]) && (rowdata & (1<<col))){
+ //this creates new row data, if a key is defined in the keymap, it will be set here
+ out |= 1<<col;
+ }
+ }
+ return out;
+}
+static inline bool popcount_more_than_one(matrix_row_t rowdata)
+{
+ rowdata &= rowdata-1; //if there are less than two bits (keys) set, rowdata will become zero
+ return rowdata;
+}
-#ifdef MATRIX_HAS_GHOST
-static bool has_ghost_in_row(uint8_t row)
+static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata)
{
- matrix_row_t matrix_row = matrix_get_row(row);
- // No ghost exists when less than 2 keys are down on the row
- if (((matrix_row - 1) & matrix_row) == 0)
+ /* No ghost exists when less than 2 keys are down on the row.
+ If there are "active" blanks in the matrix, the key can't be pressed by the user,
+ there is no doubt as to which keys are really being pressed.
+ The ghosts will be ignored, they are KC_NO. */
+ rowdata = get_real_keys(row, rowdata);
+ if ((popcount_more_than_one(rowdata)) == 0){
return false;
-
- // Ghost occurs when the row shares column line with other row
+ }
+ /* Ghost occurs when the row shares a column line with other row,
+ and two columns are read on each row. Blanks in the matrix don't matter,
+ so they are filtered out.
+ If there are two or more real keys pressed and they match columns with
+ at least two of another row's real keys, the row will be ignored. Keep in mind,
+ we are checking one row at a time, not all of them at once.
+ */
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
- if (i != row && (matrix_get_row(i) & matrix_row))
+ if (i != row && popcount_more_than_one(get_real_keys(i, matrix_get_row(i)) & rowdata)){
return true;
+ }
}
return false;
}
+
#endif
__attribute__ ((weak))
@@ -127,7 +155,7 @@ void keyboard_task(void)
{
static matrix_row_t matrix_prev[MATRIX_ROWS];
#ifdef MATRIX_HAS_GHOST
- static matrix_row_t matrix_ghost[MATRIX_ROWS];
+ // static matrix_row_t matrix_ghost[MATRIX_ROWS];
#endif
static uint8_t led_status = 0;
matrix_row_t matrix_row = 0;
@@ -139,18 +167,18 @@ void keyboard_task(void)
matrix_change = matrix_row ^ matrix_prev[r];
if (matrix_change) {
#ifdef MATRIX_HAS_GHOST
- if (has_ghost_in_row(r)) {
+ if (has_ghost_in_row(r, matrix_row)) {
/* Keep track of whether ghosted status has changed for
* debugging. But don't update matrix_prev until un-ghosted, or
* the last key would be lost.
*/
- if (debug_matrix && matrix_ghost[r] != matrix_row) {
- matrix_print();
- }
- matrix_ghost[r] = matrix_row;
+ //if (debug_matrix && matrix_ghost[r] != matrix_row) {
+ // matrix_print();
+ //}
+ //matrix_ghost[r] = matrix_row;
continue;
}
- matrix_ghost[r] = matrix_row;
+ //matrix_ghost[r] = matrix_row;
#endif
if (debug_matrix) matrix_print();
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h
index 7738251b6..f17003c2f 100644
--- a/tmk_core/common/keyboard.h
+++ b/tmk_core/common/keyboard.h
@@ -57,7 +57,6 @@ static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) &&
.time = (timer_read() | 1) \
}
-
/* it runs once at early stage of startup before keyboard_init. */
void keyboard_setup(void);
/* it runs once after initializing host side protocol, debug and MCU peripherals. */