Browse Source

Fixing USB send rate.

- Only send USB events when something changes (rather than every ms)
simple
Jacob Alexander 9 years ago
parent
commit
97b514a9d4
3 changed files with 21 additions and 1 deletions
  1. 1
    1
      Macro/PartialMap/kll.h
  2. 19
    0
      Output/pjrcUSB/output_com.c
  3. 1
    0
      Output/pjrcUSB/output_com.h

+ 1
- 1
Macro/PartialMap/kll.h View File

// Default Args (always sent): key state/analog of last key // Default Args (always sent): key state/analog of last key
// Combo Length of 0 signifies end of sequence // Combo Length of 0 signifies end of sequence
// //
// ResultMacro.guide -> [<combo length>|<capability index>|<arg1>|<argn>|<capability index>|...|<combo length>|...|0]
// ResultMacro.guide -> [<combo length>|<capability index>|<arg1>|<argn>|<capability index>|...|<combo length>|...|0]
// //
// ResultMacroRecord.pos -> <current combo position> // ResultMacroRecord.pos -> <current combo position>
// ResultMacroRecord.state -> <last key state> // ResultMacroRecord.state -> <last key state>

+ 19
- 0
Output/pjrcUSB/output_com.c View File

// 1 - NKRO Mode // 1 - NKRO Mode
volatile uint8_t USBKeys_Protocol = 1; 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 // the idle configuration, how often we send the report to the
// host (ms * 4) even when it hasn't changed // host (ms * 4) even when it hasn't changed
uint8_t USBKeys_Idle_Config = 125; uint8_t USBKeys_Idle_Config = 125;
} }


// TODO Analog inputs // 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 // Only send keypresses if press or hold state
if ( stateType == 0x00 && state == 0x03 ) // Release state if ( stateType == 0x00 && state == 0x03 ) // Release state
return; return;
// USB Data Send // USB Data Send
inline void Output_send(void) 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 // TODO undo potentially old keys
for ( uint8_t c = USBKeys_Sent; c < USBKeys_MaxSize; c++ ) for ( uint8_t c = USBKeys_Sent; c < USBKeys_MaxSize; c++ )
USBKeys_Array[c] = 0; USBKeys_Array[c] = 0;

+ 1
- 0
Output/pjrcUSB/output_com.h View File

extern uint8_t USBKeys_Array[USB_MAX_KEY_SEND]; extern uint8_t USBKeys_Array[USB_MAX_KEY_SEND];
extern uint8_t USBKeys_Sent; extern uint8_t USBKeys_Sent;
extern volatile uint8_t USBKeys_LEDs; extern volatile uint8_t USBKeys_LEDs;
extern uint8_t USBKeys_Changed;


static const uint8_t USBKeys_MaxSize = USB_MAX_KEY_SEND; static const uint8_t USBKeys_MaxSize = USB_MAX_KEY_SEND;
extern volatile uint8_t USBKeys_Protocol; // 0 - Boot Mode, 1 - NKRO Mode extern volatile uint8_t USBKeys_Protocol; // 0 - Boot Mode, 1 - NKRO Mode