MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / processAsync

Method processAsync

Engine/source/platformWin32/winDInputDevice.cpp:625–687  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

623
624//------------------------------------------------------------------------------
625bool DInputDevice::processAsync()
626{
627 DIDEVICEOBJECTDATA eventBuffer[QUEUED_BUFFER_SIZE];
628 DWORD numEvents = QUEUED_BUFFER_SIZE;
629 HRESULT result;
630
631 if ( !mDevice )
632 return false;
633
634 do
635 {
636 result = mDevice->GetDeviceData( sizeof( DIDEVICEOBJECTDATA ), eventBuffer, &numEvents, 0 );
637
638 if ( !SUCCEEDED( result ) )
639 {
640 switch ( result )
641 {
642 case DIERR_INPUTLOST:
643 // Data stream was interrupted, so try to reacquire the device:
644 mAcquired = false;
645 acquire();
646 break;
647
648 case DIERR_INVALIDPARAM:
649 Con::errorf( "DInputDevice::processAsync -- Invalid parameter passed to GetDeviceData of the %s input device!", mName );
650#ifdef LOG_INPUT
651 Input::log( "Invalid parameter passed to GetDeviceData for %s!\n", mName );
652#endif
653 break;
654
655 case DIERR_NOTACQUIRED:
656 // We can't get the device, so quit:
657 mAcquired = false;
658 // Don't error out - this is actually a natural occurrence...
659 //Con::errorf( "DInputDevice::processAsync -- GetDeviceData called when %s input device is not acquired!", mName );
660#ifdef LOG_INPUT
661 Input::log( "GetDeviceData called when %s is not acquired!\n", mName );
662#endif
663 break;
664 }
665
666 return false;
667 }
668
669 // We have buffered input, so act on it:
670 for ( DWORD i = 0; i < numEvents; i++ )
671 buildEvent( findObjInstance( eventBuffer[i].dwOfs ), eventBuffer[i].dwData, eventBuffer[i].dwData );
672
673 // Check for buffer overflow:
674 if ( result == DI_BUFFEROVERFLOW )
675 {
676 // This is a problem, but we can keep going...
677 Con::errorf( "DInputDevice::processAsync -- %s input device's event buffer overflowed!", mName );
678#ifdef LOG_INPUT
679 Input::log( "%s event buffer overflowed!\n", mName );
680#endif
681 mNeedSync = true; // Let it know to resync next time through...
682 }

Callers

nothing calls this directly

Calls 2

errorfFunction · 0.50
logFunction · 0.50

Tested by

no test coverage detected