diff options
| author | Damien <Dbroqua@users.noreply.github.com> | 2017-05-26 15:57:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-26 15:57:08 +0200 |
| commit | 0a4a966c6648e66a1129ae3af36639054d3e0ed3 (patch) | |
| tree | ec50b19b9031b1f3f24e003879f95cf9690d61af /tmk_core | |
| parent | 7180e195e84aabf252fcadb2852644417ac1d663 (diff) | |
| parent | 7a4ec3bd926865e490fbf7c5ec68d762e998683f (diff) | |
| download | qmk_firmware-0a4a966c6648e66a1129ae3af36639054d3e0ed3.tar.gz qmk_firmware-0a4a966c6648e66a1129ae3af36639054d3e0ed3.zip | |
Merge pull request #22 from qmk/master
Merge from QMK
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/avr.mk | 42 | ||||
| -rw-r--r-- | tmk_core/chibios.mk | 4 | ||||
| -rw-r--r-- | tmk_core/common/action.c | 19 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.c | 58 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.h | 1 |
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 | |||
| 89 | #============================================================================ | 89 | #============================================================================ |
| 90 | # Autodecct teensy loader | 90 | # Autodecct teensy loader |
| 91 | ifneq (, $(shell which teensy-loader-cli 2>/dev/null)) | 91 | ifneq (, $(shell which teensy-loader-cli 2>/dev/null)) |
| 92 | TEENSY_LOADER_CLI = teensy-loader-cli | 92 | TEENSY_LOADER_CLI ?= teensy-loader-cli |
| 93 | else | 93 | else |
| 94 | TEENSY_LOADER_CLI = teensy_loader_cli | 94 | TEENSY_LOADER_CLI ?= teensy_loader_cli |
| 95 | endif | 95 | endif |
| 96 | 96 | ||
| 97 | # Program the device. | 97 | # Program the device. |
| @@ -100,43 +100,47 @@ program: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep | |||
| 100 | 100 | ||
| 101 | teensy: $(BUILD_DIR)/$(TARGET).hex | 101 | teensy: $(BUILD_DIR)/$(TARGET).hex |
| 102 | $(TEENSY_LOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex | 102 | $(TEENSY_LOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex |
| 103 | |||
| 104 | BATCHISP ?= batchisp | ||
| 103 | 105 | ||
| 104 | flip: $(BUILD_DIR)/$(TARGET).hex | 106 | flip: $(BUILD_DIR)/$(TARGET).hex |
| 105 | batchisp -hardware usb -device $(MCU) -operation erase f | 107 | $(BATCHISP) -hardware usb -device $(MCU) -operation erase f |
| 106 | batchisp -hardware usb -device $(MCU) -operation loadbuffer $(BUILD_DIR)/$(TARGET).hex program | 108 | $(BATCHISP) -hardware usb -device $(MCU) -operation loadbuffer $(BUILD_DIR)/$(TARGET).hex program |
| 107 | batchisp -hardware usb -device $(MCU) -operation start reset 0 | 109 | $(BATCHISP) -hardware usb -device $(MCU) -operation start reset 0 |
| 110 | |||
| 111 | DFU_PROGRAMMER ?= dfu-programmer | ||
| 108 | 112 | ||
| 109 | dfu: $(BUILD_DIR)/$(TARGET).hex sizeafter | 113 | dfu: $(BUILD_DIR)/$(TARGET).hex sizeafter |
| 110 | until dfu-programmer $(MCU) get bootloader-version; do\ | 114 | until $(DFU_PROGRAMMER) $(MCU) get bootloader-version; do\ |
| 111 | echo "Error: Bootloader not found. Trying again in 5s." ;\ | 115 | echo "Error: Bootloader not found. Trying again in 5s." ;\ |
| 112 | sleep 5 ;\ | 116 | sleep 5 ;\ |
| 113 | done | 117 | done |
| 114 | ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) | 118 | ifneq (, $(findstring 0.7, $(shell $(DFU_PROGRAMMER) --version 2>&1))) |
| 115 | dfu-programmer $(MCU) erase --force | 119 | $(DFU_PROGRAMMER) $(MCU) erase --force |
| 116 | else | 120 | else |
| 117 | dfu-programmer $(MCU) erase | 121 | $(DFU_PROGRAMMER) $(MCU) erase |
| 118 | endif | 122 | endif |
| 119 | dfu-programmer $(MCU) flash $(BUILD_DIR)/$(TARGET).hex | 123 | $(DFU_PROGRAMMER) $(MCU) flash $(BUILD_DIR)/$(TARGET).hex |
| 120 | dfu-programmer $(MCU) reset | 124 | $(DFU_PROGRAMMER) $(MCU) reset |
| 121 | 125 | ||
| 122 | dfu-start: | 126 | dfu-start: |
| 123 | dfu-programmer $(MCU) reset | 127 | $(DFU_PROGRAMMER) $(MCU) reset |
| 124 | dfu-programmer $(MCU) start | 128 | $(DFU_PROGRAMMER) $(MCU) start |
| 125 | 129 | ||
| 126 | flip-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep | 130 | flip-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep |
| 127 | $(COPY) $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET)eep.hex | 131 | $(COPY) $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET)eep.hex |
| 128 | batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase | 132 | $(BATCHISP) -hardware usb -device $(MCU) -operation memory EEPROM erase |
| 129 | batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(BUILD_DIR)/$(TARGET)eep.hex program | 133 | $(BATCHISP) -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(BUILD_DIR)/$(TARGET)eep.hex program |
| 130 | batchisp -hardware usb -device $(MCU) -operation start reset 0 | 134 | $(BATCHISP) -hardware usb -device $(MCU) -operation start reset 0 |
| 131 | $(REMOVE) $(BUILD_DIR)/$(TARGET)eep.hex | 135 | $(REMOVE) $(BUILD_DIR)/$(TARGET)eep.hex |
| 132 | 136 | ||
| 133 | dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep | 137 | dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep |
| 134 | ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) | 138 | ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) |
| 135 | dfu-programmer $(MCU) flash --eeprom $(BUILD_DIR)/$(TARGET).eep | 139 | $(DFU_PROGRAMMER) $(MCU) flash --eeprom $(BUILD_DIR)/$(TARGET).eep |
| 136 | else | 140 | else |
| 137 | dfu-programmer $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep | 141 | $(DFU_PROGRAMMER) $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep |
| 138 | endif | 142 | endif |
| 139 | dfu-programmer $(MCU) reset | 143 | $(DFU_PROGRAMMER) $(MCU) reset |
| 140 | 144 | ||
| 141 | # Convert hex to bin. | 145 | # Convert hex to bin. |
| 142 | flashbin: $(BUILD_DIR)/$(TARGET).hex | 146 | 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 | |||
| 151 | # List any extra directories to look for libraries here. | 151 | # List any extra directories to look for libraries here. |
| 152 | EXTRALIBDIRS = $(RULESPATH)/ld | 152 | EXTRALIBDIRS = $(RULESPATH)/ld |
| 153 | 153 | ||
| 154 | DFU_UTIL ?= dfu-util | ||
| 155 | |||
| 154 | dfu-util: $(BUILD_DIR)/$(TARGET).bin sizeafter | 156 | dfu-util: $(BUILD_DIR)/$(TARGET).bin sizeafter |
| 155 | dfu-util $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin | 157 | $(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/>. | |||
| 26 | #include "action_macro.h" | 26 | #include "action_macro.h" |
| 27 | #include "action_util.h" | 27 | #include "action_util.h" |
| 28 | #include "action.h" | 28 | #include "action.h" |
| 29 | #include "wait.h" | ||
| 29 | 30 | ||
| 30 | #ifdef DEBUG_ACTION | 31 | #ifdef DEBUG_ACTION |
| 31 | #include "debug.h" | 32 | #include "debug.h" |
| @@ -438,6 +439,9 @@ void process_action(keyrecord_t *record, action_t action) | |||
| 438 | } else { | 439 | } else { |
| 439 | if (tap_count > 0) { | 440 | if (tap_count > 0) { |
| 440 | dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n"); | 441 | dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n"); |
| 442 | if (action.layer_tap.code == KC_CAPS) { | ||
| 443 | wait_ms(80); | ||
| 444 | } | ||
| 441 | unregister_code(action.layer_tap.code); | 445 | unregister_code(action.layer_tap.code); |
| 442 | } else { | 446 | } else { |
| 443 | dprint("KEYMAP_TAP_KEY: No tap: Off on release\n"); | 447 | dprint("KEYMAP_TAP_KEY: No tap: Off on release\n"); |
| @@ -537,6 +541,21 @@ void process_action(keyrecord_t *record, action_t action) | |||
| 537 | break; | 541 | break; |
| 538 | } | 542 | } |
| 539 | 543 | ||
| 544 | #ifndef NO_ACTION_LAYER | ||
| 545 | // if this event is a layer action, update the leds | ||
| 546 | switch (action.kind.id) { | ||
| 547 | case ACT_LAYER: | ||
| 548 | #ifndef NO_ACTION_TAPPING | ||
| 549 | case ACT_LAYER_TAP: | ||
| 550 | case ACT_LAYER_TAP_EXT: | ||
| 551 | #endif | ||
| 552 | led_set(host_keyboard_leds()); | ||
| 553 | break; | ||
| 554 | default: | ||
| 555 | break; | ||
| 556 | } | ||
| 557 | #endif | ||
| 558 | |||
| 540 | #ifndef NO_ACTION_ONESHOT | 559 | #ifndef NO_ACTION_ONESHOT |
| 541 | /* Because we switch layers after a oneshot event, we need to release the | 560 | /* Because we switch layers after a oneshot event, we need to release the |
| 542 | * key before we leave the layer or no key up event will be generated. | 561 | * 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/>. | |||
| 61 | # include "visualizer/visualizer.h" | 61 | # include "visualizer/visualizer.h" |
| 62 | #endif | 62 | #endif |
| 63 | 63 | ||
| 64 | #ifdef MATRIX_HAS_GHOST | ||
| 65 | extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; | ||
| 66 | static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata){ | ||
| 67 | matrix_row_t out = 0; | ||
| 68 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
| 69 | //read each key in the row data and check if the keymap defines it as a real key | ||
| 70 | if (pgm_read_byte(&keymaps[0][row][col]) && (rowdata & (1<<col))){ | ||
| 71 | //this creates new row data, if a key is defined in the keymap, it will be set here | ||
| 72 | out |= 1<<col; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | return out; | ||
| 76 | } | ||
| 64 | 77 | ||
| 78 | static inline bool popcount_more_than_one(matrix_row_t rowdata) | ||
| 79 | { | ||
| 80 | rowdata &= rowdata-1; //if there are less than two bits (keys) set, rowdata will become zero | ||
| 81 | return rowdata; | ||
| 82 | } | ||
| 65 | 83 | ||
| 66 | #ifdef MATRIX_HAS_GHOST | 84 | static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata) |
| 67 | static bool has_ghost_in_row(uint8_t row) | ||
| 68 | { | 85 | { |
| 69 | matrix_row_t matrix_row = matrix_get_row(row); | 86 | /* No ghost exists when less than 2 keys are down on the row. |
| 70 | // No ghost exists when less than 2 keys are down on the row | 87 | If there are "active" blanks in the matrix, the key can't be pressed by the user, |
| 71 | if (((matrix_row - 1) & matrix_row) == 0) | 88 | there is no doubt as to which keys are really being pressed. |
| 89 | The ghosts will be ignored, they are KC_NO. */ | ||
| 90 | rowdata = get_real_keys(row, rowdata); | ||
| 91 | if ((popcount_more_than_one(rowdata)) == 0){ | ||
| 72 | return false; | 92 | return false; |
| 73 | 93 | } | |
| 74 | // Ghost occurs when the row shares column line with other row | 94 | /* Ghost occurs when the row shares a column line with other row, |
| 95 | and two columns are read on each row. Blanks in the matrix don't matter, | ||
| 96 | so they are filtered out. | ||
| 97 | If there are two or more real keys pressed and they match columns with | ||
| 98 | at least two of another row's real keys, the row will be ignored. Keep in mind, | ||
| 99 | we are checking one row at a time, not all of them at once. | ||
| 100 | */ | ||
| 75 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | 101 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { |
| 76 | if (i != row && (matrix_get_row(i) & matrix_row)) | 102 | if (i != row && popcount_more_than_one(get_real_keys(i, matrix_get_row(i)) & rowdata)){ |
| 77 | return true; | 103 | return true; |
| 104 | } | ||
| 78 | } | 105 | } |
| 79 | return false; | 106 | return false; |
| 80 | } | 107 | } |
| 108 | |||
| 81 | #endif | 109 | #endif |
| 82 | 110 | ||
| 83 | __attribute__ ((weak)) | 111 | __attribute__ ((weak)) |
| @@ -127,7 +155,7 @@ void keyboard_task(void) | |||
| 127 | { | 155 | { |
| 128 | static matrix_row_t matrix_prev[MATRIX_ROWS]; | 156 | static matrix_row_t matrix_prev[MATRIX_ROWS]; |
| 129 | #ifdef MATRIX_HAS_GHOST | 157 | #ifdef MATRIX_HAS_GHOST |
| 130 | static matrix_row_t matrix_ghost[MATRIX_ROWS]; | 158 | // static matrix_row_t matrix_ghost[MATRIX_ROWS]; |
| 131 | #endif | 159 | #endif |
| 132 | static uint8_t led_status = 0; | 160 | static uint8_t led_status = 0; |
| 133 | matrix_row_t matrix_row = 0; | 161 | matrix_row_t matrix_row = 0; |
| @@ -139,18 +167,18 @@ void keyboard_task(void) | |||
| 139 | matrix_change = matrix_row ^ matrix_prev[r]; | 167 | matrix_change = matrix_row ^ matrix_prev[r]; |
| 140 | if (matrix_change) { | 168 | if (matrix_change) { |
| 141 | #ifdef MATRIX_HAS_GHOST | 169 | #ifdef MATRIX_HAS_GHOST |
| 142 | if (has_ghost_in_row(r)) { | 170 | if (has_ghost_in_row(r, matrix_row)) { |
| 143 | /* Keep track of whether ghosted status has changed for | 171 | /* Keep track of whether ghosted status has changed for |
| 144 | * debugging. But don't update matrix_prev until un-ghosted, or | 172 | * debugging. But don't update matrix_prev until un-ghosted, or |
| 145 | * the last key would be lost. | 173 | * the last key would be lost. |
| 146 | */ | 174 | */ |
| 147 | if (debug_matrix && matrix_ghost[r] != matrix_row) { | 175 | //if (debug_matrix && matrix_ghost[r] != matrix_row) { |
| 148 | matrix_print(); | 176 | // matrix_print(); |
| 149 | } | 177 | //} |
| 150 | matrix_ghost[r] = matrix_row; | 178 | //matrix_ghost[r] = matrix_row; |
| 151 | continue; | 179 | continue; |
| 152 | } | 180 | } |
| 153 | matrix_ghost[r] = matrix_row; | 181 | //matrix_ghost[r] = matrix_row; |
| 154 | #endif | 182 | #endif |
| 155 | if (debug_matrix) matrix_print(); | 183 | if (debug_matrix) matrix_print(); |
| 156 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | 184 | 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) && | |||
| 57 | .time = (timer_read() | 1) \ | 57 | .time = (timer_read() | 1) \ |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | |||
| 61 | /* it runs once at early stage of startup before keyboard_init. */ | 60 | /* it runs once at early stage of startup before keyboard_init. */ |
| 62 | void keyboard_setup(void); | 61 | void keyboard_setup(void); |
| 63 | /* it runs once after initializing host side protocol, debug and MCU peripherals. */ | 62 | /* it runs once after initializing host side protocol, debug and MCU peripherals. */ |
