#ifndef PRODUCER_EXAMPLES_MYKEYBOARD_MOUSE_CALLBACK
#define PRODUCER_EXAMPLES_MYKEYBOARD_MOUSE_CALLBACK
#include <stdio.h>
#include <Producer/RenderSurface> // For definition of KeySymbol
#include <Producer/KeyboardMouse>

#ifdef WIN32
#include <windows.h>
#else
#include <X11/keysym.h>
#endif

class MyKeyboardMouseCallback : public Producer::KeyboardMouseCallback
{
    public:
		MyKeyboardMouseCallback(bool &done) :
			Producer::KeyboardMouseCallback(),
			_mx(0.0f),_my(0.0f),_mbutton(0),
			_done(done)	
			{}

		virtual void specialKeyPress( Producer::KeyCharacter key )
		{
			switch( key )
			{
				case Producer::KeyChar_Escape:
					_done = true;
					break;
			}
		}

        virtual void shutdown()
        {

            _done = true; 
        }

		virtual void keyPress( Producer::KeyCharacter key )
		{
		}

		virtual void mouseMotion( float mx, float my ) 
		{
			_mx = mx;
			_my = my;
		}
		virtual void buttonPress( float mx, float my, unsigned int mbutton ) 
		{
			_mx = mx;
			_my = my;
			_mbutton |= (1<<(mbutton-1));
		}
		virtual void buttonRelease( float mx, float my, unsigned int mbutton ) 
		{
			_mx = mx;
			_my = my;
			_mbutton &= ~(1<<(mbutton-1));
		}

		bool done() { return _done; }
		float mx()  { return _mx; }
		float my()  { return _my; }
		unsigned int mbutton()  { return _mbutton; }

    protected:
		virtual ~MyKeyboardMouseCallback() {}

    private:
		bool &_done;
		float _mx, _my;
		unsigned int _mbutton;
};
#endif
