00001 /* 00002 MX library. 00003 00004 http://lostsidedead.com/svn 00005 00006 00007 libmx written by jared bruni, it is wrappers around SDL 00008 and other api's to provide a set of classes and functions 00009 to produce multi media applications, using object oriented 00010 techniques. 00011 00012 (C) 2008 LostSideDead 00013 */ 00014 00015 00016 00017 00018 #ifndef __MX_JOYSTICK_H_ 00019 #define __MX_JOYSTICK_H_ 00020 00021 00022 #include "SDL.h" 00023 #include<string> 00024 00025 00026 namespace mx 00027 { 00028 00030 class mxJoystick { 00031 00032 public: 00034 mxJoystick(int joy_index=0); 00038 mxJoystick(SDL_Joystick *stick); 00040 ~mxJoystick(); 00042 void initJoystick(int id); 00044 void freeJoystick(); 00046 const bool isOpen() const { return SDL_JoystickOpened(index) ? true : false; } 00048 const std::string joystickName() const { return SDL_JoystickName(index); } 00053 const bool joystickGetButton(int button) const; 00058 const int joystickGetAxis(int axis) const; 00063 const int joystickGetHat(int hat) const; 00069 const int joystickGetBall(int ball, int &x, int &y); 00070 00074 static const int joystickNum() { return SDL_NumJoysticks(); } 00077 static const void joystickUpdate() { SDL_JoystickUpdate(); } 00078 00079 protected: 00081 SDL_Joystick *stick; 00083 int index; 00084 private: // no copy constructor or operator= allowed 00085 mxJoystick(const mxJoystick &j); 00086 mxJoystick &operator=(const mxJoystick &j); 00087 00088 }; 00089 } 00090 #endif 00091
1.5.8