00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ARJOYHANDLER_H
00027 #define ARJOYHANDLER_H
00028
00029 #include "ariaTypedefs.h"
00030 #include "ariaUtil.h"
00031
00032 #ifdef WIN32
00033 #include <mmsystem.h>
00034 #else // if not win32
00035 #include <stdio.h>
00036 #include <unistd.h>
00037 #include <stdlib.h>
00038 #include <sys/ioctl.h>
00039 #include <fcntl.h>
00040 #endif
00041 #ifdef linux
00042 #include <linux/joystick.h>
00043 #endif
00044
00045
00046
00048
00068 class ArJoyHandler
00069 {
00070 public:
00072 AREXPORT ArJoyHandler(bool useOSCal = true, bool useOldJoystick = false);
00074 AREXPORT ~ArJoyHandler();
00076 AREXPORT bool init(void);
00078 AREXPORT bool haveJoystick(void) { return myInitialized; }
00080 AREXPORT void getDoubles(double *x, double *y, double *z = NULL);
00082 AREXPORT bool getButton(unsigned int button);
00084 AREXPORT bool haveZAxis(void) { return myHaveZ; }
00085
00087 AREXPORT void setSpeeds(int x, int y, int z = 0)
00088 { myTopX = x; myTopY = y; myTopZ = z; }
00090 AREXPORT void getAdjusted(int *x, int *y, int *z = NULL);
00091
00093 AREXPORT unsigned int getNumAxes(void);
00095 AREXPORT double getAxis(unsigned int axis);
00097 AREXPORT unsigned int getNumButtons(void);
00098
00100 AREXPORT void setUseOSCal(bool useOSCal);
00102 AREXPORT bool getUseOSCal(void);
00104 AREXPORT void startCal(void);
00106 AREXPORT void endCal(void);
00109 AREXPORT void getUnfiltered(int *x, int *y, int *z = NULL);
00111 AREXPORT void getStats(int *maxX, int *minX, int *maxY, int *minY,
00112 int *cenX, int *cenY);
00114 AREXPORT void setStats(int maxX, int minX, int maxY, int minY,
00115 int cenX, int cenY);
00117 AREXPORT void getSpeeds(int *x, int *y, int *z);
00118 protected:
00119
00120 void getData(void);
00121 int myMaxX, myMinX, myMaxY, myMinY, myCenX, myCenY, myTopX, myTopY, myTopZ;
00122 bool myHaveZ;
00123
00124 std::map<unsigned int, int> myAxes;
00125 std::map<unsigned int, bool> myButtons;
00126
00127 int myPhysMax;
00128 bool myInitialized;
00129 bool myUseOSCal;
00130 bool myUseOld;
00131 bool myFirstData;
00132 ArTime myLastDataGathered;
00133 #ifdef WIN32
00134 unsigned int myJoyID;
00135 int myLastZ;
00136 JOYINFO myJoyInfo;
00137 JOYCAPS myJoyCaps;
00138 #else // if not win32
00139 int myJoyNumber;
00140 char myJoyNameTemp[512];
00141 ArTime myLastOpenTry;
00142 void getOldData(void);
00143 void getNewData(void);
00144 #ifdef linux
00145 struct JS_DATA_TYPE myJoyData;
00146 #else
00147 int myJoyData;
00148 #endif
00149 FILE * myOldJoyDesc;
00150 int myJoyDesc;
00151 #endif // linux
00152 };
00153
00154
00155 #endif // ARJOYHANDLER_H
00156