/* JoystickController.h A trackd module for the standard linux gameport. Author: Ben Chang Revision: 3-11-03 */ #ifndef _JoystickController_H #define _JoystickController_H #define JoystickController_VERSION "5.0.0" #ifndef LINKAGE #ifdef WIN32 #define LINKAGE __declspec(dllexport) #else #define LINKAGE #endif #endif #include "MessageH.h" #include "BaseMod.h" #include #include #include #include #include #include #include #include #include #include #define NAME_LENGTH 128 #define JS_SELECT_UDELAY 25000 #define DT_MAX_NUM_TRACKERS 0 #define DT_MAX_NUM_CONTROLLERS 5 // These below are prototype definitions of the functions needed to use this // class as a module. #ifndef _NO_DLL extern "C" LINKAGE CBase *createDev(void *config=NULL, CMessageH *p_msgh=NULL); extern "C" LINKAGE bool deleteDev(CBase *dev=NULL); #endif // This class is derived from CBaseMod class defined in BaseMod.h. class JoystickController: public CBaseMod { private: bool con[DT_MAX_NUM_CONTROLLERS]; // Joystick communication data. char port[32]; int fd; // file descriptor /* we can have up to 3 valuators, and 6 buttons. maybe that should be more, later. valScale scales the valuator readings. for instance, the wand returns -1 to 1 while the joystick does -32767 to 32767 . */ int numVals; float val[16]; float valScale[16]; int numBut; int but[16]; protected: // This function is used to retrieve controller data. The setConData(s) // function should also be called within this function to update the // controller data in the storage visible to Trackd. // However, this JoystickController does not have controller, so this // method is just empty but returning 1. int updateConData(void); // This function is used to retrieve tracker data. The setTraData(s) // function should also be called within this function to update the // tracker data in the storage visible to Trackd. int updateTraData(void); public: // Constructor JoystickController(void *_config=NULL, CMessageH *p_msgh=NULL ); // Destructor to deallocate memory. ~JoystickController(void); //Iniitlaize and Configure Data Members int init(void *initInfo); // This is used to configure the device sending commands. int configure(void); // This is used to start the device. bool start(void); // This is used to stop the device. bool stop(void); // This is used to print out config data when trackd is starting up. bool printConfig(void); // This is not a standard Module Development method. It is used // specifically for this program. void sleep(clock_t wait); }; #endif /* _JoystickController_H */