00001 00007 #ifndef JOYSTICKMANAGER_H 00008 #define JOYSTICKMANAGER_H 00009 00010 #include <linux/joystick.h> 00011 #include <pthread.h> 00012 #include "sysLog.h" 00013 #include "roboteqSC.h" 00014 00015 class JoystickManager{ 00016 public: 00020 enum Status { 00021 //Listening to the controller to pass the high stick test 00022 LISTENING = 2, 00024 INITIALIZE = 3, 00026 CLOSED = 0, 00028 ERROR = -2, 00030 OPEN = 1 00031 }; 00032 00037 static JoystickManager * theInstance(); 00038 00043 int startJoystickCtrl(); 00044 00049 int stopJoystickCtrl(); 00050 00054 static void highStickThread(); 00055 00059 static void joystickCtrl(); 00060 00065 void setStatus(Status newStatus); 00066 00071 void highStickCheck(); 00072 00077 void setInitWheel(int value); 00078 00085 void convertToSC(int x, int y, int factor); 00086 00091 void setXAxis(int x); 00092 00097 void setYAxis(int y); 00098 00103 void setMaxSpeed(int spd); 00104 00111 void spin(int x, int y, int factor); 00112 00117 inline Status getStatus(){return status;} 00118 00123 inline int getfd(){return jsfd;} 00124 00129 inline unsigned char getAxes(){return axes;} 00130 00135 inline unsigned char getButtons(){return buttons;} 00136 00141 inline int getInitWheel(){return initWheel;} 00142 00147 inline int getXAxis(){return xAxis;} 00148 00153 inline int getYAxis(){return yAxis;} 00154 00159 inline int getMaxSpeed(){return maxSpeed;} 00160 protected: 00166 JoystickManager(); 00167 00171 ~JoystickManager(); 00172 00173 private: 00175 static Status status; 00177 static SysLog * systemLogger; 00179 static RoboteqSC * speedCtrl; 00181 pthread_t joystickThread; 00183 int jsfd; 00185 unsigned char axes; 00187 unsigned char buttons; 00189 int initWheel; 00191 int xAxis; 00193 int yAxis; 00195 int maxSpeed; 00196 }; 00197 00198 #endif 00199