Skip to content

Commit e92e957

Browse files
committed
Optimize macro recording and playback, record keyboard reports only on keypress, recreate the releases and have fixed delays on playback
1 parent 0c8185e commit e92e957

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Amiga500-USB-Keyboard-Leonardo.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
#define MAX_MACRO_LENGTH 24 // Maximum number of key reports in a macro
2525
#define MACRO_SLOTS 5
26-
#define MACRO_DELAY 10 //ms
26+
#define MACRO_DELAY 30 //ms between reports in macro playback
27+
#define MACRO_DELAY_RELESE 10 //ms between key press and release in macro playback
2728
#define PERSISTENT_MACRO 1 // Save macros to EEPROM
2829

2930
#if PERSISTENT_MACRO
@@ -500,7 +501,6 @@ void keyRelease(uint8_t keyCode)
500501
#if DEBUG_MODE
501502
printKeyReport();
502503
#endif
503-
record_last_report();
504504
}
505505

506506
void keystroke(uint8_t keyCode, uint8_t modifiers)
@@ -553,7 +553,6 @@ void stopRecording()
553553
Serial.println("Stop recording macro");
554554
#endif
555555
noInterrupts(); // Disable interrupts to enter critical section
556-
macros[currentMacroSlot].length = macroIndex;
557556
recording = false;
558557
recordingSlot = false;
559558
// Save macros to EEPROM
@@ -611,6 +610,9 @@ void playMacro()
611610
{
612611
noInterrupts(); // Disable interrupts to enter critical section
613612
HID().SendReport(2, &macros[currentMacroSlot].keyReports[macroIndex], sizeof(KeyReport));
613+
//wait 10 ms an release all keys
614+
delay(MACRO_DELAY_RELESE);
615+
Keyboard.releaseAll();
614616
macroIndex++;
615617
lastKeyPressTime = millis();
616618
interrupts(); // Enable interrupts to exit critical section

0 commit comments

Comments
 (0)