PageRenderTime 17ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llviewerjoystick.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 103 lines | 67 code | 11 blank | 25 comment | 0 complexity | c02481453789ec7c32f1836c04fc2172 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llviewerjoystick.h
  3. * @brief Viewer joystick / NDOF device functionality.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLVIEWERJOYSTICK_H
  27. #define LL_LLVIEWERJOYSTICK_H
  28. #include "stdtypes.h"
  29. #if LIB_NDOF
  30. #include "ndofdev_external.h"
  31. #else
  32. #define NDOF_Device void
  33. #define NDOF_HotPlugResult S32
  34. #endif
  35. typedef enum e_joystick_driver_state
  36. {
  37. JDS_UNINITIALIZED,
  38. JDS_INITIALIZED,
  39. JDS_INITIALIZING
  40. } EJoystickDriverState;
  41. class LLViewerJoystick : public LLSingleton<LLViewerJoystick>
  42. {
  43. public:
  44. LLViewerJoystick();
  45. virtual ~LLViewerJoystick();
  46. void init(bool autoenable);
  47. void terminate();
  48. void updateStatus();
  49. void scanJoystick();
  50. void moveObjects(bool reset = false);
  51. void moveAvatar(bool reset = false);
  52. void moveFlycam(bool reset = false);
  53. F32 getJoystickAxis(U32 axis) const;
  54. U32 getJoystickButton(U32 button) const;
  55. bool isJoystickInitialized() const {return (mDriverState==JDS_INITIALIZED);}
  56. bool isLikeSpaceNavigator() const;
  57. void setNeedsReset(bool reset = true) { mResetFlag = reset; }
  58. void setCameraNeedsUpdate(bool b) { mCameraUpdated = b; }
  59. bool getCameraNeedsUpdate() const { return mCameraUpdated; }
  60. bool getOverrideCamera() { return mOverrideCamera; }
  61. void setOverrideCamera(bool val);
  62. bool toggleFlycam();
  63. void setSNDefaults();
  64. std::string getDescription();
  65. protected:
  66. void updateEnabled(bool autoenable);
  67. void handleRun(F32 inc);
  68. void agentSlide(F32 inc);
  69. void agentPush(F32 inc);
  70. void agentFly(F32 inc);
  71. void agentPitch(F32 pitch_inc);
  72. void agentYaw(F32 yaw_inc);
  73. void agentJump();
  74. void resetDeltas(S32 axis[]);
  75. #if LIB_NDOF
  76. static NDOF_HotPlugResult HotPlugAddCallback(NDOF_Device *dev);
  77. static void HotPlugRemovalCallback(NDOF_Device *dev);
  78. #endif
  79. private:
  80. F32 mAxes[6];
  81. long mBtn[16];
  82. EJoystickDriverState mDriverState;
  83. NDOF_Device *mNdofDev;
  84. bool mResetFlag;
  85. F32 mPerfScale;
  86. bool mCameraUpdated;
  87. bool mOverrideCamera;
  88. U32 mJoystickRun;
  89. static F32 sLastDelta[7];
  90. static F32 sDelta[7];
  91. };
  92. #endif