author | Mike Kinghan <mikek@symbian.org> |
Mon, 22 Nov 2010 13:48:58 +0000 | |
branch | GCC_SURGE |
changeset 120 | 10294cf40451 |
parent 51 | 254b9435d75e |
permissions | -rwxr-xr-x |
0 | 1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// omap3530/beagle_drivers/serialmouse/serialmouse.cpp |
|
15 |
// Serial mouse driver |
|
16 |
// |
|
17 |
||
18 |
||
19 |
||
20 |
/** |
|
21 |
@file |
|
22 |
@internalTechnology |
|
23 |
*/ |
|
24 |
||
25 |
#include <e32keys.h> |
|
26 |
#include <arm.h> |
|
27 |
#include <comm.h> |
|
28 |
#include <assp.h> |
|
29 |
||
30 |
#include <assp/omap3530_assp/omap3530_uart.h> |
|
31 |
//#include <assp/omap3530_assp/omap3530_prm.h> |
|
32 |
#include <assp/omap3530_assp/omap3530_prcm.h> |
|
33 |
//#include <resourceman.h> |
|
34 |
||
35 |
#include "serialmouse.h" |
|
36 |
||
51
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
37 |
#ifdef USE_SYMBIAN_PRM |
0 | 38 |
_LIT( KName, "SERMOUSE" ); |
51
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
39 |
#endif |
0 | 40 |
|
41 |
#ifdef _FRAME_BUFFER_CURSOR_ |
|
42 |
# define CURSOR_SIZE 5 |
|
43 |
#endif |
|
44 |
||
21
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
45 |
// AndyS Add support for sending keyboard events |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
46 |
#define STDKEY(x) (0x1FFF&(x)) |
0 | 47 |
|
48 |
LOCAL_C TInt halFunction(TAny* aPtr, TInt aFunction, TAny* a1, TAny* a2) |
|
49 |
{ |
|
50 |
TSerialMouse* pH=(TSerialMouse*)aPtr; |
|
51 |
return pH->HalFunction(aFunction,a1,a2); |
|
52 |
} |
|
53 |
||
54 |
TSerialMouse::TSerialMouse() |
|
55 |
: iKeyDfc( KeyDfcFn, this, Kern::DfcQue0(), 1 ), iState(ENormal), |
|
56 |
iUart( Omap3530Uart::EUart2 ) |
|
57 |
{ |
|
58 |
Kern::Printf("+TSerialMouse::TSerialMouse"); |
|
59 |
||
60 |
# ifdef _FRAME_BUFFER_CURSOR_ |
|
61 |
iCursorBuffer = new TUint16[CURSOR_SIZE*CURSOR_SIZE]; |
|
62 |
# endif |
|
63 |
||
64 |
} |
|
65 |
||
66 |
TSerialMouse::~TSerialMouse() |
|
67 |
{ |
|
68 |
# ifdef _FRAME_BUFFER_CURSOR_ |
|
69 |
delete[] iCursorBuffer; |
|
70 |
# endif |
|
71 |
} |
|
72 |
||
73 |
TInt TSerialMouse::Create() |
|
74 |
{ |
|
75 |
||
76 |
GetScreenInfo(); |
|
77 |
||
78 |
TInt r=Kern::AddHalEntry(EHalGroupMouse, halFunction, this); |
|
79 |
if (r!=KErrNone) |
|
80 |
return r; |
|
81 |
||
21
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
82 |
Kern::Printf("TSerialMouse initialising"); |
0 | 83 |
|
84 |
__KTRACE_OPT(KBOOT,Kern::Printf("+TSerialMouse::Init")) ; |
|
21
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
85 |
/* |
0 | 86 |
iDebugPort = Kern::SuperPage().iDebugPort; // Get the debug port number |
21
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
87 |
Kern::Printf("Debugport=%d", iDebugPort); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
88 |
|
0 | 89 |
if( Arm::EDebugPortJTAG == iDebugPort ) |
90 |
{ |
|
91 |
__KTRACE_OPT(KBOOT,Kern::Printf("-TSerialMouse::Init: JTAG not supported")); |
|
92 |
// We don't want to return an error here, just don't bother to initialize |
|
93 |
return KErrNone; |
|
94 |
} |
|
95 |
else if( 2 != iDebugPort ) |
|
96 |
{ |
|
97 |
__KTRACE_OPT(KBOOT,Kern::Printf("-TSerialMouse::Init: Only UART3 supported")); |
|
98 |
// We don't want to return an error here, just don't bother to initialize |
|
99 |
return KErrNone; |
|
100 |
} |
|
21
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
101 |
*/ |
0 | 102 |
|
51
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
103 |
#ifdef USE_SYMBIAN_PRM |
0 | 104 |
// Register with the power resource manager |
51
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
105 |
r = PowerResourceManager::RegisterClient( iPrmClientId, KName ); |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
106 |
__KTRACE_OPT(KBOOT,Kern::Printf("+TSerialMouse::Init:PRM client ID=%x, r=%d", iPrmClientId, r )) ; |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
107 |
if( r != KErrNone ) |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
108 |
{ |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
109 |
return r; |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
110 |
} |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
111 |
#endif |
0 | 112 |
|
21
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
113 |
Prcm::SetClockState(iUart.PrcmInterfaceClk(), Prcm::EClkOn); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
114 |
Prcm::SetClockState(iUart.PrcmFunctionClk(), Prcm::EClkOn); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
115 |
|
0 | 116 |
r =Interrupt::Bind( iUart.InterruptId(),Isr,this); |
117 |
if ( r < 0 ) |
|
118 |
{ |
|
119 |
Kern::Printf("TSerialMouse::Create Cant Bind to Interrupt %d ret %d",iUart.InterruptId(), r ); |
|
120 |
return r; |
|
121 |
} |
|
122 |
||
51
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
123 |
#ifdef USE_SYMBIAN_PRM |
0 | 124 |
// Ask power resource manager to turn on clocks to the UART |
125 |
// (this could take some time but we're not in any hurry) |
|
51
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
126 |
r = PowerResourceManager::ChangeResourceState( iPrmClientId, iUart.PrmFunctionClk(), Prcm::EClkAuto ); |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
127 |
if( r = KErrNone ) |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
128 |
{ |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
129 |
r = PowerResourceManager::ChangeResourceState( iPrmClientId, iUart.PrmInterfaceClk(), Prcm::EClkAuto ); |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
130 |
} |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
131 |
|
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
132 |
if( r != KErrNone ) |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
133 |
{ |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
134 |
__KTRACE_OPT(KBOOT, Kern::Printf("+TSerialMouse:PRM ChangeResourceState(clock(s)) failed, client ID=%x, err=%d", iPrmClientId, r)); |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
135 |
return r; |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
136 |
} |
254b9435d75e
Fixed build warnings
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
21
diff
changeset
|
137 |
#endif |
0 | 138 |
|
139 |
iUart.Init(); |
|
140 |
iUart.DefineMode( Omap3530Uart::TUart::EUart ); |
|
141 |
iUart.SetBaud( Omap3530Uart::TUart::E1200 ); |
|
142 |
iUart.SetDataFormat( Omap3530Uart::TUart::E7Data, Omap3530Uart::TUart::E1Stop, Omap3530Uart::TUart::ENone ); |
|
143 |
iUart.EnableFifo( Omap3530Uart::TUart::EEnabled, Omap3530Uart::TUart::ETriggerUnchanged, Omap3530Uart::TUart::ETrigger8 ); |
|
144 |
iUart.EnableInterrupt( Omap3530Uart::TUart::EIntRhr ); |
|
145 |
iUart.Enable(); |
|
146 |
||
147 |
Interrupt::Enable(iUart.InterruptId()); |
|
21
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
148 |
|
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
149 |
Kern::Printf("TSerialMouse initialised ID=%d", iUart.InterruptId()); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
150 |
|
0 | 151 |
return KErrNone; |
152 |
} |
|
153 |
||
154 |
||
155 |
void TSerialMouse::Isr( TAny* aPtr ) |
|
156 |
// |
|
157 |
// Interrupt service routine. Called when we receive an interrupt |
|
158 |
// on the IRQ line it is bound to. If it's a receive, queues DFC |
|
159 |
// to post the event into the event queue. |
|
160 |
// |
|
161 |
{ |
|
162 |
TSerialMouse* self = (TSerialMouse*)aPtr; |
|
163 |
||
164 |
const TUint iir = Omap3530Uart::IIR::iMem.Read( self->iUart ); |
|
165 |
||
166 |
if ( 0 == (iir bitand Omap3530Uart::IIR::IT_PENDING::KMask) ) |
|
167 |
{ |
|
168 |
const TUint pending = iir bitand Omap3530Uart::IIR::IT_TYPE::KFieldMask; |
|
169 |
||
170 |
// Although the TI datasheet descrivwed IT_TYPE as being an enumerated priority-decoded interrupt |
|
171 |
// it appears to actually be a bitmask of active interrupt sources |
|
172 |
if ( (pending bitand Omap3530Uart::IIR::IT_TYPE::ERHR) || (pending bitand Omap3530Uart::IIR::IT_TYPE::ERxLineStatus) ) |
|
173 |
{ |
|
174 |
TUint byte = self->iUart.Read(); |
|
175 |
||
176 |
self->iKey = byte; |
|
177 |
self->iKeyDfc.Add(); |
|
178 |
Interrupt::Disable( self->iUart.InterruptId() ); |
|
179 |
} |
|
180 |
} |
|
181 |
} |
|
182 |
||
183 |
void TSerialMouse::KeyDfcFn( TAny* aPtr ) |
|
184 |
// |
|
185 |
// DFC function. Just calls inline function KeyDfc() |
|
186 |
// |
|
187 |
{ |
|
188 |
((TSerialMouse*)aPtr)->KeyDfc(); |
|
189 |
} |
|
190 |
||
191 |
inline void TSerialMouse::KeyDfc() |
|
192 |
// |
|
193 |
// Processes received characters |
|
194 |
// |
|
195 |
{ |
|
196 |
||
197 |
const TUint8 b = iKey; |
|
198 |
if ( b & 1<<6 ) |
|
199 |
{ |
|
200 |
// Beginning of a new frame |
|
201 |
iByteIndex = 0; |
|
202 |
iB0 = b; |
|
203 |
} |
|
204 |
else if ( iByteIndex == 0 ) |
|
205 |
{ |
|
206 |
iByteIndex = 1; |
|
207 |
iB1 = b; |
|
208 |
} |
|
209 |
else if ( iByteIndex == 1 ) |
|
210 |
{ |
|
211 |
iByteIndex = -1; |
|
212 |
iB2 = b; |
|
213 |
||
214 |
const TInt8 x_increment = (iB0 & 0x3)<<6 | (iB1 & 0x3f); |
|
215 |
const TInt8 y_increment = (iB0 & 0xC)<<4 | (iB2 & 0x3f); |
|
216 |
const TBool isLeftButtonDown = iB0& 1<<5; |
|
217 |
const TBool isRightButtonDown = iB0& 1<<4; |
|
218 |
||
21
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
219 |
Kern::Printf("Mouse dx=%d dy=%d lmb=%d", x_increment, y_increment, isLeftButtonDown); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
220 |
|
0 | 221 |
# ifdef _FRAME_BUFFER_CURSOR_ |
222 |
iLastX = iX; |
|
223 |
iLastY = iY; |
|
224 |
# endif |
|
225 |
||
226 |
iX += x_increment; //Scale ( x_increment ); |
|
227 |
iY += y_increment; //Scale ( y_increment ); |
|
228 |
||
229 |
Clip( iX, iY ); |
|
230 |
||
231 |
//DBG_PRINT4(_L("\nx:%d y:%d (%d,%d)"), x_increment, y_increment, iX, iY ); |
|
232 |
||
233 |
TBool rightButtonEvent = (isRightButtonDown != iLastRightButtonDown); |
|
234 |
TBool leftButtonEvent = (isLeftButtonDown != iLastLeftButtonDown); |
|
235 |
iLastLeftButtonDown = isLeftButtonDown; |
|
236 |
iLastRightButtonDown = isRightButtonDown; |
|
237 |
||
238 |
TRawEvent e; |
|
239 |
||
240 |
if ( rightButtonEvent ) |
|
241 |
{ |
|
21
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
242 |
if(isRightButtonDown) |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
243 |
{ |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
244 |
e.Set( isRightButtonDown ? TRawEvent::EButton2Down : TRawEvent::EButton2Up, iX, iY ); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
245 |
Kern::AddEvent(e); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
246 |
} |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
247 |
else |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
248 |
{ |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
249 |
AddKey(EStdKeyApplication0); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
250 |
} |
0 | 251 |
//DBG_PRINT1(_L(" right:%S"), isRightButtonDown?&_L("down"):&_L("up") ); |
252 |
} |
|
253 |
||
254 |
if ( leftButtonEvent ) |
|
255 |
{ |
|
256 |
e.Set( isLeftButtonDown ? TRawEvent::EButton1Down : TRawEvent::EButton1Up, iX, iY ); |
|
257 |
Kern::AddEvent(e); |
|
258 |
//DBG_PRINT1(_L(" left:%S"), isLeftButtonDown?&_L("down"):&_L("up") ); |
|
259 |
} |
|
260 |
||
261 |
if ( !rightButtonEvent && !leftButtonEvent ) |
|
262 |
{ |
|
263 |
# ifdef _TRACK_COORDINATES_ |
|
264 |
// Reoprt the exact coordinate to the windowserver |
|
265 |
e.Set(TRawEvent::EPointerMove,iX,iY); |
|
266 |
# else |
|
267 |
// Report the change in coordinates to the windowserver |
|
268 |
e.Set(TRawEvent::EPointerMove,x_increment,y_increment); |
|
269 |
# endif |
|
270 |
Kern::AddEvent(e); |
|
271 |
} |
|
272 |
||
273 |
# ifdef _FRAME_BUFFER_CURSOR_ |
|
274 |
DrawCursor(iX,iY); |
|
275 |
# endif |
|
276 |
||
277 |
} |
|
278 |
||
279 |
Interrupt::Enable(iUart.InterruptId()); // Can handle new chars now |
|
280 |
} /* end of function - KeyDfc - */ |
|
281 |
||
282 |
||
283 |
/* |
|
284 |
Perform 2:1 scaling on a mosue movement. |
|
285 |
*/ |
|
286 |
TInt TSerialMouse::Scale(const TInt& aVal) |
|
287 |
{ |
|
288 |
switch (aVal) |
|
289 |
{ |
|
290 |
case 0: return 0; |
|
291 |
case 1: |
|
292 |
case 2: return 1; |
|
293 |
case 3: return 3; |
|
294 |
case 4: return 6; |
|
295 |
case 5: return 9; |
|
296 |
case -1: |
|
297 |
case -2: return -1; |
|
298 |
case -3: return -3; |
|
299 |
case -4: return -6; |
|
300 |
case -5: return -9; |
|
301 |
default: return 2*aVal; |
|
302 |
} |
|
303 |
} |
|
304 |
||
305 |
/* |
|
306 |
Clip the mouse coordinates into the dimensions of the screen |
|
307 |
*/ |
|
308 |
void TSerialMouse::Clip(TInt& aX, TInt& aY) |
|
309 |
{ |
|
310 |
if ( aX < 0 ) aX = 0; |
|
311 |
if ( aX >= iScreenWidth ) aX = iScreenWidth - 1; |
|
312 |
if ( aY < 0 ) aY = 0; |
|
313 |
if ( aY >= iScreenHeight ) aY = iScreenHeight - 1; |
|
314 |
} |
|
315 |
||
316 |
void TSerialMouse::GetScreenInfo() |
|
317 |
{ |
|
318 |
TScreenInfoV01 screenInfo; |
|
319 |
TPckg<TScreenInfoV01> sI(screenInfo); |
|
320 |
Kern::HalFunction(EHalGroupDisplay,EDisplayHalScreenInfo,(TAny*)&sI,NULL); |
|
321 |
iScreenWidth = screenInfo.iScreenSize.iWidth; |
|
322 |
iScreenHeight = screenInfo.iScreenSize.iHeight; |
|
323 |
# ifdef _FRAME_BUFFER_CURSOR_ |
|
324 |
iVideoAddress = (TUint8*)screenInfo.iScreenAddress; |
|
325 |
# endif |
|
326 |
} |
|
327 |
||
328 |
#ifdef _FRAME_BUFFER_CURSOR_ |
|
329 |
void TSerialMouse::Blit(TInt x, TInt y, TUint16 aColour) |
|
330 |
{ |
|
331 |
||
332 |
TUint16* fb = (TUint16*)iVideoAddress; |
|
333 |
fb += (iLastY * iScreenWidth) + iLastX; |
|
334 |
for (TInt i = 0; i<CURSOR_SIZE; ++i) //row |
|
335 |
{ |
|
336 |
||
337 |
if ( (iLastY + i) >= iScreenHeight) break; |
|
338 |
||
339 |
for (TInt j = 0; j<CURSOR_SIZE; ++j) //column |
|
340 |
{ |
|
341 |
||
342 |
if ((iLastX+j) < iScreenWidth) |
|
343 |
{ |
|
344 |
*fb = iCursorBuffer[i*CURSOR_SIZE + j]; |
|
345 |
} |
|
346 |
||
347 |
++fb; |
|
348 |
} |
|
349 |
fb += iScreenWidth - CURSOR_SIZE; |
|
350 |
} |
|
351 |
||
352 |
||
353 |
fb = (TUint16*)iVideoAddress; |
|
354 |
fb += (y * iScreenWidth) + x; |
|
355 |
for (TInt i = 0; i<CURSOR_SIZE; ++i) //row |
|
356 |
{ |
|
357 |
||
358 |
if ( (y + i) >= iScreenHeight) break; |
|
359 |
||
360 |
for (TInt j = 0; j<CURSOR_SIZE; ++j) //column |
|
361 |
{ |
|
362 |
||
363 |
if ((x+j) < iScreenWidth) |
|
364 |
{ |
|
365 |
iCursorBuffer[i*CURSOR_SIZE + j] = *fb; |
|
366 |
*fb = aColour; |
|
367 |
} |
|
368 |
||
369 |
++fb; |
|
370 |
} |
|
371 |
fb += iScreenWidth - CURSOR_SIZE; |
|
372 |
} |
|
373 |
||
374 |
/*TUint8* fb = iVideoAddress; |
|
375 |
fb += ( (y * iScreenWidth) + x ) * 2; |
|
376 |
||
377 |
TBuf8<256> cur; |
|
378 |
cur.FillZ(); |
|
379 |
TUint8* cursor = &cur[0]; |
|
380 |
||
381 |
for (TInt i = 0; i<cursorSize; ++i) |
|
382 |
{ |
|
383 |
||
384 |
if ( (y + i) >= iScreenHeight) break; |
|
385 |
||
386 |
TInt bytes_to_copy = Min( cursorSize, iScreenWidth*2 - x*2 ); |
|
387 |
||
388 |
Mem::Copy(fb, cursor, bytes_to_copy ); |
|
389 |
||
390 |
cursor += cursorSize; |
|
391 |
||
392 |
}*/ |
|
393 |
||
394 |
} |
|
395 |
||
396 |
void TSerialMouse::DrawCursor(TInt x, TInt y) |
|
397 |
{ |
|
398 |
TUint16 cursorColour = iLastLeftButtonDown ? 0x1F : 0x00; |
|
399 |
Blit(x, y, cursorColour); |
|
400 |
} |
|
401 |
#endif |
|
402 |
||
403 |
||
404 |
TInt TSerialMouse::HalFunction(TInt aFunction, TAny* a1, TAny* /*a2*/) |
|
405 |
{ |
|
406 |
TInt r=KErrNone; |
|
407 |
switch(aFunction) |
|
408 |
{ |
|
409 |
case EMouseHalMouseInfo: |
|
410 |
{ |
|
411 |
TPckgBuf<TMouseInfoV01> vPckg; |
|
412 |
TMouseInfoV01& xyinfo=vPckg(); |
|
413 |
xyinfo.iMouseButtons=2; |
|
414 |
xyinfo.iMouseAreaSize.iWidth=iScreenWidth; |
|
415 |
xyinfo.iMouseAreaSize.iHeight=iScreenHeight; |
|
416 |
xyinfo.iOffsetToDisplay.iX=0; |
|
417 |
xyinfo.iOffsetToDisplay.iY=0; |
|
418 |
Kern::InfoCopy(*(TDes8*)a1,vPckg); |
|
419 |
break; |
|
420 |
} |
|
421 |
default: |
|
422 |
r=KErrNotSupported; |
|
423 |
break; |
|
424 |
} |
|
425 |
return r; |
|
426 |
} |
|
427 |
||
428 |
void DoCreate( TAny* aParam ) |
|
429 |
{ |
|
430 |
TInt r = reinterpret_cast< TSerialMouse* >( aParam )->Create(); |
|
431 |
__ASSERT_ALWAYS( r == KErrNone, Kern::Fault( "SERKEY-Cr", r ) ); |
|
432 |
} |
|
433 |
||
21
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
434 |
// AndyS support for sending keypresses |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
435 |
void TSerialMouse::AddKey( TUint aKey ) |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
436 |
{ |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
437 |
const TUint8 stdKey = STDKEY(aKey); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
438 |
|
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
439 |
TRawEvent e; |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
440 |
|
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
441 |
Kern::Printf("AddKey %d", stdKey); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
442 |
|
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
443 |
e.Set( TRawEvent::EKeyDown, stdKey, 0 ); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
444 |
Kern::AddEvent( e ); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
445 |
e.Set( TRawEvent::EKeyUp, stdKey, 0 ); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
446 |
Kern::AddEvent( e ); |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
447 |
} |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
448 |
|
0 | 449 |
|
450 |
// |
|
451 |
// Kernel Extension entry point |
|
452 |
// |
|
453 |
DECLARE_STANDARD_EXTENSION() |
|
454 |
{ |
|
455 |
__KTRACE_OPT(KBOOT,Kern::Printf("Starting mouse driver")); |
|
456 |
||
457 |
// create mouse driver |
|
458 |
TInt r=KErrNoMemory; |
|
459 |
TSerialMouse* mouse = new TSerialMouse; |
|
460 |
if ( mouse ) |
|
461 |
{ |
|
462 |
// Because the Power Resource Manager doesn't finish initializing until after it |
|
463 |
// has run a DFC on SvMsgQue, we need to defer our initialization until after that |
|
464 |
// so we know that the PRM is ready for us to use it |
|
465 |
static TDfc createDfc( &DoCreate, NULL ); |
|
466 |
new( &createDfc ) TDfc( &DoCreate, mouse, Kern::SvMsgQue(), KMaxDfcPriority-2 ); |
|
467 |
createDfc.Enque(); |
|
468 |
r = KErrNone; |
|
469 |
} |
|
470 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("Returns %d",r)); |
|
471 |
return r; |
|
472 |
} |