forked from PAWPAW-Mirror/lib_xua
Removed "0 means all" logic throughout
This commit is contained in:
@@ -41,44 +41,20 @@ XUD_Result_t HidInterfaceClassRequests(
|
|||||||
|
|
||||||
unsigned HidIsSetIdleSilenced( const unsigned id )
|
unsigned HidIsSetIdleSilenced( const unsigned id )
|
||||||
{
|
{
|
||||||
unsigned currentTime;
|
unsigned isSilenced = hidIsIdleActive( id );
|
||||||
// Use inline assembly to access the time without creating a side-effect.
|
|
||||||
// The mapper complains if the time comes from an XC timer because this function is called in the guard of a select case.
|
|
||||||
// Appearently the use of a timer creates a side-effect that prohibits the operation of the select functionality.
|
|
||||||
asm volatile( "gettime %0" : "=r" ( currentTime ));
|
|
||||||
unsigned nextTime = hidGetNextReportTime( id );
|
|
||||||
unsigned isSilenced = timeafter(nextTime, currentTime);
|
|
||||||
if (!isSilenced)
|
|
||||||
{
|
|
||||||
debug_printf("%d\n", nextTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calling hidGetReportPeriod with an ID of 0 is meaningless if we are using
|
if( !isSilenced ) {
|
||||||
// report IDs.
|
unsigned currentTime;
|
||||||
if (!hidIsReportIdInUse() || (id != 0))
|
// Use inline assembly to access the time without creating a side-effect.
|
||||||
{
|
// The mapper complains if the time comes from an XC timer because this function is called in the guard of a select case.
|
||||||
isSilenced |= ( 0U == hidGetReportPeriod( id ) );
|
// Appearently the use of a timer creates a side-effect that prohibits the operation of the select functionality.
|
||||||
}
|
asm volatile( "gettime %0" : "=r" ( currentTime ));
|
||||||
|
isSilenced = ( 0U == hidGetReportPeriod( id ) || ( timeafter( hidGetNextReportTime( id ), currentTime )));
|
||||||
|
}
|
||||||
|
|
||||||
return isSilenced;
|
return isSilenced;
|
||||||
}
|
}
|
||||||
|
|
||||||
//unsigned HidIsSetIdleSilenced( const unsigned id )
|
|
||||||
//{
|
|
||||||
// unsigned isSilenced = hidIsIdleActive( id );
|
|
||||||
//
|
|
||||||
// if( !isSilenced ) {
|
|
||||||
// unsigned currentTime;
|
|
||||||
// // Use inline assembly to access the time without creating a side-effect.
|
|
||||||
// // The mapper complains if the time comes from an XC timer because this function is called in the guard of a select case.
|
|
||||||
// // Appearently the use of a timer creates a side-effect that prohibits the operation of the select functionality.
|
|
||||||
// asm volatile( "gettime %0" : "=r" ( currentTime ));
|
|
||||||
// isSilenced = ( 0U == hidGetReportPeriod( id ) || ( timeafter( hidGetNextReportTime( id ), currentTime )));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return isSilenced;
|
|
||||||
//}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Calculate the timer value for sending the next HID Report.
|
* \brief Calculate the timer value for sending the next HID Report.
|
||||||
*
|
*
|
||||||
@@ -176,7 +152,7 @@ static void HidUpdateReportPeriod( unsigned reportId, unsigned reportDuration )
|
|||||||
hidSetNextReportTime( reportId, nextReportTime );
|
hidSetNextReportTime( reportId, nextReportTime );
|
||||||
currentPeriod = reportDuration * MS_IN_TICKS;
|
currentPeriod = reportDuration * MS_IN_TICKS;
|
||||||
} else {
|
} else {
|
||||||
currentPeriod = ENDPOINT_INT_INTERVAL_IN_HID * MS_IN_TICKS;
|
currentPeriod = ENDPOINT_INT_INTERVAL_IN_HID * MS_IN_TICKS * HID_REPORT_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
hidSetReportPeriod( reportId, currentPeriod );
|
hidSetReportPeriod( reportId, currentPeriod );
|
||||||
|
|||||||
@@ -136,6 +136,9 @@ static unsigned hidGetUsagePage( const unsigned id );
|
|||||||
*/
|
*/
|
||||||
static size_t hidTranslateItem( const USB_HID_Short_Item_t* inPtr, unsigned char** outPtrPtr );
|
static size_t hidTranslateItem( const USB_HID_Short_Item_t* inPtr, unsigned char** outPtrPtr );
|
||||||
|
|
||||||
|
unsigned hidAreReportIdsInUse ( void ) {
|
||||||
|
return !hidIsReportIdInUse(0U);
|
||||||
|
}
|
||||||
|
|
||||||
void hidCalcNextReportTime( const unsigned id )
|
void hidCalcNextReportTime( const unsigned id )
|
||||||
{
|
{
|
||||||
@@ -213,35 +216,19 @@ static unsigned hidGetItemType( const unsigned char header )
|
|||||||
return bType;
|
return bType;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned hidGetNextReportTime( const unsigned id )
|
unsigned hidGetNextReportTime( const unsigned id ) {
|
||||||
{
|
|
||||||
swlock_acquire(&hidStaticVarLock);
|
swlock_acquire(&hidStaticVarLock);
|
||||||
unsigned retVal = (id == 0U) ? s_hidNextReportTime[0] : 0U;
|
unsigned retVal = 0U;
|
||||||
|
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
for ( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
||||||
if (id == 0U)
|
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
||||||
{
|
|
||||||
unsigned nextReportTime = s_hidNextReportTime[ idx ];
|
|
||||||
retVal = (nextReportTime < retVal) ? nextReportTime : retVal;
|
|
||||||
} else if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
|
||||||
retVal = s_hidNextReportTime[ idx ];
|
retVal = s_hidNextReportTime[ idx ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
swlock_release(&hidStaticVarLock);
|
swlock_release(&hidStaticVarLock);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
//unsigned hidGetNextReportTime( const unsigned id ) {
|
|
||||||
// unsigned retVal = 0U;
|
|
||||||
//
|
|
||||||
// for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
|
||||||
// if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
|
||||||
// retVal = s_hidNextReportTime[ idx ];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return retVal;
|
|
||||||
//}
|
|
||||||
|
|
||||||
unsigned char* hidGetReportDescriptor( void )
|
unsigned char* hidGetReportDescriptor( void )
|
||||||
{
|
{
|
||||||
unsigned char* retVal = NULL;
|
unsigned char* retVal = NULL;
|
||||||
@@ -398,9 +385,7 @@ unsigned hidIsChangePending( const unsigned id )
|
|||||||
swlock_acquire(&hidStaticVarLock);
|
swlock_acquire(&hidStaticVarLock);
|
||||||
|
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
||||||
if( id == 0U && s_hidChangePending[ idx ] != 0U ) {
|
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
||||||
retVal = 1;
|
|
||||||
} else if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
|
||||||
retVal = ( s_hidChangePending[ idx ] != 0U );
|
retVal = ( s_hidChangePending[ idx ] != 0U );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -413,15 +398,10 @@ unsigned hidIsChangePending( const unsigned id )
|
|||||||
unsigned hidIsIdleActive( const unsigned id )
|
unsigned hidIsIdleActive( const unsigned id )
|
||||||
{
|
{
|
||||||
unsigned retVal = 0U;
|
unsigned retVal = 0U;
|
||||||
if( 0U == id ) {
|
|
||||||
retVal = 1U;
|
|
||||||
}
|
|
||||||
|
|
||||||
swlock_acquire(&hidStaticVarLock);
|
swlock_acquire(&hidStaticVarLock);
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
||||||
if( id == 0U ) {
|
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
||||||
retVal &= ( s_hidIdleActive[ idx ] != 0U );
|
|
||||||
} else if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
|
||||||
retVal = ( s_hidIdleActive[ idx ] != 0U );
|
retVal = ( s_hidIdleActive[ idx ] != 0U );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -438,16 +418,6 @@ unsigned hidIsReportDescriptorPrepared( void )
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned hidIsReportIdInUse ( void ) {
|
|
||||||
swlock_acquire(&hidStaticVarLock);
|
|
||||||
if ( hidGetElementReportId( hidReports[ 0 ]->location ) ) {
|
|
||||||
swlock_release(&hidStaticVarLock);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
swlock_release(&hidStaticVarLock);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned hidIsReportIdValid ( unsigned id ) {
|
unsigned hidIsReportIdValid ( unsigned id ) {
|
||||||
size_t retVal = 0;
|
size_t retVal = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user