EpocGameEngine.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. /*
  5. ============================================================================
  6. Name : EpocGameEngine.h
  7. Author :
  8. Description : Declares view class for application.
  9. ============================================================================
  10. */
  11. #ifndef __EPOCGAMEENGINE_H__
  12. #define __EPOCGAMEENGINE_H__
  13. // INCLUDES
  14. #include <coecntrl.h>
  15. #include <EGL/egl.h>
  16. #include <gles2/gl2.h>
  17. #include <akndef.h>
  18. #include <aknappui.h>
  19. #include "GameEngine.h"
  20. #include "GameApp.h"
  21. // volume keys
  22. #include <remconcoreapitargetobserver.h>
  23. #include <remconcoreapitarget.h>
  24. #include <remconinterfaceselector.h>
  25. // profile
  26. #include <centralrepository.h>
  27. // audio
  28. #include <mmf/server/sounddevice.h>
  29. #include <mmf/server/mmfdatabuffer.h>
  30. #include <mmf/common/mmfutilities.h>
  31. #include <mmf/common/mmffourcc.h>
  32. // goom
  33. #ifdef USE_GOOM_MONITOR
  34. #include <goommonitorsession.h>
  35. #include <goommonitorplugin.hrh>
  36. #endif
  37. // sensor
  38. #include <sensrvchannelfinder.h>
  39. #include <sensrvchannel.h>
  40. #include <sensrvorientationsensor.h>
  41. #include <sensrvdatalistener.h>
  42. #include <sensrvaccelerometersensor.h>
  43. #include <sensrvorientationsensor.h>
  44. #include <sensrvchannelinfo.h>
  45. #include "HdmiOutput.h"
  46. // frame count window used to compute average framerate in debug builds
  47. #define FRAMERATE_WINDOW 64
  48. // namespace GF {
  49. #ifdef IAP
  50. #include "../../epong_iap_impl/miniiapsymbianclient.h"
  51. #endif
  52. enum EState {
  53. ENotRunning=0,
  54. ERunning=1,
  55. EDelayedStop=2,
  56. };
  57. // CLASS DECLARATION
  58. class EpocGameEngine : public CCoeControl, public GF::GameEngine, public MCoeControlObserver, public MRemConCoreApiTargetObserver,
  59. public MDevSoundObserver,
  60. public MSensrvDataListener,
  61. public MHdmiOutputCallback
  62. {
  63. public:
  64. // New methods
  65. /**
  66. * NewL.
  67. * Two-phased constructor.
  68. * Create a CEPongAppView object, which will draw itself to aRect.
  69. * @param aRect The rectangle this view will be drawn to.
  70. * @return a pointer to the created instance of CEPongAppView.
  71. */
  72. static EpocGameEngine* NewL(const TRect& aRect);
  73. /**
  74. * NewLC.
  75. * Two-phased constructor.
  76. * Create a CEPongAppView object, which will draw itself
  77. * to aRect.
  78. * @param aRect Rectangle this view will be drawn to.
  79. * @return A pointer to the created instance of CEPongAppView.
  80. */
  81. static EpocGameEngine* NewLC(const TRect& aRect);
  82. /**
  83. * ConstructL
  84. * 2nd phase constructor.
  85. * Perform the second phase construction of a
  86. * CEPongAppView object.
  87. * @param aRect The rectangle this view will be drawn to.
  88. */
  89. void ConstructL(const TRect& aRect);
  90. private:
  91. /**
  92. * CEPongAppView.
  93. * C++ default constructor.
  94. */
  95. EpocGameEngine();
  96. public:
  97. /**
  98. * ~CEPongAppView
  99. * Virtual Destructor.
  100. */
  101. virtual ~EpocGameEngine();
  102. // Functions from base classes
  103. /**
  104. * From CCoeControl, Draw
  105. * Draw this CEPongAppView to the screen.
  106. * @param aRect the rectangle of this view that needs updating
  107. */
  108. void Draw(const TRect& aRect) const;
  109. /**
  110. * From CoeControl, SizeChanged.
  111. * Called by framework when the view size is changed.
  112. */
  113. virtual void SizeChanged();
  114. /**
  115. * From CoeControl, HandlePointerEventL.
  116. * Called by framework when a pointer touch event occurs.
  117. * Note: although this method is compatible with earlier SDKs,
  118. * it will not be called in SDKs without Touch support.
  119. * @param aPointerEvent the information about this event
  120. */
  121. virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
  122. virtual void HandleResourceChange(TInt aType);
  123. virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
  124. virtual TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType);
  125. void MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct);
  126. private:
  127. virtual void OutputChanged(CHdmiOutput *aHdmi);
  128. private:
  129. // MSensrvDataListener
  130. void DataReceived(CSensrvChannel& aChannel, TInt aCount, TInt aDataLost);
  131. void DataError(CSensrvChannel& aChannel, TSensrvErrorSeverity aError);
  132. void GetDataListenerInterfaceL(TUid aInterfaceUid, TAny*& aInterface);
  133. private:
  134. virtual void InitializeComplete(TInt aError);
  135. virtual void BufferToBeFilled(CMMFBuffer* aBuffer);
  136. virtual void PlayError(TInt aError) {}
  137. virtual void ToneFinished(TInt /*aError*/) {}
  138. virtual void BufferToBeEmptied(CMMFBuffer* /*aBuffer*/) {}
  139. virtual void RecordError(TInt /*aError*/) {}
  140. virtual void ConvertError(TInt /*aError*/) {}
  141. virtual void DeviceMessage (TUid /*aMessageType*/,const TDesC8& /*aMsg*/) {}
  142. virtual void SendEventToClient(const TMMFEvent& /*aEvent*/) {}
  143. public:
  144. virtual int openUrlInBrowser(const char *path);
  145. virtual void render();
  146. virtual void exit();
  147. virtual bool startAudio( int frequency, int channels );
  148. virtual void stopAudio();
  149. virtual int loadGLTexture( const char *fileName );
  150. virtual void releaseTexture(int textureHandle);
  151. virtual void sendEvent(GF::ENGINE_EVENT_TYPE type, int flags);
  152. virtual bool queryTextInput(const char *prompt, char *target, int targetLength );
  153. void startEngine();
  154. void stopEngine(TBool aDelayedStop=EFalse);
  155. void setVolume(int volume);
  156. virtual const char *adjustPath(const char *inputPath, char *outputPath, int outputPathLength, bool *isOk = 0);
  157. virtual void setUpdateAndPauseState(bool iUpdatesDisabled, bool aPauseResumeDisabled);
  158. #ifdef IAP
  159. // gets (and if not existing, creates) "global" MiniIAPClient.
  160. virtual MiniIAPClientApi *getMiniIAPClient();
  161. #endif
  162. private:
  163. void initEGL();
  164. void initEGLSurface();
  165. void releaseEGLSurface();
  166. static TInt timerCallback( TAny* aInstance);
  167. static TInt stopEngineCallback( TAny* aInstance);
  168. virtual void startAudioEngine();
  169. virtual void stopAudioEngine();
  170. #ifdef IAP
  171. MiniIAPSymbianClient *m_miniIAPClientApi;
  172. #endif
  173. CRemConInterfaceSelector* iInterfaceSelector;
  174. CRemConCoreApiTarget* iCoreTarget;
  175. RWsSession wsSession;
  176. CWsScreenDevice *iScreenDevice;
  177. RWindowGroup *iWindowGroup;
  178. RWindow *iWindow;
  179. EGLDisplay iEglDisplay;
  180. EGLSurface iEglSurface;
  181. EGLContext iEglContext;
  182. CPeriodic* iPeriodic;
  183. CPeriodic* iDelayedStopTimer;
  184. CAknAppUi* iAppUi;
  185. EState iRunning;
  186. TBool iQueryVisible;
  187. TBool iPauseResumeDisabled;
  188. TBool iUpdatesDisabled;
  189. TUint iLastFrameTime;
  190. TUint iOldFrameTime[FRAMERATE_WINDOW];
  191. TUint iFrameCount;
  192. float iAverageDeltaTime;
  193. int iAudioRate;
  194. int iAudioChannels;
  195. GF::GameApp *iGame;
  196. TUint iCurrentVolume;
  197. CMMFDevSound *iDevSound;
  198. CMMFDescriptorBuffer *iBuffer;
  199. TUint8 *iMixingBuffer;
  200. CRepository* iProfileRepository;
  201. CSensrvChannel *iAccelerometerChannel;
  202. #ifdef USE_GOOM_MONITOR
  203. RGOomMonitorSession iGoom;
  204. #endif
  205. CHdmiOutput *iHdmiOutput;
  206. };
  207. // }
  208. #endif // __EPOCGAMEENGINE_H__
  209. // End of File