aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterjoystick.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:42 -0500
committerJacek Antonelli2008-08-15 23:45:42 -0500
commitce28e056c20bf2723f565bbf464b87781ec248a2 (patch)
treeef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/newview/llfloaterjoystick.cpp
parentSecond Life viewer sources 1.19.1.4b (diff)
downloadmeta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/newview/llfloaterjoystick.cpp')
-rw-r--r--linden/indra/newview/llfloaterjoystick.cpp272
1 files changed, 272 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterjoystick.cpp b/linden/indra/newview/llfloaterjoystick.cpp
new file mode 100644
index 0000000..5323b35
--- /dev/null
+++ b/linden/indra/newview/llfloaterjoystick.cpp
@@ -0,0 +1,272 @@
1/**
2 * @file llfloaterjoystick.cpp
3 * @brief Joystick preferences panel
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "llviewerprecompiledheaders.h"
33
34// file include
35#include "llfloaterjoystick.h"
36
37// linden library includes
38#include "llerror.h"
39#include "llrect.h"
40#include "llstring.h"
41
42// project includes
43#include "lluictrlfactory.h"
44#include "llviewercontrol.h"
45#include "llappviewer.h"
46#include "llviewerjoystick.h"
47
48LLFloaterJoystick::LLFloaterJoystick(const LLSD& data)
49 : LLFloater("floater_joystick")
50{
51 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_joystick.xml");
52 center();
53}
54
55void LLFloaterJoystick::draw()
56{
57 bool joystick_inited = LLViewerJoystick::getInstance()->isJoystickInitialized();
58 childSetEnabled("enable_joystick", joystick_inited);
59 childSetEnabled("joystick_type", joystick_inited);
60 std::string desc = LLViewerJoystick::getInstance()->getDescription();
61 if (desc.empty()) desc = getUIString("NoDevice");
62 childSetText("joystick_type", desc);
63
64 LLViewerJoystick* joystick(LLViewerJoystick::getInstance());
65 for (U32 i = 0; i < 6; i++)
66 {
67 F32 value = joystick->getJoystickAxis(i);
68 mAxisStats[i]->addValue(value * gFrameIntervalSeconds);
69
70 if (mAxisStatsBar[i]->mMinBar > value)
71 {
72 mAxisStatsBar[i]->mMinBar = value;
73 }
74 if (mAxisStatsBar[i]->mMaxBar < value)
75 {
76 mAxisStatsBar[i]->mMaxBar = value;
77 }
78 }
79
80 LLFloater::draw();
81}
82
83BOOL LLFloaterJoystick::postBuild()
84{
85 F32 range = gSavedSettings.getBOOL("Cursor3D") ? 1024.f : 2.f;
86 LLUIString axis = getUIString("Axis");
87 LLUIString joystick = getUIString("JoystickMonitor");
88
89 // use this child to get relative positioning info; we'll place the
90 // joystick monitor on its right, vertically aligned to it.
91 LLView* child = getChild<LLView>("FlycamAxisScale1");
92 LLRect rect;
93
94 if (child)
95 {
96 LLRect r = child->getRect();
97 LLRect f = getRect();
98 rect = LLRect(350, r.mTop, r.mRight + 200, 0);
99 }
100
101 mAxisStatsView = new LLStatView("axis values", joystick, "", rect);
102 mAxisStatsView->setDisplayChildren(TRUE);
103
104 for (U32 i = 0; i < 6; i++)
105 {
106 axis.setArg("[NUM]", llformat("%d", i));
107 mAxisStats[i] = new LLStat(4);
108 mAxisStatsBar[i] = mAxisStatsView->addStat(axis, mAxisStats[i]);
109 mAxisStatsBar[i]->mMinBar = -range;
110 mAxisStatsBar[i]->mMaxBar = range;
111 mAxisStatsBar[i]->mLabelSpacing = range * 0.5f;
112 mAxisStatsBar[i]->mTickSpacing = range * 0.25f;
113 }
114
115 addChild(mAxisStatsView);
116
117 childSetAction("SpaceNavigatorDefaults", onClickRestoreSNDefaults, this);
118 refresh();
119 return TRUE;
120}
121
122LLFloaterJoystick::~LLFloaterJoystick()
123{
124 // Children all cleaned up by default view destructor.
125}
126
127
128void LLFloaterJoystick::apply()
129{
130}
131
132void LLFloaterJoystick::refresh()
133{
134 LLFloater::refresh();
135
136 mJoystickAxis[0] = gSavedSettings.getS32("JoystickAxis0");
137 mJoystickAxis[1] = gSavedSettings.getS32("JoystickAxis1");
138 mJoystickAxis[2] = gSavedSettings.getS32("JoystickAxis2");
139 mJoystickAxis[3] = gSavedSettings.getS32("JoystickAxis3");
140 mJoystickAxis[4] = gSavedSettings.getS32("JoystickAxis4");
141 mJoystickAxis[5] = gSavedSettings.getS32("JoystickAxis5");
142 mJoystickAxis[6] = gSavedSettings.getS32("JoystickAxis6");
143
144 m3DCursor = gSavedSettings.getBOOL("Cursor3D");
145 mAutoLeveling = gSavedSettings.getBOOL("AutoLeveling");
146 mZoomDirect = gSavedSettings.getBOOL("ZoomDirect");
147
148 mAvatarAxisScale[0] = gSavedSettings.getF32("AvatarAxisScale0");
149 mAvatarAxisScale[1] = gSavedSettings.getF32("AvatarAxisScale1");
150 mAvatarAxisScale[2] = gSavedSettings.getF32("AvatarAxisScale2");
151 mAvatarAxisScale[3] = gSavedSettings.getF32("AvatarAxisScale3");
152 mAvatarAxisScale[4] = gSavedSettings.getF32("AvatarAxisScale4");
153 mAvatarAxisScale[5] = gSavedSettings.getF32("AvatarAxisScale5");
154
155 mBuildAxisScale[0] = gSavedSettings.getF32("BuildAxisScale0");
156 mBuildAxisScale[1] = gSavedSettings.getF32("BuildAxisScale1");
157 mBuildAxisScale[2] = gSavedSettings.getF32("BuildAxisScale2");
158 mBuildAxisScale[3] = gSavedSettings.getF32("BuildAxisScale3");
159 mBuildAxisScale[4] = gSavedSettings.getF32("BuildAxisScale4");
160 mBuildAxisScale[5] = gSavedSettings.getF32("BuildAxisScale5");
161
162 mFlycamAxisScale[0] = gSavedSettings.getF32("FlycamAxisScale0");
163 mFlycamAxisScale[1] = gSavedSettings.getF32("FlycamAxisScale1");
164 mFlycamAxisScale[2] = gSavedSettings.getF32("FlycamAxisScale2");
165 mFlycamAxisScale[3] = gSavedSettings.getF32("FlycamAxisScale3");
166 mFlycamAxisScale[4] = gSavedSettings.getF32("FlycamAxisScale4");
167 mFlycamAxisScale[5] = gSavedSettings.getF32("FlycamAxisScale5");
168 mFlycamAxisScale[6] = gSavedSettings.getF32("FlycamAxisScale6");
169
170 mAvatarAxisDeadZone[0] = gSavedSettings.getF32("AvatarAxisDeadZone0");
171 mAvatarAxisDeadZone[1] = gSavedSettings.getF32("AvatarAxisDeadZone1");
172 mAvatarAxisDeadZone[2] = gSavedSettings.getF32("AvatarAxisDeadZone2");
173 mAvatarAxisDeadZone[3] = gSavedSettings.getF32("AvatarAxisDeadZone3");
174 mAvatarAxisDeadZone[4] = gSavedSettings.getF32("AvatarAxisDeadZone4");
175 mAvatarAxisDeadZone[5] = gSavedSettings.getF32("AvatarAxisDeadZone5");
176
177 mBuildAxisDeadZone[0] = gSavedSettings.getF32("BuildAxisDeadZone0");
178 mBuildAxisDeadZone[1] = gSavedSettings.getF32("BuildAxisDeadZone1");
179 mBuildAxisDeadZone[2] = gSavedSettings.getF32("BuildAxisDeadZone2");
180 mBuildAxisDeadZone[3] = gSavedSettings.getF32("BuildAxisDeadZone3");
181 mBuildAxisDeadZone[4] = gSavedSettings.getF32("BuildAxisDeadZone4");
182 mBuildAxisDeadZone[5] = gSavedSettings.getF32("BuildAxisDeadZone5");
183
184 mFlycamAxisDeadZone[0] = gSavedSettings.getF32("FlycamAxisDeadZone0");
185 mFlycamAxisDeadZone[1] = gSavedSettings.getF32("FlycamAxisDeadZone1");
186 mFlycamAxisDeadZone[2] = gSavedSettings.getF32("FlycamAxisDeadZone2");
187 mFlycamAxisDeadZone[3] = gSavedSettings.getF32("FlycamAxisDeadZone3");
188 mFlycamAxisDeadZone[4] = gSavedSettings.getF32("FlycamAxisDeadZone4");
189 mFlycamAxisDeadZone[5] = gSavedSettings.getF32("FlycamAxisDeadZone5");
190 mFlycamAxisDeadZone[6] = gSavedSettings.getF32("FlycamAxisDeadZone6");
191
192 mAvatarFeathering = gSavedSettings.getF32("AvatarFeathering");
193 mBuildFeathering = gSavedSettings.getF32("BuildFeathering");
194 mFlycamFeathering = gSavedSettings.getF32("FlycamFeathering");
195}
196
197void LLFloaterJoystick::cancel()
198{
199 llinfos << "reading from gSavedSettings->Cursor3D="
200 << gSavedSettings.getBOOL("Cursor3D") << "; m3DCursor="
201 << m3DCursor << llendl;
202
203 gSavedSettings.setS32("JoystickAxis0", mJoystickAxis[0]);
204 gSavedSettings.setS32("JoystickAxis1", mJoystickAxis[1]);
205 gSavedSettings.setS32("JoystickAxis2", mJoystickAxis[2]);
206 gSavedSettings.setS32("JoystickAxis3", mJoystickAxis[3]);
207 gSavedSettings.setS32("JoystickAxis4", mJoystickAxis[4]);
208 gSavedSettings.setS32("JoystickAxis5", mJoystickAxis[5]);
209 gSavedSettings.setS32("JoystickAxis6", mJoystickAxis[6]);
210
211 gSavedSettings.setBOOL("Cursor3D", m3DCursor);
212 gSavedSettings.setBOOL("AutoLeveling", mAutoLeveling);
213 gSavedSettings.setBOOL("ZoomDirect", mZoomDirect );
214
215 gSavedSettings.setF32("AvatarAxisScale0", mAvatarAxisScale[0]);
216 gSavedSettings.setF32("AvatarAxisScale1", mAvatarAxisScale[1]);
217 gSavedSettings.setF32("AvatarAxisScale2", mAvatarAxisScale[2]);
218 gSavedSettings.setF32("AvatarAxisScale3", mAvatarAxisScale[3]);
219 gSavedSettings.setF32("AvatarAxisScale4", mAvatarAxisScale[4]);
220 gSavedSettings.setF32("AvatarAxisScale5", mAvatarAxisScale[5]);
221
222 gSavedSettings.setF32("BuildAxisScale0", mBuildAxisScale[0]);
223 gSavedSettings.setF32("BuildAxisScale1", mBuildAxisScale[1]);
224 gSavedSettings.setF32("BuildAxisScale2", mBuildAxisScale[2]);
225 gSavedSettings.setF32("BuildAxisScale3", mBuildAxisScale[3]);
226 gSavedSettings.setF32("BuildAxisScale4", mBuildAxisScale[4]);
227 gSavedSettings.setF32("BuildAxisScale5", mBuildAxisScale[5]);
228
229 gSavedSettings.setF32("FlycamAxisScale0", mFlycamAxisScale[0]);
230 gSavedSettings.setF32("FlycamAxisScale1", mFlycamAxisScale[1]);
231 gSavedSettings.setF32("FlycamAxisScale2", mFlycamAxisScale[2]);
232 gSavedSettings.setF32("FlycamAxisScale3", mFlycamAxisScale[3]);
233 gSavedSettings.setF32("FlycamAxisScale4", mFlycamAxisScale[4]);
234 gSavedSettings.setF32("FlycamAxisScale5", mFlycamAxisScale[5]);
235 gSavedSettings.setF32("FlycamAxisScale6", mFlycamAxisScale[6]);
236
237 gSavedSettings.setF32("AvatarAxisDeadZone0", mAvatarAxisDeadZone[0]);
238 gSavedSettings.setF32("AvatarAxisDeadZone1", mAvatarAxisDeadZone[1]);
239 gSavedSettings.setF32("AvatarAxisDeadZone2", mAvatarAxisDeadZone[2]);
240 gSavedSettings.setF32("AvatarAxisDeadZone3", mAvatarAxisDeadZone[3]);
241 gSavedSettings.setF32("AvatarAxisDeadZone4", mAvatarAxisDeadZone[4]);
242 gSavedSettings.setF32("AvatarAxisDeadZone5", mAvatarAxisDeadZone[5]);
243
244 gSavedSettings.setF32("BuildAxisDeadZone0", mBuildAxisDeadZone[0]);
245 gSavedSettings.setF32("BuildAxisDeadZone1", mBuildAxisDeadZone[1]);
246 gSavedSettings.setF32("BuildAxisDeadZone2", mBuildAxisDeadZone[2]);
247 gSavedSettings.setF32("BuildAxisDeadZone3", mBuildAxisDeadZone[3]);
248 gSavedSettings.setF32("BuildAxisDeadZone4", mBuildAxisDeadZone[4]);
249 gSavedSettings.setF32("BuildAxisDeadZone5", mBuildAxisDeadZone[5]);
250
251 gSavedSettings.setF32("FlycamAxisDeadZone0", mFlycamAxisDeadZone[0]);
252 gSavedSettings.setF32("FlycamAxisDeadZone1", mFlycamAxisDeadZone[1]);
253 gSavedSettings.setF32("FlycamAxisDeadZone2", mFlycamAxisDeadZone[2]);
254 gSavedSettings.setF32("FlycamAxisDeadZone3", mFlycamAxisDeadZone[3]);
255 gSavedSettings.setF32("FlycamAxisDeadZone4", mFlycamAxisDeadZone[4]);
256 gSavedSettings.setF32("FlycamAxisDeadZone5", mFlycamAxisDeadZone[5]);
257 gSavedSettings.setF32("FlycamAxisDeadZone6", mFlycamAxisDeadZone[6]);
258
259 gSavedSettings.setF32("AvatarFeathering", mAvatarFeathering);
260 gSavedSettings.setF32("BuildFeathering", mBuildFeathering);
261 gSavedSettings.setF32("FlycamFeathering", mFlycamFeathering);
262}
263
264void LLFloaterJoystick::onClickRestoreSNDefaults(void *joy_panel)
265{
266 setSNDefaults();
267}
268
269void LLFloaterJoystick::setSNDefaults()
270{
271 LLViewerJoystick::getInstance()->setSNDefaults();
272}