PageRenderTime 243ms CodeModel.GetById 110ms app.highlight 8ms RepoModel.GetById 123ms 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
  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
 27#ifndef LL_LLVIEWERJOYSTICK_H
 28#define LL_LLVIEWERJOYSTICK_H
 29
 30#include "stdtypes.h"
 31
 32#if LIB_NDOF
 33#include "ndofdev_external.h"
 34#else
 35#define NDOF_Device	void
 36#define NDOF_HotPlugResult S32
 37#endif
 38
 39typedef enum e_joystick_driver_state
 40{
 41	JDS_UNINITIALIZED,
 42	JDS_INITIALIZED,
 43	JDS_INITIALIZING
 44} EJoystickDriverState;
 45
 46class LLViewerJoystick : public LLSingleton<LLViewerJoystick>
 47{
 48public:
 49	LLViewerJoystick();
 50	virtual ~LLViewerJoystick();
 51	
 52	void init(bool autoenable);
 53	void terminate();
 54
 55	void updateStatus();
 56	void scanJoystick();
 57	void moveObjects(bool reset = false);
 58	void moveAvatar(bool reset = false);
 59	void moveFlycam(bool reset = false);
 60	F32 getJoystickAxis(U32 axis) const;
 61	U32 getJoystickButton(U32 button) const;
 62	bool isJoystickInitialized() const {return (mDriverState==JDS_INITIALIZED);}
 63	bool isLikeSpaceNavigator() const;
 64	void setNeedsReset(bool reset = true) { mResetFlag = reset; }
 65	void setCameraNeedsUpdate(bool b)     { mCameraUpdated = b; }
 66	bool getCameraNeedsUpdate() const     { return mCameraUpdated; }
 67	bool getOverrideCamera() { return mOverrideCamera; }
 68	void setOverrideCamera(bool val);
 69	bool toggleFlycam();
 70	void setSNDefaults();
 71	std::string getDescription();
 72	
 73protected:
 74	void updateEnabled(bool autoenable);
 75	void handleRun(F32 inc);
 76	void agentSlide(F32 inc);
 77	void agentPush(F32 inc);
 78	void agentFly(F32 inc);
 79	void agentPitch(F32 pitch_inc);
 80	void agentYaw(F32 yaw_inc);
 81	void agentJump();
 82	void resetDeltas(S32 axis[]);
 83#if LIB_NDOF
 84	static NDOF_HotPlugResult HotPlugAddCallback(NDOF_Device *dev);
 85	static void HotPlugRemovalCallback(NDOF_Device *dev);
 86#endif
 87	
 88private:
 89	F32						mAxes[6];
 90	long					mBtn[16];
 91	EJoystickDriverState	mDriverState;
 92	NDOF_Device				*mNdofDev;
 93	bool					mResetFlag;
 94	F32						mPerfScale;
 95	bool					mCameraUpdated;
 96	bool 					mOverrideCamera;
 97	U32						mJoystickRun;
 98	
 99	static F32				sLastDelta[7];
100	static F32				sDelta[7];
101};
102
103#endif