1
0
Fork 0

dynamic_macro.h: Ignore all the initial key releases

Right after the user initiates the macro recording, they usually need
to release some keys used to access the DYN_REC_START layers. It makes
sense to ignore them.

Note: The keys used to access the DYN_REC_STOP key are *not* ignored.
This commit is contained in:
Wojciech Siewierski 2017-05-03 23:47:52 +02:00
parent c8ac556e63
commit 40fe30e4d6

View file

@ -97,17 +97,24 @@ void dynamic_macro_play(
/** /**
* Record a single key in a dynamic macro. * 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_pointer[in,out] The current buffer position.
* @param macro_end2[in] The end of the other macro which shouldn't be overwritten. * @param macro_end2[in] The end of the other macro which shouldn't be overwritten.
* @param direction[in] Either +1 or -1, which way to iterate the buffer. * @param direction[in] Either +1 or -1, which way to iterate the buffer.
* @param record[in] The current keypress. * @param record[in] The current keypress.
*/ */
void dynamic_macro_record_key( void dynamic_macro_record_key(
keyrecord_t *macro_buffer,
keyrecord_t **macro_pointer, keyrecord_t **macro_pointer,
keyrecord_t *macro_end2, keyrecord_t *macro_end2,
int8_t direction, int8_t direction,
keyrecord_t *record) keyrecord_t *record)
{ {
/* If we've just started recording, ignore all the key releases. */
if (!record->event.pressed && *macro_pointer == macro_buffer) {
return;
}
if (*macro_pointer + direction != macro_end2) { if (*macro_pointer + direction != macro_end2) {
**macro_pointer = *record; **macro_pointer = *record;
*macro_pointer += direction; *macro_pointer += direction;
@ -230,10 +237,10 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record)
/* Store the key in the macro buffer and process it normally. */ /* Store the key in the macro buffer and process it normally. */
switch (macro_id) { switch (macro_id) {
case 1: 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; break;
case 2: 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; break;
} }
return true; return true;