summaryrefslogtreecommitdiff
path: root/quantum/dynamic_macro.h
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-05-04 15:07:04 -0400
committerGitHub <noreply@github.com>2017-05-04 15:07:04 -0400
commit3af95509b5aa61113c1776751d9a0b9b5eef3c50 (patch)
tree73bf93013fd8aa3434f045dbcce38b0aaee4512d /quantum/dynamic_macro.h
parent425f0a768b5b8389d88bd187d9029171f392b883 (diff)
parent436d661775178fb62b46afdc3d755fdb413dcb35 (diff)
downloadqmk_firmware-3af95509b5aa61113c1776751d9a0b9b5eef3c50.tar.gz
qmk_firmware-3af95509b5aa61113c1776751d9a0b9b5eef3c50.zip
Merge pull request #1273 from Vifon/pr_1267_fix
Add DYN_REC_STOP to the dynamic macros, cleanup PR #1267
Diffstat (limited to 'quantum/dynamic_macro.h')
-rw-r--r--quantum/dynamic_macro.h27
1 files changed, 16 insertions, 11 deletions
diff --git a/quantum/dynamic_macro.h b/quantum/dynamic_macro.h
index 64093f293e..9e7845c992 100644
--- a/quantum/dynamic_macro.h
+++ b/quantum/dynamic_macro.h
@@ -40,6 +40,7 @@
enum dynamic_macro_keycodes {
DYN_REC_START1 = DYNAMIC_MACRO_RANGE,
DYN_REC_START2,
+ DYN_REC_STOP,
DYN_MACRO_PLAY1,
DYN_MACRO_PLAY2,
};
@@ -96,24 +97,29 @@ void dynamic_macro_play(
/**
* Record a single key in a dynamic macro.
*
+ * @param macro_buffer[in] The start of the used macro buffer.
* @param macro_pointer[in,out] The current buffer position.
- * @param macro_end2[in] The end of the other macro which shouldn't be overwritten.
+ * @param macro2_end[in] The last buffer element it is safe to use before overwriting the other macro.
* @param direction[in] Either +1 or -1, which way to iterate the buffer.
* @param record[in] The current keypress.
*/
void dynamic_macro_record_key(
+ keyrecord_t *macro_buffer,
keyrecord_t **macro_pointer,
- keyrecord_t *macro_end2,
+ keyrecord_t *macro2_end,
int8_t direction,
keyrecord_t *record)
{
- if (*macro_pointer + direction != macro_end2) {
+ /* If we've just started recording, ignore all the key releases. */
+ if (!record->event.pressed && *macro_pointer == macro_buffer) {
+ return;
+ }
+
+ if (*macro_pointer - direction != macro2_end) {
**macro_pointer = *record;
*macro_pointer += direction;
} else {
- /* Notify about the end of buffer. The blinks are paired
- * because they should happen on both down and up events. */
- backlight_toggle();
+ dynamic_macro_led_blink();
}
}
@@ -209,9 +215,8 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record)
} else {
/* A macro is being recorded right now. */
switch (keycode) {
- case MO(_DYN):
- /* Use the layer key used to access the macro recording as
- * a stop button. */
+ case DYN_REC_STOP:
+ /* Stop the macro recording. */
if (record->event.pressed) { /* Ignore the initial release
* just after the recoding
* starts. */
@@ -230,10 +235,10 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record)
/* Store the key in the macro buffer and process it normally. */
switch (macro_id) {
case 1:
- dynamic_macro_record_key(&macro_pointer, r_macro_end, +1, record);
+ dynamic_macro_record_key(macro_buffer, &macro_pointer, r_macro_end, +1, record);
break;
case 2:
- dynamic_macro_record_key(&macro_pointer, macro_end, -1, record);
+ dynamic_macro_record_key(r_macro_buffer, &macro_pointer, macro_end, -1, record);
break;
}
return true;