79 |
cycrow |
1 |
/****h* EZ.LCD.SDK.Wrapper/EzLcd
|
|
|
2 |
* NAME
|
|
|
3 |
* EZ_LCD.cpp
|
|
|
4 |
* COPYRIGHT
|
|
|
5 |
* The Logitech EZ LCD SDK Wrapper, including all accompanying
|
|
|
6 |
* documentation, is protected by intellectual property laws. All rights
|
|
|
7 |
* not expressly granted by Logitech are reserved.
|
|
|
8 |
* PURPOSE
|
|
|
9 |
* The EZ LCD SDK Wrapper is aimed at developers wanting to make use of the LCD
|
|
|
10 |
* display on Logitech G-series keyboard. It comes with a very intuitive
|
|
|
11 |
* and easy to use interface which enables one to easily display static
|
|
|
12 |
* strings, scrolling strings, progress bars, and icons.
|
|
|
13 |
* See the following to get started:
|
|
|
14 |
* - readme.txt: Describes how to get started
|
|
|
15 |
* - Use one of the samples included to see how things work.
|
|
|
16 |
* AUTHOR
|
|
|
17 |
* Christophe Juncker (christophe_juncker@logitech.com)
|
|
|
18 |
* CREATION DATE
|
|
|
19 |
* 06/13/2005
|
|
|
20 |
* MODIFICATION HISTORY
|
|
|
21 |
* 03/01/2006 - Vahid Afshar. Added the concept of pages to the API. A
|
|
|
22 |
* client can now have multiple pages, each with its own
|
|
|
23 |
* controls. A page can be shown, while another is modified.
|
|
|
24 |
* - Introduced the InitYourself() method.
|
|
|
25 |
*******
|
|
|
26 |
*/
|
|
|
27 |
|
|
|
28 |
#include "StdAfx.h"
|
|
|
29 |
|
|
|
30 |
#include "EZ_LCD_Defines.h"
|
|
|
31 |
#include "EZ_LCD_Page.h"
|
|
|
32 |
#include "EZ_LCD.h"
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
/****f* EZ.LCD.Wrapper/CEzLcd::CEzLcd
|
|
|
37 |
* NAME
|
|
|
38 |
* CEzLcd::CEzLcd() -- Basic constructor. The user must call the
|
|
|
39 |
* InitYourself(...) method after calling this constructor.
|
|
|
40 |
* FUNCTION
|
|
|
41 |
* Object is created.
|
|
|
42 |
* INPUTS
|
|
|
43 |
******
|
|
|
44 |
*/
|
|
|
45 |
CEzLcd::CEzLcd()
|
|
|
46 |
{
|
|
|
47 |
m_iPageCount = 0;
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
/****f* EZ.LCD.Wrapper/CEzLcd::CEzLcd
|
|
|
51 |
* NAME
|
|
|
52 |
* CEzLcd::CEzLcd(LPCTSTR pFriendlyName, INT iWidth, INT iHeight).
|
|
|
53 |
* FUNCTION
|
|
|
54 |
* Does necessary initialization. If you are calling this constructor,
|
|
|
55 |
* then you should NOT call the InitYourself(...) method.
|
|
|
56 |
* INPUTS
|
|
|
57 |
* pFriendlyName - friendly name of the applet/game. This name will be
|
|
|
58 |
* displayed in the Logitech G-series LCD Manager.
|
|
|
59 |
* iWidth - width in pixels of the LCD.
|
|
|
60 |
* iHeight - height in pixels of the LCD.
|
|
|
61 |
******
|
|
|
62 |
*/
|
|
|
63 |
CEzLcd::CEzLcd(LPCTSTR pFriendlyName, INT iWidth, INT iHeight)
|
|
|
64 |
{
|
|
|
65 |
m_iPageCount = 0;
|
|
|
66 |
InitYourself(pFriendlyName, FALSE, FALSE, NULL, iWidth, iHeight);
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
CEzLcd::~CEzLcd()
|
|
|
70 |
{
|
|
|
71 |
// delete all the screens
|
|
|
72 |
LCD_PAGE_LIST::iterator it = m_LCDPageList.begin();
|
|
|
73 |
while(it != m_LCDPageList.end())
|
|
|
74 |
{
|
|
|
75 |
CEzLcdPage *pPage = *it;
|
|
|
76 |
LCDUIASSERT(NULL != pPage);
|
|
|
77 |
|
|
|
78 |
delete pPage;
|
|
|
79 |
++it;
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
m_output.Shutdown();
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
/****f* EZ.LCD.Wrapper/CEzLcd::InitYourself
|
|
|
86 |
* NAME
|
|
|
87 |
* HRESULT CEzLcd::InitYourself(pFriendlyName, BOOL IsAutoStartable,
|
|
|
88 |
* BOOL IsPersistent, lgLcdOnConfigureCB callbackFunction ,width ,
|
|
|
89 |
* height)
|
|
|
90 |
* FUNCTION
|
|
|
91 |
* Does necessary initialization. This method SHOULD ONLY be called if
|
|
|
92 |
* the empty constructor is used: CEzLcd::CEzLcd()
|
|
|
93 |
* INPUTS
|
|
|
94 |
* pFriendlyName - friendly name of the applet/game. This name will be
|
|
|
95 |
* displayed in the Logitech G-series LCD Manager.
|
|
|
96 |
* IsAutoStartable - Determines if the applet is to be started
|
|
|
97 |
* automatically every time by the LCD manager software
|
|
|
98 |
* (Part of G15 software package)
|
|
|
99 |
* IsPersistent - Determines if the applet's friendlyName will remain
|
|
|
100 |
* in the list of applets seen by the LCD manager
|
|
|
101 |
* software after the applet terminates
|
|
|
102 |
* pConfigContext - Pointer to the lgLcdConfigContext structure used
|
|
|
103 |
* during callback into the applet
|
|
|
104 |
* width - width in pixels of the LCD.
|
|
|
105 |
* height - height in pixels of the LCD.
|
|
|
106 |
* RETURN VALUE
|
|
|
107 |
* The method returns the S_OK if it can connect to the LCD Manager
|
|
|
108 |
* library, or returns E_FAIL if it can not.
|
|
|
109 |
******
|
|
|
110 |
*/
|
|
|
111 |
HRESULT CEzLcd::InitYourself(LPCTSTR pFriendlyName, BOOL bIsAutoStartable, BOOL bIsPersistent,
|
|
|
112 |
lgLcdConfigureContext * pConfigContext, INT iWidth, INT iHeight)
|
|
|
113 |
{
|
|
|
114 |
if (m_iPageCount != 0)
|
|
|
115 |
{
|
|
|
116 |
// Maybe the user is calling the old constructor and calling InitYourself as well.
|
|
|
117 |
// Alert him of the problem. If the old constructor is called, then InitYourself should
|
|
|
118 |
// not be called. InitYourself should be called, when the empty parameter constructor is
|
|
|
119 |
// called, CEzLcd::CEzLcd()
|
|
|
120 |
return E_FAIL;
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
m_iLcdWidth = iWidth;
|
|
|
124 |
m_iLcdHeight = iHeight;
|
|
|
125 |
_tcscpy(m_chFriendlyName, pFriendlyName);
|
|
|
126 |
|
|
|
127 |
m_bInitNeeded = TRUE;
|
|
|
128 |
m_bInitSucceeded = FALSE;
|
|
|
129 |
|
|
|
130 |
for (INT ii = 0; ii < NUMBER_SOFT_BUTTONS; ii++)
|
|
|
131 |
{
|
|
|
132 |
m_bButtonIsPressed[ii] = FALSE;
|
|
|
133 |
m_bButtonWasPressed[ii] = FALSE;
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
m_pConfigContext = pConfigContext; // Keep the context structure pointer
|
|
|
137 |
m_bIsPersistent = bIsPersistent;
|
|
|
138 |
m_bIsAutoStartable = bIsAutoStartable;
|
|
|
139 |
|
|
|
140 |
// No active page to start with
|
|
|
141 |
m_pActivePage = NULL;
|
|
|
142 |
|
|
|
143 |
// Add the first page for backwards compatibility
|
|
|
144 |
AddNewPage();
|
|
|
145 |
ModifyControlsOnPage(0);
|
|
|
146 |
|
|
|
147 |
// Will now connect to the real library and see it the lgLcdInit() succeeds
|
|
|
148 |
lgLcdConnectContext lgdConnectContext_;
|
|
|
149 |
lgLcdConfigureContext lgdConfigureContext_;
|
|
|
150 |
|
|
|
151 |
if (m_pConfigContext != NULL)
|
|
|
152 |
{
|
|
|
153 |
lgdConfigureContext_.configCallback = m_pConfigContext->configCallback;
|
|
|
154 |
lgdConfigureContext_.configContext = m_pConfigContext->configContext;
|
|
|
155 |
}
|
|
|
156 |
else
|
|
|
157 |
{
|
|
|
158 |
lgdConfigureContext_.configCallback = NULL;
|
|
|
159 |
lgdConfigureContext_.configContext = NULL;
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
lgdConnectContext_.appFriendlyName = m_chFriendlyName;
|
|
|
163 |
lgdConnectContext_.isPersistent = m_bIsPersistent;
|
|
|
164 |
lgdConnectContext_.isAutostartable = m_bIsAutoStartable;
|
|
|
165 |
lgdConnectContext_.onConfigure = lgdConfigureContext_;
|
|
|
166 |
|
|
|
167 |
if (FAILED(m_output.Initialize(&lgdConnectContext_, FALSE)))
|
|
|
168 |
{
|
|
|
169 |
// This means the LCD SDK's lgLcdInit failed, and therefore
|
|
|
170 |
// we will not be able to ever connect to the LCD, even if
|
|
|
171 |
// a G-series keyboard is actually connected.
|
|
|
172 |
LCDUITRACE(_T("ERROR: LCD SDK initialization failed\n"));
|
|
|
173 |
m_bInitSucceeded = FALSE;
|
|
|
174 |
return E_FAIL;
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
return S_OK;
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
/****f* EZ.LCD.Wrapper/CEzLcd::AddNewPage
|
|
|
181 |
* NAME
|
|
|
182 |
* INT CEzLcd::AddNewPage(VOID) -- Call this method to create a new page
|
|
|
183 |
* to be displayed on the LCD. The method returns the current number
|
|
|
184 |
* of pages, after the page is added.
|
|
|
185 |
* INPUTS
|
|
|
186 |
* NONE
|
|
|
187 |
* RETURN VALUE
|
|
|
188 |
* The method returns the current number of pages, after the page is
|
|
|
189 |
* added.
|
|
|
190 |
******
|
|
|
191 |
*/
|
|
|
192 |
INT CEzLcd::AddNewPage(VOID)
|
|
|
193 |
{
|
|
|
194 |
CEzLcdPage* pPage = NULL;
|
|
|
195 |
|
|
|
196 |
// Create a new page and add it in
|
|
|
197 |
pPage = new CEzLcdPage(this, m_iLcdWidth, m_iLcdHeight);
|
|
|
198 |
pPage->Initialize();
|
|
|
199 |
pPage->SetExpiration(INFINITE);
|
|
|
200 |
|
|
|
201 |
m_LCDPageList.push_back(pPage);
|
|
|
202 |
|
|
|
203 |
m_iPageCount = m_LCDPageList.size();
|
|
|
204 |
return m_iPageCount;
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
/****f* EZ.LCD.Wrapper/CEzLcd::RemovePage
|
|
|
208 |
* NAME
|
|
|
209 |
* INT CEzLcd::RemovePage(INT iPageNumber) -- Call this method to remove
|
|
|
210 |
* a page from the pages you've created to be displayed on the LCD.
|
|
|
211 |
* The method returns the current number of pages, after the page is
|
|
|
212 |
* deleted.
|
|
|
213 |
* INPUTS
|
|
|
214 |
* iPageNumber - The number for the page that is to be removed.
|
|
|
215 |
* RETURN VALUE
|
|
|
216 |
* The method returns the current number of pages, after the page is
|
|
|
217 |
* removed.
|
|
|
218 |
******
|
|
|
219 |
*/
|
|
|
220 |
INT CEzLcd::RemovePage(INT iPageNumber)
|
|
|
221 |
{
|
|
|
222 |
// Do we have this page, if not return error
|
|
|
223 |
if (iPageNumber >= m_iPageCount)
|
|
|
224 |
{
|
|
|
225 |
return -1;
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
// find the next active screen
|
|
|
229 |
LCD_PAGE_LIST::iterator it = m_LCDPageList.begin();
|
|
|
230 |
m_LCDPageList.erase(it + iPageNumber);
|
|
|
231 |
|
|
|
232 |
--m_iPageCount; // Decrement the number of pages
|
|
|
233 |
if (m_iPageCount > 0)
|
|
|
234 |
{
|
|
|
235 |
m_pActivePage = *it;
|
|
|
236 |
}
|
|
|
237 |
else
|
|
|
238 |
{
|
|
|
239 |
m_pActivePage = NULL;
|
|
|
240 |
}
|
|
|
241 |
return m_iPageCount;
|
|
|
242 |
}
|
|
|
243 |
|
|
|
244 |
/****f* EZ.LCD.Wrapper/CEzLcd::GetPageCount
|
|
|
245 |
* NAME
|
|
|
246 |
* INT CEzLcd::GetPageCount(VOID) returns the current number of pages.
|
|
|
247 |
* INPUTS
|
|
|
248 |
* None.
|
|
|
249 |
* RETURN VALUE
|
|
|
250 |
* The method returns the current number of pages.
|
|
|
251 |
******
|
|
|
252 |
*/
|
|
|
253 |
INT CEzLcd::GetPageCount(VOID)
|
|
|
254 |
{
|
|
|
255 |
return m_iPageCount;
|
|
|
256 |
}
|
|
|
257 |
|
|
|
258 |
/****f* EZ.LCD.Wrapper/CEzLcd::AddNumberOfPages
|
|
|
259 |
* NAME
|
|
|
260 |
* INT CEzLcd::AddNumberOfPages(INT iNumberOfPages) - Adds iNumberOfPages
|
|
|
261 |
* to the total of pages you've created.
|
|
|
262 |
* INPUTS
|
|
|
263 |
* iNumberOfPages - Count of pages to add in.
|
|
|
264 |
* RETURN VALUE
|
|
|
265 |
* The method returns the current number of pages, after the pages are
|
|
|
266 |
* added.
|
|
|
267 |
******
|
|
|
268 |
*/
|
|
|
269 |
INT CEzLcd::AddNumberOfPages(INT iNumberOfPages)
|
|
|
270 |
{
|
|
|
271 |
for (int iCount=0; iCount<iNumberOfPages; iCount++)
|
|
|
272 |
{
|
|
|
273 |
AddNewPage();
|
|
|
274 |
}
|
|
|
275 |
|
|
|
276 |
return GetPageCount();
|
|
|
277 |
}
|
|
|
278 |
|
|
|
279 |
|
|
|
280 |
/****f* EZ.LCD.Wrapper/CEzLcd::ModifyControlsOnPage
|
|
|
281 |
* NAME
|
|
|
282 |
* INT CEzLcd::ModifyControlsOnPage(INT iPageNumber) - Call this method
|
|
|
283 |
* in order to modify the controls on page. This method must be
|
|
|
284 |
* called first prior to any modifications on that page.
|
|
|
285 |
* INPUTS
|
|
|
286 |
* iPageNumber - The page number that the controls will be modified on.
|
|
|
287 |
* RETURN VALUE
|
|
|
288 |
* TRUE - If succeeded.
|
|
|
289 |
* FALSE - If encountered an error.
|
|
|
290 |
******
|
|
|
291 |
*/
|
|
|
292 |
BOOL CEzLcd::ModifyControlsOnPage(INT iPageNumber)
|
|
|
293 |
{
|
|
|
294 |
if (iPageNumber >= m_iPageCount)
|
|
|
295 |
{
|
|
|
296 |
return FALSE;
|
|
|
297 |
}
|
|
|
298 |
|
|
|
299 |
LCD_PAGE_LIST::iterator it = m_LCDPageList.begin();
|
|
|
300 |
m_pActivePage = *(it + iPageNumber);
|
|
|
301 |
|
|
|
302 |
return TRUE;
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
/****f* EZ.LCD.Wrapper/CEzLcd::ShowPage
|
|
|
306 |
* NAME
|
|
|
307 |
* INT CEzLcd::ShowPage(INT iPageNumber) Call this method in order to
|
|
|
308 |
* make the page shown on the LCD,
|
|
|
309 |
* INPUTS
|
|
|
310 |
* iPageNumber - The page that will be shown among your pages on the LCD.
|
|
|
311 |
* RETURN VALUE
|
|
|
312 |
* TRUE - If succeeded.
|
|
|
313 |
* FALSE - If encountered an error.
|
|
|
314 |
******
|
|
|
315 |
*/
|
|
|
316 |
BOOL CEzLcd::ShowPage(INT iPageNumber)
|
|
|
317 |
{
|
|
|
318 |
if (iPageNumber >= m_iPageCount)
|
|
|
319 |
{
|
|
|
320 |
return FALSE;
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
LCD_PAGE_LIST::iterator it = m_LCDPageList.begin();
|
|
|
324 |
m_pActivePage = *(it + iPageNumber);
|
|
|
325 |
|
|
|
326 |
m_output.UnlockScreen();
|
|
|
327 |
m_output.LockScreen(m_pActivePage);
|
|
|
328 |
|
|
|
329 |
return TRUE;
|
|
|
330 |
}
|
|
|
331 |
|
|
|
332 |
/****f* EZ.LCD.Wrapper/CEzLcd::AddText
|
|
|
333 |
* NAME
|
|
|
334 |
* HANDLE CEzLcd::AddText(LGObjectType type, LGTextSize size,
|
|
|
335 |
* INT iAlignment, INT iMaxLengthPixels) -- Add a text object to the
|
|
|
336 |
* page you are working on.
|
|
|
337 |
* INPUTS
|
|
|
338 |
* type - specifies whether the text is static or
|
|
|
339 |
* scrolling. Possible types are: LG_SCROLLING_TEXT,
|
|
|
340 |
* LG_STATIC_TEXT
|
|
|
341 |
* size - size of the text. Choose between these three:
|
|
|
342 |
* LG_SMALL, LG_MEDIUM or LG_BIG.
|
|
|
343 |
* iAlignment - alignment of the text. Values are: DT_LEFT,
|
|
|
344 |
* DT_CENTER, DT_RIGHT.
|
|
|
345 |
* iMaxLengthPixels - max length in pixels of the text. If the text is
|
|
|
346 |
* longer and of type LG_STATIC_TEXT, it will be cut
|
|
|
347 |
* off. If the text is longer and of type
|
|
|
348 |
* LG_SCROLLING_TEXT, it will scroll.
|
|
|
349 |
* RETURN VALUE
|
|
|
350 |
* Handle for this object.
|
|
|
351 |
* SEE ALSO
|
|
|
352 |
* CEzLcd::AddIcon
|
|
|
353 |
* CEzLcd::AddProgressBar
|
|
|
354 |
******
|
|
|
355 |
*/
|
|
|
356 |
HANDLE CEzLcd::AddText(LGObjectType type, LGTextSize size, INT iAlignment, INT iMaxLengthPixels)
|
|
|
357 |
{
|
|
|
358 |
return AddText(type, size, iAlignment, iMaxLengthPixels, 1);
|
|
|
359 |
}
|
|
|
360 |
|
|
|
361 |
/****f* EZ.LCD.Wrapper/CEzLcd::AddText
|
|
|
362 |
* NAME
|
|
|
363 |
* HANDLE CEzLcd::AddText(LGObjectType type, LGTextSize size,
|
|
|
364 |
* INT iAlignment, INT iMaxLengthPixels, INT iNumberOfLines) -- Add a
|
|
|
365 |
* text object to the page you are working on.
|
|
|
366 |
* INPUTS
|
|
|
367 |
* type - specifies whether the text is static or
|
|
|
368 |
* scrolling. Possible types are: LG_SCROLLING_TEXT,
|
|
|
369 |
* LG_STATIC_TEXT
|
|
|
370 |
* size - size of the text. Choose between these three:
|
|
|
371 |
* LG_SMALL, LG_MEDIUM or LG_BIG.
|
|
|
372 |
* iAlignment - alignment of the text. Values are: DT_LEFT,
|
|
|
373 |
* DT_CENTER, DT_RIGHT.
|
|
|
374 |
* iMaxLengthPixels - max length in pixels of the text. If the text is
|
|
|
375 |
* longer and of type LG_STATIC_TEXT, it will be cut
|
|
|
376 |
* off. If the text is longer and of type
|
|
|
377 |
* LG_SCROLLING_TEXT, it will scroll.
|
|
|
378 |
* iNumberOfLines - number of lines the text can use. For static text
|
|
|
379 |
* only. If number bigger than 1 and statoc text is
|
|
|
380 |
* too long to fit on LCD, the text will be displayed
|
|
|
381 |
* on multiple lines as necessary.
|
|
|
382 |
* RETURN VALUE
|
|
|
383 |
* Handle for this object.
|
|
|
384 |
* SEE ALSO
|
|
|
385 |
* CEzLcd::AddIcon
|
|
|
386 |
* CEzLcd::AddProgressBar
|
|
|
387 |
******
|
|
|
388 |
*/
|
|
|
389 |
HANDLE CEzLcd::AddText(LGObjectType type, LGTextSize size, INT iAlignment, INT iMaxLengthPixels,
|
|
|
390 |
INT iNumberOfLines)
|
|
|
391 |
{
|
|
|
392 |
if (m_pActivePage == NULL)
|
|
|
393 |
{
|
|
|
394 |
return NULL;
|
|
|
395 |
}
|
|
|
396 |
|
|
|
397 |
return m_pActivePage->AddText(type, size, iAlignment, iMaxLengthPixels, iNumberOfLines);
|
|
|
398 |
}
|
|
|
399 |
|
|
|
400 |
/****f* EZ.LCD.Wrapper/CEzLcd::SetText
|
|
|
401 |
* NAME
|
|
|
402 |
* HRESULT CEzLcd::SetText -- Sets the text in the control on the page
|
|
|
403 |
* that you are working on.
|
|
|
404 |
* INPUTS
|
|
|
405 |
* hHandle - handle to the object.
|
|
|
406 |
* pText - text string.
|
|
|
407 |
* RETURN VALUE
|
|
|
408 |
* E_FAIL if there was an error.
|
|
|
409 |
* S_OK if no error.
|
|
|
410 |
******
|
|
|
411 |
*/
|
|
|
412 |
HRESULT CEzLcd::SetText(HANDLE hHandle, LPCTSTR pText)
|
|
|
413 |
{
|
|
|
414 |
if (m_pActivePage == NULL)
|
|
|
415 |
{
|
|
|
416 |
return E_FAIL;
|
|
|
417 |
}
|
|
|
418 |
|
|
|
419 |
return m_pActivePage->SetText(hHandle, pText);
|
|
|
420 |
}
|
|
|
421 |
|
|
|
422 |
HRESULT CEzLcd::SetSpeed(HANDLE hHandle, DWORD speed)
|
|
|
423 |
{
|
|
|
424 |
if (m_pActivePage == NULL)
|
|
|
425 |
{
|
|
|
426 |
return E_FAIL;
|
|
|
427 |
}
|
|
|
428 |
|
|
|
429 |
return m_pActivePage->SetSpeed(hHandle, speed);
|
|
|
430 |
}
|
|
|
431 |
|
242 |
cycrow |
432 |
HRESULT CEzLcd::SetText(HANDLE hHandle, const std::wstring &pText)
|
79 |
cycrow |
433 |
{
|
|
|
434 |
if (m_pActivePage == NULL)
|
|
|
435 |
{
|
|
|
436 |
return E_FAIL;
|
|
|
437 |
}
|
|
|
438 |
|
|
|
439 |
return m_pActivePage->SetText(hHandle, pText);
|
|
|
440 |
}
|
|
|
441 |
|
|
|
442 |
/****f* EZ.LCD.Wrapper/CEzLcd::AddIcon
|
|
|
443 |
* NAME
|
|
|
444 |
* HANDLE CEzLcd::AddIcon -- Add an icon object to the page that
|
|
|
445 |
* you are working on.
|
|
|
446 |
* INPUTS
|
|
|
447 |
* hIcon - icon to be displayed on the page. Should be 1 bpp
|
|
|
448 |
* bitmap.
|
|
|
449 |
* iSizeX - x-axis size of the bitmap.
|
|
|
450 |
* iSizeY - y-axis size of the bitmap.
|
|
|
451 |
* RETURN VALUE
|
|
|
452 |
* Handle for this object.
|
|
|
453 |
* SEE ALSO
|
|
|
454 |
* CEzLcd::AddText
|
|
|
455 |
* CEzLcd::AddProgressBar
|
|
|
456 |
******
|
|
|
457 |
*/
|
|
|
458 |
HANDLE CEzLcd::AddIcon(HICON hIcon, INT iSizeX, INT iSizeY)
|
|
|
459 |
{
|
|
|
460 |
if (m_pActivePage == NULL)
|
|
|
461 |
{
|
|
|
462 |
return NULL;
|
|
|
463 |
}
|
|
|
464 |
|
|
|
465 |
return m_pActivePage->AddIcon(hIcon, iSizeX, iSizeY);
|
|
|
466 |
}
|
|
|
467 |
|
|
|
468 |
/****f* EZ.LCD.Wrapper/CEzLcd::AddProgressBar
|
|
|
469 |
* NAME
|
|
|
470 |
* HANDLE CEzLcd::AddProgressBar -- Add a progress bar object to the
|
|
|
471 |
* page that you are working on.
|
|
|
472 |
* INPUTS
|
|
|
473 |
* type - type of the progress bar. Types are: LG_CURSOR,
|
|
|
474 |
* LG_FILLED, LG_DOT_CURSOR.
|
|
|
475 |
* RETURN VALUE
|
|
|
476 |
* Handle for this object.
|
|
|
477 |
* SEE ALSO
|
|
|
478 |
* CEzLcd::AddText
|
|
|
479 |
* CEzLcd::AddIcon
|
|
|
480 |
******
|
|
|
481 |
*/
|
|
|
482 |
HANDLE CEzLcd::AddProgressBar(LGProgressBarType type)
|
|
|
483 |
{
|
|
|
484 |
if (m_pActivePage == NULL)
|
|
|
485 |
{
|
|
|
486 |
return NULL;
|
|
|
487 |
}
|
|
|
488 |
|
|
|
489 |
return m_pActivePage->AddProgressBar(type);
|
|
|
490 |
}
|
|
|
491 |
|
|
|
492 |
/****f* EZ.LCD.Wrapper/CEzLcd::SetProgressBarPosition
|
|
|
493 |
* NAME
|
|
|
494 |
* HRESULT CEzLcd::SetProgressBarPosition -- Set position of the
|
|
|
495 |
* progress bar's cursor.
|
|
|
496 |
* INPUTS
|
|
|
497 |
* hHandle - handle to the object.
|
|
|
498 |
* fPercentage - percentage of progress (0 to 100).
|
|
|
499 |
* RETURN VALUE
|
|
|
500 |
* E_FAIL if there was an error or if handle does not correspond to a
|
|
|
501 |
* progress bar.
|
|
|
502 |
* S_OK if no error.
|
|
|
503 |
******
|
|
|
504 |
*/
|
|
|
505 |
HRESULT CEzLcd::SetProgressBarPosition(HANDLE hHandle, FLOAT fPercentage)
|
|
|
506 |
{
|
|
|
507 |
if (m_pActivePage == NULL)
|
|
|
508 |
{
|
|
|
509 |
return E_FAIL;
|
|
|
510 |
}
|
|
|
511 |
|
|
|
512 |
return m_pActivePage->SetProgressBarPosition(hHandle, fPercentage);
|
|
|
513 |
}
|
|
|
514 |
|
|
|
515 |
/****f* EZ.LCD.Wrapper/CEzLcd::SetProgressBarSize
|
|
|
516 |
* NAME
|
|
|
517 |
* HRESULT CEzLcd::SetProgressBarSize -- Set size of progress bar.
|
|
|
518 |
* INPUTS
|
|
|
519 |
* hHandle - handle to the object.
|
|
|
520 |
* iWidth - x-axis part of the size
|
|
|
521 |
* iHeight - y-axis part of the size (a good default value is 5).
|
|
|
522 |
* RETURN VALUE
|
|
|
523 |
* E_FAIL if there was an error or if handle does not correspond to a
|
|
|
524 |
* progress bar.
|
|
|
525 |
* S_OK if no error.
|
|
|
526 |
******
|
|
|
527 |
*/
|
|
|
528 |
HRESULT CEzLcd::SetProgressBarSize(HANDLE hHandle, INT iWidth, INT iHeight)
|
|
|
529 |
{
|
|
|
530 |
if (m_pActivePage == NULL)
|
|
|
531 |
{
|
|
|
532 |
return E_FAIL;
|
|
|
533 |
}
|
|
|
534 |
|
|
|
535 |
return m_pActivePage->SetProgressBarSize(hHandle, iWidth, iHeight);
|
|
|
536 |
}
|
|
|
537 |
|
|
|
538 |
/****f* EZ.LCD.Wrapper/CEzLcd::AddBitmap
|
|
|
539 |
* NAME
|
|
|
540 |
* HANDLE CEzLcd::AddBitmap() -- Add a bitmap object to the page that
|
|
|
541 |
* you are working on.
|
|
|
542 |
* NOTES
|
|
|
543 |
* A bitmap's size currently must always be 160x43 pixels.
|
|
|
544 |
* RETURN VALUE
|
|
|
545 |
* Handle for this object.
|
|
|
546 |
* SEE ALSO
|
|
|
547 |
* CEzLcd::AddText
|
|
|
548 |
* CEzLcd::AddIcon
|
|
|
549 |
******
|
|
|
550 |
*/
|
|
|
551 |
HANDLE CEzLcd::AddBitmap()
|
|
|
552 |
{
|
|
|
553 |
if (m_pActivePage == NULL)
|
|
|
554 |
{
|
|
|
555 |
return NULL;
|
|
|
556 |
}
|
|
|
557 |
|
|
|
558 |
return m_pActivePage->AddBitmap();
|
|
|
559 |
}
|
|
|
560 |
|
|
|
561 |
/****f* EZ.LCD.Wrapper/CEzLcd::SetBitmap
|
|
|
562 |
* NAME
|
|
|
563 |
* HRESULT CEzLcd::SetBitmap(HANDLE hHandle, HBITMAP hBitmap) -- Set the
|
|
|
564 |
* bitmap.
|
|
|
565 |
* INPUTS
|
|
|
566 |
* hHandle - handle to the object.
|
|
|
567 |
* hBitmap - 1bpp bitmap.
|
|
|
568 |
* RETURN VALUE
|
|
|
569 |
* E_FAIL if there was an error or if handle does not correspond to a
|
|
|
570 |
* bitmap.
|
|
|
571 |
* S_OK if no error.
|
|
|
572 |
******
|
|
|
573 |
*/
|
|
|
574 |
HRESULT CEzLcd::SetBitmap(HANDLE hHandle, HBITMAP hBitmap)
|
|
|
575 |
{
|
|
|
576 |
if (m_pActivePage == NULL)
|
|
|
577 |
{
|
|
|
578 |
return E_FAIL;
|
|
|
579 |
}
|
|
|
580 |
|
|
|
581 |
return m_pActivePage->SetBitmap(hHandle, hBitmap);
|
|
|
582 |
}
|
|
|
583 |
|
|
|
584 |
/****f* EZ.LCD.Wrapper/CEzLcd::SetOrigin
|
|
|
585 |
* NAME
|
|
|
586 |
* HRESULT CEzLcd::SetOrigin -- Set the origin of an object. The origin
|
|
|
587 |
* corresponds to the furthest pixel on the upper left corner of an
|
|
|
588 |
* object.
|
|
|
589 |
* INPUTS
|
|
|
590 |
* hHandle - handle to the object.
|
|
|
591 |
* iXOrigin - x-axis part of the origin.
|
|
|
592 |
* iYOrigin - y-axis part of the origin.
|
|
|
593 |
* RETURN VALUE
|
|
|
594 |
* E_FAIL if there was an error.
|
|
|
595 |
* S_OK if no error.
|
|
|
596 |
******
|
|
|
597 |
*/
|
|
|
598 |
HRESULT CEzLcd::SetOrigin(HANDLE hHandle, INT iXOrigin, INT iYOrigin)
|
|
|
599 |
{
|
|
|
600 |
if (m_pActivePage == NULL)
|
|
|
601 |
{
|
|
|
602 |
return E_FAIL;
|
|
|
603 |
}
|
|
|
604 |
|
|
|
605 |
return m_pActivePage->SetOrigin(hHandle, iXOrigin, iYOrigin);
|
|
|
606 |
}
|
|
|
607 |
|
|
|
608 |
/****f* EZ.LCD.Wrapper/CEzLcd::SetVisible
|
|
|
609 |
* NAME
|
|
|
610 |
* HRESULT CEzLcd::SetVisible -- set corresponding object to be
|
|
|
611 |
* visible or invisible on the page that you are working on.
|
|
|
612 |
* INPUTS
|
|
|
613 |
* hHandle - handle to the object.
|
|
|
614 |
* bVisible - set to FALSE to make object invisible, TRUE to
|
|
|
615 |
* make it visible (default).
|
|
|
616 |
* RETURN VALUE
|
|
|
617 |
* E_FAIL if there was an error.
|
|
|
618 |
* S_OK if no error.
|
|
|
619 |
******
|
|
|
620 |
*/
|
|
|
621 |
HRESULT CEzLcd::SetVisible(HANDLE hHandle, BOOL bVisible)
|
|
|
622 |
{
|
|
|
623 |
if (m_pActivePage == NULL)
|
|
|
624 |
{
|
|
|
625 |
return E_FAIL;
|
|
|
626 |
}
|
|
|
627 |
|
|
|
628 |
return m_pActivePage->SetVisible(hHandle, bVisible);
|
|
|
629 |
}
|
|
|
630 |
|
|
|
631 |
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
632 |
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
633 |
/****f* EZ.LCD.Wrapper/CEzLcd::ButtonTriggered
|
|
|
634 |
* NAME
|
|
|
635 |
* BOOL CEzLcd::ButtonTriggered -- Check if a button was triggered.
|
|
|
636 |
* INPUTS
|
|
|
637 |
* iButton - name of the button to be checked. Possible names are:
|
|
|
638 |
* LG_BUTTON_1, LG_BUTTON_2, LG_BUTTON_3, LG_BUTTON_4
|
|
|
639 |
* RETURN VALUE
|
|
|
640 |
* TRUE if the specific button was triggered
|
|
|
641 |
* FALSE otherwise
|
|
|
642 |
* SEE ALSO
|
|
|
643 |
* CEzLcd::ButtonReleased
|
|
|
644 |
* CEzLcd::ButtonIsPressed
|
|
|
645 |
******
|
|
|
646 |
*/
|
|
|
647 |
BOOL CEzLcd::ButtonTriggered(INT iButton)
|
|
|
648 |
{
|
|
|
649 |
if (m_bButtonIsPressed[iButton] && !m_bButtonWasPressed[iButton])
|
|
|
650 |
{
|
|
|
651 |
return TRUE;
|
|
|
652 |
}
|
|
|
653 |
|
|
|
654 |
return FALSE;
|
|
|
655 |
}
|
|
|
656 |
|
|
|
657 |
/****f* EZ.LCD.Wrapper/CEzLcd::ButtonReleased
|
|
|
658 |
* NAME
|
|
|
659 |
* BOOL CEzLcd::ButtonReleased -- Check if a button was released.
|
|
|
660 |
* INPUTS
|
|
|
661 |
* iButton - name of the button to be checked. Possible names are:
|
|
|
662 |
* LG_BUTTON_1, LG_BUTTON_2, LG_BUTTON_3, LG_BUTTON_4
|
|
|
663 |
* RETURN VALUE
|
|
|
664 |
* TRUE if the specific button was released
|
|
|
665 |
* FALSE otherwise
|
|
|
666 |
* SEE ALSO
|
|
|
667 |
* CEzLcd::ButtonTriggered
|
|
|
668 |
* CEzLcd::ButtonIsPressed
|
|
|
669 |
******
|
|
|
670 |
*/
|
|
|
671 |
BOOL CEzLcd::ButtonReleased(INT iButton)
|
|
|
672 |
{
|
|
|
673 |
if (!m_bButtonIsPressed[iButton] && m_bButtonWasPressed[iButton])
|
|
|
674 |
{
|
|
|
675 |
return TRUE;
|
|
|
676 |
}
|
|
|
677 |
return FALSE;
|
|
|
678 |
}
|
|
|
679 |
|
|
|
680 |
/****f* EZ.LCD.Wrapper/CEzLcd::ButtonIsPressed
|
|
|
681 |
* NAME
|
|
|
682 |
* BOOL CEzLcd::ButtonIsPressed -- Check if a button is being pressed.
|
|
|
683 |
* INPUTS
|
|
|
684 |
* iButton - name of the button to be checked. Possible names are:
|
|
|
685 |
* LG_BUTTON_1, LG_BUTTON_2, LG_BUTTON_3, LG_BUTTON_4
|
|
|
686 |
* RETURN VALUE
|
|
|
687 |
* TRUE if the specific button is being pressed
|
|
|
688 |
* FALSE otherwise
|
|
|
689 |
* SEE ALSO
|
|
|
690 |
* CEzLcd::ButtonTriggered
|
|
|
691 |
* CEzLcd::ButtonReleased
|
|
|
692 |
******
|
|
|
693 |
*/
|
|
|
694 |
BOOL CEzLcd::ButtonIsPressed(INT iButton)
|
|
|
695 |
{
|
|
|
696 |
return m_bButtonIsPressed[iButton];
|
|
|
697 |
}
|
|
|
698 |
|
|
|
699 |
/****f* EZ.LCD.Wrapper/CEzLcd::IsConnected
|
|
|
700 |
* NAME
|
|
|
701 |
* BOOL CEzLcd::IsConnected -- Check if a Logitech G-series LCD is
|
|
|
702 |
* connected.
|
|
|
703 |
* RETURN VALUE
|
|
|
704 |
* TRUE if an LCD is connected
|
|
|
705 |
* FALSE otherwise
|
|
|
706 |
******
|
|
|
707 |
*/
|
|
|
708 |
BOOL CEzLcd::IsConnected()
|
|
|
709 |
{
|
|
|
710 |
return m_output.IsOpened();
|
|
|
711 |
}
|
|
|
712 |
|
|
|
713 |
/****f* EZ.LCD.Wrapper/CEzLcd::SetAsForeground
|
|
|
714 |
* NAME
|
|
|
715 |
* HRESULT CEzLcd::SetAsForeground(BOOL bSetAsForeground) -- Become
|
|
|
716 |
* foreground applet on LCD, or remove yourself as foreground applet.
|
|
|
717 |
* INPUTS
|
|
|
718 |
* bSetAsForeground - Determines whether to be foreground or not.
|
|
|
719 |
* Possible values are:
|
|
|
720 |
* - TRUE implies foreground
|
|
|
721 |
* - FALSE implies no longer foreground
|
|
|
722 |
* RETURN VALUE
|
|
|
723 |
* E_FAIL if there was an error.
|
|
|
724 |
* S_OK if no error.
|
|
|
725 |
******
|
|
|
726 |
*/
|
|
|
727 |
HRESULT CEzLcd::SetAsForeground(BOOL bSetAsForeground)
|
|
|
728 |
{
|
|
|
729 |
m_output.SetAsForeground(bSetAsForeground);
|
|
|
730 |
|
|
|
731 |
return S_OK;
|
|
|
732 |
}
|
|
|
733 |
|
|
|
734 |
/****f* EZ.LCD.Wrapper/CEzLcd::SetScreenPriority
|
|
|
735 |
* NAME
|
|
|
736 |
* HRESULT CEzLcd::SetScreenPriority(DWORD priority) -- Set screen
|
|
|
737 |
* priority.
|
|
|
738 |
* INPUTS
|
|
|
739 |
* dwPriority - priority of the screen. Possible values are:
|
|
|
740 |
* - LGLCD_PRIORITY_IDLE_NO_SHOW
|
|
|
741 |
* - LGLCD_PRIORITY_BACKGROUND
|
|
|
742 |
* - LGLCD_PRIORITY_NORMAL
|
|
|
743 |
* - LGLCD_PRIORITY_ALERT.
|
|
|
744 |
* Default is LGLCD_PRIORITY_NORMAL.
|
|
|
745 |
* RETURN VALUE
|
|
|
746 |
* E_FAIL if there was an error.
|
|
|
747 |
* S_OK if no error.
|
|
|
748 |
******
|
|
|
749 |
*/
|
|
|
750 |
HRESULT CEzLcd::SetScreenPriority(DWORD dwPriority)
|
|
|
751 |
{
|
|
|
752 |
m_output.SetScreenPriority(dwPriority);
|
|
|
753 |
|
|
|
754 |
return S_OK;
|
|
|
755 |
}
|
|
|
756 |
|
|
|
757 |
/****f* EZ.LCD.Wrapper/CEzLcd::Update
|
|
|
758 |
* NAME
|
|
|
759 |
* VOID CEzLcd::Update -- Update LCD display
|
|
|
760 |
* FUNCTION
|
|
|
761 |
* Updates the display. Must be called every loop.
|
|
|
762 |
******
|
|
|
763 |
*/
|
|
|
764 |
VOID CEzLcd::Update()
|
|
|
765 |
{
|
|
|
766 |
if (m_bInitNeeded)
|
|
|
767 |
{
|
|
|
768 |
// find the next active screen
|
|
|
769 |
LCD_PAGE_LIST::iterator it = m_LCDPageList.begin();
|
|
|
770 |
while(it != m_LCDPageList.end())
|
|
|
771 |
{
|
|
|
772 |
CEzLcdPage *pPage = *it;
|
|
|
773 |
LCDUIASSERT(NULL != pPage);
|
|
|
774 |
|
|
|
775 |
// Add the screen to list of screens that m_output manages
|
|
|
776 |
m_output.AddScreen(pPage);
|
|
|
777 |
|
|
|
778 |
++it;
|
|
|
779 |
}
|
|
|
780 |
|
|
|
781 |
// Make the active screen the one on the output
|
|
|
782 |
m_output.UnlockScreen();
|
|
|
783 |
m_output.LockScreen(m_pActivePage);
|
|
|
784 |
|
|
|
785 |
// Setup registration and configure contexts.
|
|
|
786 |
lgLcdConnectContext lgdConnectContext_;
|
|
|
787 |
lgLcdConfigureContext lgdConfigureContext_;
|
|
|
788 |
|
|
|
789 |
// Further expansion of registration and configure contexts.
|
|
|
790 |
if (m_pConfigContext != NULL)
|
|
|
791 |
{
|
|
|
792 |
lgdConfigureContext_.configCallback = m_pConfigContext->configCallback;
|
|
|
793 |
lgdConfigureContext_.configContext = m_pConfigContext->configContext;
|
|
|
794 |
}
|
|
|
795 |
else
|
|
|
796 |
{
|
|
|
797 |
lgdConfigureContext_.configCallback = NULL;
|
|
|
798 |
lgdConfigureContext_.configContext = NULL;
|
|
|
799 |
}
|
|
|
800 |
|
|
|
801 |
lgdConnectContext_.appFriendlyName = m_chFriendlyName;
|
|
|
802 |
lgdConnectContext_.isPersistent = m_bIsPersistent;
|
|
|
803 |
lgdConnectContext_.isAutostartable = m_bIsAutoStartable;
|
|
|
804 |
lgdConnectContext_.onConfigure = lgdConfigureContext_;
|
|
|
805 |
|
|
|
806 |
if (FAILED(m_output.Initialize(&lgdConnectContext_, FALSE)))
|
|
|
807 |
{
|
|
|
808 |
// This means the LCD SDK's lgLcdInit failed, and therefore
|
|
|
809 |
// we will not be able to ever connect to the LCD, even if
|
|
|
810 |
// a G-series keyboard is actually connected.
|
|
|
811 |
LCDUITRACE(_T("ERROR: LCD SDK initialization failed\n"));
|
|
|
812 |
m_bInitSucceeded = FALSE;
|
|
|
813 |
}
|
|
|
814 |
else
|
|
|
815 |
{
|
|
|
816 |
m_bInitSucceeded = TRUE;
|
|
|
817 |
}
|
|
|
818 |
|
|
|
819 |
m_bInitNeeded = FALSE;
|
|
|
820 |
}
|
|
|
821 |
|
|
|
822 |
// Only do stuff if initialization was successful. Otherwise
|
|
|
823 |
// IsConnected will simply return false.
|
|
|
824 |
if (m_bInitSucceeded)
|
|
|
825 |
{
|
|
|
826 |
// Save copy of button state
|
|
|
827 |
for (INT ii = 0; ii < NUMBER_SOFT_BUTTONS; ii++)
|
|
|
828 |
{
|
|
|
829 |
m_bButtonWasPressed[ii] = m_bButtonIsPressed[ii];
|
|
|
830 |
}
|
|
|
831 |
|
|
|
832 |
m_output.Update(GetTickCount());
|
|
|
833 |
m_output.Draw();
|
|
|
834 |
}
|
|
|
835 |
}
|
|
|
836 |
|
|
|
837 |
|
|
|
838 |
VOID CEzLcd::OnLCDButtonDown(INT nButton)
|
|
|
839 |
{
|
|
|
840 |
switch(nButton)
|
|
|
841 |
{
|
|
|
842 |
case LGLCDBUTTON_BUTTON0:
|
|
|
843 |
m_bButtonIsPressed[LG_BUTTON_1] = TRUE;
|
|
|
844 |
break;
|
|
|
845 |
case LGLCDBUTTON_BUTTON1:
|
|
|
846 |
m_bButtonIsPressed[LG_BUTTON_2] = TRUE;
|
|
|
847 |
break;
|
|
|
848 |
case LGLCDBUTTON_BUTTON2:
|
|
|
849 |
m_bButtonIsPressed[LG_BUTTON_3] = TRUE;
|
|
|
850 |
break;
|
|
|
851 |
case LGLCDBUTTON_BUTTON3:
|
|
|
852 |
m_bButtonIsPressed[LG_BUTTON_4] = TRUE;
|
|
|
853 |
break;
|
|
|
854 |
default:
|
|
|
855 |
LCDUITRACE(_T("ERROR: unknown button was pressed\n"));
|
|
|
856 |
break;
|
|
|
857 |
}
|
|
|
858 |
}
|
|
|
859 |
|
|
|
860 |
VOID CEzLcd::OnLCDButtonUp(int nButton)
|
|
|
861 |
{
|
|
|
862 |
switch(nButton)
|
|
|
863 |
{
|
|
|
864 |
case LGLCDBUTTON_BUTTON0:
|
|
|
865 |
m_bButtonIsPressed[LG_BUTTON_1] = FALSE;
|
|
|
866 |
break;
|
|
|
867 |
case LGLCDBUTTON_BUTTON1:
|
|
|
868 |
m_bButtonIsPressed[LG_BUTTON_2] = FALSE;
|
|
|
869 |
break;
|
|
|
870 |
case LGLCDBUTTON_BUTTON2:
|
|
|
871 |
m_bButtonIsPressed[LG_BUTTON_3] = FALSE;
|
|
|
872 |
break;
|
|
|
873 |
case LGLCDBUTTON_BUTTON3:
|
|
|
874 |
m_bButtonIsPressed[LG_BUTTON_4] = FALSE;
|
|
|
875 |
break;
|
|
|
876 |
default:
|
|
|
877 |
LCDUITRACE(_T("ERROR: unknown button was pressed\n"));
|
|
|
878 |
break;
|
|
|
879 |
}
|
|
|
880 |
}
|