3 #include "sdlepocapi.h"
11 #include "SDL_epocevents_c.h"
12 #include "SDL_keysym.h"
14 #include "SDL_loadso.h"
16 extern SDLKey
* KeyMap();
17 extern void ResetKeyMap();
24 NONSHARABLE_CLASS(EpocSdlEnvData
)
29 CEventQueue
* iEventQueue
;
37 CArrayFix
<TSdlCleanupItem
>* iCleanupItems
;
39 TRequestStatus
* iCallerStatus
;
42 EpocSdlEnvData
* gEpocEnv
;
44 NONSHARABLE_CLASS(EnvUtils
)
47 static inline TBool
IsOwnThreaded();
48 static TBool
Rendezvous(RThread
& aThread
, TRequestStatus
& aStatus
);
49 static void RunSingleThread();
52 inline TBool
EnvUtils::IsOwnThreaded()
54 return gEpocEnv
->iEpocEnvFlags
& CSDL::EOwnThread
;
57 void EnvUtils::RunSingleThread()
59 if(!EnvUtils::IsOwnThreaded())
61 int count
= RThread().RequestCount();
65 if(CActiveScheduler::RunIfReady(err
, CActive::EPriorityIdle
))
67 CActiveScheduler::Current()->WaitForAnyRequest();
73 int Panic(int aErr
, int aLine
)
76 b
.Format(_L("Main at %d"), aLine
);
82 class CEventQueue
: public CBase
, public MEventQueue
87 int Append(const TWsEvent
& aEvent
);
88 const TWsEvent
Shift();
94 std::queue
<TWsEvent
> m_queue
;
98 void CEventQueue::ConstructL()
100 if(EnvUtils::IsOwnThreaded())
101 User::LeaveIfError(iCS
.CreateLocal());
104 CEventQueue::~CEventQueue()
109 int CEventQueue::Append(const TWsEvent
& aEvent
)
112 m_queue
.push(aEvent
);
118 TBool
CEventQueue::HasData()
120 EnvUtils::RunSingleThread();
121 return !m_queue
.empty();
124 void CEventQueue::Lock()
126 if(EnvUtils::IsOwnThreaded())
130 void CEventQueue::Unlock()
132 if(EnvUtils::IsOwnThreaded())
136 const TWsEvent
CEventQueue::Shift()
138 const TWsEvent event
= m_queue
.front();
144 TSdlCleanupItem::TSdlCleanupItem(TSdlCleanupOperation aOperation
, TAny
* aItem
) :
145 iOperation(aOperation
), iItem(aItem
), iThread(RThread().Id())
148 #define MAINFUNC(x) EXPORT_C TMainFunc::TMainFunc(mainfunc##x aFunc){Mem::FillZ(iMainFunc, sizeof(iMainFunc)); iMainFunc[x - 1] = (void*) aFunc;}
157 EXPORT_C
TMainFunc::TMainFunc()
159 Mem::FillZ(iMainFunc
, sizeof(iMainFunc
));
163 const void* TMainFunc::operator[](int aIndex
) const
165 return iMainFunc
[aIndex
];
169 NONSHARABLE_CLASS(CSdlAppServ
) : public CActive
174 EAppSrvNoop
= CDsa::ELastDsaRequest
,
177 EAppSrvWindowDisplayMode
,
178 EAppSrvWindowPointerCursorMode
,
186 int Request(int aService
);
187 int RequestValue(int aService
);
189 void PanicMain(int aReason
);
190 void PanicMain(const TDesC
& aInfo
, int aReason
);
191 void SetObserver(MSDLObserver
* aObserver
);
192 int ObserverEvent(int aEvent
, int aParam
);
193 void SetParam(int aParam
);
194 void HandleObserverValue(int aService
, int aReturnValue
, TBool aMainThread
);
195 MSDLObserver
* Observer();
200 const TThreadId iMainId
;
205 MSDLObserver
* iObserver
;
206 TRequestStatus
* iStatusPtr
;
209 CSdlAppServ::CSdlAppServ() : CActive(CActive::EPriorityHigh
), iMainId(RThread().Id()), iObserver( NULL
)
213 MSDLObserver
* CSdlAppServ::Observer()
218 void CSdlAppServ::SetObserver(MSDLObserver
* aObserver
)
220 iObserver
= aObserver
;
223 int CSdlAppServ::ObserverEvent(int aEvent
, int aParam
)
225 if(iObserver
!= NULL
)
227 if(RThread().Id() == gEpocEnv
->iId
&& EnvUtils::IsOwnThreaded())
229 return iObserver
->SdlThreadEvent(aEvent
, aParam
);
231 else if(RThread().Id() == iMainId
)
233 return iObserver
->SdlEvent(aEvent
, aParam
);
235 PANIC(KErrNotSupported
);
240 void CSdlAppServ::PanicMain(int aReason
)
242 iAppThread
.Panic(RThread().Name(), aReason
);
245 void CSdlAppServ::PanicMain(const TDesC
& aInfo
, int aReason
)
247 iAppThread
.Panic(aInfo
, aReason
);
250 void CSdlAppServ::ConstructL()
252 CActiveScheduler::Add(this);
253 if(EnvUtils::IsOwnThreaded())
254 User::LeaveIfError(iSema
.CreateLocal(1));
255 iStatus
= KRequestPending
;
256 iStatusPtr
= &iStatus
;
260 CSdlAppServ::~CSdlAppServ()
263 if(iSema
.Handle() != NULL
)
269 int CSdlAppServ::Request(int aService
)
271 if(EnvUtils::IsOwnThreaded())
273 if(RThread().Id() == iAppThread
.Id())
274 return KErrBadHandle
;
277 EnvUtils::RunSingleThread();
279 iAppThread
.RequestComplete(iStatusPtr
, KErrNone
);
283 int CSdlAppServ::RequestValue(int aService
)
286 Request(EAppSrvNoop
);
290 void CSdlAppServ::Init()
292 PANIC_IF_ERROR(iAppThread
.Open(iMainId
));
295 void CSdlAppServ::SetParam(int aParam
)
297 iReturnValue
= aParam
;
300 void CSdlAppServ::HandleObserverValue(int aService
, int aReturnValue
, TBool aMainThread
)
302 if(iObserver
!= NULL
&& aMainThread
)
306 case MSDLObserver::EEventScreenSizeChanged
:
307 if(aReturnValue
== MSDLObserver::EScreenSizeChangedDefaultPalette
)
308 EpocSdlEnv::LockPalette(EFalse
);
312 if(!aMainThread
&& aService
== MSDLObserver::EEventSuspend
)
314 if(iObserver
== NULL
|| (gEpocEnv
->iDsa
!= NULL
&& gEpocEnv
->iDsa
->Stopped() && aReturnValue
!= MSDLObserver::ESuspendNoSuspend
))
316 EpocSdlEnv::Suspend();
321 void CSdlAppServ::RunL()
323 if(iStatus
== KErrNone
)
327 case CSdlAppServ::EAppSrvWaitDsa
:
328 EpocSdlEnv::SetWaitDsa();
329 iReturnValue
= EpocSdlEnv::IsDsaAvailable();
332 case CSdlAppServ::EAppSrvStopThread
:
333 if(gEpocEnv
->iDsa
!= NULL
)
334 gEpocEnv
->iDsa
->SetSuspend();
337 case EAppSrvWindowPointerCursorMode
:
338 iReturnValue
= gEpocEnv
->iDsa
!= NULL
? gEpocEnv
->iDsa
->Session().PointerCursorMode() : KErrNotReady
;
341 case EAppSrvDsaStatus
:
342 if(gEpocEnv
->iDsa
!= NULL
)
343 gEpocEnv
->iDsa
->Stop();
344 iReturnValue
= KErrNone
;
347 case CDsa::ERequestUpdate
:
348 gEpocEnv
->iDsa
->UnlockHWSurfaceRequestComplete();
354 case MSDLObserver::EEventResume
:
355 case MSDLObserver::EEventSuspend
:
356 case MSDLObserver::EEventScreenSizeChanged
:
357 case MSDLObserver::EEventWindowReserved
:
358 case MSDLObserver::EEventKeyMapInit
:
359 case MSDLObserver::EEventWindowNotAvailable
:
360 case MSDLObserver::EEventMainExit
:
361 iReturnValue
= ObserverEvent(iService
, iReturnValue
);
362 HandleObserverValue(iService
, iReturnValue
, ETrue
);
366 PANIC(KErrNotSupported
);
370 iStatus
= KRequestPending
;
371 iStatusPtr
= &iStatus
;
375 if(EnvUtils::IsOwnThreaded())
379 void CSdlAppServ::DoCancel()
381 if(EnvUtils::IsOwnThreaded())
383 TRequestStatus
* s
= &iStatus
;
384 iAppThread
.RequestComplete(s
, KErrCancel
);
387 MEventQueue
& EpocSdlEnv::EventQueue()
389 __ASSERT_DEBUG(gEpocEnv
!= NULL
, PANIC(KErrNotReady
));
390 return *gEpocEnv
->iEventQueue
;
394 TBool
EpocSdlEnv::Flags(int aFlag
)
396 const int flag
= gEpocEnv
->iEpocEnvFlags
& aFlag
;
397 return flag
== aFlag
;
400 int EpocSdlEnv::Argc()
402 __ASSERT_DEBUG(gEpocEnv
!= NULL
, PANIC(KErrNotReady
));
403 return gEpocEnv
->iArgc
;
406 char** EpocSdlEnv::Argv()
408 __ASSERT_DEBUG(gEpocEnv
!= NULL
, PANIC(KErrNotReady
));
409 return gEpocEnv
->iArgv
;
412 TBool
EpocSdlEnv::IsDsaAvailable()
414 __ASSERT_DEBUG(gEpocEnv
!= NULL
, PANIC(KErrNotReady
));
415 return gEpocEnv
->iDsa
!= NULL
&& gEpocEnv
->iDsa
->IsDsaAvailable();
418 void EpocSdlEnv::WaitDsaAvailable()
420 EpocSdlEnv::ObserverEvent(MSDLObserver::EEventWindowNotAvailable
, 0);
421 gEpocEnv
->iAppSrv
->Request(CSdlAppServ::EAppSrvStopThread
);
422 if(EpocSdlEnv::Flags(CSDL::EEnableFocusStop
))
424 EpocSdlEnv::ObserverEvent(MSDLObserver::EEventSuspend
, 0);
428 void EpocSdlEnv::Suspend()
430 if(gEpocEnv
->iDsa
!= NULL
&& (gEpocEnv
->iDsa
->Stopped() || EpocSdlEnv::Flags(CSDL::EEnableFocusStop
)))
432 gEpocEnv
->iDsa
->SetSuspend();
433 if(EnvUtils::IsOwnThreaded())
436 EpocSdlEnv::ObserverEvent(MSDLObserver::EEventResume
, 0);
441 void EpocSdlEnv::SetWaitDsa()
443 if(!IsDsaAvailable())
445 if(EnvUtils::IsOwnThreaded())
448 th
.Open(gEpocEnv
->iId
);
452 if(gEpocEnv
->iDsa
!= NULL
)
453 gEpocEnv
->iDsa
->SetSuspend();
457 void EpocSdlEnv::Resume()
459 if(gEpocEnv
->iDsa
!= NULL
)
461 gEpocEnv
->iDsa
->Resume();
463 if(EnvUtils::IsOwnThreaded())
466 th
.Open(gEpocEnv
->iId
);
470 const int value
= gEpocEnv
->iAppSrv
->ObserverEvent(MSDLObserver::EEventResume
, 0);
471 gEpocEnv
->iAppSrv
->HandleObserverValue(MSDLObserver::EEventResume
, value
, ETrue
);
475 int EpocSdlEnv::AllocSwSurface(const TSize
& aSize
, TDisplayMode aMode
)
477 return gEpocEnv
->iDsa
->AllocSurface(EFalse
, aSize
, aMode
);
480 int EpocSdlEnv::AllocHwSurface(const TSize
& aSize
, TDisplayMode aMode
)
482 return gEpocEnv
->iDsa
->AllocSurface(ETrue
, aSize
, aMode
);
485 void EpocSdlEnv::UnlockHwSurface()
487 gEpocEnv
->iDsa
->UnlockHwSurface();
490 TUint8
* EpocSdlEnv::LockHwSurface()
492 return gEpocEnv
->iDsa
->LockHwSurface();
495 void EpocSdlEnv::UpdateSwSurface()
497 gEpocEnv
->iDsa
->UpdateSwSurface();
500 TBool
EpocSdlEnv::AddUpdateRect(TUint8
* aAddress
, const TRect
& aUpdateRect
, const TRect
& aRect
)
502 return gEpocEnv
->iDsa
->AddUpdateRect(aAddress
, aUpdateRect
, aRect
);
505 void EpocSdlEnv::Request(int aService
)
507 __ASSERT_DEBUG(gEpocEnv
!= NULL
, PANIC(KErrNotReady
));
508 gEpocEnv
->iAppSrv
->Request(aService
);
511 TSize
EpocSdlEnv::WindowSize(const TSize
& aRequestedSize
)
513 __ASSERT_DEBUG(gEpocEnv
!= NULL
, PANIC(KErrNotReady
));
514 return gEpocEnv
->iDsa
== NULL
? TSize(0, 0) : gEpocEnv
->iDsa
->WindowSize();
517 TSize
EpocSdlEnv::WindowSize()
519 __ASSERT_DEBUG(gEpocEnv
!= NULL
, PANIC(KErrNotReady
));
520 return gEpocEnv
->iDsa
== NULL
? TSize(0, 0) : gEpocEnv
->iDsa
->WindowSize();
523 TDisplayMode
EpocSdlEnv::DisplayMode()
525 return gEpocEnv
->iDsa
== NULL
? ENone
: gEpocEnv
->iDsa
->DisplayMode();
528 TPointerCursorMode
EpocSdlEnv::PointerMode()
530 return static_cast<TPointerCursorMode
>(gEpocEnv
->iAppSrv
->RequestValue(CSdlAppServ::EAppSrvWindowPointerCursorMode
));
533 int EpocSdlEnv::SetPalette(int aFirstcolor
, int aColorCount
, TUint32
* aPalette
)
535 return gEpocEnv
->iDsa
->SetPalette(aFirstcolor
, aColorCount
, aPalette
);
538 void EpocSdlEnv::PanicMain(int aErr
)
540 gEpocEnv
->iAppSrv
->PanicMain(aErr
);
544 int EpocSdlEnv::AppendCleanupItem(const TSdlCleanupItem
& aItem
)
546 TRAPD(err
, gEpocEnv
->iCleanupItems
->AppendL(aItem
));
550 void EpocSdlEnv::RemoveCleanupItem(TAny
* aItem
)
552 for(int i
= 0; i
< gEpocEnv
->iCleanupItems
->Count(); i
++)
554 if(gEpocEnv
->iCleanupItems
->At(i
).iItem
== aItem
)
555 gEpocEnv
->iCleanupItems
->Delete(i
);
559 void EpocSdlEnv::CleanupItems()
561 const TThreadId id
= RThread().Id();
562 int last
= gEpocEnv
->iCleanupItems
->Count() - 1;
565 for(i
= last
; i
>= 0 ; i
--)
567 TSdlCleanupItem
& item
= gEpocEnv
->iCleanupItems
->At(i
);
568 if(item
.iThread
== id
)
570 item
.iThread
= TThreadId(0);
571 item
.iOperation(item
.iItem
);
575 last
= gEpocEnv
->iCleanupItems
->Count() - 1;
577 for(i
= last
; i
>= 0 ; i
--)
579 TSdlCleanupItem
& item
= gEpocEnv
->iCleanupItems
->At(i
);
580 if(item
.iThread
== TThreadId(0))
582 gEpocEnv
->iCleanupItems
->Delete(i
);
587 void EpocSdlEnv::FreeSurface()
589 Request(CSdlAppServ::EAppSrvDsaStatus
);
590 if(gEpocEnv
->iDsa
!= NULL
)
591 gEpocEnv
->iDsa
->Free();
594 void EpocSdlEnv::LockPalette(TBool aLock
)
596 gEpocEnv
->iDsa
->LockPalette(aLock
);
599 void EpocSdlEnv::ObserverEvent(int aService
, int aParam
)
601 const TBool sdlThread
= RThread().Id() == gEpocEnv
->iId
;
602 const int valuea
= gEpocEnv
->iAppSrv
->ObserverEvent(aService
, aParam
);
603 gEpocEnv
->iAppSrv
->HandleObserverValue(aService
, valuea
, !sdlThread
);
606 gEpocEnv
->iAppSrv
->SetParam(aParam
);
607 const int valuet
= gEpocEnv
->iAppSrv
->RequestValue(aService
);
608 gEpocEnv
->iAppSrv
->HandleObserverValue(aService
, valuet
, EFalse
);
612 TPoint
EpocSdlEnv::WindowCoordinates(const TPoint
& aPoint
)
614 return gEpocEnv
->iDsa
== NULL
? aPoint
: gEpocEnv
->iDsa
->WindowCoordinates(aPoint
);
617 void EpocSdlEnv::PanicMain(const TDesC
& aInfo
, int aErr
)
619 gEpocEnv
->iAppSrv
->PanicMain(aInfo
, aErr
);
622 //Dsa is a low priority ao, it has to wait if its pending event, but ws
623 //event has been prioritized before it
624 //this is not called from app thread!
625 void EpocSdlEnv::WaitDeviceChange()
628 gEpocEnv
->iAppSrv
->RequestValue(CSdlAppServ::EAppSrvWaitDsa
);
629 const TSize sz
= WindowSize();
630 const int param
= reinterpret_cast<int>(&sz
);
631 ObserverEvent(MSDLObserver::EEventScreenSizeChanged
, param
);
634 LOCAL_C TBool
CheckSdl()
638 if(sdl
.Open(gEpocEnv
->iId
) == KErrNone
)
640 if(sdl
.ExitType() == EExitPending
)
649 void EpocSdlEnvData::Free()
651 if(RThread().Id() == gEpocEnv
->iId
)
658 __ASSERT_ALWAYS(iArgv
== NULL
|| CheckSdl(), PANIC(KErrNotReady
));
661 void EpocSdlEnvData::Delete()
663 for(int i
= 0; i
<= iArgc
; i
++)
666 User::Free( iArgv
[i
] );
683 _LIT(KSDLMain
, "SDLMain");
687 gEpocEnv
->iCleanupItems
= new (ELeave
) CArrayFixFlat
<TSdlCleanupItem
>(8);
690 /* !! process exits here if there is "exit()" in main! */
692 for(int i
= 0; i
< 6; i
++)
694 void* f
= (void*) gEpocEnv
->iMain
[i
];
700 ret
= ((mainfunc1
)f
)();
708 ret
= ((mainfunc2
)f
)(EpocSdlEnv::Argc(), EpocSdlEnv::Argv());
712 ((mainfunc2
)f
)(EpocSdlEnv::Argc(), EpocSdlEnv::Argv());
716 ret
= ((mainfunc3
)f
)(EpocSdlEnv::Argc(), EpocSdlEnv::Argv(), envp
);
720 ((mainfunc3
)f
)(EpocSdlEnv::Argc(), EpocSdlEnv::Argv(), envp
);
729 LOCAL_C
int DoMain(TAny
* /*aParam*/)
731 TBool fbsconnected
= EFalse
;
732 CTrapCleanup
* cleanup
= NULL
;
734 if(EnvUtils::IsOwnThreaded())
736 cleanup
= CTrapCleanup::New();
738 if(RFbsSession::GetSession() == NULL
)
740 PANIC_IF_ERROR(RFbsSession::Connect());
741 fbsconnected
= ETrue
;
744 gEpocEnv
->iAppSrv
->Init();
748 if(EnvUtils::IsOwnThreaded())
750 //completes waiting rendesvous
751 RThread::Rendezvous(KErrNone
);
754 TRAPD(err
, err
= MainL());
756 EpocSdlEnv::ObserverEvent(MSDLObserver::EEventMainExit
, err
);
758 // Free resources and return
759 EpocSdlEnv::CleanupItems();
761 gEpocEnv
->iCleanupItems
->Reset();
762 delete gEpocEnv
->iCleanupItems
;
763 gEpocEnv
->iCleanupItems
= NULL
;
765 gEpocEnv
->Free(); //free up in thread resources
768 RFbsSession::Disconnect();
772 if(gEpocEnv
->iCallerStatus
!= NULL
)
774 User::RequestComplete(gEpocEnv
->iCallerStatus
, err
);
779 return err
== KErrNone
? ret
: err
;
783 EXPORT_C
CSDL::~CSDL()
788 User::Free(gEpocEnv
);
792 EXPORT_C CSDL
* CSDL::NewL(int aFlags
)
794 __ASSERT_ALWAYS(gEpocEnv
== NULL
, PANIC(KErrAlreadyExists
));
795 gEpocEnv
= (EpocSdlEnvData
*) User::AllocL(sizeof(EpocSdlEnvData
));
796 Mem::FillZ(gEpocEnv
, sizeof(EpocSdlEnvData
));
798 gEpocEnv
->iEpocEnvFlags
= aFlags
;
799 gEpocEnv
->iEventQueue
= new (ELeave
) CEventQueue();
800 gEpocEnv
->iAppSrv
= new (ELeave
) CSdlAppServ();
802 CSDL
* sdl
= new (ELeave
) CSDL();
804 gEpocEnv
->iSdl
= sdl
;
809 EXPORT_C
void CSDL::SetContainerWindowL(RWindow
& aWindow
, RWsSession
& aSession
, CWsScreenDevice
& aDevice
)
811 if(gEpocEnv
->iDsa
== NULL
)
812 gEpocEnv
->iDsa
= CDsa::CreateL(aSession
);
813 gEpocEnv
->iDsa
->ConstructL(aWindow
, aDevice
);
816 int EpocSdlEnv::ApplyGlesDsa()
819 TRAPD(err
, dsa
= gEpocEnv
->iDsa
->CreateGlesDsaL());
820 gEpocEnv
->iDsa
= dsa
;
824 RWindow
* EpocSdlEnv::Window()
826 return gEpocEnv
->iDsa
->Window();
829 EXPORT_C TThreadId
CSDL::CallMainL(const TMainFunc
& aFunc
, TRequestStatus
* const aStatus
, const CDesC8Array
* const aArg
, int aStackSize
)
831 ASSERT(gEpocEnv
!= NULL
);
832 gEpocEnv
->iMain
= aFunc
;
833 const TBool args
= aArg
!= NULL
;
835 if(gEpocEnv
->iArgv
!= NULL
)
836 User::Leave(KErrAlreadyExists
);
838 gEpocEnv
->iArgc
= args
? aArg
->Count() + 1 : 0;
839 gEpocEnv
->iArgv
= (char**) User::AllocL(sizeof(char*) * (gEpocEnv
->iArgc
+ 2));
842 const TFileName processName
= RProcess().FileName();
843 const int len
= processName
.Length();
844 gEpocEnv
->iArgv
[k
] = (char*) User::AllocL(len
+ 1);
845 Mem::Copy(gEpocEnv
->iArgv
[k
], processName
.Ptr(), len
);
846 gEpocEnv
->iArgv
[k
][len
] = 0;
848 for(int i
= 0; args
&& (i
< aArg
->Count()); i
++)
851 const int len
= aArg
->MdcaPoint(i
).Length();
852 gEpocEnv
->iArgv
[k
] = (char*) User::AllocL(len
+ 1);
853 Mem::Copy(gEpocEnv
->iArgv
[k
], aArg
->MdcaPoint(i
).Ptr(), len
);
854 gEpocEnv
->iArgv
[k
][len
] = 0;
857 gEpocEnv
->iArgv
[k
+ 1] = NULL
;
859 gEpocEnv
->iEventQueue
->ConstructL();
860 gEpocEnv
->iAppSrv
->ConstructL();
862 if(EnvUtils::IsOwnThreaded())
865 User::LeaveIfError(thread
.Create(KSDLMain
, DoMain
, aStackSize
, NULL
, NULL
));
869 thread
.Logon(*aStatus
);
872 gEpocEnv
->iId
= thread
.Id();
873 thread
.SetPriority(EPriorityLess
);
879 gEpocEnv
->iCallerStatus
= aStatus
;
881 *aStatus
= KRequestPending
;
882 gEpocEnv
->iId
= RThread().Id();
883 // when priority is not lowered screen updates much more frequently, which
884 // may be undesired, for example in case of openttd's generating world dialog
885 RThread().SetPriority(EPriorityLess
);
889 return gEpocEnv
->iId
;
892 EXPORT_C
int CSDL::AppendWsEvent(const TWsEvent
& aEvent
)
894 return EpocSdlEnv::EventQueue().Append(aEvent
);
897 EXPORT_C
void CSDL::SDLPanic(const TDesC
& aInfo
, int aErr
)
899 EpocSdlEnv::PanicMain(aInfo
, aErr
);
902 EXPORT_C
int CSDL::GetSDLCode(int aScanCode
)
906 if(aScanCode
>= MAX_SCANCODE
)
908 return KeyMap()[aScanCode
];
911 EXPORT_C
int CSDL::SDLCodesCount() const
916 EXPORT_C
void CSDL::ResetSDLCodes()
921 EXPORT_C
int CSDL::SetSDLCode(int aScanCode
, int aSDLCode
)
923 const int current
= GetSDLCode(aScanCode
);
924 if(aScanCode
>= 0 && aScanCode
< MAX_SCANCODE
)
925 KeyMap()[aScanCode
] = static_cast<SDLKey
>(aSDLCode
);
930 EXPORT_C MSDLObserver
* CSDL::Observer()
932 return gEpocEnv
->iAppSrv
->Observer();
935 EXPORT_C
void CSDL::SetObserver(MSDLObserver
* aObserver
)
937 gEpocEnv
->iAppSrv
->SetObserver(aObserver
);
940 EXPORT_C
void CSDL::Resume()
942 EpocSdlEnv::Resume();
945 EXPORT_C
void CSDL::Suspend()
947 if(gEpocEnv
->iDsa
!= NULL
)
948 gEpocEnv
->iDsa
->DoStop();
951 EXPORT_C
CSDL::CSDL()
954 EXPORT_C
int CSDL::SetBlitter(MBlitter
* aBlitter
)
956 if(gEpocEnv
&& gEpocEnv
->iDsa
)
958 gEpocEnv
->iDsa
->SetBlitter(aBlitter
);
964 EXPORT_C
int CSDL::RedrawRequest()
966 if(gEpocEnv
&& gEpocEnv
->iDsa
)
968 const int err
= gEpocEnv
->iDsa
->RedrawRequest();
969 EnvUtils::RunSingleThread();
975 TBool
EnvUtils::Rendezvous(RThread
& aThread
, TRequestStatus
& aStatus
)
977 if(gEpocEnv
->iId
!= TThreadId(0) &&
978 aThread
.Open(gEpocEnv
->iId
) &&
979 aThread
.ExitType() == EExitPending
)
981 aThread
.Rendezvous(aStatus
);
987 void* SDL_LoadObject(const char *sofile
)
989 RLibrary
* lib
= new RLibrary();
993 name
.Copy(TPtrC8((const TUint8
*)sofile
));
994 if(KErrNone
== lib
->Load(name
))
1000 void* SDL_LoadFunction(void *handle
, const char *name
)
1002 TLex8
v((const TUint8
*)(name
));
1005 if(KErrNone
!= v
.Val(ord
))
1008 const RLibrary
* lib
= reinterpret_cast<RLibrary
*>(handle
);
1009 TLibraryFunction f
= lib
->Lookup(ord
);
1013 void SDL_UnloadObject(void *handle
)
1015 RLibrary
* lib
= reinterpret_cast<RLibrary
*>(handle
);