
/*
	file : event.h

	Dragon Wings (c) 2005 Philipp Roßberger, Sebastian Roll
		www.einszunull.net
		www.sebastianroll.de

	This software is provided 'as-is', without any express or implied
	warranty.  In no event will the authors be held liable for any damages
	arising from the use of this software.

	Permission is granted to anyone to use this software for any purpose,
	including commercial applications, and to alter it and redistribute it
	freely, subject to the following restrictions:

	1. The origin of this software must not be misrepresented; you must not
		claim that you wrote the original software. If you use this software
		in a product, an acknowledgment in the product documentation would be
		appreciated but is not required.
	2. Altered source versions must be plainly marked as such, and must not be
		misrepresented as being the original software.
	3. This notice may not be removed or altered from any source distribution.

	Used software libraries from other people (thank you very much):

	The Irrlicht Engine:
		Copyright (c) 2002-2005 Nikolaus Gebhardt
		www.irrlicht.sourceforge.net
  
	The Character Animation Library (cal3D):
		Copyright (c) 2001, 2002 Bruno 'Beosil' Heidelberger
		www.cal3d.sourceforge.net

	The FMOD audio library:
		Copyright (c), Firelight Technologies Pty, Ltd. 1999-2004
		www.fmod.org

	Article - Using Cal3D with Irrlicht:
		Copyright (c) Thomas Suter 2004
		www.thomas.webtracker.ch/jahia/Jahia/cache/off/pid/672

*/



class EventReceiver : public irr::IEventReceiver
{
public:

	bool EventReceiver::OnEvent(irr::SEvent event)
	{
		static float leftAngle = 0.00f;

		if (event.EventType == irr::EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown)
		{
			if (gameState == STATE_DEMO)
			{
				doDemoExit = true;
				//return true;
			}

			switch(event.KeyInput.Key)
			{
				case KEY_ESCAPE:
				{
					doAppExit = true;
					return true;
				}
				case KEY_KEY_C:
				{
					if (haveTracker)
						calibrate();
					return true;
				}
				case KEY_KEY_T:
				{
					haveTracker = !haveTracker;
					udpClose();
					if (haveTracker)
					{
						udpInit("dtrack-pc138", 5000);
					}
					return true;
				}
				case KEY_KEY_F:
				{
					fullScreen = !fullScreen;
					return true;
				}
				case KEY_KEY_A:
				{
					renderOfflineAnim = !renderOfflineAnim;
					return true;
				}
				case KEY_KEY_R:
				{
					gameState = STATE_GAME_START;
					return true;
				}
				case KEY_KEY_P:
				{
					paused = !paused;
					doDemoExit = true;
					return true;
				}
				case KEY_KEY_M:
				{
					doMusic = !doMusic;
					soundPlayMusic();
					return true;
				}
				case KEY_KEY_D:
				{
					isDebug = !isDebug;
					if (dbg)
					{	
						dbg->remove();
						dbg = 0;
					}
					if (isDebug)
						dbg = guienv->addStaticText(L"", rect<s32>(10, 10, SCREEN_X/2-100, SCREEN_Y/2), true, true, 0, -1, true);
					return true;
				}
			}
		}
		return false;
	}
private:
	
};