Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "mapinfo.h"
  8. class CSurroundTest : public CPointEntity
  9. {
  10. public:
  11. DECLARE_CLASS( CSurroundTest, CPointEntity );
  12. void FireCorrectOutput( inputdata_t &inputdata );
  13. void Spawn( void );
  14. private:
  15. COutputEvent m_On2Speakers;
  16. COutputEvent m_On4Speakers;
  17. COutputEvent m_On51Speakers;
  18. DECLARE_DATADESC();
  19. };
  20. LINK_ENTITY_TO_CLASS( point_surroundtest, CSurroundTest );
  21. BEGIN_DATADESC( CSurroundTest )
  22. DEFINE_INPUTFUNC( FIELD_VOID, "FireCorrectOutput", FireCorrectOutput ),
  23. DEFINE_OUTPUT( m_On2Speakers, "On2Speakers" ),
  24. DEFINE_OUTPUT( m_On4Speakers, "On4Speakers" ),
  25. DEFINE_OUTPUT( m_On51Speakers, "On51Speakers" ),
  26. END_DATADESC()
  27. enum
  28. {
  29. SND_SURROUND_HEADPHONES = 0,
  30. SND_SURROUND_2SPEAKERS = 2,
  31. SND_SURROUND_4SPEAKERS = 4,
  32. SND_SURROUND_51SPEAKERS,
  33. };
  34. void CSurroundTest::FireCorrectOutput( inputdata_t &inputdata )
  35. {
  36. ConVar const *pSurroundCVar = cvar->FindVar( "snd_surround_speakers" );
  37. if ( pSurroundCVar )
  38. {
  39. int iSetting = pSurroundCVar->GetInt();
  40. if ( iSetting == SND_SURROUND_HEADPHONES || iSetting == SND_SURROUND_2SPEAKERS )
  41. {
  42. m_On2Speakers.FireOutput( this, this );
  43. }
  44. else if ( iSetting == SND_SURROUND_4SPEAKERS )
  45. {
  46. m_On4Speakers.FireOutput( this, this );
  47. }
  48. else if ( iSetting == SND_SURROUND_51SPEAKERS )
  49. {
  50. m_On51Speakers.FireOutput( this, this );
  51. }
  52. }
  53. }
  54. void CSurroundTest::Spawn( void )
  55. {
  56. BaseClass::Spawn();
  57. }