diff options
Diffstat (limited to 'tmk_core/common')
| -rw-r--r-- | tmk_core/common/action.c | 16 | ||||
| -rw-r--r-- | tmk_core/common/action_code.h | 10 | ||||
| -rw-r--r-- | tmk_core/common/action_macro.h | 26 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.c | 1 | ||||
| -rw-r--r-- | tmk_core/common/matrix.h | 2 | ||||
| -rw-r--r-- | tmk_core/common/report.h | 7 |
6 files changed, 41 insertions, 21 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index d485b46c7..f03670a7f 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -49,6 +49,13 @@ void action_exec(keyevent_t event) | |||
| 49 | 49 | ||
| 50 | keyrecord_t record = { .event = event }; | 50 | keyrecord_t record = { .event = event }; |
| 51 | 51 | ||
| 52 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | ||
| 53 | if (has_oneshot_layer_timed_out()) { | ||
| 54 | dprintf("Oneshot layer: timeout\n"); | ||
| 55 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); | ||
| 56 | } | ||
| 57 | #endif | ||
| 58 | |||
| 52 | #ifndef NO_ACTION_TAPPING | 59 | #ifndef NO_ACTION_TAPPING |
| 53 | action_tapping_process(record); | 60 | action_tapping_process(record); |
| 54 | #else | 61 | #else |
| @@ -100,7 +107,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 100 | return true; | 107 | return true; |
| 101 | } | 108 | } |
| 102 | 109 | ||
| 103 | void process_record(keyrecord_t *record) | 110 | void process_record(keyrecord_t *record) |
| 104 | { | 111 | { |
| 105 | if (IS_NOEVENT(record->event)) { return; } | 112 | if (IS_NOEVENT(record->event)) { return; } |
| 106 | 113 | ||
| @@ -126,13 +133,6 @@ void process_action(keyrecord_t *record, action_t action) | |||
| 126 | uint8_t tap_count = record->tap.count; | 133 | uint8_t tap_count = record->tap.count; |
| 127 | #endif | 134 | #endif |
| 128 | 135 | ||
| 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) { | 136 | if (event.pressed) { |
| 137 | // clear the potential weak mods left by previously pressed keys | 137 | // clear the potential weak mods left by previously pressed keys |
| 138 | clear_weak_mods(); | 138 | 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_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/keyboard.c b/tmk_core/common/keyboard.c index 765350792..3aa82231b 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" |
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/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; |
