Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

JoystickDevice.h

Go to the documentation of this file.
00001 
00003 //
00004 //  Copyright (c) 2002, Perry L. Miller IV
00005 //  All rights reserved.
00006 //  BSD License: http://www.opensource.org/licenses/bsd-license.html
00007 //
00009 
00011 //
00012 //  Wrapper class for two instances of gadget::AnalogInterface.
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   // Useful typedefs.
00037   typedef Referenced BaseClass;
00038   typedef gadget::AnalogInterface AI;
00039 
00041   VRJGA_DECLARE_POINTER ( JoystickDevice );
00042 
00043   // Constructor.
00044   JoystickDevice ( const std::string &h, const std::string &v );
00045 
00046   // Set/get the callback.
00047   void              callback ( Message m, Callback::Ptr c );
00048   Callback *        callback ( Message m );
00049 
00050   // Get the device's values.
00051   float             horizontal() const { return _h; }
00052   float             vertical()   const { return _v; }
00053 
00054   // Notify the client of any state changes.
00055   void              notify();
00056 
00057   // Update the internal state.
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   // Not copyable.
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 }; // namespace vrjGA
00092 
00093 
00094 #endif // _VRJGA_JOYSTICK_DEVICE_H_

Generated on Thu Aug 12 16:42:14 2004 for vrjGA by doxygen 1.3.5