# HG changeset patch # User Jacob Alexander # Date 1411179097 25200 # Node ID 78e89528487fc53bbfc744e59f39a695e4c246be # Parent 8ceb1a0582ee32c13e56a51a28d8ff2bf29419f4 Fixing USB send rate. - Only send USB events when something changes (rather than every ms) diff -r 8ceb1a0582ee -r 78e89528487f Macro/PartialMap/kll.h --- a/Macro/PartialMap/kll.h Tue Sep 16 23:29:21 2014 -0700 +++ b/Macro/PartialMap/kll.h Fri Sep 19 19:11:37 2014 -0700 @@ -64,7 +64,7 @@ // Default Args (always sent): key state/analog of last key // Combo Length of 0 signifies end of sequence // -// ResultMacro.guide -> [|||||...||...|0] +// ResultMacro.guide -> [|||||...||...|0] // // ResultMacroRecord.pos -> // ResultMacroRecord.state -> diff -r 8ceb1a0582ee -r 78e89528487f Output/pjrcUSB/output_com.c --- a/Output/pjrcUSB/output_com.c Tue Sep 16 23:29:21 2014 -0700 +++ b/Output/pjrcUSB/output_com.c Fri Sep 19 19:11:37 2014 -0700 @@ -89,6 +89,10 @@ // 1 - NKRO Mode volatile uint8_t USBKeys_Protocol = 1; +// Indicate if USB should send update +// OS only needs update if there has been a change in state + uint8_t USBKeys_Changed = 0; + // the idle configuration, how often we send the report to the // host (ms * 4) even when it hasn't changed uint8_t USBKeys_Idle_Config = 125; @@ -111,6 +115,10 @@ } // TODO Analog inputs + // Only indicate USB has changed if either a press or release has occured + if ( state == 0x01 || state == 0x03 ) + USBKeys_Changed = 1; + // Only send keypresses if press or hold state if ( stateType == 0x00 && state == 0x03 ) // Release state return; @@ -164,6 +172,17 @@ // USB Data Send inline void Output_send(void) { + // Don't send update if USB has not changed + if ( !USBKeys_Changed ) + { + // Clear modifiers and keys + USBKeys_Modifiers = 0; + USBKeys_Sent = 0; + + return; + } + USBKeys_Changed = 0; + // TODO undo potentially old keys for ( uint8_t c = USBKeys_Sent; c < USBKeys_MaxSize; c++ ) USBKeys_Array[c] = 0; diff -r 8ceb1a0582ee -r 78e89528487f Output/pjrcUSB/output_com.h --- a/Output/pjrcUSB/output_com.h Tue Sep 16 23:29:21 2014 -0700 +++ b/Output/pjrcUSB/output_com.h Fri Sep 19 19:11:37 2014 -0700 @@ -47,6 +47,7 @@ extern uint8_t USBKeys_Array[USB_MAX_KEY_SEND]; extern uint8_t USBKeys_Sent; extern volatile uint8_t USBKeys_LEDs; +extern uint8_t USBKeys_Changed; static const uint8_t USBKeys_MaxSize = USB_MAX_KEY_SEND; extern volatile uint8_t USBKeys_Protocol; // 0 - Boot Mode, 1 - NKRO Mode