#ifndef Joysticks_C_INCLUDED
	#define Joysticks_C_INCLUDED

#include <bncs_script_helper.h>

#ifdef WIN32
	#ifdef DOEXPORT_SCRIPT
		#define EXPORT_SCRIPT __declspec(dllexport) 
	#else
		#define EXPORT_SCRIPT 
	#endif
#else 
	#define EXPORT_SCRIPT
#endif
 
#define	NUM_JOYSTICKS	6

class Joysticks_C : public bncs_script_helper
{
public:
	Joysticks_C(bncs_client_callback * parent, const char* path);
	virtual ~Joysticks_C();

	void buttonCallback(buttonNotify *b);
	int revertiveCallback(revertiveNotify * r);
	void databaseCallback(revertiveNotify * r);
	bncs_string parentCallback(parentNotify *p);
	void timerCallback(int);
	
private:
	bncs_string js_down;				// statesheet name for mimic display when joystick is pressed
	bncs_string js_up;					// statesheet name for mimic display when joystick is not pressed

	int gpiDriver;						// BNCS Driver ID of gpi interface to which joysticks connect
	int	sdiDriver;						// BNCS Driver ID for SDI matrix
	int sdiDest;						// Destination that is switched by joystick presses
	int nonPressed;						// Source ID to select when no joystick is pressed.
	int currentSource;					// Keeps record of currently selected source on sdiDest
	int maxSDIdest;						// Holds the maximum destination number for the SDI router
	int minGPI;							// Lowest numbered GPI contact for the leftmost joystick
	int maxGPI;							// Highest numbered GPI contact for rightmost joystick
	int stickPressed[NUM_JOYSTICKS];	// Flag per joystick indicating status (index range 0 ..5)
	int stickID[NUM_JOYSTICKS];			// Holds the the GPI input ID for each joystick
	int videoSource[NUM_JOYSTICKS];		// Video source to select when joystick idx is pressed and active
	int jsRevertRx[NUM_JOYSTICKS];		// A flag is set per joystick when each joystick returns the initial poll.

	bool sdiRevertRx;					// Set true when a revertive has been seen from the SDI router
	bool joyRevertRx;					// Set true when all joysticks have returned a status revertive
	bool debounceTimer;					// Set true when the joystick debounce timer is running.

	// My Methods
	void ReportError(const bncs_string err_msg);
};


#endif // Joysticks_C_INCLUDED