summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/src/video/symbian/EKA1
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2018-02-07 20:04:46 -0500
committerFranklin Wei <git@fwei.tk>2018-03-12 20:52:01 -0400
commit6039eb05ba6d82ef56f2868c96654c552d117bf9 (patch)
tree9db7016bcbf66cfdf7b9bc998d84c6eaff9c8378 /apps/plugins/sdl/src/video/symbian/EKA1
parentef373c03b96b0be08babca581d9f10bccfd4931f (diff)
downloadrockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.tar.gz
rockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.zip
sdl: remove non-rockbox drivers
We never use any of these other drivers, so having them around just takes up space. Change-Id: Iced812162df1fef3fd55522b7e700acb6c3bcd41
Diffstat (limited to 'apps/plugins/sdl/src/video/symbian/EKA1')
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocevents.cpp626
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.cpp1356
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.h34
3 files changed, 0 insertions, 2016 deletions
diff --git a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocevents.cpp b/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocevents.cpp
deleted file mode 100644
index 5ceed5fe3b..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocevents.cpp
+++ /dev/null
@@ -1,626 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@devolution.com
21*/
22
23/*
24 SDL_epocevents.cpp
25 Handle the event stream, converting Epoc events into SDL events
26
27 Epoc version by Hannu Viitala (hannu.j.viitala@mbnet.fi)
28*/
29
30
31#include <stdio.h>
32#undef NULL
33extern "C" {
34//#define DEBUG_TRACE_ENABLED
35#include "SDL_error.h"
36#include "SDL_video.h"
37#include "SDL_keysym.h"
38#include "SDL_keyboard.h"
39#include "SDL_events_c.h"
40#include "SDL_timer.h"
41}; /* extern "C" */
42
43#include "SDL_epocvideo.h"
44#include "SDL_epocevents_c.h"
45
46#include<linereader.h>
47#include<bautils.h>
48
49
50#include <hal.h>
51
52extern "C" {
53/* The translation tables from a console scancode to a SDL keysym */
54static SDLKey keymap[MAX_SCANCODE];
55static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym);
56void DisableKeyBlocking(_THIS);
57}; /* extern "C" */
58
59TBool isCursorVisible = EFalse;
60
61int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
62{
63 int posted = 0;
64 SDL_keysym keysym;
65
66// SDL_TRACE1("hws %d", aWsEvent.Type());
67
68 switch (aWsEvent.Type())
69 {
70 case EEventPointer: /* Mouse pointer events */
71 {
72
73 const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode();
74
75 if(mode == EPointerCursorNone)
76 {
77 return 0; //TODO: Find out why events are get despite of cursor should be off
78 }
79
80 const TPointerEvent* pointerEvent = aWsEvent.Pointer();
81 TPoint mousePos = pointerEvent->iPosition;
82
83 /*!! TODO Pointer do not yet work properly
84 //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!!
85
86 if (Private->EPOC_ShrinkedHeight) {
87 mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height
88 }
89 if (Private->EPOC_ShrinkedWidth) {
90 mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width
91 }
92 */
93
94 posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
95
96 switch (pointerEvent->iType)
97 {
98 case TPointerEvent::EButton1Down:
99 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
100 break;
101 case TPointerEvent::EButton1Up:
102 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
103 break;
104 case TPointerEvent::EButton2Down:
105 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
106 break;
107 case TPointerEvent::EButton2Up:
108 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
109 break;
110 case TPointerEvent::EButton3Down:
111 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);
112 break;
113 case TPointerEvent::EButton3Up:
114 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
115 break;
116 } // switch
117 break;
118 }
119
120 case EEventKeyDown: /* Key events */
121 {
122#ifdef SYMBIAN_CRYSTAL
123 // special case: 9300/9500 rocker down, simulate left mouse button
124 if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
125 {
126 const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode();
127 if(mode != EPointerCursorNone)
128 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
129 }
130#endif
131 (void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym);
132
133#ifndef DISABLE_JOYSTICK
134 /* Special handling */
135 switch((int)keysym.sym) {
136 case SDLK_CAPSLOCK:
137 if (!isCursorVisible) {
138 /* Enable virtual cursor */
139 HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
140 }
141 else {
142 /* Disable virtual cursor */
143 HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
144 }
145 isCursorVisible = !isCursorVisible;
146 break;
147 }
148#endif
149 posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
150 break;
151 }
152
153 case EEventKeyUp: /* Key events */
154 {
155#ifdef SYMBIAN_CRYSTAL
156 // special case: 9300/9500 rocker up, simulate left mouse button
157 if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
158 {
159 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
160 }
161#endif
162 posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym));
163 break;
164 }
165
166 case EEventFocusGained: /* SDL window got focus */
167 {
168 Private->EPOC_IsWindowFocused = ETrue;
169 posted += SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
170 /* Draw window background and screen buffer */
171 DisableKeyBlocking(_this); //Markus: guess why:-)
172
173 RedrawWindowL(_this);
174 break;
175 }
176
177 case EEventFocusLost: /* SDL window lost focus */
178 {
179/*
180 CFbsBitmap* bmp = new (ELeave) CFbsBitmap();
181 bmp->Create(Private->EPOC_ScreenSize, Private->EPOC_DisplayMode);
182 Private->EPOC_WsScreen->CopyScreenToBitmap(bmp);
183 Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow);
184 Private->EPOC_WsWindow.BeginRedraw(TRect(Private->EPOC_WsWindow.Size()));
185 Private->EPOC_WindowGc->BitBlt(TPoint(0, 0), bmp);
186 Private->EPOC_WsWindow.EndRedraw();
187 Private->EPOC_WindowGc->Deactivate();
188 bmp->Save(_L("C:\\scr.mbm"));
189 delete bmp;
190*/
191
192 Private->EPOC_IsWindowFocused = EFalse;
193
194 posted += SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
195
196 RWsSession s;
197 s.Connect();
198 RWindowGroup g(s);
199 g.Construct(TUint32(&g), EFalse);
200 g.EnableReceiptOfFocus(EFalse);
201 RWindow w(s);
202 w.Construct(g, TUint32(&w));
203 w.SetExtent(TPoint(0, 0), Private->EPOC_WsWindow.Size());
204 w.SetOrdinalPosition(0);
205 w.Activate();
206 w.Close();
207 g.Close();
208 s.Close();
209
210/*
211 Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(Private->EPOC_WsWindowGroupID, -1);
212
213
214 SDL_Delay(500);
215 TInt focus = -1;
216 while(focus < 0)
217 {
218 const TInt curr = Private->EPOC_WsSession.GetFocusWindowGroup();
219 if(curr != Private->EPOC_WsWindowGroupID)
220 focus = curr;
221 else
222 SDL_Delay(500);
223 }
224
225 if(1 < Private->EPOC_WsSession.GetWindowGroupOrdinalPriority(Private->EPOC_WsWindowGroupID))
226 {
227 Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, -1);
228 SDL_Delay(500);
229 Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, 0);
230 }
231*/
232 /*//and the request redraw
233 TRawEvent redrawEvent;
234 redrawEvent.Set(TRawEvent::ERedraw);
235 Private->EPOC_WsSession.SimulateRawEvent(redrawEvent);
236 Private->EPOC_WsSession.Flush();*/
237#if 0
238 //!! Not used
239 // Wait and eat events until focus is gained again
240 while (ETrue) {
241 Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
242 User::WaitForRequest(Private->EPOC_WsEventStatus);
243 Private->EPOC_WsSession.GetEvent(Private->EPOC_WsEvent);
244 TInt eventType = Private->EPOC_WsEvent.Type();
245 Private->EPOC_WsEventStatus = KRequestPending;
246 //Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
247 if (eventType == EEventFocusGained) {
248 RedrawWindowL(_this);
249 break;
250 }
251 }
252#endif
253 break;
254 }
255
256 case EEventModifiersChanged:
257 {
258 TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged();
259 TUint modstate = KMOD_NONE;
260 if (modEvent->iModifiers == EModifierLeftShift)
261 modstate |= KMOD_LSHIFT;
262 if (modEvent->iModifiers == EModifierRightShift)
263 modstate |= KMOD_RSHIFT;
264 if (modEvent->iModifiers == EModifierLeftCtrl)
265 modstate |= KMOD_LCTRL;
266 if (modEvent->iModifiers == EModifierRightCtrl)
267 modstate |= KMOD_RCTRL;
268 if (modEvent->iModifiers == EModifierLeftAlt)
269 modstate |= KMOD_LALT;
270 if (modEvent->iModifiers == EModifierRightAlt)
271 modstate |= KMOD_RALT;
272 if (modEvent->iModifiers == EModifierLeftFunc)
273 modstate |= KMOD_LMETA;
274 if (modEvent->iModifiers == EModifierRightFunc)
275 modstate |= KMOD_RMETA;
276 if (modEvent->iModifiers == EModifierCapsLock)
277 modstate |= KMOD_CAPS;
278 SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT)));
279 break;
280 }
281 default:
282 break;
283 }
284
285 return posted;
286}
287
288extern "C" {
289
290void EPOC_PumpEvents(_THIS)
291{
292 int posted = 0; // !! Do we need this?
293 //Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
294 while (Private->EPOC_WsEventStatus != KRequestPending) {
295
296 Private->EPOC_WsSession.GetEvent(Private->EPOC_WsEvent);
297 posted = EPOC_HandleWsEvent(_this, Private->EPOC_WsEvent);
298 Private->EPOC_WsEventStatus = KRequestPending;
299 Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
300 }
301}
302
303
304_LIT(KMapFileName, "C:\\sdl_info\\sdlkeymap.cfg");
305LOCAL_C void ReadL(RFs& aFs, RArray<TInt>& aArray)
306 {
307 TInt drive = -1;
308 TFileName name(KMapFileName);
309 for(TInt i = 'z'; drive < 0 && i >= 'a'; i--)
310 {
311 name[0] = (TUint16)i;
312 if(BaflUtils::FileExists(aFs, name))
313 drive = i;
314 }
315 if(drive < 0)
316 return;
317 CLineReader* reader = CLineReader::NewLC(aFs, name);
318 while(reader->NextL())
319 {
320 TPtrC ln = reader->Current();
321 TLex line(ln);
322 TInt n = 0;
323 for(;;)
324 {
325 const TPtrC token = line.NextToken();
326 if(token.Length() == 0)
327 break;
328 if((n & 1) != 0)
329 {
330 TInt value;
331 TLex lex(token);
332 User::LeaveIfError(lex.Val(value));
333 User::LeaveIfError(aArray.Append(value));
334 }
335 n++;
336 }
337 }
338 CleanupStack::PopAndDestroy();
339 }
340
341
342void EPOC_InitOSKeymap(_THIS)
343{
344 int i;
345
346 /* Initialize the key translation table */
347 for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
348 keymap[i] = SDLK_UNKNOWN;
349
350
351 /* Numbers */
352 for ( i = 0; i<32; ++i ){
353 keymap[' ' + i] = (SDLKey)(SDLK_SPACE+i);
354 }
355 /* e.g. Alphabet keys */
356 for ( i = 0; i<32; ++i ){
357 keymap['A' + i] = (SDLKey)(SDLK_a+i);
358 }
359
360 keymap[EStdKeyBackspace] = SDLK_BACKSPACE;
361 keymap[EStdKeyTab] = SDLK_TAB;
362 keymap[EStdKeyEnter] = SDLK_RETURN;
363 keymap[EStdKeyEscape] = SDLK_ESCAPE;
364 keymap[EStdKeySpace] = SDLK_SPACE;
365 keymap[EStdKeyPause] = SDLK_PAUSE;
366 keymap[EStdKeyHome] = SDLK_HOME;
367 keymap[EStdKeyEnd] = SDLK_END;
368 keymap[EStdKeyPageUp] = SDLK_PAGEUP;
369 keymap[EStdKeyPageDown] = SDLK_PAGEDOWN;
370 keymap[EStdKeyDelete] = SDLK_DELETE;
371 keymap[EStdKeyUpArrow] = SDLK_UP;
372 keymap[EStdKeyDownArrow] = SDLK_DOWN;
373 keymap[EStdKeyLeftArrow] = SDLK_LEFT;
374 keymap[EStdKeyRightArrow] = SDLK_RIGHT;
375 keymap[EStdKeyCapsLock] = SDLK_CAPSLOCK;
376 keymap[EStdKeyLeftShift] = SDLK_LSHIFT;
377 keymap[EStdKeyRightShift] = SDLK_RSHIFT;
378 keymap[EStdKeyLeftAlt] = SDLK_LALT;
379 keymap[EStdKeyRightAlt] = SDLK_RALT;
380 keymap[EStdKeyLeftCtrl] = SDLK_LCTRL;
381 keymap[EStdKeyRightCtrl] = SDLK_RCTRL;
382 keymap[EStdKeyLeftFunc] = SDLK_LMETA;
383 keymap[EStdKeyRightFunc] = SDLK_RMETA;
384 keymap[EStdKeyInsert] = SDLK_INSERT;
385 keymap[EStdKeyComma] = SDLK_COMMA;
386 keymap[EStdKeyFullStop] = SDLK_PERIOD;
387 keymap[EStdKeyForwardSlash] = SDLK_SLASH;
388 keymap[EStdKeyBackSlash] = SDLK_BACKSLASH;
389 keymap[EStdKeySemiColon] = SDLK_SEMICOLON;
390 keymap[EStdKeySingleQuote] = SDLK_QUOTE;
391 keymap[EStdKeyHash] = SDLK_HASH;
392 keymap[EStdKeySquareBracketLeft] = SDLK_LEFTBRACKET;
393 keymap[EStdKeySquareBracketRight] = SDLK_RIGHTBRACKET;
394 keymap[EStdKeyMinus] = SDLK_MINUS;
395 keymap[EStdKeyEquals] = SDLK_EQUALS;
396
397 keymap[EStdKeyF1] = SDLK_F1; /* chr + q */
398 keymap[EStdKeyF2] = SDLK_F2; /* chr + w */
399 keymap[EStdKeyF3] = SDLK_F3; /* chr + e */
400 keymap[EStdKeyF4] = SDLK_F4; /* chr + r */
401 keymap[EStdKeyF5] = SDLK_F5; /* chr + t */
402 keymap[EStdKeyF6] = SDLK_F6; /* chr + y */
403 keymap[EStdKeyF7] = SDLK_F7; /* chr + i */
404 keymap[EStdKeyF8] = SDLK_F8; /* chr + o */
405
406 keymap[EStdKeyF9] = SDLK_F9; /* chr + a */
407 keymap[EStdKeyF10] = SDLK_F10; /* chr + s */
408 keymap[EStdKeyF11] = SDLK_F11; /* chr + d */
409 keymap[EStdKeyF12] = SDLK_F12; /* chr + f */
410
411 #ifndef SYMBIAN_CRYSTAL
412 //!!7650 additions
413 #ifdef __WINS__
414 keymap[EStdKeyXXX] = SDLK_RETURN; /* "fire" key */
415 #else
416 keymap[EStdKeyDevice3] = SDLK_RETURN; /* "fire" key */
417 #endif
418 keymap[EStdKeyNkpAsterisk] = SDLK_ASTERISK;
419 keymap[EStdKeyYes] = SDLK_HOME; /* "call" key */
420 keymap[EStdKeyNo] = SDLK_END; /* "end call" key */
421 keymap[EStdKeyDevice0] = SDLK_SPACE; /* right menu key */
422 keymap[EStdKeyDevice1] = SDLK_ESCAPE; /* left menu key */
423 keymap[EStdKeyDevice2] = SDLK_POWER; /* power key */
424 #endif
425
426 #ifdef SYMBIAN_CRYSTAL
427 keymap[EStdKeyMenu] = SDLK_ESCAPE; // menu key
428 keymap[EStdKeyDevice6] = SDLK_LEFT; // Rocker (joystick) left
429 keymap[EStdKeyDevice7] = SDLK_RIGHT; // Rocker (joystick) right
430 keymap[EStdKeyDevice8] = SDLK_UP; // Rocker (joystick) up
431 keymap[EStdKeyDevice9] = SDLK_DOWN; // Rocker (joystick) down
432 keymap[EStdKeyLeftFunc] = SDLK_LALT; //chr?
433 keymap[EStdKeyRightFunc] = SDLK_RALT;
434 keymap[EStdKeyDeviceA] = SDLK_RETURN; /* "fire" key */
435#endif
436
437 ///////////////////////////////////////////////////////////
438
439 RFs fs;
440 if(KErrNone == fs.Connect())
441 {
442 RArray<TInt> array;
443 TRAPD(err, ReadL(fs, array));
444 if(err == KErrNone && array.Count() > 0)
445 {
446
447 SDLKey temp[MAX_SCANCODE];
448 Mem::Copy(temp, keymap, MAX_SCANCODE * sizeof(SDLKey));
449
450 for(TInt k = 0; k < array.Count(); k+= 2)
451 {
452 const TInt oldval = array[k];
453 const TInt newval = array[k + 1];
454 if(oldval >= 0 && oldval < MAX_SCANCODE && newval >= 0 && newval < MAX_SCANCODE)
455 {
456 keymap[oldval] = temp[newval];
457 }
458 }
459 }
460 array.Close();
461 }
462
463 fs.Close();
464 ///////////////////////////////////////////////////////////
465
466 /* !!TODO
467 EStdKeyNumLock=0x1b,
468 EStdKeyScrollLock=0x1c,
469
470 EStdKeyNkpForwardSlash=0x84,
471 EStdKeyNkpAsterisk=0x85,
472 EStdKeyNkpMinus=0x86,
473 EStdKeyNkpPlus=0x87,
474 EStdKeyNkpEnter=0x88,
475 EStdKeyNkp1=0x89,
476 EStdKeyNkp2=0x8a,
477 EStdKeyNkp3=0x8b,
478 EStdKeyNkp4=0x8c,
479 EStdKeyNkp5=0x8d,
480 EStdKeyNkp6=0x8e,
481 EStdKeyNkp7=0x8f,
482 EStdKeyNkp8=0x90,
483 EStdKeyNkp9=0x91,
484 EStdKeyNkp0=0x92,
485 EStdKeyNkpFullStop=0x93,
486 EStdKeyMenu=0x94,
487 EStdKeyBacklightOn=0x95,
488 EStdKeyBacklightOff=0x96,
489 EStdKeyBacklightToggle=0x97,
490 EStdKeyIncContrast=0x98,
491 EStdKeyDecContrast=0x99,
492 EStdKeySliderDown=0x9a,
493 EStdKeySliderUp=0x9b,
494 EStdKeyDictaphonePlay=0x9c,
495 EStdKeyDictaphoneStop=0x9d,
496 EStdKeyDictaphoneRecord=0x9e,
497 EStdKeyHelp=0x9f,
498 EStdKeyOff=0xa0,
499 EStdKeyDial=0xa1,
500 EStdKeyIncVolume=0xa2,
501 EStdKeyDecVolume=0xa3,
502 EStdKeyDevice0=0xa4,
503 EStdKeyDevice1=0xa5,
504 EStdKeyDevice2=0xa6,
505 EStdKeyDevice3=0xa7,
506 EStdKeyDevice4=0xa8,
507 EStdKeyDevice5=0xa9,
508 EStdKeyDevice6=0xaa,
509 EStdKeyDevice7=0xab,
510 EStdKeyDevice8=0xac,
511 EStdKeyDevice9=0xad,
512 EStdKeyDeviceA=0xae,
513 EStdKeyDeviceB=0xaf,
514 EStdKeyDeviceC=0xb0,
515 EStdKeyDeviceD=0xb1,
516 EStdKeyDeviceE=0xb2,
517 EStdKeyDeviceF=0xb3,
518 EStdKeyApplication0=0xb4,
519 EStdKeyApplication1=0xb5,
520 EStdKeyApplication2=0xb6,
521 EStdKeyApplication3=0xb7,
522 EStdKeyApplication4=0xb8,
523 EStdKeyApplication5=0xb9,
524 EStdKeyApplication6=0xba,
525 EStdKeyApplication7=0xbb,
526 EStdKeyApplication8=0xbc,
527 EStdKeyApplication9=0xbd,
528 EStdKeyApplicationA=0xbe,
529 EStdKeyApplicationB=0xbf,
530 EStdKeyApplicationC=0xc0,
531 EStdKeyApplicationD=0xc1,
532 EStdKeyApplicationE=0xc2,
533 EStdKeyApplicationF=0xc3,
534 EStdKeyYes=0xc4,
535 EStdKeyNo=0xc5,
536 EStdKeyIncBrightness=0xc6,
537 EStdKeyDecBrightness=0xc7,
538 EStdKeyCaseOpen=0xc8,
539 EStdKeyCaseClose=0xc9
540 */
541
542}
543
544
545
546static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym)
547{
548// char debug[256];
549 //SDL_TRACE1("SDL: TranslateKey, scancode=%d", scancode); //!!
550
551 /* Set the keysym information */
552
553 keysym->scancode = scancode;
554
555 if ((scancode >= MAX_SCANCODE) &&
556 ((scancode - ENonCharacterKeyBase + 0x0081) >= MAX_SCANCODE)) {
557 SDL_SetError("Too big scancode");
558 keysym->scancode = SDLK_UNKNOWN;
559 keysym->mod = KMOD_NONE;
560 return keysym;
561 }
562
563 keysym->mod = SDL_GetModState();
564
565 /* Handle function keys: F1, F2, F3 ... */
566 if (keysym->mod & KMOD_META) {
567 if (scancode >= 'A' && scancode < ('A' + 24)) { /* first 32 alphabet keys */
568 switch(scancode) {
569 case 'Q': scancode = EStdKeyF1; break;
570 case 'W': scancode = EStdKeyF2; break;
571 case 'E': scancode = EStdKeyF3; break;
572 case 'R': scancode = EStdKeyF4; break;
573 case 'T': scancode = EStdKeyF5; break;
574 case 'Y': scancode = EStdKeyF6; break;
575 case 'U': scancode = EStdKeyF7; break;
576 case 'I': scancode = EStdKeyF8; break;
577 case 'A': scancode = EStdKeyF9; break;
578 case 'S': scancode = EStdKeyF10; break;
579 case 'D': scancode = EStdKeyF11; break;
580 case 'F': scancode = EStdKeyF12; break;
581 }
582 keysym->sym = keymap[scancode];
583 }
584 }
585
586 if (scancode >= ENonCharacterKeyBase) {
587 // Non character keys
588 keysym->sym = keymap[scancode -
589 ENonCharacterKeyBase + 0x0081]; // !!hard coded
590 } else {
591 keysym->sym = keymap[scancode];
592 }
593
594 /* Remap the arrow keys if the device is rotated */
595 if (Private->EPOC_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) {
596 switch(keysym->sym) {
597 case SDLK_UP: keysym->sym = SDLK_LEFT; break;
598 case SDLK_DOWN: keysym->sym = SDLK_RIGHT; break;
599 case SDLK_LEFT: keysym->sym = SDLK_DOWN; break;
600 case SDLK_RIGHT:keysym->sym = SDLK_UP; break;
601 }
602 }
603
604 /* If UNICODE is on, get the UNICODE value for the key */
605 keysym->unicode = 0;
606
607#if 0 // !!TODO:unicode
608
609 if ( SDL_TranslateUNICODE )
610 {
611 /* Populate the unicode field with the ASCII value */
612 keysym->unicode = scancode;
613 }
614#endif
615
616 //!!
617 //sprintf(debug, "SDL: TranslateKey: keysym->scancode=%d, keysym->sym=%d, keysym->mod=%d",
618 // keysym->scancode, keysym->sym, keysym->mod);
619 //SDL_TRACE(debug); //!!
620
621 return(keysym);
622}
623
624}; /* extern "C" */
625
626
diff --git a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.cpp b/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.cpp
deleted file mode 100644
index 06874d546c..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.cpp
+++ /dev/null
@@ -1,1356 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@devolution.com
21*/
22
23/*
24 SDL_epocvideo.cpp
25 Epoc based SDL video driver implementation
26
27 Thanks to Peter van Sebille, the author of EMame. It is a great example of
28 low level graphics coding in Epoc.
29
30 Epoc version by Hannu Viitala (hannu.j.viitala@mbnet.fi)
31 Assembler routines by Kimmo Kinnunen
32*/
33
34
35
36#include <stdlib.h>
37#include <stdio.h>
38#include <string.h>
39
40extern "C" {
41#include "SDL_error.h"
42#include "SDL_timer.h"
43#include "SDL_video.h"
44#undef NULL
45#include "SDL_pixels_c.h"
46#include "SDL.h"
47};
48
49#include "SDL_epocvideo.h"
50#include "SDL_epocevents_c.h"
51
52#include "sdl_epocruntime.h"
53
54#include <hal.h>
55#include <coedef.h>
56#include <flogger.h>
57
58#ifdef SYMBIAN_QUARTZ
59SDL_VideoDevice* _thisDevice;
60#endif
61
62_LIT(KLibName, "SDL");
63
64/* For debugging */
65
66//if old SOS, from 7.x this is public!
67class CLockable : public CFbsBitmap
68 {
69 public:
70 static CLockable* Lockable(CFbsBitmap* aBmp) {return static_cast<CLockable*>(aBmp);}
71 void Lock() {LockHeap();}
72 void Unlock() {UnlockHeap();}
73 };
74#define LockHeap(x) CLockable::Lockable(x)->Lock()
75#define UnlockHeap(x) CLockable::Lockable(x)->Unlock()
76
77void RDebug_Print_b(char* error_str, void* param)
78 {
79 TBuf8<128> error8((TUint8*)error_str);
80 TBuf<128> error;
81 error.Copy(error8);
82
83#ifndef TRACE_TO_FILE
84 if (param) //!! Do not work if the parameter is really 0!!
85 RDebug::Print(error, param);
86 else
87 RDebug::Print(error);
88#else
89 if (param) //!! Do not work if the parameter is really 0!!
90 RFileLogger::WriteFormat(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error, param);
91 else
92 RFileLogger::Write(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error);
93#endif
94
95 }
96
97extern "C" void RDebug_Print(char* error_str, void* param)
98 {
99 RDebug_Print_b(error_str, param);
100 }
101
102
103int Debug_AvailMem2()
104 {
105 //User::CompressAllHeaps();
106 TMemoryInfoV1Buf membuf;
107 User::LeaveIfError(UserHal::MemoryInfo(membuf));
108 TMemoryInfoV1 minfo = membuf();
109 return(minfo.iFreeRamInBytes);
110 }
111
112extern "C" int Debug_AvailMem()
113 {
114 return(Debug_AvailMem2());
115 }
116
117
118extern "C" {
119
120/* Initialization/Query functions */
121
122static int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat);
123static SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
124static SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
125static int EPOC_SetColors(_THIS, int firstcolor, int ncolors,
126 SDL_Color *colors);
127static void EPOC_VideoQuit(_THIS);
128
129/* Hardware surface functions */
130
131static int EPOC_AllocHWSurface(_THIS, SDL_Surface *surface);
132static int EPOC_LockHWSurface(_THIS, SDL_Surface *surface);
133static int EPOC_FlipHWSurface(_THIS, SDL_Surface *surface);
134static void EPOC_UnlockHWSurface(_THIS, SDL_Surface *surface);
135static void EPOC_FreeHWSurface(_THIS, SDL_Surface *surface);
136static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
137
138static int EPOC_Available(void);
139static SDL_VideoDevice *EPOC_CreateDevice(int devindex);
140
141void DrawBackground(_THIS);
142void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);
143void DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);
144
145/* Mouse functions */
146
147static WMcursor *EPOC_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
148static void EPOC_FreeWMCursor(_THIS, WMcursor *cursor);
149static int EPOC_ShowWMCursor(_THIS, WMcursor *cursor);
150
151
152
153/* !!For 12 bit screen HW. Table for fast conversion from 8 bit to 12 bit */
154// TUint16 is enough, but using TUint32 so we can use better instruction selection on ARMI
155static TUint32 EPOC_HWPalette_256_to_Screen[256];
156
157VideoBootStrap EPOC_bootstrap = {
158 "epoc", "EPOC system",
159 EPOC_Available, EPOC_CreateDevice
160};
161
162const TUint32 WindowClientHandle = 9210; //!! const
163
164/* Epoc video driver bootstrap functions */
165
166static int EPOC_Available(void)
167{
168 return 1; /* Always available */
169}
170
171static void EPOC_DeleteDevice(SDL_VideoDevice *device)
172{
173 free(device->hidden);
174 free(device);
175}
176
177static SDL_VideoDevice *EPOC_CreateDevice(int /*devindex*/)
178{
179 SDL_VideoDevice *device;
180
181 SDL_TRACE("SDL:EPOC_CreateDevice");
182
183 /* Allocate all variables that we free on delete */
184 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
185 if ( device ) {
186 memset(device, 0, (sizeof *device));
187 device->hidden = (struct SDL_PrivateVideoData *)
188 malloc((sizeof *device->hidden));
189 }
190 if ( (device == NULL) || (device->hidden == NULL) ) {
191 SDL_OutOfMemory();
192 if ( device ) {
193 free(device);
194 }
195 return(0);
196 }
197 memset(device->hidden, 0, (sizeof *device->hidden));
198
199 /* Set the function pointers */
200 device->VideoInit = EPOC_VideoInit;
201 device->ListModes = EPOC_ListModes;
202 device->SetVideoMode = EPOC_SetVideoMode;
203 device->SetColors = EPOC_SetColors;
204 device->UpdateRects = NULL;
205 device->VideoQuit = EPOC_VideoQuit;
206 device->AllocHWSurface = EPOC_AllocHWSurface;
207 device->CheckHWBlit = NULL;
208 device->FillHWRect = NULL;
209 device->SetHWColorKey = NULL;
210 device->SetHWAlpha = NULL;
211 device->LockHWSurface = EPOC_LockHWSurface;
212 device->UnlockHWSurface = EPOC_UnlockHWSurface;
213 device->FlipHWSurface = EPOC_FlipHWSurface;
214 device->FreeHWSurface = EPOC_FreeHWSurface;
215 device->SetIcon = NULL;
216 device->SetCaption = NULL;
217 device->GetWMInfo = NULL;
218 device->FreeWMCursor = EPOC_FreeWMCursor;
219 device->CreateWMCursor = EPOC_CreateWMCursor;
220 device->ShowWMCursor = EPOC_ShowWMCursor;
221 device->WarpWMCursor = NULL;
222 device->InitOSKeymap = EPOC_InitOSKeymap;
223 device->PumpEvents = EPOC_PumpEvents;
224 device->free = EPOC_DeleteDevice;
225
226 return device;
227}
228
229
230int GetBpp(TDisplayMode displaymode)
231{
232 /*TInt numColors = TDisplayModeUtils::NumDisplayModeColors(displaymode);
233 TInt bitsPerPixel = 1;
234 for (TInt32 i = 2; i < numColors; i <<= 1, bitsPerPixel++);
235 return bitsPerPixel;*/
236 return TDisplayModeUtils::NumDisplayModeBitsPerPixel(displaymode);
237}
238
239
240void DisableKeyBlocking(_THIS)
241 {
242 // Disable key blocking
243 TRawEvent event;
244 event.Set((TRawEvent::TType)/*EDisableKeyBlock*/51); // !!EDisableKeyBlock not found in epoc32\include!
245 Private->EPOC_WsSession.SimulateRawEvent(event);
246 }
247
248void ConstructWindowL(_THIS)
249{
250 TInt error;
251
252 SDL_TRACE("SDL:ConstructWindowL");
253 error = Private->EPOC_WsSession.Connect();
254 User::LeaveIfError(error);
255 Private->EPOC_WsScreen=new(ELeave) CWsScreenDevice(Private->EPOC_WsSession);
256 User::LeaveIfError(Private->EPOC_WsScreen->Construct());
257 User::LeaveIfError(Private->EPOC_WsScreen->CreateContext(Private->EPOC_WindowGc));
258
259 Private->EPOC_WsWindowGroup=RWindowGroup(Private->EPOC_WsSession);
260 User::LeaveIfError(Private->EPOC_WsWindowGroup.Construct(WindowClientHandle));
261 Private->EPOC_WsWindowGroup.SetOrdinalPosition(0);
262
263 // Set window group name (the same as process name)) !!Gives always "EPOC" in WINS
264 RProcess thisProcess;
265 TParse exeName;
266 exeName.Set(thisProcess.FileName(), NULL, NULL);
267 TBuf<32> winGroupName;
268 winGroupName.Append(0);
269 winGroupName.Append(0);
270 winGroupName.Append(0);// uid
271 winGroupName.Append(0);
272 winGroupName.Append(exeName.Name()); // caption
273 winGroupName.Append(0);
274 winGroupName.Append(0); //doc name
275 Private->EPOC_WsWindowGroup.SetName(winGroupName);
276
277 Private->EPOC_WsWindow=RWindow(Private->EPOC_WsSession);
278 // Markus, it was:
279 // User::LeaveIfError(Private->EPOC_WsWindow.Construct(Private->EPOC_WsWindowGroup,WindowClientHandle ));
280 // but SOS 7.0s debug does not accept same window handle twice
281 User::LeaveIfError(Private->EPOC_WsWindow.Construct(Private->EPOC_WsWindowGroup,WindowClientHandle - 1));
282 Private->EPOC_WsWindow.SetBackgroundColor(KRgbWhite);
283 Private->EPOC_WsWindow.Activate();
284 Private->EPOC_WsWindow.SetSize(Private->EPOC_WsScreen->SizeInPixels());
285 Private->EPOC_WsWindow.SetVisible(ETrue);
286
287 Private->EPOC_WsWindowGroupID = Private->EPOC_WsWindowGroup.Identifier();
288 Private->EPOC_IsWindowFocused = EFalse;
289
290 DisableKeyBlocking(_this); //disable key blocking
291}
292
293int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat)
294{
295 // !!TODO:handle leave functions!
296
297 int i;
298
299 SDL_TRACE("SDL:EPOC_VideoInit");
300
301 /* Initialize all variables that we clean on shutdown */
302
303 for ( i=0; i<SDL_NUMMODES; ++i ) {
304 Private->SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
305 Private->SDL_modelist[i]->x = Private->SDL_modelist[i]->y = 0;
306 }
307
308 /* Modes sorted largest to smallest */
309 Private->SDL_modelist[0]->w = 800; Private->SDL_modelist[0]->h = 250;
310 Private->SDL_modelist[1]->w = 640; Private->SDL_modelist[1]->h = 480;
311 Private->SDL_modelist[2]->w = 480; Private->SDL_modelist[2]->h = 600;
312 Private->SDL_modelist[3]->w = 640; Private->SDL_modelist[3]->h = 400;
313 Private->SDL_modelist[4]->w = 352; Private->SDL_modelist[4]->h = 416;
314 Private->SDL_modelist[5]->w = 416; Private->SDL_modelist[5]->h = 352;
315 Private->SDL_modelist[6]->w = 416; Private->SDL_modelist[6]->h = 312;
316 Private->SDL_modelist[7]->w = 352; Private->SDL_modelist[7]->h = 264;
317 Private->SDL_modelist[8]->w = 800; Private->SDL_modelist[8]->h = 240; //for doom all these..
318 Private->SDL_modelist[9]->w = 640; Private->SDL_modelist[9]->h = 240;
319 Private->SDL_modelist[10]->w = 480; Private->SDL_modelist[10]->h = 240;
320 Private->SDL_modelist[11]->w = 640; Private->SDL_modelist[11]->h = 240;
321 Private->SDL_modelist[12]->w = 352; Private->SDL_modelist[12]->h = 240;
322 Private->SDL_modelist[13]->w = 416; Private->SDL_modelist[13]->h = 240;
323 Private->SDL_modelist[14]->w = 416; Private->SDL_modelist[14]->h = 240;
324 Private->SDL_modelist[15]->w = 352; Private->SDL_modelist[15]->h = 240;
325 Private->SDL_modelist[16]->w = 640; Private->SDL_modelist[16]->h = 200;
326 Private->SDL_modelist[17]->w = 320; Private->SDL_modelist[17]->h = 240; //...for doom, currently engine renders no-higher windows :-(, propably should get fixed
327 Private->SDL_modelist[18]->w = 320; Private->SDL_modelist[18]->h = 200;
328 Private->SDL_modelist[19]->w = 256; Private->SDL_modelist[19]->h = 192;
329 Private->SDL_modelist[20]->w = 176; Private->SDL_modelist[20]->h = 208;
330 Private->SDL_modelist[21]->w = 208; Private->SDL_modelist[21]->h = 176; // Rotated
331 Private->SDL_modelist[22]->w = 160; Private->SDL_modelist[22]->h = 144;
332
333 Private->SDL_modelist[23]->w = 640; Private->SDL_modelist[2]->h = 200; //s80 some new modes
334 Private->SDL_modelist[24]->w = 640; Private->SDL_modelist[2]->h = 320; //s90 modes are added
335 Private->SDL_modelist[25]->w = 640; Private->SDL_modelist[2]->h = 240; //here
336 Private->SDL_modelist[26]->w = 640; Private->SDL_modelist[4]->h = 200; //now
337
338 Private->SDL_modelist[27] = NULL;
339
340 /* Construct Epoc window */
341
342 ConstructWindowL(_this);
343
344 /* Initialise Epoc frame buffer */
345
346 TDisplayMode displayMode = Private->EPOC_WsScreen->DisplayMode();
347
348#if !defined(__WINS__) && !defined(TEST_BM_DRAW)
349
350 TScreenInfoV01 screenInfo;
351 TPckg<TScreenInfoV01> sInfo(screenInfo);
352 UserSvr::ScreenInfo(sInfo);
353
354 Private->EPOC_ScreenSize = screenInfo.iScreenSize;
355 Private->EPOC_DisplayMode = displayMode;
356 Private->EPOC_HasFrameBuffer = screenInfo.iScreenAddressValid;
357 Private->EPOC_FrameBuffer = Private->EPOC_HasFrameBuffer ? (TUint8*) screenInfo.iScreenAddress : NULL;
358 Private->EPOC_BytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1;
359
360 Private->EPOC_BytesPerScanLine = screenInfo.iScreenSize.iWidth * Private->EPOC_BytesPerPixel;
361 Private->EPOC_BytesPerScreen = Private->EPOC_BytesPerScanLine * Private->EPOC_ScreenSize.iHeight;
362
363 SDL_TRACE1("Screen width %d", screenInfo.iScreenSize.iWidth);
364 SDL_TRACE1("Screen height %d", screenInfo.iScreenSize.iHeight);
365 SDL_TRACE1("Screen dmode %d", displayMode);
366 SDL_TRACE1("Screen valid %d", screenInfo.iScreenAddressValid);
367
368 SDL_TRACE1("bpp %d", Private->EPOC_BytesPerPixel);
369 SDL_TRACE1("bpsl %d", Private->EPOC_BytesPerScanLine);
370 SDL_TRACE1("bps %d", Private->EPOC_BytesPerScreen);
371
372
373 /* It seems that in SA1100 machines for 8bpp displays there is a 512 palette table at the
374 * beginning of the frame buffer. E.g. Series 7 and Netbook.
375 * In 12 bpp machines the table has 16 entries.
376 */
377 if (Private->EPOC_HasFrameBuffer && GetBpp(displayMode) == 8)
378 {
379 Private->EPOC_FrameBuffer += 512;
380 }
381 else
382 {
383 Private->EPOC_FrameBuffer += 32;
384 }
385 /*if (Private->EPOC_HasFrameBuffer && GetBpp(displayMode) == 12)
386 Private->EPOC_FrameBuffer += 16 * 2;
387 if (Private->EPOC_HasFrameBuffer && GetBpp(displayMode) == 16)
388 Private->EPOC_FrameBuffer += 16 * 2;
389 */
390#else /* defined __WINS__ */
391
392 /* Create bitmap, device and context for screen drawing */
393 Private->EPOC_ScreenSize = Private->EPOC_WsScreen->SizeInPixels();
394
395 Private->EPOC_Bitmap = new (ELeave) CWsBitmap(Private->EPOC_WsSession);
396 Private->EPOC_Bitmap->Create(Private->EPOC_ScreenSize, displayMode);
397
398 Private->EPOC_DisplayMode = displayMode;
399 Private->EPOC_HasFrameBuffer = ETrue;
400 Private->EPOC_FrameBuffer = NULL; /* Private->EPOC_Bitmap->DataAddress() can change any time */
401 Private->EPOC_BytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1;
402 Private->EPOC_BytesPerScanLine = Private->EPOC_WsScreen->SizeInPixels().iWidth * Private->EPOC_BytesPerPixel;
403
404#endif /* __WINS__ */
405
406#ifndef SYMBIAN_CRYSTAL
407 // Get draw device for updating the screen
408 TScreenInfoV01 screenInfo2;
409
410 Epoc_Runtime::GetScreenInfo(screenInfo2);
411
412 TRAPD(status, Private->EPOC_DrawDevice = CFbsDrawDevice::NewScreenDeviceL(screenInfo2, displayMode));
413 User::LeaveIfError(status);
414#endif
415
416 /* The "best" video format should be returned to caller. */
417
418 vformat->BitsPerPixel = /*!!GetBpp(displayMode) */ 8;
419 vformat->BytesPerPixel = /*!!Private->EPOC_BytesPerPixel*/ 1;
420
421 /* Activate events for me */
422
423 Private->EPOC_WsEventStatus = KRequestPending;
424 Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
425
426 SDL_TRACE("SDL:WsEventStatus");
427 User::WaitForRequest(Private->EPOC_WsEventStatus); //Markus: I added this and ...
428
429 Private->EPOC_RedrawEventStatus = KRequestPending;
430 Private->EPOC_WsSession.RedrawReady(&Private->EPOC_RedrawEventStatus);
431
432 SDL_TRACE("SDL:RedrawEventStatus");
433 User::WaitForRequest(Private->EPOC_RedrawEventStatus); //...this, if not catches a stray event is risen
434 //if there are active objects used, or confucing
435 //actions with User::WaitForAnyRequest
436 Private->EPOC_WsWindow.PointerFilter(EPointerFilterDrag, 0);
437
438 Private->EPOC_ScreenOffset = TPoint(0, 0);
439
440#if defined(__WINS__) || defined(TEST_BM_DRAW)
441 LockHeap(Private->EPOC_Bitmap); // Lock bitmap heap
442#endif
443
444 SDL_TRACE("SDL:DrawBackground");
445 DrawBackground(_this); // Clear screen
446
447#if defined(__WINS__) || defined(TEST_BM_DRAW)
448 UnlockHeap(Private->EPOC_Bitmap); // Unlock bitmap heap
449#endif
450 //!! TODO: error handling
451 //if (ret != KErrNone)
452 // return(-1);
453 //else
454 return(0);
455}
456
457
458SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 /*flags*/)
459{
460 if (format->BitsPerPixel == 12 || format->BitsPerPixel == 8)
461 return Private->SDL_modelist;
462 return NULL;
463}
464
465int EPOC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
466{
467 if ((firstcolor+ncolors) > 256)
468 return -1;
469// SDL_TRACE1("colors %d", (TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode)));
470 if(TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode) == 4096)
471 {
472 // Set 12 bit palette
473 for(int i = firstcolor; i < ncolors; i++)
474 {
475 // 4k value: 0000 rrrr gggg bbbb
476 TUint32 color4K = (colors[i].r & 0x0000f0) << 4;
477 color4K |= (colors[i].g & 0x0000f0);
478 color4K |= (colors[i].b & 0x0000f0) >> 4;
479 EPOC_HWPalette_256_to_Screen[i] = color4K;
480 }
481 }
482 else if(TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode) == 65536)
483 {
484 for(int i = firstcolor; i < ncolors; i++)
485 {
486 // 64k-colour displays effectively support RGB values
487 // with 5 bits allocated to red, 6 to green and 5 to blue
488 // 64k value: rrrr rggg gggb bbbb
489 TUint32 color64K = (colors[i].r & 0x0000f8) << 8;
490 color64K |= (colors[i].g & 0x0000fc) << 3;
491 color64K |= (colors[i].b & 0x0000f8) >> 3;
492 EPOC_HWPalette_256_to_Screen[i] = color64K;
493 }
494 }
495 else if(TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode) == 16777216)
496 {
497 for(int i = firstcolor; i < ncolors; i++)
498 {
499 // 16M-colour
500 //0000 0000 rrrr rrrr gggg gggg bbbb bbbb
501 TUint32 color16M = colors[i].r << 16;
502 color16M |= colors[i].g << 8;
503 color16M |= colors[i].b;
504 EPOC_HWPalette_256_to_Screen[i] = color16M;
505 }
506 }
507 else
508 {
509 return -2;
510 }
511 return(0);
512}
513
514
515SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current,
516 int width, int height, int bpp, Uint32 /*flags*/)
517{
518 SDL_TRACE("SDL:EPOC_SetVideoMode");
519 /* Check parameters */
520#ifdef SYMBIAN_CRYSTAL
521 if (! (bpp == 8 || bpp == 12 || bpp == 16) &&
522 (
523 (width == 640 && height == 200) ||
524 (width == 640 && height == 400) ||
525 (width == 640 && height == 480) ||
526 (width == 320 && height == 200) ||
527 (width == 320 && height == 240)
528 )) {
529 SDL_SetError("Requested video mode is not supported");
530 return NULL;
531 }
532#else // SYMBIAN_SERIES60
533 if (! (bpp == 8 || bpp == 12 || bpp == 16) &&
534 (
535 (width == 320 && height == 200) ||
536 (width == 320 && height == 240) ||
537 (width == 256 && height == 192) ||
538 (width == 176 && height == 208) ||
539 (width == 208 && height == 176) || // Rotated
540 (width == 160 && height == 144)
541 )) {
542 SDL_SetError("Requested video mode is not supported");
543 return NULL;
544 }
545#endif
546
547 if (current && current->pixels) {
548 free(current->pixels);
549 current->pixels = NULL;
550 }
551 if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
552 return(NULL);
553 }
554
555 /* Set up the new mode framebuffer */
556 if (bpp == 8)
557 current->flags = (SDL_FULLSCREEN|SDL_SWSURFACE|SDL_PREALLOC|SDL_HWPALETTE);
558 else // 12 bpp, 16 bpp
559 current->flags = (SDL_FULLSCREEN|SDL_SWSURFACE|SDL_PREALLOC);
560 current->w = width;
561 current->h = height;
562 int numBytesPerPixel = ((bpp-1)>>3) + 1;
563 current->pitch = numBytesPerPixel * width; // Number of bytes in scanline
564 current->pixels = malloc(width * height * numBytesPerPixel);
565 memset(current->pixels, 0, width * height * numBytesPerPixel);
566
567 /* Set the blit function */
568 _this->UpdateRects = EPOC_DirectUpdate;
569
570 /*
571 * Logic for getting suitable screen dimensions, offset, scaling and orientation
572 */
573
574 int w = current->w;
575 int h = current->h;
576
577 // Rotate, if the screen does not fit horizontally and it is landscape screen
578/*
579 if ((width>Private->EPOC_ScreenSize.iWidth) && (width>height)) {
580 Private->EPOC_ScreenOrientation = CFbsBitGc::EGraphicsOrientationRotated270;
581 w = current->h;
582 h = current->w;
583 }
584*/
585 // Get nearest stepwise scale values for width and height. The smallest supported scaled screen is 1/2.
586 TInt scaleValue = 0;
587 Private->EPOC_ScreenXScaleValue = 1;
588 Private->EPOC_ScreenYScaleValue = 1;
589 if (w > Private->EPOC_ScreenSize.iWidth) {
590 // Find the biggest scale value that result the width that fits in the screen HW
591 for (scaleValue = 2; scaleValue++;) {
592 TInt scaledWidth = (w * (scaleValue-1))/scaleValue;
593 if (scaledWidth > Private->EPOC_ScreenSize.iWidth)
594 break;
595 }
596 Private->EPOC_ScreenXScaleValue = Max(2, scaleValue - 1);
597 w = (w * (Private->EPOC_ScreenXScaleValue-1))/Private->EPOC_ScreenXScaleValue;
598 }
599 if (h > Private->EPOC_ScreenSize.iHeight) {
600 // Find the biggest scale value that result the height that fits in the screen HW
601 for (scaleValue = 2; scaleValue++;) {
602 TInt scaledHeight = (h * (scaleValue-1))/scaleValue;
603 if (scaledHeight > Private->EPOC_ScreenSize.iHeight)
604 break;
605 }
606 Private->EPOC_ScreenYScaleValue = Max(2, scaleValue - 1);
607 h = (h * (Private->EPOC_ScreenYScaleValue-1))/Private->EPOC_ScreenYScaleValue;
608 }
609
610 /* Centralize game window on device screen */
611 Private->EPOC_ScreenOffset.iX = (Private->EPOC_ScreenSize.iWidth - w) / 2;
612 if (Private->EPOC_ScreenOffset.iX < 0)
613 Private->EPOC_ScreenOffset.iX = 0;
614 Private->EPOC_ScreenOffset.iY = (Private->EPOC_ScreenSize.iHeight - h) / 2;
615 if (Private->EPOC_ScreenOffset.iY < 0)
616 Private->EPOC_ScreenOffset.iY = 0;
617
618
619 SDL_TRACE1("View width %d", w);
620 SDL_TRACE1("View height %d", h);
621 SDL_TRACE1("View bmode %d", bpp);
622 SDL_TRACE1("View s %d", scaleValue);
623 SDL_TRACE1("View x %d", Private->EPOC_ScreenOffset.iX);
624 SDL_TRACE1("View y %d", Private->EPOC_ScreenOffset.iY);
625
626 /* We're done */
627 return(current);
628}
629
630
631void RedrawWindowL(_THIS)
632{
633
634#if defined(__WINS__) || defined(TEST_BM_DRAW)
635 LockHeap(Private->EPOC_Bitmap); // Lock bitmap heap
636 Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow);
637#endif
638
639 int w = _this->screen->w;
640 int h = _this->screen->h;
641 if (Private->EPOC_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) {
642 w = _this->screen->h;
643 h = _this->screen->w;
644 }
645 if ((w < Private->EPOC_ScreenSize.iWidth)
646 || (h < Private->EPOC_ScreenSize.iHeight)) {
647 DrawBackground(_this);
648 }
649
650 /* Tell the system that something has been drawn */
651 TRect rect = TRect(Private->EPOC_WsWindow.Size());
652 Private->EPOC_WsWindow.Invalidate(rect);
653
654#if defined(__WINS__) || defined(TEST_BM_DRAW)
655 Private->EPOC_WsWindow.BeginRedraw(rect);
656 Private->EPOC_WindowGc->BitBlt(TPoint(), Private->EPOC_Bitmap);
657 Private->EPOC_WsWindow.EndRedraw();
658 Private->EPOC_WindowGc->Deactivate();
659 UnlockHeap(Private->EPOC_Bitmap);; // Unlock bitmap heap
660 Private->EPOC_WsSession.Flush();
661#endif
662
663 /* Draw current buffer */
664 SDL_Rect fullScreen;
665 fullScreen.x = 0;
666 fullScreen.y = 0;
667 fullScreen.w = _this->screen->w;
668 fullScreen.h = _this->screen->h;
669 EPOC_DirectUpdate(_this, 1, &fullScreen);
670}
671
672
673void DrawBackground(_THIS)
674{
675 /* Draw background */
676#if defined(__WINS__) || defined(TEST_BM_DRAW)
677 //warning heap is not locked! - a function calling must ensure that it's ok
678 TUint16* screenBuffer = (TUint16*)Private->EPOC_Bitmap->DataAddress();
679#else
680 TUint16* screenBuffer = (TUint16*)Private->EPOC_FrameBuffer;
681#endif
682 // Draw black background
683 Mem::FillZ(screenBuffer, Private->EPOC_BytesPerScreen);
684
685#if 0
686 for (int y = 0; y < Private->EPOC_ScreenSize.iHeight; y++) {
687 for (int x = 0; x < Private->EPOC_ScreenSize.iWidth; x++) {
688#ifdef SYMBIAN_CRYSTAL
689 const TUint16 color = 0; // ((x+y)>>1) & 0xf; /* Draw blue stripes pattern, because in e.g. 320x200 mode there is a big background area*/
690#else // SYMBIAN_SERIES60
691 const TUint16 color = 0; /* Draw black background */
692#endif
693 *screenBuffer++ = color;
694 }
695 }
696#endif
697}
698
699
700/* We don't actually allow hardware surfaces other than the main one */
701static int EPOC_AllocHWSurface(_THIS, SDL_Surface* /*surface*/)
702{
703 return(-1);
704}
705static void EPOC_FreeHWSurface(_THIS, SDL_Surface* /*surface*/)
706{
707 return;
708}
709
710static int EPOC_LockHWSurface(_THIS, SDL_Surface* /*surface*/)
711{
712 return(0);
713}
714static void EPOC_UnlockHWSurface(_THIS, SDL_Surface* /*surface*/)
715{
716 return;
717}
718
719static int EPOC_FlipHWSurface(_THIS, SDL_Surface* /*surface*/)
720{
721 return(0);
722}
723
724static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
725{
726 //TInt focusWindowGroupId = Private->EPOC_WsSession.GetFocusWindowGroup();//these are async services
727 // if (focusWindowGroupId != Private->EPOC_WsWindowGroupID) { //for that cannot be called from
728 //SDL threads ???
729 if (!Private->EPOC_IsWindowFocused)
730 {
731 /* Force focus window to redraw again for cleaning away SDL screen graphics */
732/*
733 TInt pos = Private->EPOC_WsWindowGroup.OrdinalPosition();
734 Private->EPOC_WsWindowGroup.SetOrdinalPosition(0, KMaxTInt);
735 TRect rect = TRect(Private->EPOC_WsWindow.Size());
736 Private->EPOC_WsWindow.Invalidate(rect);
737 Private->EPOC_WsWindowGroup.SetOrdinalPosition(pos, ECoeWinPriorityNormal);
738 */ /* If this is not the topmost window, wait here! Sleep for 1 second to give cpu time to
739 multitasking and poll for being the topmost window.
740 */
741 // if (Private->EPOC_WsSession.GetFocusWindowGroup() != Private->EPOC_WsWindowGroupID) {
742
743 /* !!TODO: Could call GetRedraw() etc. for WsSession and redraw the screen if needed. That might be
744 needed if a small dialog comes in front of Game screen.
745 */
746 // while (Private->EPOC_WsSession.GetFocusWindowGroup() != Private->EPOC_WsWindowGroupID)
747
748 SDL_PauseAudio(1);
749 SDL_Delay(1000);
750 return;
751 // }
752
753 // RedrawWindowL(_this);
754 }
755
756 SDL_PauseAudio(0);
757
758 // if we are not focused, do not draw
759// if (!Private->EPOC_IsWindowFocused)
760// return;
761#if defined(__WINS__) || defined(TEST_BM_DRAW)
762 TBitmapUtil lock(Private->EPOC_Bitmap);
763 lock.Begin(TPoint(0,0)); // Lock bitmap heap
764 Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow);
765 TUint16* screenBuffer = (TUint16*)Private->EPOC_Bitmap->DataAddress();
766#else
767 TUint16* screenBuffer = (TUint16*)Private->EPOC_FrameBuffer;
768#endif
769
770 if (Private->EPOC_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270)
771 DirectDrawRotated(_this, numrects, rects, screenBuffer);
772 else
773 DirectDraw(_this, numrects, rects, screenBuffer);
774
775
776#if defined(__WINS__) || defined(TEST_BM_DRAW)
777
778 TRect rect = TRect(Private->EPOC_WsWindow.Size());
779 Private->EPOC_WsWindow.Invalidate(rect);
780 Private->EPOC_WsWindow.BeginRedraw(rect);
781 Private->EPOC_WindowGc->BitBlt(TPoint(), Private->EPOC_Bitmap);
782 Private->EPOC_WsWindow.EndRedraw();
783 Private->EPOC_WindowGc->Deactivate();
784 lock.End(); // Unlock bitmap heap
785 Private->EPOC_WsSession.Flush();
786#else
787#ifndef SYMBIAN_CRYSTAL
788 // This is not needed in Crystal. What is the performance penalty in SERIES60?
789 TRect rect2 = TRect(Private->EPOC_WsWindow.Size());
790
791 Private->EPOC_DrawDevice->UpdateRegion(rect2); // Should we update rects parameter area only??
792 Private->EPOC_DrawDevice->Update();
793#endif
794#endif
795
796 /* Update virtual cursor. !!Do not yet work properly
797 Private->EPOC_WsSession.SetPointerCursorPosition(Private->EPOC_WsSession.PointerCursorPosition());
798 */
799
800 /*static int foo = 1;
801
802 for ( int i=0; i < numrects; ++i ) {
803 const SDL_Rect& currentRect = rects[i];
804 SDL_Rect rect2;
805 rect2.x = currentRect.x;
806 rect2.y = currentRect.y;
807 rect2.w = currentRect.w;
808 rect2.h = currentRect.h;
809
810 if (rect2.w <= 0 || rect2.h <= 0)
811 continue;
812
813
814 foo++;
815 if((foo % 200) == 0)
816 {
817 SDL_TRACE1("foo %d", foo);
818 CFbsBitmap* b = new (ELeave) CFbsBitmap;
819 SDL_TRACE1("bee %d", (int)b);
820 int e = b->Create(TSize(currentRect.w, currentRect.h), Private->EPOC_DisplayMode);
821
822 SDL_TRACE1("err %d", e);
823 if(e != KErrNone)
824 User::Panic(_L("damn"), e);
825
826 TBitmapUtil u(b);
827 u.Begin(TPoint(0, 0));
828 TUint32* d = b->DataAddress();
829
830 SDL_TRACE1("addr %d", (int)d);
831
832 for(TInt o = 0; o < currentRect.h; o++)
833 for(TInt p = 0; p < currentRect.w; p++)
834 {
835 u.SetPos(TPoint(p, o));
836 u.SetPixel(0xFFFF);
837 }
838
839 SDL_TRACE1("w %d", (int)currentRect.w);
840 SDL_TRACE1("h %d", (int)currentRect.h);
841
842 SDL_TRACE1("addr %d", (int)Private->EPOC_DisplayMode);
843
844
845 const TUint f = (TUint)Private->EPOC_FrameBuffer;
846 const TUint y = (TUint)Private->EPOC_BytesPerScreen;
847
848
849 SDL_TRACE1("frame %u", f);
850 SDL_TRACE1("bytes %u", y);
851
852 Mem::Copy(d, Private->EPOC_FrameBuffer, Private->EPOC_BytesPerScreen);
853
854 SDL_TRACE("kopied");
855
856 u.End();
857 TBuf<32> name;
858 name.Format(_L("C:\\nokia\\images\\doom%d.mbm"), (foo / 200));
859 e= b->Save(name);
860 if(e != KErrNone)
861 User::Panic(_L("damned"), e);
862 delete b;
863 }}*/
864}
865
866
867void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
868{
869 TInt i;
870
871 const TInt sourceNumBytesPerPixel = ((_this->screen->format->BitsPerPixel-1)>>3) + 1;
872 const TPoint fixedOffset = Private->EPOC_ScreenOffset;
873 const TInt screenW = _this->screen->w;
874 const TInt screenH = _this->screen->h;
875 const TInt sourceScanlineLength = screenW;
876 const TInt targetScanlineLength = Private->EPOC_ScreenSize.iWidth;
877
878 /* Render the rectangles in the list */
879
880 for ( i=0; i < numrects; ++i ) {
881 const SDL_Rect& currentRect = rects[i];
882 SDL_Rect rect2;
883 rect2.x = currentRect.x;
884 rect2.y = currentRect.y;
885 rect2.w = currentRect.w;
886 rect2.h = currentRect.h;
887
888 if (rect2.w <= 0 || rect2.h <= 0) /* sanity check */
889 continue;
890
891 /* All variables are measured in pixels */
892
893 /* Check rects validity, i.e. upper and lower bounds */
894 TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1);
895 TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1);
896 if (maxX < 0 || maxY < 0) /* sanity check */
897 continue;
898 /* Clip from bottom */
899 maxY = Min(maxY, Private->EPOC_ScreenSize.iHeight-1);
900 /* TODO: Clip from the right side */
901
902 const TInt sourceRectWidth = maxX - rect2.x + 1;
903 const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel;
904 const TInt sourceRectHeight = maxY - rect2.y + 1;
905 const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength;
906 const TUint skipValue = 1; // no skip
907
908 TInt targetStartOffset = fixedOffset.iX + rect2.x + (fixedOffset.iY +rect2.y) * targetScanlineLength;
909
910 // Nokia7650 native mode: 12 bpp --> 12 bpp
911 //
912
913 switch (_this->screen->format->BitsPerPixel)
914 {
915 case 12:
916 {
917 TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset;
918 TUint16* screenMemory = screenBuffer + targetStartOffset;
919 if (skipValue == 1)
920 {
921 for(TInt y = 0 ; y < sourceRectHeight ; y++)
922 {
923 Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes);
924 }
925 bitmapLine += sourceScanlineLength;
926 screenMemory += targetScanlineLength;
927 }
928 else
929 {
930 for(TInt y = 0 ; y < sourceRectHeight ; y++)
931 {
932 //TODO: optimize: separate loops for 1, 2 and n skip. Mem::Copy() can be used in unscaled case.
933 TUint16* bitmapPos = bitmapLine; /* 2 bytes per pixel */
934 TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
935 for(TInt x = 0 ; x < sourceRectWidth ; x++)
936 {
937 __ASSERT_DEBUG(screenMemory < (screenBuffer + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight), User::Panic(_L("SDL"), KErrCorrupt));
938 __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
939 __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
940 __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
941
942 *screenMemoryLinePos++ = *bitmapPos;
943 bitmapPos+=skipValue;
944 }
945 bitmapLine += sourceScanlineLength;
946 screenMemory += targetScanlineLength;
947 }
948 }
949 }
950 break;
951 // 256 color paletted mode: 8 bpp --> 12 bpp
952 //
953 default:
954 {
955 if(Private->EPOC_BytesPerPixel <= 2)
956 {
957 TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset;
958 TUint16* screenMemory = screenBuffer + targetStartOffset;
959 for(TInt y = 0 ; y < sourceRectHeight ; y++)
960 {
961 TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
962 TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
963 /* Convert each pixel from 256 palette to 4k color values */
964 for(TInt x = 0 ; x < sourceRectWidth ; x++)
965 {
966 __ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
967 __ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
968 __ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
969 __ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
970 *screenMemoryLinePos++ = EPOC_HWPalette_256_to_Screen[*bitmapPos++];
971 // bitmapPos+=skipValue; //TODO: optimize: separate loops for 1, 2 and n skip
972 }
973 bitmapLine += sourceScanlineLength;
974 screenMemory += targetScanlineLength;
975 }
976 }
977 else
978 {
979 TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset;
980 TUint32* screenMemory = reinterpret_cast<TUint32*>(screenBuffer + targetStartOffset);
981 for(TInt y = 0 ; y < sourceRectHeight ; y++)
982 {
983 TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
984 TUint32* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
985 /* Convert each pixel from 256 palette to 4k color values */
986 for(TInt x = 0 ; x < sourceRectWidth ; x++)
987 {
988 __ASSERT_DEBUG(screenMemoryLinePos < (reinterpret_cast<TUint32*>(screenBuffer) + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
989 __ASSERT_DEBUG(screenMemoryLinePos >= reinterpret_cast<TUint32*>(screenBuffer), User::Panic(_L("SDL"), KErrCorrupt));
990 __ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
991 __ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
992 *screenMemoryLinePos++ = EPOC_HWPalette_256_to_Screen[*bitmapPos++];
993 // bitmapPos+=skipValue; //TODO: optimize: separate loops for 1, 2 and n skip
994 }
995 bitmapLine += sourceScanlineLength;
996 screenMemory += targetScanlineLength;
997 }
998 }
999 }
1000 } // switch
1001 } // for
1002}
1003
1004/*
1005void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
1006{
1007 TInt i;
1008 const TInt sourceNumBytesPerPixel = ((_this->screen->format->BitsPerPixel-1)>>3) + 1;
1009 const TPoint fixedOffset = Private->EPOC_ScreenOffset;
1010 const TInt screenW = _this->screen->w;
1011 const TInt screenH = _this->screen->h;
1012 const TInt sourceScanlineLength = screenW;
1013 const TInt targetScanlineLength = Private->EPOC_ScreenSize.iWidth;
1014
1015 /* Render the rectangles in the list */
1016
1017/* for ( i=0; i < numrects; ++i ) {
1018 const SDL_Rect& currentRect = rects[i];
1019 SDL_Rect rect2;
1020 rect2.x = currentRect.x;
1021 rect2.y = currentRect.y;
1022 rect2.w = currentRect.w;
1023 rect2.h = currentRect.h;
1024
1025 if (rect2.w <= 0 || rect2.h <= 0) /* sanity check */
1026/* continue;
1027
1028 /* All variables are measured in pixels */
1029
1030 /* Check rects validity, i.e. upper and lower bounds */
1031/* TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1);
1032 TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1);
1033 if (maxX < 0 || maxY < 0) /* sanity check */
1034/* continue;
1035 /* Clip from bottom */
1036/* maxY = Min(maxY, Private->EPOC_ScreenSize.iHeight-1);
1037 /* TODO: Clip from the right side */
1038
1039/* TInt sourceRectWidth = maxX - rect2.x + 1;
1040 const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel;
1041 const TInt sourceRectHeight = maxY - rect2.y + 1;
1042 const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength;
1043 const TUint skipValue = Private->EPOC_ScreenXScaleValue; //1; // no skip
1044
1045 const TInt targetStartOffset = // = (fixedOffset.iX + (rect2.x / skipValue) + (fixedOffset.iY + rect2.y) * targetScanlineLength ) ;
1046 (skipValue > 1 ?
1047 (fixedOffset.iX + (rect2.x / skipValue) + (fixedOffset.iY + rect2.y) * targetScanlineLength ) :
1048 (fixedOffset.iX + rect2.x + (fixedOffset.iY + rect2.y) * targetScanlineLength ));
1049
1050 __ASSERT_DEBUG(skipValue >= 1, User::Panic(KLibName, KErrArgument));
1051
1052 // Nokia7650 native mode: 12 bpp --> 12 bpp
1053 //
1054 switch (_this->screen->format->BitsPerPixel)
1055 {
1056 case 12:
1057 {
1058 TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset;
1059 TUint16* screenMemory = screenBuffer + targetStartOffset;
1060 if (skipValue == 1)
1061 {
1062 for(TInt y = 0 ; y < sourceRectHeight ; y++)
1063 {
1064 Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes);
1065 }
1066 bitmapLine += sourceScanlineLength;
1067 screenMemory += targetScanlineLength;
1068 }
1069 else
1070 {
1071 for(TInt y = 0 ; y < sourceRectHeight ; y++)
1072 {
1073 //TODO: optimize: separate loops for 1, 2 and n skip. Mem::Copy() can be used in unscaled case.
1074 TUint16* bitmapPos = bitmapLine; /* 2 bytes per pixel */
1075/* TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
1076/* for(TInt x = 0 ; x < sourceRectWidth ; x++)
1077 {
1078 __ASSERT_DEBUG(screenMemory < (screenBuffer + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight), User::Panic(KLibName, KErrCorrupt));
1079 __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(KLibName, KErrCorrupt));
1080 __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt));
1081 __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt));
1082
1083 *screenMemoryLinePos++ = *bitmapPos;
1084 bitmapPos+=skipValue;
1085 }
1086 bitmapLine += sourceScanlineLength;
1087 screenMemory += targetScanlineLength;
1088 }
1089 }
1090 }
1091 break;
1092 // 256 color paletted mode: 8 bpp --> 12 bpp
1093 //
1094 default:
1095 {
1096 TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset;
1097 TUint16* screenMemory = screenBuffer + targetStartOffset;
1098 if (skipValue > 1)
1099 sourceRectWidth /= skipValue;
1100#if defined __MARM_ARMI__
1101 __asm volatile("
1102 mov %4, %4, lsl #1 @ targetScanLineLength is in pixels, we need it in bytes
1103 1:
1104 mov r6, %0 @ bitmapLine
1105 mov r7, %2 @ screenMemory
1106 mov r8, %6 @ sourceRectWidth
1107 2:
1108 ldrb r4, [%0], %7 @ r4 = *bitmapPos; bitmapPos += skipValue
1109 ldr r5, [%1, r4, lsl #2] @ only 16 lower bits actually used
1110 subs r8, r8, #1 @ x--
1111 strh r5, [%2], #2 @ *screenMemoryLinePos++ = r4
1112 bne 2b
1113
1114 add %0, r6, %3 @ bitmapLine += sourceScanlineLength
1115 add %2, r7, %4 @ screenMemory += targetScanlineLength
1116 subs %5, %5, #1 @ sourceRectHeight--
1117 bne 1b
1118 "
1119 : // no output
1120 // %0 %1 %2 %3 %4 %5 %6 %7
1121 : "r" (bitmapLine), "r" (&EPOC_HWPalette_256_to_Screen[0]), "r" (screenMemory), "r" (sourceScanlineLength), "r" (targetScanlineLength), "r" (sourceRectHeight), "r" (sourceRectWidth), "r" (skipValue)
1122 : "r4", "r5", "r6", "r7", "r8"
1123 );
1124#else
1125 for(TInt y = 0 ; y < sourceRectHeight ; y++)
1126 {
1127 TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
1128/* TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
1129 /* Convert each pixel from 256 palette to 4k color values */
1130/* for (TInt x = 0 ; x < sourceRectWidth ; x++)
1131 {
1132 //__ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(KLibName, KErrCorrupt));
1133 //__ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(KLibName, KErrCorrupt));
1134 //__ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt));
1135 //__ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt));
1136
1137 *screenMemoryLinePos++ = EPOC_HWPalette_256_to_Screen[*bitmapPos];
1138 bitmapPos += skipValue;
1139 }
1140 bitmapLine += sourceScanlineLength;
1141 screenMemory += targetScanlineLength;
1142 }
1143//#endif
1144 }
1145 } // switch
1146 } // for
1147}
1148*/
1149
1150void DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
1151{
1152 TInt i;
1153// TInt sourceNumBytesPerPixel = ((_this->screen->format->BitsPerPixel-1)>>3) + 1;
1154 TPoint fixedScreenOffset = Private->EPOC_ScreenOffset;
1155 TInt bufferW = _this->screen->w;
1156 TInt bufferH = _this->screen->h;
1157 TInt ScreenW = Private->EPOC_ScreenSize.iWidth;
1158// TInt ScreenH = Private->EPOC_ScreenSize.iWidth;
1159 TInt sourceW = bufferW;
1160 TInt sourceH = bufferH;
1161 TInt targetW = ScreenW - fixedScreenOffset.iX * 2;
1162// TInt targetH = ScreenH - fixedScreenOffset.iY * 2;
1163 TInt sourceScanlineLength = bufferW;
1164 TInt targetScanlineLength = Private->EPOC_ScreenSize.iWidth;
1165
1166 /* Render the rectangles in the list */
1167
1168 for ( i=0; i < numrects; ++i ) {
1169 SDL_Rect rect2;
1170 const SDL_Rect& currentRect = rects[i];
1171 rect2.x = currentRect.x;
1172 rect2.y = currentRect.y;
1173 rect2.w = currentRect.w;
1174 rect2.h = currentRect.h;
1175
1176 if (rect2.w <= 0 || rect2.h <= 0) /* sanity check */
1177 continue;
1178
1179 /* All variables are measured in pixels */
1180
1181 /* Check rects validity, i.e. upper and lower bounds */
1182 TInt maxX = Min(sourceW - 1, rect2.x + rect2.w - 1);
1183 TInt maxY = Min(sourceH - 1, rect2.y + rect2.h - 1);
1184 if (maxX < 0 || maxY < 0) /* sanity check */
1185 continue;
1186 /* Clip from bottom */
1187 //maxX = Min(maxX, Private->EPOC_ScreenSize.iHeight-1);
1188 /* TODO: Clip from the right side */
1189
1190 TInt sourceRectWidth = maxX - rect2.x + 1;
1191// TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel;
1192 TInt sourceRectHeight = maxY - rect2.y + 1;
1193 TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength;
1194 TInt targetStartOffset = fixedScreenOffset.iX + (targetW-1 - rect2.y) + (fixedScreenOffset.iY +rect2.x) * targetScanlineLength;
1195
1196 // Nokia7650 native mode: 12 bpp --> 12 bpp
1197 if (_this->screen->format->BitsPerPixel == 12) {
1198
1199 /* !!TODO: not yet implemented
1200
1201 TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset;
1202 TUint16* screenMemory = screenBuffer + targetStartOffset;
1203 for(TInt y = 0 ; y < sourceRectHeight ; y++) {
1204 //TODO: optimize: separate loops for 1, 2 and n skip
1205 //Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes);
1206 TUint16* bitmapPos = bitmapLine; // 2 bytes per pixel
1207 TUint16* screenMemoryLinePos = screenMemory; // 2 bytes per pixel
1208 for(TInt x = 0 ; x < sourceRectWidth ; x++) {
1209
1210 __ASSERT_DEBUG(screenMemory < (screenBuffer + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight), User::Panic(KLibName, KErrCorrupt));
1211 __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(KLibName, KErrCorrupt));
1212 __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt));
1213 __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt));
1214
1215 *screenMemoryLinePos = *bitmapPos;
1216 bitmapPos++;
1217 screenMemoryLinePos += targetScanlineLength;
1218 }
1219 bitmapLine += sourceScanlineLength;
1220 screenMemory--;
1221 }
1222
1223 */
1224 }
1225 // 256 color paletted mode: 8 bpp --> 12 bpp
1226 else {
1227 TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset;
1228 TUint16* screenMemory = screenBuffer + targetStartOffset;
1229 TInt screenXScaleValue = Private->EPOC_ScreenXScaleValue;
1230 TInt debug_ycount=0;
1231 for(TInt y = 0 ; y < sourceRectHeight ; y++) {
1232 if(--screenXScaleValue) {
1233 TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
1234 TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
1235 TInt screenYScaleValue = Private->EPOC_ScreenYScaleValue;
1236 TInt debug_xcount=0;
1237 /* Convert each pixel from 256 palette to 4k color values */
1238 for(TInt x = 0 ; x < sourceRectWidth ; x++) {
1239 if(--screenYScaleValue) {
1240
1241 __ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(KLibName, KErrCorrupt));
1242 __ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(KLibName, KErrCorrupt));
1243 __ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt));
1244 __ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt));
1245
1246 *screenMemoryLinePos = TUint16(EPOC_HWPalette_256_to_Screen[*bitmapPos]);
1247 screenMemoryLinePos += targetScanlineLength; debug_xcount++;
1248 }
1249 else
1250 screenYScaleValue = Private->EPOC_ScreenYScaleValue;
1251 bitmapPos++;
1252 }
1253 screenMemory--; debug_ycount++;
1254 } // endif
1255 else
1256 screenXScaleValue = Private->EPOC_ScreenXScaleValue;
1257 bitmapLine += sourceScanlineLength;
1258 }
1259 }
1260 }
1261}
1262
1263
1264/* Note: If we are terminated, this could be called in the middle of
1265 another SDL video routine -- notably UpdateRects.
1266*/
1267void EPOC_VideoQuit(_THIS)
1268{
1269 int i;
1270
1271 /* Free video mode lists */
1272 for ( i=0; i<SDL_NUMMODES; ++i ) {
1273 if ( Private->SDL_modelist[i] != NULL ) {
1274 free(Private->SDL_modelist[i]);
1275 Private->SDL_modelist[i] = NULL;
1276 }
1277 }
1278
1279 if ( _this->screen && (_this->screen->flags & SDL_HWSURFACE) ) {
1280 /* Direct screen access, no memory buffer */
1281 _this->screen->pixels = NULL;
1282 }
1283
1284 if (_this->screen && _this->screen->pixels) {
1285 free(_this->screen->pixels);
1286 _this->screen->pixels = NULL;
1287 }
1288
1289 /* Free Epoc resources */
1290
1291 /* Disable events for me */
1292 if (Private->EPOC_WsEventStatus != KRequestPending)
1293 Private->EPOC_WsSession.EventReadyCancel();
1294 if (Private->EPOC_RedrawEventStatus != KRequestPending)
1295 Private->EPOC_WsSession.RedrawReadyCancel();
1296
1297 #if defined(__WINS__) || defined(TEST_BM_DRAW)
1298 delete Private->EPOC_Bitmap;
1299 Private->EPOC_Bitmap = NULL;
1300 #else
1301 #endif
1302
1303#ifndef SYMBIAN_CRYSTAL
1304 free(Private->EPOC_DrawDevice);
1305#endif
1306
1307 if (Private->EPOC_WsWindow.WsHandle())
1308 Private->EPOC_WsWindow.Close();
1309
1310 if (Private->EPOC_WsWindowGroup.WsHandle())
1311 Private->EPOC_WsWindowGroup.Close();
1312
1313 delete Private->EPOC_WindowGc;
1314 Private->EPOC_WindowGc = NULL;
1315
1316 delete Private->EPOC_WsScreen;
1317 Private->EPOC_WsScreen = NULL;
1318
1319 if (Private->EPOC_WsSession.WsHandle())
1320 Private->EPOC_WsSession.Close();
1321}
1322
1323
1324WMcursor *EPOC_CreateWMCursor(_THIS, Uint8* /*data*/, Uint8* /*mask*/, int /*w*/, int /*h*/, int /*hot_x*/, int /*hot_y*/)
1325{
1326 return (WMcursor *) 9210; // it's ok to return something unuseful but true
1327}
1328
1329void EPOC_FreeWMCursor(_THIS, WMcursor* /*cursor*/)
1330{
1331 /* Disable virtual cursor */
1332 HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
1333 Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone);
1334}
1335
1336int EPOC_ShowWMCursor(_THIS, WMcursor *cursor)
1337{
1338
1339 if (cursor == (WMcursor *)9210) {
1340 /* Enable virtual cursor */
1341 Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNormal);
1342 if (isCursorVisible)
1343 HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
1344 else
1345 Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone);
1346 }
1347 else {
1348 /* Disable virtual cursor */
1349 HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
1350 Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone);
1351 }
1352
1353 return(1);
1354}
1355
1356}; // extern "C"
diff --git a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.h b/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.h
deleted file mode 100644
index bd0b0e29c5..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@devolution.com
21*/
22
23#ifndef _SDL_epocvideo_h
24#define _SDL_epocvideo_h
25
26#ifndef EKA2
27#include"SDL_epocvideo_org.h"
28#else
29#include"SDL_epocvideo2.h"
30#endif
31
32
33#endif
34