aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llwindow/lllogitechlcd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llwindow/lllogitechlcd.cpp')
-rw-r--r--linden/indra/llwindow/lllogitechlcd.cpp296
1 files changed, 296 insertions, 0 deletions
diff --git a/linden/indra/llwindow/lllogitechlcd.cpp b/linden/indra/llwindow/lllogitechlcd.cpp
new file mode 100644
index 0000000..8141ba3
--- /dev/null
+++ b/linden/indra/llwindow/lllogitechlcd.cpp
@@ -0,0 +1,296 @@
1/**
2 * @file lcd.cpp
3 * @brief cLcd panel class
4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
7 * Copyright (c) 2001-2007, 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://secondlife.com/developers/opensource/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://secondlife.com/developers/opensource/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 "llpreprocessor.h"
33
34#if LL_LCD_COMPILE
35
36#include "linden_common.h"
37#include "../win_crash_logger/StdAfx.h"
38
39#include "EZ_LCD.h"
40#include "../newview/res/resource.h"
41#include "llcontrol.h"
42extern LLControlGroup gSavedSettings;
43
44#ifndef LL_LOGITECH_LCD_H
45#include "lllogitechlcd.h"
46#endif
47
48#define WAIT_DURATION 7
49#define DEBOUNCE_DURATION 0.3f
50
51llLCDPageGroup::llLCDPageGroup(CEzLcd *LCD, int type, HICON SLIcon):
52mType(type),
53mSLIcon(SLIcon),
54mDisplayPage(false),
55mLCD(LCD)
56{
57 mPageArray.clear();
58}
59
60llLCDPageGroup::~llLCDPageGroup()
61{
62 mPageArray.clear();
63}
64
65void llDefaultPageGroup::UpdateDetails()
66{
67 mLCD->ModifyControlsOnPage(mPageArray[0].mPageIndex);
68}
69
70void llDefaultPageGroup::GetDisplayable()
71{
72
73}
74
75llDefaultPageGroup::llDefaultPageGroup(CEzLcd *LCD, int type, HICON SLIcon)
76:llLCDPageGroup(LCD, type, SLIcon)
77{
78 // create a new specific page
79 llLCDSpecificPage newPage;
80 newPage.mPageIndex = mLCD->AddNewPage() - 1;
81 mLCD->ModifyControlsOnPage(newPage.mPageIndex);
82
83 // add in all the display parts for this specific page
84
85 // add in the icon - all pages have this - we don't need to track this because we never update it
86 HANDLE m_rightIcon = mLCD->AddIcon(mSLIcon, 32, 32);
87 mLCD->SetOrigin(m_rightIcon, 0, 0);
88
89 // add Title
90 HANDLE title = mLCD->AddText(LG_STATIC_TEXT, LG_MEDIUM, DT_CENTER, 128);
91 mLCD->SetOrigin(title, 32, 20);
92 mLCD->SetText(title, _T("Second Life Display"));
93 newPage.mDisplayItemArray.push_back(title);
94
95 // and then insert it
96 mPageArray.push_back(newPage);
97}
98
99llLCD::llLCD(HINSTANCE instance):
100mInited(false),
101mDisplayTimer(),
102mDebounceTimer(),
103mPageToShow(-1),
104mInstance(instance),
105mDestinationLCD(-1),
106mFirstTimeThru(true)
107{
108 HRESULT res_ = S_OK;
109
110 // Create instance of EzLcd.
111 mLCD = new CEzLcd();
112
113 // Have it initialize itself
114 res_ = mLCD->InitYourself(_T("Second Life"));
115
116 if (res_ != S_OK)
117 {
118 // Something went wrong, when connecting to the LCD Manager software. We need to get out now
119 delete mLCD;
120 return;
121 }
122 mInited = true;
123
124 // preload the Second Life Icon
125 mSLIcon = static_cast<HICON>(LoadImage(mInstance,
126 MAKEINTRESOURCE(IDI_LCD_LL_ICON),
127 IMAGE_ICON,
128 32,
129 32,
130 LR_MONOCHROME));
131
132 // have to do this first so screens are added to the list and updateDisplay actually does something.
133 mLCD->Update();
134}
135
136llLCD::~llLCD()
137{
138 // remove the instance of the LCD controller
139 if (mInited == true)
140 {
141 delete mLCD;
142
143 // free up the used pages
144 int loopSize = mPageGroupArray.size();
145 for(int i= 0; i<loopSize; i++)
146 {
147 free (mPageGroupArray[i]);
148 }
149 }
150}
151
152llLCDPageGroup *llLCD::GetNextPageToDisplay()
153{
154 // find group with current page in it.
155
156 int groupSize = mPageGroupArray.size();
157 for(int x=1; x< groupSize; x++)
158 {
159 if (mPageGroupArray[x]->mDisplayPage)
160 {
161 // now walk all the pages in the page group we are looking at
162 int numPages = mPageGroupArray[x]->mPageArray.size();
163 for (int zx = 0; zx< numPages; zx++)
164 {
165 // found it.
166 if (mPageToShow == mPageGroupArray[x]->mPageArray[zx].mPageIndex)
167 {
168 // move to the next one
169 if (zx < numPages-1)
170 {
171 mPageToShow = mPageGroupArray[x]->mPageArray[zx+1].mPageIndex;
172 return mPageGroupArray[x];
173 }
174 else
175 {
176 for(int y=x+1; y< groupSize; y++)
177 {
178 if (mPageGroupArray[y]->mDisplayPage)
179 {
180 mPageToShow = mPageGroupArray[y]->mPageArray[0].mPageIndex;
181 return mPageGroupArray[y];
182 }
183 }
184 }
185 }
186 }
187 }
188 }
189
190 // ok, didn't find it. Start again at the beginning and find the first group that's enabled
191 for(int x=1; x< groupSize; x++)
192 {
193 if (mPageGroupArray[x]->mDisplayPage)
194 {
195 mPageToShow = mPageGroupArray[x]->mPageArray[0].mPageIndex;
196 return mPageGroupArray[x];
197 }
198 }
199 // if we got this far, we should display the default screen
200 mPageToShow = mPageGroupArray[0]->mPageArray[0].mPageIndex;
201 return mPageGroupArray[0];
202}
203
204void llLCD::SetUpDisplayPages()
205{
206 // work out if destination has changed
207 int destinationLCD = gSavedSettings.getS32("LCDDestination");
208 switch(destinationLCD)
209 {
210 case 0:
211 destinationLCD = LGLCD_DEVICE_FAMILY_KEYBOARD_G15;
212 break;
213 case 1:
214 destinationLCD = LGLCD_DEVICE_FAMILY_SPEAKERS_Z10;
215 break;
216 }
217 // set destination if it's changed
218 if (mDestinationLCD != destinationLCD)
219 {
220 mDestinationLCD = destinationLCD;
221 mLCD->SetDeviceFamilyToUse(destinationLCD);
222 }
223 int loopSize = mPageGroupArray.size();
224 for(int i= 0; i<loopSize; i++)
225 {
226 mPageGroupArray[i]->GetDisplayable();
227 }
228}
229
230void llLCD::UpdateDisplay()
231{
232 if (mInited)
233 {
234 // reset pages if anything has changed
235 SetUpDisplayPages();
236 if (mLCD->IsConnected())
237 {
238 // Switching back and forth between the pages that we've created
239 if (mDisplayTimer.getElapsedTimeF32() > WAIT_DURATION || mFirstTimeThru)
240 {
241 mCurrentGroupBeingShown = GetNextPageToDisplay();
242 mDisplayTimer.reset();
243 mFirstTimeThru = false;
244 }
245
246 // Check if button 1 triggered
247 if ((mLCD->ButtonIsPressed(LG_BUTTON_1)
248 || mLCD->ButtonIsPressed(LG_BUTTON_2)
249 || mLCD->ButtonIsPressed(LG_BUTTON_3)
250 || mLCD->ButtonIsPressed(LG_BUTTON_4)
251 ) && mDebounceTimer.getElapsedTimeF32() > DEBOUNCE_DURATION)
252 {
253 // if so, move us on a page
254 mCurrentGroupBeingShown = GetNextPageToDisplay();
255 mDisplayTimer.reset();
256 mDebounceTimer.reset();
257 }
258
259 // update that which is being show
260 mCurrentGroupBeingShown->UpdateDetails();
261
262 // set which page is shown
263 mLCD->ShowPage(mPageToShow);
264
265 // Must run the following every loop.
266 mLCD->Update();
267 }
268 }
269}
270
271
272// accessor functions
273bool llLCD::Enabled()
274{
275 return mInited;
276}
277
278BOOL llLCD::AreZ10Available()
279{
280 if (mInited == true)
281 {
282 return mLCD->AnyDeviceOfThisFamilyPresent(LGLCD_DEVICE_FAMILY_SPEAKERS_Z10);
283 }
284 return false;
285}
286
287BOOL llLCD::IsG15Available()
288{
289 if (mInited == true)
290 {
291 return mLCD->AnyDeviceOfThisFamilyPresent(LGLCD_DEVICE_FAMILY_KEYBOARD_G15);
292 }
293 return false;
294}
295
296#endif