Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages | Examples

ArJoyHandler.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
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   // function to get the data for OS dependent part
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; // structure for the buttons and x,y coords
00146   #else
00147   int myJoyData;
00148   #endif
00149   FILE * myOldJoyDesc;
00150   int myJoyDesc;
00151 #endif // linux
00152 };
00153 
00154 
00155 #endif // ARJOYHANDLER_H
00156 

Generated on Tue Feb 20 10:51:40 2007 for Aria by  doxygen 1.4.0