00001 00032 #ifndef LL_LLVIEWERJOYSTICK_H 00033 #define LL_LLVIEWERJOYSTICK_H 00034 00035 #include "stdtypes.h" 00036 00037 #define LIB_NDOF (LL_WINDOWS || LL_DARWIN) 00038 00039 #if LIB_NDOF 00040 #include "ndofdev_external.h" 00041 #else 00042 #define NDOF_Device void 00043 #define NDOF_HotPlugResult S32 00044 #endif 00045 00046 typedef enum e_joystick_driver_state 00047 { 00048 JDS_UNINITIALIZED, 00049 JDS_INITIALIZED, 00050 JDS_INITIALIZING 00051 } EJoystickDriverState; 00052 00053 class LLViewerJoystick : public LLSingleton<LLViewerJoystick> 00054 { 00055 public: 00056 LLViewerJoystick(); 00057 virtual ~LLViewerJoystick(); 00058 00059 void init(bool autoenable); 00060 void updateStatus(); 00061 void scanJoystick(); 00062 void moveObjects(bool reset = false); 00063 void moveAvatar(bool reset = false); 00064 void moveFlycam(bool reset = false); 00065 F32 getJoystickAxis(U32 axis) const; 00066 U32 getJoystickButton(U32 button) const; 00067 bool isJoystickInitialized() const {return (mDriverState==JDS_INITIALIZED);} 00068 bool isLikeSpaceNavigator() const; 00069 void setNeedsReset(bool reset = true) { mResetFlag = reset; } 00070 void setCameraNeedsUpdate(bool b) { mCameraUpdated = b; } 00071 bool getCameraNeedsUpdate() const { return mCameraUpdated; } 00072 bool getOverrideCamera() { return mOverrideCamera; } 00073 void setOverrideCamera(bool val); 00074 bool toggleFlycam(); 00075 void setSNDefaults(); 00076 std::string getDescription(); 00077 00078 protected: 00079 void updateEnabled(bool autoenable); 00080 void terminate(); 00081 void agentSlide(F32 inc); 00082 void agentPush(F32 inc); 00083 void agentFly(F32 inc); 00084 void agentRotate(F32 pitch_inc, F32 turn_inc); 00085 void agentJump(); 00086 void resetDeltas(S32 axis[], bool flycam_and_build = false); 00087 #if LIB_NDOF 00088 static NDOF_HotPlugResult HotPlugAddCallback(NDOF_Device *dev); 00089 static void HotPlugRemovalCallback(NDOF_Device *dev); 00090 #endif 00091 00092 private: 00093 F32 mAxes[6]; 00094 long mBtn[16]; 00095 EJoystickDriverState mDriverState; 00096 NDOF_Device *mNdofDev; 00097 bool mResetFlag; 00098 F32 mPerfScale; 00099 bool mCameraUpdated; 00100 bool mOverrideCamera; 00101 00102 static F32 sLastDelta[7]; 00103 static F32 sDelta[7]; 00104 }; 00105 00106 #endif