/* Handle USB state change events, this function must be called each time the USB device state is changed.  */
void HIDKBD_StateChangeEvent(USBD_State_TypeDef oldState, USBD_State_TypeDef newState)
/* Handle USB state change events, this function must be called each time the USB device state is changed.  */
void HIDKBD_StateChangeEvent(USBD_State_TypeDef oldState, USBD_State_TypeDef newState)
{
  if ( newState == USBD_STATE_CONFIGURED )
  {
    if ( oldState != USBD_STATE_SUSPENDED )
    {
      idleRate = DEFAULT_IDLE_RATE / 4;
      QueueInit();
    }
    if ( idleRate )
    {
      USBTIMER_Start( HIDKBD_IDLE_TIMER, idleRate * 4, IdleTimeout );
    }
  }
  else if ( ( oldState == USBD_STATE_CONFIGURED ) &&
            ( newState != USBD_STATE_SUSPENDED  )    )
  {
    USBTIMER_Stop( HIDKBD_IDLE_TIMER );
  }
  else if ( newState == USBD_STATE_SUSPENDED )
  {
    USBTIMER_Stop( HIDKBD_IDLE_TIMER );
  }
}