diff options
| author | Zay950 <Zay950@users.noreply.github.com> | 2017-03-29 12:00:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-29 12:00:38 -0700 |
| commit | 2366ebfbbdeb6ec29cc9a0facda44d666305dd6e (patch) | |
| tree | 883efed0b7260f3143f5a2a879bc3844a8255e0b /tmk_core/common | |
| parent | 80c5ada3394c5ad8087df00ef878eb2cbcd87d70 (diff) | |
| parent | 942f2ccee44bdb2e251553e9730cd8d59307d8b2 (diff) | |
| download | qmk_firmware-2366ebfbbdeb6ec29cc9a0facda44d666305dd6e.tar.gz qmk_firmware-2366ebfbbdeb6ec29cc9a0facda44d666305dd6e.zip | |
Merge branch 'master' into to_push
Diffstat (limited to 'tmk_core/common')
| -rw-r--r-- | tmk_core/common/action.c | 29 | ||||
| -rw-r--r-- | tmk_core/common/action_code.h | 10 | ||||
| -rw-r--r-- | tmk_core/common/action_layer.c | 12 | ||||
| -rw-r--r-- | tmk_core/common/action_layer.h | 5 | ||||
| -rw-r--r-- | tmk_core/common/action_macro.h | 26 | ||||
| -rw-r--r-- | tmk_core/common/action_tapping.c | 11 | ||||
| -rw-r--r-- | tmk_core/common/avr/bootloader.c | 12 | ||||
| -rw-r--r-- | tmk_core/common/avr/suspend.c | 11 | ||||
| -rw-r--r-- | tmk_core/common/avr/timer.c | 69 | ||||
| -rw-r--r-- | tmk_core/common/backlight.c | 4 | ||||
| -rw-r--r-- | tmk_core/common/command.c | 9 | ||||
| -rw-r--r-- | tmk_core/common/host_driver.h | 9 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.c | 9 | ||||
| -rw-r--r-- | tmk_core/common/keycode.h | 2 | ||||
| -rw-r--r-- | tmk_core/common/matrix.h | 2 | ||||
| -rw-r--r-- | tmk_core/common/raw_hid.h | 8 | ||||
| -rw-r--r-- | tmk_core/common/report.h | 7 |
17 files changed, 167 insertions, 68 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index d485b46c7..94de36918 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -33,6 +33,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 33 | #include "nodebug.h" | 33 | #include "nodebug.h" |
| 34 | #endif | 34 | #endif |
| 35 | 35 | ||
| 36 | #ifdef FAUXCLICKY_ENABLE | ||
| 37 | #include <fauxclicky.h> | ||
| 38 | #endif | ||
| 36 | 39 | ||
| 37 | void action_exec(keyevent_t event) | 40 | void action_exec(keyevent_t event) |
| 38 | { | 41 | { |
| @@ -41,6 +44,16 @@ void action_exec(keyevent_t event) | |||
| 41 | dprint("EVENT: "); debug_event(event); dprintln(); | 44 | dprint("EVENT: "); debug_event(event); dprintln(); |
| 42 | } | 45 | } |
| 43 | 46 | ||
| 47 | #ifdef FAUXCLICKY_ENABLE | ||
| 48 | if (IS_PRESSED(event)) { | ||
| 49 | FAUXCLICKY_ACTION_PRESS; | ||
| 50 | } | ||
| 51 | if (IS_RELEASED(event)) { | ||
| 52 | FAUXCLICKY_ACTION_RELEASE; | ||
| 53 | } | ||
| 54 | fauxclicky_check(); | ||
| 55 | #endif | ||
| 56 | |||
| 44 | #ifdef ONEHAND_ENABLE | 57 | #ifdef ONEHAND_ENABLE |
| 45 | if (!IS_NOEVENT(event)) { | 58 | if (!IS_NOEVENT(event)) { |
| 46 | process_hand_swap(&event); | 59 | process_hand_swap(&event); |
| @@ -49,6 +62,13 @@ void action_exec(keyevent_t event) | |||
| 49 | 62 | ||
| 50 | keyrecord_t record = { .event = event }; | 63 | keyrecord_t record = { .event = event }; |
| 51 | 64 | ||
| 65 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | ||
| 66 | if (has_oneshot_layer_timed_out()) { | ||
| 67 | dprintf("Oneshot layer: timeout\n"); | ||
| 68 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); | ||
| 69 | } | ||
| 70 | #endif | ||
| 71 | |||
| 52 | #ifndef NO_ACTION_TAPPING | 72 | #ifndef NO_ACTION_TAPPING |
| 53 | action_tapping_process(record); | 73 | action_tapping_process(record); |
| 54 | #else | 74 | #else |
| @@ -100,7 +120,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 100 | return true; | 120 | return true; |
| 101 | } | 121 | } |
| 102 | 122 | ||
| 103 | void process_record(keyrecord_t *record) | 123 | void process_record(keyrecord_t *record) |
| 104 | { | 124 | { |
| 105 | if (IS_NOEVENT(record->event)) { return; } | 125 | if (IS_NOEVENT(record->event)) { return; } |
| 106 | 126 | ||
| @@ -126,13 +146,6 @@ void process_action(keyrecord_t *record, action_t action) | |||
| 126 | uint8_t tap_count = record->tap.count; | 146 | uint8_t tap_count = record->tap.count; |
| 127 | #endif | 147 | #endif |
| 128 | 148 | ||
| 129 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | ||
| 130 | if (has_oneshot_layer_timed_out()) { | ||
| 131 | dprintf("Oneshot layer: timeout\n"); | ||
| 132 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); | ||
| 133 | } | ||
| 134 | #endif | ||
| 135 | |||
| 136 | if (event.pressed) { | 149 | if (event.pressed) { |
| 137 | // clear the potential weak mods left by previously pressed keys | 150 | // clear the potential weak mods left by previously pressed keys |
| 138 | clear_weak_mods(); | 151 | clear_weak_mods(); |
diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h index 33da35f35..b15aaa0eb 100644 --- a/tmk_core/common/action_code.h +++ b/tmk_core/common/action_code.h | |||
| @@ -47,10 +47,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 47 | * 0100|10| usage(10) (reserved) | 47 | * 0100|10| usage(10) (reserved) |
| 48 | * 0100|11| usage(10) (reserved) | 48 | * 0100|11| usage(10) (reserved) |
| 49 | * | 49 | * |
| 50 | * ACT_MOUSEKEY(0110): TODO: Not needed? | 50 | * |
| 51 | * ACT_MOUSEKEY(0101): TODO: Merge these two actions to conserve space? | ||
| 51 | * 0101|xxxx| keycode Mouse key | 52 | * 0101|xxxx| keycode Mouse key |
| 52 | * | 53 | * |
| 53 | * 011x|xxxx xxxx xxxx (reseved) | 54 | * ACT_SWAP_HANDS(0110): |
| 55 | * 0110|xxxx| keycode Swap hands (keycode on tap, or options) | ||
| 56 | * | ||
| 57 | * | ||
| 58 | * 0111|xxxx xxxx xxxx (reserved) | ||
| 54 | * | 59 | * |
| 55 | * | 60 | * |
| 56 | * Layer Actions(10xx) | 61 | * Layer Actions(10xx) |
| @@ -67,7 +72,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 67 | * ee: on event(01:press, 10:release, 11:both) | 72 | * ee: on event(01:press, 10:release, 11:both) |
| 68 | * | 73 | * |
| 69 | * 1001|xxxx|xxxx xxxx (reserved) | 74 | * 1001|xxxx|xxxx xxxx (reserved) |
| 70 | * 1001|oopp|BBBB BBBB 8-bit Bitwise Operation??? | ||
| 71 | * | 75 | * |
| 72 | * ACT_LAYER_TAP(101x): | 76 | * ACT_LAYER_TAP(101x): |
| 73 | * 101E|LLLL| keycode On/Off with tap key (0x00-DF)[TAP] | 77 | * 101E|LLLL| keycode On/Off with tap key (0x00-DF)[TAP] |
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c index a3c757964..58d919a04 100644 --- a/tmk_core/common/action_layer.c +++ b/tmk_core/common/action_layer.c | |||
| @@ -16,8 +16,14 @@ | |||
| 16 | */ | 16 | */ |
| 17 | uint32_t default_layer_state = 0; | 17 | uint32_t default_layer_state = 0; |
| 18 | 18 | ||
| 19 | __attribute__((weak)) | ||
| 20 | uint32_t default_layer_state_set_kb(uint32_t state) { | ||
| 21 | return state; | ||
| 22 | } | ||
| 23 | |||
| 19 | static void default_layer_state_set(uint32_t state) | 24 | static void default_layer_state_set(uint32_t state) |
| 20 | { | 25 | { |
| 26 | state = default_layer_state_set_kb(state); | ||
| 21 | debug("default_layer_state: "); | 27 | debug("default_layer_state: "); |
| 22 | default_layer_debug(); debug(" to "); | 28 | default_layer_debug(); debug(" to "); |
| 23 | default_layer_state = state; | 29 | default_layer_state = state; |
| @@ -57,8 +63,14 @@ void default_layer_xor(uint32_t state) | |||
| 57 | */ | 63 | */ |
| 58 | uint32_t layer_state = 0; | 64 | uint32_t layer_state = 0; |
| 59 | 65 | ||
| 66 | __attribute__((weak)) | ||
| 67 | uint32_t layer_state_set_kb(uint32_t state) { | ||
| 68 | return state; | ||
| 69 | } | ||
| 70 | |||
| 60 | static void layer_state_set(uint32_t state) | 71 | static void layer_state_set(uint32_t state) |
| 61 | { | 72 | { |
| 73 | state = layer_state_set_kb(state); | ||
| 62 | dprint("layer_state: "); | 74 | dprint("layer_state: "); |
| 63 | layer_debug(); dprint(" to "); | 75 | layer_debug(); dprint(" to "); |
| 64 | layer_state = state; | 76 | layer_state = state; |
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h index 025cf5420..d89ed6e5c 100644 --- a/tmk_core/common/action_layer.h +++ b/tmk_core/common/action_layer.h | |||
| @@ -29,6 +29,9 @@ extern uint32_t default_layer_state; | |||
| 29 | void default_layer_debug(void); | 29 | void default_layer_debug(void); |
| 30 | void default_layer_set(uint32_t state); | 30 | void default_layer_set(uint32_t state); |
| 31 | 31 | ||
| 32 | __attribute__((weak)) | ||
| 33 | uint32_t default_layer_state_set_kb(uint32_t state); | ||
| 34 | |||
| 32 | #ifndef NO_ACTION_LAYER | 35 | #ifndef NO_ACTION_LAYER |
| 33 | /* bitwise operation */ | 36 | /* bitwise operation */ |
| 34 | void default_layer_or(uint32_t state); | 37 | void default_layer_or(uint32_t state); |
| @@ -69,6 +72,8 @@ void layer_xor(uint32_t state); | |||
| 69 | #define layer_xor(state) | 72 | #define layer_xor(state) |
| 70 | #define layer_debug() | 73 | #define layer_debug() |
| 71 | 74 | ||
| 75 | __attribute__((weak)) | ||
| 76 | uint32_t layer_state_set_kb(uint32_t state); | ||
| 72 | #endif | 77 | #endif |
| 73 | 78 | ||
| 74 | /* pressed actions cache */ | 79 | /* pressed actions cache */ |
diff --git a/tmk_core/common/action_macro.h b/tmk_core/common/action_macro.h index aedc32ec6..f373f5068 100644 --- a/tmk_core/common/action_macro.h +++ b/tmk_core/common/action_macro.h | |||
| @@ -20,11 +20,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | #include "progmem.h" | 20 | #include "progmem.h" |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | #define MACRO_NONE 0 | 23 | |
| 24 | typedef uint8_t macro_t; | ||
| 25 | |||
| 26 | #define MACRO_NONE (macro_t*)0 | ||
| 24 | #define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; }) | 27 | #define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; }) |
| 25 | #define MACRO_GET(p) pgm_read_byte(p) | 28 | #define MACRO_GET(p) pgm_read_byte(p) |
| 26 | 29 | ||
| 27 | typedef uint8_t macro_t; | 30 | // Sends press when the macro key is pressed, release when release, or tap_macro when the key has been tapped |
| 31 | #define MACRO_TAP_HOLD(record, press, release, tap_macro) ( ((record)->event.pressed) ? \ | ||
| 32 | ( ((record)->tap.count <= 0 || (record)->tap.interrupted) ? (press) : MACRO_NONE ) : \ | ||
| 33 | ( ((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (tap_macro) : (release) ) ) | ||
| 34 | |||
| 35 | // Holds down the modifier mod when the macro key is held, or sends macro instead when tapped | ||
| 36 | #define MACRO_TAP_HOLD_MOD(record, macro, mod) MACRO_TAP_HOLD(record, (MACRO(D(mod), END)), MACRO(U(mod), END), macro) | ||
| 37 | |||
| 38 | // Holds down the modifier mod when the macro key is held, or pressed a shifted key when tapped (eg: shift+3 for #) | ||
| 39 | #define MACRO_TAP_SHFT_KEY_HOLD_MOD(record, key, mod) MACRO_TAP_HOLD_MOD(record, (MACRO(I(10), D(LSFT), T(key), U(LSFT), END)), mod) | ||
| 40 | |||
| 41 | |||
| 42 | // Momentary switch layer when held, sends macro if tapped | ||
| 43 | #define MACRO_TAP_HOLD_LAYER(record, macro, layer) ( ((record)->event.pressed) ? \ | ||
| 44 | ( ((record)->tap.count <= 0 || (record)->tap.interrupted) ? ({layer_on((layer)); MACRO_NONE; }) : MACRO_NONE ) : \ | ||
| 45 | ( ((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (macro) : ({layer_off((layer)); MACRO_NONE; }) ) ) | ||
| 46 | |||
| 47 | // Momentary switch layer when held, presses a shifted key when tapped (eg: shift+3 for #) | ||
| 48 | #define MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, key, layer) MACRO_TAP_HOLD_LAYER(record, MACRO(I(10), D(LSFT), T(key), U(LSFT), END), layer) | ||
| 49 | |||
| 28 | 50 | ||
| 29 | 51 | ||
| 30 | #ifndef NO_ACTION_MACRO | 52 | #ifndef NO_ACTION_MACRO |
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c index e16e11be7..bd9a69ae0 100644 --- a/tmk_core/common/action_tapping.c +++ b/tmk_core/common/action_tapping.c | |||
| @@ -228,6 +228,7 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 228 | if (WITHIN_TAPPING_TERM(event)) { | 228 | if (WITHIN_TAPPING_TERM(event)) { |
| 229 | if (event.pressed) { | 229 | if (event.pressed) { |
| 230 | if (IS_TAPPING_KEY(event.key)) { | 230 | if (IS_TAPPING_KEY(event.key)) { |
| 231 | #ifndef TAPPING_FORCE_HOLD | ||
| 231 | if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) { | 232 | if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) { |
| 232 | // sequential tap. | 233 | // sequential tap. |
| 233 | keyp->tap = tapping_key.tap; | 234 | keyp->tap = tapping_key.tap; |
| @@ -237,11 +238,11 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 237 | tapping_key = *keyp; | 238 | tapping_key = *keyp; |
| 238 | debug_tapping_key(); | 239 | debug_tapping_key(); |
| 239 | return true; | 240 | return true; |
| 240 | } else { | ||
| 241 | // FIX: start new tap again | ||
| 242 | tapping_key = *keyp; | ||
| 243 | return true; | ||
| 244 | } | 241 | } |
| 242 | #endif | ||
| 243 | // FIX: start new tap again | ||
| 244 | tapping_key = *keyp; | ||
| 245 | return true; | ||
| 245 | } else if (is_tap_key(event.key)) { | 246 | } else if (is_tap_key(event.key)) { |
| 246 | // Sequential tap can be interfered with other tap key. | 247 | // Sequential tap can be interfered with other tap key. |
| 247 | debug("Tapping: Start with interfering other tap.\n"); | 248 | debug("Tapping: Start with interfering other tap.\n"); |
| @@ -257,7 +258,7 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 257 | return true; | 258 | return true; |
| 258 | } | 259 | } |
| 259 | } else { | 260 | } else { |
| 260 | if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n") {}; | 261 | if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n"); |
| 261 | process_record(keyp); | 262 | process_record(keyp); |
| 262 | return true; | 263 | return true; |
| 263 | } | 264 | } |
diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c index ad547b985..34db8d0b0 100644 --- a/tmk_core/common/avr/bootloader.c +++ b/tmk_core/common/avr/bootloader.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include <stdint.h> | 1 | #include <stdint.h> |
| 2 | #include <stdbool.h> | 2 | #include <stdbool.h> |
| 3 | #include <avr/io.h> | 3 | #include <avr/io.h> |
| 4 | #include <avr/eeprom.h> | ||
| 4 | #include <avr/interrupt.h> | 5 | #include <avr/interrupt.h> |
| 5 | #include <avr/wdt.h> | 6 | #include <avr/wdt.h> |
| 6 | #include <util/delay.h> | 7 | #include <util/delay.h> |
| @@ -89,6 +90,12 @@ void bootloader_jump(void) { | |||
| 89 | _delay_ms(5); | 90 | _delay_ms(5); |
| 90 | #endif | 91 | #endif |
| 91 | 92 | ||
| 93 | #ifdef BOOTLOADHID_BOOTLOADER | ||
| 94 | // force bootloadHID to stay in bootloader mode, so that it waits | ||
| 95 | // for a new firmware to be flashed | ||
| 96 | eeprom_write_byte((uint8_t *)1, 0x00); | ||
| 97 | #endif | ||
| 98 | |||
| 92 | // watchdog reset | 99 | // watchdog reset |
| 93 | reset_key = BOOTLOADER_RESET_KEY; | 100 | reset_key = BOOTLOADER_RESET_KEY; |
| 94 | wdt_enable(WDTO_250MS); | 101 | wdt_enable(WDTO_250MS); |
| @@ -114,6 +121,11 @@ void bootloader_jump(void) { | |||
| 114 | #endif | 121 | #endif |
| 115 | } | 122 | } |
| 116 | 123 | ||
| 124 | #ifdef __AVR_ATmega32A__ | ||
| 125 | // MCUSR is actually called MCUCSR in ATmega32A | ||
| 126 | #define MCUSR MCUCSR | ||
| 127 | #endif | ||
| 128 | |||
| 117 | /* this runs before main() */ | 129 | /* this runs before main() */ |
| 118 | void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3"))); | 130 | void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3"))); |
| 119 | void bootloader_jump_after_watchdog_reset(void) | 131 | void bootloader_jump_after_watchdog_reset(void) |
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 8a7272bbc..0c81e8361 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c | |||
| @@ -47,6 +47,7 @@ void suspend_idle(uint8_t time) | |||
| 47 | sleep_disable(); | 47 | sleep_disable(); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | #ifndef NO_SUSPEND_POWER_DOWN | ||
| 50 | /* Power down MCU with watchdog timer | 51 | /* Power down MCU with watchdog timer |
| 51 | * wdto: watchdog timer timeout defined in <avr/wdt.h> | 52 | * wdto: watchdog timer timeout defined in <avr/wdt.h> |
| 52 | * WDTO_15MS | 53 | * WDTO_15MS |
| @@ -61,6 +62,7 @@ void suspend_idle(uint8_t time) | |||
| 61 | * WDTO_8S | 62 | * WDTO_8S |
| 62 | */ | 63 | */ |
| 63 | static uint8_t wdt_timeout = 0; | 64 | static uint8_t wdt_timeout = 0; |
| 65 | |||
| 64 | static void power_down(uint8_t wdto) | 66 | static void power_down(uint8_t wdto) |
| 65 | { | 67 | { |
| 66 | #ifdef PROTOCOL_LUFA | 68 | #ifdef PROTOCOL_LUFA |
| @@ -98,19 +100,19 @@ static void power_down(uint8_t wdto) | |||
| 98 | // Disable watchdog after sleep | 100 | // Disable watchdog after sleep |
| 99 | wdt_disable(); | 101 | wdt_disable(); |
| 100 | } | 102 | } |
| 103 | #endif | ||
| 101 | 104 | ||
| 102 | void suspend_power_down(void) | 105 | void suspend_power_down(void) |
| 103 | { | 106 | { |
| 107 | #ifndef NO_SUSPEND_POWER_DOWN | ||
| 104 | power_down(WDTO_15MS); | 108 | power_down(WDTO_15MS); |
| 109 | #endif | ||
| 105 | } | 110 | } |
| 106 | 111 | ||
| 107 | __attribute__ ((weak)) void matrix_power_up(void) {} | 112 | __attribute__ ((weak)) void matrix_power_up(void) {} |
| 108 | __attribute__ ((weak)) void matrix_power_down(void) {} | 113 | __attribute__ ((weak)) void matrix_power_down(void) {} |
| 109 | bool suspend_wakeup_condition(void) | 114 | bool suspend_wakeup_condition(void) |
| 110 | { | 115 | { |
| 111 | #ifdef BACKLIGHT_ENABLE | ||
| 112 | backlight_set(0); | ||
| 113 | #endif | ||
| 114 | matrix_power_up(); | 116 | matrix_power_up(); |
| 115 | matrix_scan(); | 117 | matrix_scan(); |
| 116 | matrix_power_down(); | 118 | matrix_power_down(); |
| @@ -126,10 +128,9 @@ void suspend_wakeup_init(void) | |||
| 126 | // clear keyboard state | 128 | // clear keyboard state |
| 127 | clear_keyboard(); | 129 | clear_keyboard(); |
| 128 | #ifdef BACKLIGHT_ENABLE | 130 | #ifdef BACKLIGHT_ENABLE |
| 129 | backlight_set(0); | ||
| 130 | backlight_init(); | 131 | backlight_init(); |
| 131 | #endif | 132 | #endif |
| 132 | led_set(host_keyboard_leds()); | 133 | led_set(host_keyboard_leds()); |
| 133 | } | 134 | } |
| 134 | 135 | ||
| 135 | #ifndef NO_SUSPEND_POWER_DOWN | 136 | #ifndef NO_SUSPEND_POWER_DOWN |
diff --git a/tmk_core/common/avr/timer.c b/tmk_core/common/avr/timer.c index 292b41c3a..369015200 100644 --- a/tmk_core/common/avr/timer.c +++ b/tmk_core/common/avr/timer.c | |||
| @@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | 17 | ||
| 18 | #include <avr/io.h> | 18 | #include <avr/io.h> |
| 19 | #include <avr/interrupt.h> | 19 | #include <avr/interrupt.h> |
| 20 | #include <util/atomic.h> | ||
| 20 | #include <stdint.h> | 21 | #include <stdint.h> |
| 21 | #include "timer_avr.h" | 22 | #include "timer_avr.h" |
| 22 | #include "timer.h" | 23 | #include "timer.h" |
| @@ -24,38 +25,47 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 24 | 25 | ||
| 25 | // counter resolution 1ms | 26 | // counter resolution 1ms |
| 26 | // NOTE: union { uint32_t timer32; struct { uint16_t dummy; uint16_t timer16; }} | 27 | // NOTE: union { uint32_t timer32; struct { uint16_t dummy; uint16_t timer16; }} |
| 27 | volatile uint32_t timer_count = 0; | 28 | volatile uint32_t timer_count; |
| 28 | 29 | ||
| 29 | void timer_init(void) | 30 | void timer_init(void) |
| 30 | { | 31 | { |
| 31 | // Timer0 CTC mode | ||
| 32 | TCCR0A = 0x02; | ||
| 33 | |||
| 34 | #if TIMER_PRESCALER == 1 | 32 | #if TIMER_PRESCALER == 1 |
| 35 | TCCR0B = 0x01; | 33 | uint8_t prescaler = 0x01; |
| 36 | #elif TIMER_PRESCALER == 8 | 34 | #elif TIMER_PRESCALER == 8 |
| 37 | TCCR0B = 0x02; | 35 | uint8_t prescaler = 0x02; |
| 38 | #elif TIMER_PRESCALER == 64 | 36 | #elif TIMER_PRESCALER == 64 |
| 39 | TCCR0B = 0x03; | 37 | uint8_t prescaler = 0x03; |
| 40 | #elif TIMER_PRESCALER == 256 | 38 | #elif TIMER_PRESCALER == 256 |
| 41 | TCCR0B = 0x04; | 39 | uint8_t prescaler = 0x04; |
| 42 | #elif TIMER_PRESCALER == 1024 | 40 | #elif TIMER_PRESCALER == 1024 |
| 43 | TCCR0B = 0x05; | 41 | uint8_t prescaler = 0x05; |
| 44 | #else | 42 | #else |
| 45 | # error "Timer prescaler value is NOT vaild." | 43 | # error "Timer prescaler value is NOT vaild." |
| 46 | #endif | 44 | #endif |
| 47 | 45 | ||
| 46 | #ifndef __AVR_ATmega32A__ | ||
| 47 | // Timer0 CTC mode | ||
| 48 | TCCR0A = 0x02; | ||
| 49 | |||
| 50 | TCCR0B = prescaler; | ||
| 51 | |||
| 48 | OCR0A = TIMER_RAW_TOP; | 52 | OCR0A = TIMER_RAW_TOP; |
| 49 | TIMSK0 = (1<<OCIE0A); | 53 | TIMSK0 = (1<<OCIE0A); |
| 54 | #else | ||
| 55 | // Timer0 CTC mode | ||
| 56 | TCCR0 = (1 << WGM01) | prescaler; | ||
| 57 | |||
| 58 | OCR0 = TIMER_RAW_TOP; | ||
| 59 | TIMSK = (1 << OCIE0); | ||
| 60 | #endif | ||
| 50 | } | 61 | } |
| 51 | 62 | ||
| 52 | inline | 63 | inline |
| 53 | void timer_clear(void) | 64 | void timer_clear(void) |
| 54 | { | 65 | { |
| 55 | uint8_t sreg = SREG; | 66 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 56 | cli(); | ||
| 57 | timer_count = 0; | 67 | timer_count = 0; |
| 58 | SREG = sreg; | 68 | } |
| 59 | } | 69 | } |
| 60 | 70 | ||
| 61 | inline | 71 | inline |
| @@ -63,10 +73,9 @@ uint16_t timer_read(void) | |||
| 63 | { | 73 | { |
| 64 | uint32_t t; | 74 | uint32_t t; |
| 65 | 75 | ||
| 66 | uint8_t sreg = SREG; | 76 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 67 | cli(); | 77 | t = timer_count; |
| 68 | t = timer_count; | 78 | } |
| 69 | SREG = sreg; | ||
| 70 | 79 | ||
| 71 | return (t & 0xFFFF); | 80 | return (t & 0xFFFF); |
| 72 | } | 81 | } |
| @@ -76,10 +85,9 @@ uint32_t timer_read32(void) | |||
| 76 | { | 85 | { |
| 77 | uint32_t t; | 86 | uint32_t t; |
| 78 | 87 | ||
| 79 | uint8_t sreg = SREG; | 88 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 80 | cli(); | 89 | t = timer_count; |
| 81 | t = timer_count; | 90 | } |
| 82 | SREG = sreg; | ||
| 83 | 91 | ||
| 84 | return t; | 92 | return t; |
| 85 | } | 93 | } |
| @@ -89,10 +97,9 @@ uint16_t timer_elapsed(uint16_t last) | |||
| 89 | { | 97 | { |
| 90 | uint32_t t; | 98 | uint32_t t; |
| 91 | 99 | ||
| 92 | uint8_t sreg = SREG; | 100 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 93 | cli(); | 101 | t = timer_count; |
| 94 | t = timer_count; | 102 | } |
| 95 | SREG = sreg; | ||
| 96 | 103 | ||
| 97 | return TIMER_DIFF_16((t & 0xFFFF), last); | 104 | return TIMER_DIFF_16((t & 0xFFFF), last); |
| 98 | } | 105 | } |
| @@ -102,16 +109,20 @@ uint32_t timer_elapsed32(uint32_t last) | |||
| 102 | { | 109 | { |
| 103 | uint32_t t; | 110 | uint32_t t; |
| 104 | 111 | ||
| 105 | uint8_t sreg = SREG; | 112 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 106 | cli(); | 113 | t = timer_count; |
| 107 | t = timer_count; | 114 | } |
| 108 | SREG = sreg; | ||
| 109 | 115 | ||
| 110 | return TIMER_DIFF_32(t, last); | 116 | return TIMER_DIFF_32(t, last); |
| 111 | } | 117 | } |
| 112 | 118 | ||
| 113 | // excecuted once per 1ms.(excess for just timer count?) | 119 | // excecuted once per 1ms.(excess for just timer count?) |
| 114 | ISR(TIMER0_COMPA_vect) | 120 | #ifndef __AVR_ATmega32A__ |
| 121 | #define TIMER_INTERRUPT_VECTOR TIMER0_COMPA_vect | ||
| 122 | #else | ||
| 123 | #define TIMER_INTERRUPT_VECTOR TIMER0_COMP_vect | ||
| 124 | #endif | ||
| 125 | ISR(TIMER_INTERRUPT_VECTOR, ISR_NOBLOCK) | ||
| 115 | { | 126 | { |
| 116 | timer_count++; | 127 | timer_count++; |
| 117 | } | 128 | } |
diff --git a/tmk_core/common/backlight.c b/tmk_core/common/backlight.c index c9e8fd3fd..0e0ad2d15 100644 --- a/tmk_core/common/backlight.c +++ b/tmk_core/common/backlight.c | |||
| @@ -36,9 +36,9 @@ void backlight_increase(void) | |||
| 36 | if(backlight_config.level < BACKLIGHT_LEVELS) | 36 | if(backlight_config.level < BACKLIGHT_LEVELS) |
| 37 | { | 37 | { |
| 38 | backlight_config.level++; | 38 | backlight_config.level++; |
| 39 | backlight_config.enable = 1; | ||
| 40 | eeconfig_update_backlight(backlight_config.raw); | ||
| 41 | } | 39 | } |
| 40 | backlight_config.enable = 1; | ||
| 41 | eeconfig_update_backlight(backlight_config.raw); | ||
| 42 | dprintf("backlight increase: %u\n", backlight_config.level); | 42 | dprintf("backlight increase: %u\n", backlight_config.level); |
| 43 | backlight_set(backlight_config.level); | 43 | backlight_set(backlight_config.level); |
| 44 | } | 44 | } |
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index f3e1bf623..f79d5a257 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c | |||
| @@ -235,8 +235,11 @@ static void print_status(void) | |||
| 235 | print("\n\t- Status -\n"); | 235 | print("\n\t- Status -\n"); |
| 236 | 236 | ||
| 237 | print_val_hex8(host_keyboard_leds()); | 237 | print_val_hex8(host_keyboard_leds()); |
| 238 | #ifndef PROTOCOL_VUSB | ||
| 239 | // these aren't set on the V-USB protocol, so we just ignore them for now | ||
| 238 | print_val_hex8(keyboard_protocol); | 240 | print_val_hex8(keyboard_protocol); |
| 239 | print_val_hex8(keyboard_idle); | 241 | print_val_hex8(keyboard_idle); |
| 242 | #endif | ||
| 240 | #ifdef NKRO_ENABLE | 243 | #ifdef NKRO_ENABLE |
| 241 | print_val_hex8(keymap_config.nkro); | 244 | print_val_hex8(keymap_config.nkro); |
| 242 | #endif | 245 | #endif |
| @@ -379,11 +382,11 @@ static bool command_common(uint8_t code) | |||
| 379 | debug_enable = !debug_enable; | 382 | debug_enable = !debug_enable; |
| 380 | if (debug_enable) { | 383 | if (debug_enable) { |
| 381 | print("\ndebug: on\n"); | 384 | print("\ndebug: on\n"); |
| 382 | debug_matrix = true; | ||
| 383 | debug_keyboard = true; | ||
| 384 | debug_mouse = true; | ||
| 385 | } else { | 385 | } else { |
| 386 | print("\ndebug: off\n"); | 386 | print("\ndebug: off\n"); |
| 387 | debug_matrix = false; | ||
| 388 | debug_keyboard = false; | ||
| 389 | debug_mouse = false; | ||
| 387 | } | 390 | } |
| 388 | break; | 391 | break; |
| 389 | 392 | ||
diff --git a/tmk_core/common/host_driver.h b/tmk_core/common/host_driver.h index edb9e5dd9..588d1c0be 100644 --- a/tmk_core/common/host_driver.h +++ b/tmk_core/common/host_driver.h | |||
| @@ -20,7 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | 20 | ||
| 21 | #include <stdint.h> | 21 | #include <stdint.h> |
| 22 | #include "report.h" | 22 | #include "report.h" |
| 23 | 23 | #ifdef MIDI_ENABLE | |
| 24 | #include "midi.h" | ||
| 25 | #endif | ||
| 24 | 26 | ||
| 25 | typedef struct { | 27 | typedef struct { |
| 26 | uint8_t (*keyboard_leds)(void); | 28 | uint8_t (*keyboard_leds)(void); |
| @@ -28,6 +30,11 @@ typedef struct { | |||
| 28 | void (*send_mouse)(report_mouse_t *); | 30 | void (*send_mouse)(report_mouse_t *); |
| 29 | void (*send_system)(uint16_t); | 31 | void (*send_system)(uint16_t); |
| 30 | void (*send_consumer)(uint16_t); | 32 | void (*send_consumer)(uint16_t); |
| 33 | #ifdef MIDI_ENABLE | ||
| 34 | void (*usb_send_func)(MidiDevice *, uint16_t, uint8_t, uint8_t, uint8_t); | ||
| 35 | void (*usb_get_midi)(MidiDevice *); | ||
| 36 | void (*midi_usb_init)(MidiDevice *); | ||
| 37 | #endif | ||
| 31 | } host_driver_t; | 38 | } host_driver_t; |
| 32 | 39 | ||
| 33 | #endif | 40 | #endif |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 371d93f3e..eac1f1dd8 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -14,6 +14,7 @@ GNU General Public License for more details. | |||
| 14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | |||
| 17 | #include <stdint.h> | 18 | #include <stdint.h> |
| 18 | #include "keyboard.h" | 19 | #include "keyboard.h" |
| 19 | #include "matrix.h" | 20 | #include "matrix.h" |
| @@ -50,6 +51,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 50 | #ifdef RGBLIGHT_ENABLE | 51 | #ifdef RGBLIGHT_ENABLE |
| 51 | # include "rgblight.h" | 52 | # include "rgblight.h" |
| 52 | #endif | 53 | #endif |
| 54 | #ifdef FAUXCLICKY_ENABLE | ||
| 55 | # include "fauxclicky.h" | ||
| 56 | #endif | ||
| 53 | #ifdef SERIAL_LINK_ENABLE | 57 | #ifdef SERIAL_LINK_ENABLE |
| 54 | # include "serial_link/system/serial_link.h" | 58 | # include "serial_link/system/serial_link.h" |
| 55 | #endif | 59 | #endif |
| @@ -107,6 +111,9 @@ void keyboard_init(void) { | |||
| 107 | #ifdef RGBLIGHT_ENABLE | 111 | #ifdef RGBLIGHT_ENABLE |
| 108 | rgblight_init(); | 112 | rgblight_init(); |
| 109 | #endif | 113 | #endif |
| 114 | #ifdef FAUXCLICKY_ENABLE | ||
| 115 | fauxclicky_init(); | ||
| 116 | #endif | ||
| 110 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) | 117 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) |
| 111 | keymap_config.nkro = 1; | 118 | keymap_config.nkro = 1; |
| 112 | #endif | 119 | #endif |
| @@ -188,7 +195,7 @@ MATRIX_LOOP_END: | |||
| 188 | #endif | 195 | #endif |
| 189 | 196 | ||
| 190 | #ifdef VISUALIZER_ENABLE | 197 | #ifdef VISUALIZER_ENABLE |
| 191 | visualizer_update(default_layer_state, layer_state, host_keyboard_leds()); | 198 | visualizer_update(default_layer_state, layer_state, visualizer_get_mods(), host_keyboard_leds()); |
| 192 | #endif | 199 | #endif |
| 193 | 200 | ||
| 194 | // update LED | 201 | // update LED |
diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index 2f208c54e..54e9c322c 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h | |||
| @@ -85,7 +85,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 85 | #define KC_LCAP KC_LOCKING_CAPS | 85 | #define KC_LCAP KC_LOCKING_CAPS |
| 86 | #define KC_LNUM KC_LOCKING_NUM | 86 | #define KC_LNUM KC_LOCKING_NUM |
| 87 | #define KC_LSCR KC_LOCKING_SCROLL | 87 | #define KC_LSCR KC_LOCKING_SCROLL |
| 88 | #define KC_ERAS KC_ALT_ERASE, | 88 | #define KC_ERAS KC_ALT_ERASE |
| 89 | #define KC_CLR KC_CLEAR | 89 | #define KC_CLR KC_CLEAR |
| 90 | /* Japanese specific */ | 90 | /* Japanese specific */ |
| 91 | #define KC_ZKHK KC_GRAVE | 91 | #define KC_ZKHK KC_GRAVE |
diff --git a/tmk_core/common/matrix.h b/tmk_core/common/matrix.h index cee3593ee..2543f5abc 100644 --- a/tmk_core/common/matrix.h +++ b/tmk_core/common/matrix.h | |||
| @@ -50,7 +50,7 @@ void matrix_init(void); | |||
| 50 | uint8_t matrix_scan(void); | 50 | uint8_t matrix_scan(void); |
| 51 | /* whether modified from previous scan. used after matrix_scan. */ | 51 | /* whether modified from previous scan. used after matrix_scan. */ |
| 52 | bool matrix_is_modified(void) __attribute__ ((deprecated)); | 52 | bool matrix_is_modified(void) __attribute__ ((deprecated)); |
| 53 | /* whether a swtich is on */ | 53 | /* whether a switch is on */ |
| 54 | bool matrix_is_on(uint8_t row, uint8_t col); | 54 | bool matrix_is_on(uint8_t row, uint8_t col); |
| 55 | /* matrix state on row */ | 55 | /* matrix state on row */ |
| 56 | matrix_row_t matrix_get_row(uint8_t row); | 56 | matrix_row_t matrix_get_row(uint8_t row); |
diff --git a/tmk_core/common/raw_hid.h b/tmk_core/common/raw_hid.h new file mode 100644 index 000000000..86da02fd1 --- /dev/null +++ b/tmk_core/common/raw_hid.h | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #ifndef _RAW_HID_H_ | ||
| 2 | #define _RAW_HID_H_ | ||
| 3 | |||
| 4 | void raw_hid_receive( uint8_t *data, uint8_t length ); | ||
| 5 | |||
| 6 | void raw_hid_send( uint8_t *data, uint8_t length ); | ||
| 7 | |||
| 8 | #endif | ||
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index 0c799eca3..8fb28b6ce 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h | |||
| @@ -134,13 +134,6 @@ typedef union { | |||
| 134 | } nkro; | 134 | } nkro; |
| 135 | #endif | 135 | #endif |
| 136 | } __attribute__ ((packed)) report_keyboard_t; | 136 | } __attribute__ ((packed)) report_keyboard_t; |
| 137 | /* | ||
| 138 | typedef struct { | ||
| 139 | uint8_t mods; | ||
| 140 | uint8_t reserved; | ||
| 141 | uint8_t keys[REPORT_KEYS]; | ||
| 142 | } __attribute__ ((packed)) report_keyboard_t; | ||
| 143 | */ | ||
| 144 | 137 | ||
| 145 | typedef struct { | 138 | typedef struct { |
| 146 | uint8_t buttons; | 139 | uint8_t buttons; |
