00001
00003
00004
00005
00006
00007
00009
00011
00012
00013
00015
00016 #ifndef _VRJGA_JOYSTICK_DEVICE_H_
00017 #define _VRJGA_JOYSTICK_DEVICE_H_
00018
00019 #include "vrjGA/Callback.h"
00020
00021 #include "gadget/Type/AnalogInterface.h"
00022
00023 #include "gmtl/Matrix.h"
00024
00025 #include <string>
00026 #include <map>
00027
00028
00029 namespace vrjGA {
00030
00031
00032 class VRJ_GA_EXPORT JoystickDevice : public Referenced
00033 {
00034 public:
00035
00036
00037 typedef Referenced BaseClass;
00038 typedef gadget::AnalogInterface AI;
00039
00041 VRJGA_DECLARE_POINTER ( JoystickDevice );
00042
00043
00044 JoystickDevice ( const std::string &h, const std::string &v );
00045
00046
00047 void callback ( Message m, Callback::Ptr c );
00048 Callback * callback ( Message m );
00049
00050
00051 float horizontal() const { return _h; }
00052 float vertical() const { return _v; }
00053
00054
00055 void notify();
00056
00057
00058 void update();
00059
00060 protected:
00061
00062 virtual ~JoystickDevice();
00063
00064 private:
00065
00066 typedef std::pair<Message,Message> MessagePair;
00067 typedef std::map<MessagePair,MessagePair> Transitions;
00068 typedef std::map<Message,Callback::Ptr> Callbacks;
00069
00070
00071 JoystickDevice ( const JoystickDevice & );
00072 JoystickDevice& operator = ( const JoystickDevice & );
00073
00074 void _notify ( Message last, Message current );
00075
00076 void _sendMessage ( Message m );
00077
00078 void _updateState();
00079
00080 Callbacks _cbm;
00081 Transitions _tm;
00082 AI _hai;
00083 AI _vai;
00084 float _h;
00085 float _v;
00086 Message _hs;
00087 Message _vs;
00088 };
00089
00090
00091 };
00092
00093
00094 #endif // _VRJGA_JOYSTICK_DEVICE_H_