00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034
00035 #include "llfloaterjoystick.h"
00036
00037
00038 #include "llerror.h"
00039 #include "llrect.h"
00040 #include "llstring.h"
00041
00042
00043 #include "lluictrlfactory.h"
00044 #include "llviewercontrol.h"
00045 #include "llappviewer.h"
00046 #include "llviewerjoystick.h"
00047
00048 LLFloaterJoystick::LLFloaterJoystick(const LLSD& data)
00049 : LLFloater("floater_joystick")
00050 {
00051 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_joystick.xml");
00052 center();
00053 }
00054
00055 void LLFloaterJoystick::draw()
00056 {
00057 bool joystick_inited = LLViewerJoystick::getInstance()->isJoystickInitialized();
00058 childSetEnabled("enable_joystick", joystick_inited);
00059 childSetEnabled("joystick_type", joystick_inited);
00060 std::string desc = LLViewerJoystick::getInstance()->getDescription();
00061 if (desc.empty()) desc = getUIString("NoDevice");
00062 childSetText("joystick_type", desc);
00063
00064 LLViewerJoystick* joystick(LLViewerJoystick::getInstance());
00065 for (U32 i = 0; i < 6; i++)
00066 {
00067 F32 value = joystick->getJoystickAxis(i);
00068 mAxisStats[i]->addValue(value * gFrameIntervalSeconds);
00069
00070 if (mAxisStatsBar[i]->mMinBar > value)
00071 {
00072 mAxisStatsBar[i]->mMinBar = value;
00073 }
00074 if (mAxisStatsBar[i]->mMaxBar < value)
00075 {
00076 mAxisStatsBar[i]->mMaxBar = value;
00077 }
00078 }
00079
00080 LLFloater::draw();
00081 }
00082
00083 BOOL LLFloaterJoystick::postBuild()
00084 {
00085 F32 range = gSavedSettings.getBOOL("Cursor3D") ? 1024.f : 2.f;
00086 LLUIString axis = getUIString("Axis");
00087 LLUIString joystick = getUIString("JoystickMonitor");
00088
00089
00090
00091 LLView* child = getChild<LLView>("FlycamAxisScale1");
00092 LLRect rect;
00093
00094 if (child)
00095 {
00096 LLRect r = child->getRect();
00097 LLRect f = getRect();
00098 rect = LLRect(350, r.mTop, r.mRight + 200, 0);
00099 }
00100
00101 mAxisStatsView = new LLStatView("axis values", joystick, "", rect);
00102 mAxisStatsView->setDisplayChildren(TRUE);
00103
00104 for (U32 i = 0; i < 6; i++)
00105 {
00106 axis.setArg("[NUM]", llformat("%d", i));
00107 mAxisStats[i] = new LLStat(4);
00108 mAxisStatsBar[i] = mAxisStatsView->addStat(axis, mAxisStats[i]);
00109 mAxisStatsBar[i]->mMinBar = -range;
00110 mAxisStatsBar[i]->mMaxBar = range;
00111 mAxisStatsBar[i]->mLabelSpacing = range * 0.5f;
00112 mAxisStatsBar[i]->mTickSpacing = range * 0.25f;
00113 }
00114
00115 addChild(mAxisStatsView);
00116
00117 childSetAction("SpaceNavigatorDefaults", onClickRestoreSNDefaults, this);
00118 refresh();
00119 return TRUE;
00120 }
00121
00122 LLFloaterJoystick::~LLFloaterJoystick()
00123 {
00124
00125 }
00126
00127
00128 void LLFloaterJoystick::apply()
00129 {
00130 }
00131
00132 void LLFloaterJoystick::refresh()
00133 {
00134 LLFloater::refresh();
00135
00136 mJoystickAxis[0] = gSavedSettings.getS32("JoystickAxis0");
00137 mJoystickAxis[1] = gSavedSettings.getS32("JoystickAxis1");
00138 mJoystickAxis[2] = gSavedSettings.getS32("JoystickAxis2");
00139 mJoystickAxis[3] = gSavedSettings.getS32("JoystickAxis3");
00140 mJoystickAxis[4] = gSavedSettings.getS32("JoystickAxis4");
00141 mJoystickAxis[5] = gSavedSettings.getS32("JoystickAxis5");
00142 mJoystickAxis[6] = gSavedSettings.getS32("JoystickAxis6");
00143
00144 m3DCursor = gSavedSettings.getBOOL("Cursor3D");
00145 mAutoLeveling = gSavedSettings.getBOOL("AutoLeveling");
00146 mZoomDirect = gSavedSettings.getBOOL("ZoomDirect");
00147
00148 mAvatarAxisScale[0] = gSavedSettings.getF32("AvatarAxisScale0");
00149 mAvatarAxisScale[1] = gSavedSettings.getF32("AvatarAxisScale1");
00150 mAvatarAxisScale[2] = gSavedSettings.getF32("AvatarAxisScale2");
00151 mAvatarAxisScale[3] = gSavedSettings.getF32("AvatarAxisScale3");
00152 mAvatarAxisScale[4] = gSavedSettings.getF32("AvatarAxisScale4");
00153 mAvatarAxisScale[5] = gSavedSettings.getF32("AvatarAxisScale5");
00154
00155 mBuildAxisScale[0] = gSavedSettings.getF32("BuildAxisScale0");
00156 mBuildAxisScale[1] = gSavedSettings.getF32("BuildAxisScale1");
00157 mBuildAxisScale[2] = gSavedSettings.getF32("BuildAxisScale2");
00158 mBuildAxisScale[3] = gSavedSettings.getF32("BuildAxisScale3");
00159 mBuildAxisScale[4] = gSavedSettings.getF32("BuildAxisScale4");
00160 mBuildAxisScale[5] = gSavedSettings.getF32("BuildAxisScale5");
00161
00162 mFlycamAxisScale[0] = gSavedSettings.getF32("FlycamAxisScale0");
00163 mFlycamAxisScale[1] = gSavedSettings.getF32("FlycamAxisScale1");
00164 mFlycamAxisScale[2] = gSavedSettings.getF32("FlycamAxisScale2");
00165 mFlycamAxisScale[3] = gSavedSettings.getF32("FlycamAxisScale3");
00166 mFlycamAxisScale[4] = gSavedSettings.getF32("FlycamAxisScale4");
00167 mFlycamAxisScale[5] = gSavedSettings.getF32("FlycamAxisScale5");
00168 mFlycamAxisScale[6] = gSavedSettings.getF32("FlycamAxisScale6");
00169
00170 mAvatarAxisDeadZone[0] = gSavedSettings.getF32("AvatarAxisDeadZone0");
00171 mAvatarAxisDeadZone[1] = gSavedSettings.getF32("AvatarAxisDeadZone1");
00172 mAvatarAxisDeadZone[2] = gSavedSettings.getF32("AvatarAxisDeadZone2");
00173 mAvatarAxisDeadZone[3] = gSavedSettings.getF32("AvatarAxisDeadZone3");
00174 mAvatarAxisDeadZone[4] = gSavedSettings.getF32("AvatarAxisDeadZone4");
00175 mAvatarAxisDeadZone[5] = gSavedSettings.getF32("AvatarAxisDeadZone5");
00176
00177 mBuildAxisDeadZone[0] = gSavedSettings.getF32("BuildAxisDeadZone0");
00178 mBuildAxisDeadZone[1] = gSavedSettings.getF32("BuildAxisDeadZone1");
00179 mBuildAxisDeadZone[2] = gSavedSettings.getF32("BuildAxisDeadZone2");
00180 mBuildAxisDeadZone[3] = gSavedSettings.getF32("BuildAxisDeadZone3");
00181 mBuildAxisDeadZone[4] = gSavedSettings.getF32("BuildAxisDeadZone4");
00182 mBuildAxisDeadZone[5] = gSavedSettings.getF32("BuildAxisDeadZone5");
00183
00184 mFlycamAxisDeadZone[0] = gSavedSettings.getF32("FlycamAxisDeadZone0");
00185 mFlycamAxisDeadZone[1] = gSavedSettings.getF32("FlycamAxisDeadZone1");
00186 mFlycamAxisDeadZone[2] = gSavedSettings.getF32("FlycamAxisDeadZone2");
00187 mFlycamAxisDeadZone[3] = gSavedSettings.getF32("FlycamAxisDeadZone3");
00188 mFlycamAxisDeadZone[4] = gSavedSettings.getF32("FlycamAxisDeadZone4");
00189 mFlycamAxisDeadZone[5] = gSavedSettings.getF32("FlycamAxisDeadZone5");
00190 mFlycamAxisDeadZone[6] = gSavedSettings.getF32("FlycamAxisDeadZone6");
00191
00192 mAvatarFeathering = gSavedSettings.getF32("AvatarFeathering");
00193 mBuildFeathering = gSavedSettings.getF32("BuildFeathering");
00194 mFlycamFeathering = gSavedSettings.getF32("FlycamFeathering");
00195 }
00196
00197 void LLFloaterJoystick::cancel()
00198 {
00199 llinfos << "reading from gSavedSettings->Cursor3D="
00200 << gSavedSettings.getBOOL("Cursor3D") << "; m3DCursor="
00201 << m3DCursor << llendl;
00202
00203 gSavedSettings.setS32("JoystickAxis0", mJoystickAxis[0]);
00204 gSavedSettings.setS32("JoystickAxis1", mJoystickAxis[1]);
00205 gSavedSettings.setS32("JoystickAxis2", mJoystickAxis[2]);
00206 gSavedSettings.setS32("JoystickAxis3", mJoystickAxis[3]);
00207 gSavedSettings.setS32("JoystickAxis4", mJoystickAxis[4]);
00208 gSavedSettings.setS32("JoystickAxis5", mJoystickAxis[5]);
00209 gSavedSettings.setS32("JoystickAxis6", mJoystickAxis[6]);
00210
00211 gSavedSettings.setBOOL("Cursor3D", m3DCursor);
00212 gSavedSettings.setBOOL("AutoLeveling", mAutoLeveling);
00213 gSavedSettings.setBOOL("ZoomDirect", mZoomDirect );
00214
00215 gSavedSettings.setF32("AvatarAxisScale0", mAvatarAxisScale[0]);
00216 gSavedSettings.setF32("AvatarAxisScale1", mAvatarAxisScale[1]);
00217 gSavedSettings.setF32("AvatarAxisScale2", mAvatarAxisScale[2]);
00218 gSavedSettings.setF32("AvatarAxisScale3", mAvatarAxisScale[3]);
00219 gSavedSettings.setF32("AvatarAxisScale4", mAvatarAxisScale[4]);
00220 gSavedSettings.setF32("AvatarAxisScale5", mAvatarAxisScale[5]);
00221
00222 gSavedSettings.setF32("BuildAxisScale0", mBuildAxisScale[0]);
00223 gSavedSettings.setF32("BuildAxisScale1", mBuildAxisScale[1]);
00224 gSavedSettings.setF32("BuildAxisScale2", mBuildAxisScale[2]);
00225 gSavedSettings.setF32("BuildAxisScale3", mBuildAxisScale[3]);
00226 gSavedSettings.setF32("BuildAxisScale4", mBuildAxisScale[4]);
00227 gSavedSettings.setF32("BuildAxisScale5", mBuildAxisScale[5]);
00228
00229 gSavedSettings.setF32("FlycamAxisScale0", mFlycamAxisScale[0]);
00230 gSavedSettings.setF32("FlycamAxisScale1", mFlycamAxisScale[1]);
00231 gSavedSettings.setF32("FlycamAxisScale2", mFlycamAxisScale[2]);
00232 gSavedSettings.setF32("FlycamAxisScale3", mFlycamAxisScale[3]);
00233 gSavedSettings.setF32("FlycamAxisScale4", mFlycamAxisScale[4]);
00234 gSavedSettings.setF32("FlycamAxisScale5", mFlycamAxisScale[5]);
00235 gSavedSettings.setF32("FlycamAxisScale6", mFlycamAxisScale[6]);
00236
00237 gSavedSettings.setF32("AvatarAxisDeadZone0", mAvatarAxisDeadZone[0]);
00238 gSavedSettings.setF32("AvatarAxisDeadZone1", mAvatarAxisDeadZone[1]);
00239 gSavedSettings.setF32("AvatarAxisDeadZone2", mAvatarAxisDeadZone[2]);
00240 gSavedSettings.setF32("AvatarAxisDeadZone3", mAvatarAxisDeadZone[3]);
00241 gSavedSettings.setF32("AvatarAxisDeadZone4", mAvatarAxisDeadZone[4]);
00242 gSavedSettings.setF32("AvatarAxisDeadZone5", mAvatarAxisDeadZone[5]);
00243
00244 gSavedSettings.setF32("BuildAxisDeadZone0", mBuildAxisDeadZone[0]);
00245 gSavedSettings.setF32("BuildAxisDeadZone1", mBuildAxisDeadZone[1]);
00246 gSavedSettings.setF32("BuildAxisDeadZone2", mBuildAxisDeadZone[2]);
00247 gSavedSettings.setF32("BuildAxisDeadZone3", mBuildAxisDeadZone[3]);
00248 gSavedSettings.setF32("BuildAxisDeadZone4", mBuildAxisDeadZone[4]);
00249 gSavedSettings.setF32("BuildAxisDeadZone5", mBuildAxisDeadZone[5]);
00250
00251 gSavedSettings.setF32("FlycamAxisDeadZone0", mFlycamAxisDeadZone[0]);
00252 gSavedSettings.setF32("FlycamAxisDeadZone1", mFlycamAxisDeadZone[1]);
00253 gSavedSettings.setF32("FlycamAxisDeadZone2", mFlycamAxisDeadZone[2]);
00254 gSavedSettings.setF32("FlycamAxisDeadZone3", mFlycamAxisDeadZone[3]);
00255 gSavedSettings.setF32("FlycamAxisDeadZone4", mFlycamAxisDeadZone[4]);
00256 gSavedSettings.setF32("FlycamAxisDeadZone5", mFlycamAxisDeadZone[5]);
00257 gSavedSettings.setF32("FlycamAxisDeadZone6", mFlycamAxisDeadZone[6]);
00258
00259 gSavedSettings.setF32("AvatarFeathering", mAvatarFeathering);
00260 gSavedSettings.setF32("BuildFeathering", mBuildFeathering);
00261 gSavedSettings.setF32("FlycamFeathering", mFlycamFeathering);
00262 }
00263
00264 void LLFloaterJoystick::onClickRestoreSNDefaults(void *joy_panel)
00265 {
00266 setSNDefaults();
00267 }
00268
00269 void LLFloaterJoystick::setSNDefaults()
00270 {
00271 LLViewerJoystick::getInstance()->setSNDefaults();
00272 }