//! constructor
	CIrrDeviceMarmalade::CIrrDeviceMarmalade(const SIrrlichtCreationParameters& param)
		: CIrrDeviceStub(param), Paused(false)
	{
		initKeyMap();

		CursorControl = new CMarmaladeCursor(this);

		//video::SExposedVideoData data;

		SIrrlichtCreationParameters params = param;
		params.WindowSize.Width = s3eSurfaceGetInt(S3E_SURFACE_WIDTH);
		params.WindowSize.Height = s3eSurfaceGetInt(S3E_SURFACE_HEIGHT);

		int32 glver = s3eGLGetInt(S3E_GL_VERSION);
		if(glver >= 0x200)
			VideoDriver = video::createOGLES2Driver(params, FileSystem);
		else
			VideoDriver = video::createOGLES1Driver(params, FileSystem);

        glViewport(0, 0, params.WindowSize.Width, params.WindowSize.Height);

		if (VideoDriver)
			createGUIAndScene();

		s3eDeviceRegister(S3E_DEVICE_EXIT, &do_Exit, this);
		s3eDeviceRegister(S3E_DEVICE_PAUSE, &do_Pause, this);
		s3eDeviceRegister(S3E_DEVICE_UNPAUSE, &do_Unpause, this);

		s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT, &do_KeyEvent, this);
		s3eKeyboardRegister(S3E_KEYBOARD_CHAR_EVENT, &do_CharEvent, this);
	}
s3eResult s3eWwiseInit_platform()
{
    if(s3eDeviceRegister(S3E_DEVICE_UNPAUSE, (s3eCallback)applicationUnpaused, NULL) != S3E_RESULT_SUCCESS)
		return S3E_RESULT_ERROR;
		
	if(s3eDeviceRegister(S3E_DEVICE_PAUSE, (s3eCallback)applicationPaused, NULL) != S3E_RESULT_SUCCESS)
		return S3E_RESULT_ERROR;
	
    return S3E_RESULT_SUCCESS;
}
void ExampleInit()
{
    g_ButtonHidebarSticky = NewButton("Hide nav bar - sticky mode");
    g_ButtonHideBarNonSticky = NewButton("Hide nav bar - non-sticky");
    g_ButtonHideBarNonImmersive = NewButton("Hide nav bar - non-immersive");
    g_ButtonShow = NewButton("Show nav bar");
    g_ButtonShowBars = NewButton("Show nav & status bars if supported");
	g_ButtonCheck = NewButton("Check available");

	s3eDeviceRegister(S3E_DEVICE_PAUSE, _pauseCallback, NULL);
	s3eDeviceRegister(S3E_DEVICE_UNPAUSE, _resumeCallback, NULL);
}
Exemple #4
0
//--------------------------------------------------------------------------
// Main global function
//--------------------------------------------------------------------------
S3E_MAIN_DECL void IwMain()
{
#ifdef EXAMPLE_DEBUG_ONLY
// Test for Debug only examples
#endif

// Example main loop
    input_engine = GetInputEngine();
    game_class = new Game();
    game_class->Initialize();
    input_engine->RegisterInputController(game_class);
    //graphics_engine = GetHPTGraphicsEngine();
    //graphics_engine->SetBackgroundColor(100,100,255);
    //ExampleInit();
    s3eDeviceRegister(S3E_DEVICE_PAUSE,PauseCallback,NULL);
    s3eDeviceRegister(S3E_DEVICE_UNPAUSE,UnPauseCallback,NULL);
    s3eSurfaceRegister(S3E_SURFACE_SCREENSIZE,ScreenCallback,NULL);

    while (1)
    {
        s3eDeviceYield(0);
        s3eKeyboardUpdate();
        //bool result = ExampleUpdate();
        if( /*(result == false) ||*/ (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) ||
                                     (s3eKeyboardGetState(s3eKeyLSK) & S3E_KEY_STATE_DOWN) || (s3eDeviceCheckQuitRequest()))
            break;
        input_engine->InputChanged();
        game_class->ExecuteGame();
        //ExampleRender();
        //graphics_engine->BeginFrame();
        //graphics_engine->EndFrame();
        //s3eSurfaceShow();
    }
    input_engine->Release();
    delete game_class;
    //graphics_engine->Release();
    //ExampleShutDown();
}
        void init(init_desc* desc_ptr)
        {
            Input::instance.__removeFromDebugList();

            log::messageln("initialize oxygine");
            if (desc_ptr)
                desc = *desc_ptr;

#ifdef __S3E__
            log::messageln("S3E build");
            if (!IwGLInit())
            {
                s3eDebugErrorShow(S3E_MESSAGE_CONTINUE, "IwGLInit failed");
                return;
            }
            //init_ext();

            int width = IwGLGetInt(IW_GL_WIDTH);
            int height = IwGLGetInt(IW_GL_HEIGHT);

            log::messageln("Screen BPP  : %d", s3eSurfaceGetInt(S3E_SURFACE_PIXEL_TYPE) & S3E_SURFACE_PIXEL_SIZE_MASK);
            log::messageln("Screen Size : %dx%d", width, height);
            log::messageln("Vendor      : %s", (const char*)glGetString(GL_VENDOR));
            log::messageln("Renderer    : %s", (const char*)glGetString(GL_RENDERER));

            const char* version = (const char*)glGetString(GL_VERSION);
            log::messageln("Version    : %s", version);

            s3ePointerUpdate();
            if (s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE))
            {
                s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, &pointerTouchEvent, 0);
                s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, &pointerTouchMotionEvent, 0);
            }
            else
            {
                s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, &pointerEvent, 0);
                s3ePointerRegister(S3E_POINTER_MOTION_EVENT, &pointerMotionEvent, 0);
            }

            s3eDeviceRegister(S3E_DEVICE_UNPAUSE, applicationUnPause, 0);
            s3eDeviceRegister(S3E_DEVICE_PAUSE, applicationPause, 0);

#elif EMSCRIPTEN
            log::messageln("EMSCRIPTEN build");

            if (desc.w == -1 && desc.h == -1)
            {
                int fs = 0;
                emscripten_get_canvas_size(&desc.w, &desc.h, &fs);
            }

            if (SDL_Init(SDL_INIT_VIDEO) != 0)
            {
                log::error("Unable to initialize SDL: %s\n", SDL_GetError());
            }

            SDL_Surface* screen;
            screen = SDL_SetVideoMode(desc.w, desc.h, 32, SDL_OPENGL);
            _displaySize = Point(desc.w, desc.h);

            emscripten_SDL_SetEventHandler(SDL_eventsHandler, 0);

            int v = EM_ASM_INT(
            {
                var p = navigator.platform;
                if (p == 'iPad' || p == 'iPhone' || p == 'iPod')
                    return 1;
                return 0;
            }, 0);
        void init(init_desc* desc_ptr)
        {
            std::string t;

#ifdef OX_DEBUG
            t += "OX_DEBUG ";
#endif

#ifdef NDEBUG
            t += "NDEBUG ";
#endif

#ifdef _DEBUG
            t += "_DEBUG ";
#endif

#ifdef DEBUG
            t += "DEBUG ";
#endif

            log::messageln("build settings %s", t.c_str());

            init0();


            log::messageln("initialize oxygine");
            if (desc_ptr)
                desc = *desc_ptr;

#ifdef __S3E__
            log::messageln("S3E build");
            if (!IwGLInit())
            {
                s3eDebugErrorShow(S3E_MESSAGE_CONTINUE, "IwGLInit failed");
                return;
            }
            //init_ext();

            int width = IwGLGetInt(IW_GL_WIDTH);
            int height = IwGLGetInt(IW_GL_HEIGHT);

            log::messageln("Screen BPP  : %d", s3eSurfaceGetInt(S3E_SURFACE_PIXEL_TYPE) & S3E_SURFACE_PIXEL_SIZE_MASK);
            log::messageln("Screen Size : %dx%d", width, height);
            log::messageln("Vendor      : %s", (const char*)glGetString(GL_VENDOR));
            log::messageln("Renderer    : %s", (const char*)glGetString(GL_RENDERER));

            const char* version = (const char*)glGetString(GL_VERSION);
            log::messageln("Version    : %s", version);

            s3ePointerUpdate();
            if (s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE))
            {
                s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, &pointerTouchEvent, 0);
                s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, &pointerTouchMotionEvent, 0);
            }
            else
            {
                s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, &pointerEvent, 0);
                s3ePointerRegister(S3E_POINTER_MOTION_EVENT, &pointerMotionEvent, 0);
            }

            s3eDeviceRegister(S3E_DEVICE_UNPAUSE, applicationUnPause, 0);
            s3eDeviceRegister(S3E_DEVICE_PAUSE, applicationPause, 0);

#elif OXYGINE_SDL

            log::messageln("SDL build");


            SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");

            SDL_Init(SDL_INIT_VIDEO);


            if (desc.mode24bpp)
            {
                SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
                SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
                SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
            }
            else
            {
                SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
                SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
                SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
            }

            SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
            //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
            //SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);

            if (desc.force_gles)
            {
                SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
                SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);
            }

            SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);

            int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;

#if TARGET_OS_IPHONE
            flags |= SDL_WINDOW_BORDERLESS;
            flags |= SDL_WINDOW_ALLOW_HIGHDPI;
            flags |= SDL_WINDOW_FULLSCREEN;
#endif

            //SDL_DisplayMode mode;
            //SDL_GetCurrentDisplayMode(0, &mode);
            //log::messageln("display mode: %d %d", mode.w, mode.h);

            if (desc.w == -1 && desc.h == -1)
            {
                desc.w = 960;
                desc.h = 640;
            }

            if (desc.fullscreen)
                flags |= SDL_WINDOW_FULLSCREEN;

            {
                Event ev(EVENT_PRECREATEWINDOW);
                _dispatcher->dispatchEvent(&ev);
            }

            log::messageln("creating window %d %d", desc.w, desc.h);

            _window = SDL_CreateWindow(desc.title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, desc.w, desc.h, flags);

            if (!_window)
            {
                log::error("can't create window: %s", SDL_GetError());
                return;
            }
            _context = SDL_GL_CreateContext(_window);
            if (!_context)
            {
                log::error("can't create gl context: %s", SDL_GetError());
                return;
            }

            SDL_GL_SetSwapInterval(desc.vsync ? 1 : 0);

#ifdef EMSCRIPTEN
            SDL_SetEventFilter(SDL_eventsHandler, 0);

            int v = EM_ASM_INT(
            {
                var p = navigator.platform;
                if (p == 'iPad' || p == 'iPhone' || p == 'iPod')
                    return 1;
                return 0;
            }, 0);
bool MarmaladeSystem::Initialize()
{
    LOG_INFO(LOGCAT_SYSTEM, "MarmaladeSystem initialization starting.\n");

    const char* marmaladeRuntimeVersion = s3eDeviceGetString(S3E_DEVICE_SDK_VERSION);
    LOG_INFO(LOGCAT_SYSTEM, "Marmalade Runtime Version %s, Linked Version %s\n", marmaladeRuntimeVersion, MARMALADE_VERSION_STRING);

    const char* s3eRuntimeVersion = s3eDeviceGetString(S3E_DEVICE_S3E_VERSION);
    LOG_INFO(LOGCAT_SYSTEM, "S3E Runtime Version: %s, Linked Version: %s\n", s3eRuntimeVersion, S3E_VERSION_STRING);

    const char* deviceID = s3eDeviceGetString(S3E_DEVICE_ID);
    const char* deviceOS = s3eDeviceGetString(S3E_DEVICE_OS);
    int deviceOsVersion = s3eDeviceGetInt(S3E_DEVICE_OS_VERSION);
    int osVersionMajor = (deviceOsVersion >> 16);
    int osVersionMinor =  deviceOsVersion & 0xffff;
    const char* deviceClass = s3eDeviceGetString(S3E_DEVICE_CLASS);
    const char* deviceArch = s3eDeviceGetString(S3E_DEVICE_ARCHITECTURE);
    const char* deviceChipset = s3eDeviceGetString(S3E_DEVICE_CHIPSET);
    int deviceTotalMemKB = s3eDeviceGetInt(S3E_DEVICE_MEM_TOTAL);
    int deviceFreeMemKB = s3eDeviceGetInt(S3E_DEVICE_MEM_FREE);
    int heapSize = s3eMemoryGetInt(S3E_MEMORY_SIZE);

    LOG_INFO(LOGCAT_SYSTEM, "Device ID: %s\n", deviceID);
    LOG_INFO(LOGCAT_SYSTEM, "Device OS: %s (%d.%d)\n", deviceOS, osVersionMajor, osVersionMinor);
    LOG_INFO(LOGCAT_SYSTEM, "Device Class: %s\n", deviceClass);
    LOG_INFO(LOGCAT_SYSTEM, "Device Architecture: %s\n", deviceArch);
    LOG_INFO(LOGCAT_SYSTEM, "Device Chipset: %s\n", deviceChipset);
    LOG_INFO(LOGCAT_SYSTEM, "Device Memory: %dKB free, %dKB total\n", deviceFreeMemKB, deviceTotalMemKB);
    LOG_INFO(LOGCAT_SYSTEM, "S3E Memory Heap Size: %d bytes\n", heapSize);

    bool keyboardHasAlpha = false;
    bool keyboardHasDirection = false;
    if (s3eKeyboardGetInt(S3E_KEYBOARD_HAS_ALPHA))
    {
        keyboardHasAlpha = true;
        LOG_INFO(LOGCAT_SYSTEM, "Keyboard property: S3E_KEYBOARD_HAS_ALPHA\n");
    }
    if (s3eKeyboardGetInt(S3E_KEYBOARD_HAS_NUMPAD))
        LOG_INFO(LOGCAT_SYSTEM, "Keyboard property: S3E_KEYBOARD_HAS_NUMPAD\n");
    if (s3eKeyboardGetInt(S3E_KEYBOARD_HAS_DIRECTION))
    {
        keyboardHasDirection = true;
        LOG_INFO(LOGCAT_SYSTEM, "Keyboard property: S3E_KEYBOARD_HAS_DIRECTION\n");
    }

    // Android Xperia Play device detection
    // TODO: any other device ID's we need to worry about?
    bool isXperiaPlay = false;
    if (s3eDeviceGetInt(S3E_DEVICE_OS) == S3E_OS_ID_ANDROID)
    {
        LOG_INFO(LOGCAT_SYSTEM, "Detected Android as host OS.\n");
        if (strlen(deviceID) >= 4)
        {
            // possible device ID's I currently know of:
            //   R800i, R800a, R800x
            if (strncmp(deviceID, "R800", 4) == 0)
            {
                LOG_INFO(LOGCAT_SYSTEM, "Device is an Xperia Play.\n");
                isXperiaPlay = true;
            }
            else
                LOG_INFO(LOGCAT_SYSTEM, "Device is not an Xperia Play.\n");
        }
    }

    bool keyboardHasPhysicalGameControls = false;
    if ((keyboardHasAlpha && keyboardHasDirection) || isXperiaPlay)
        keyboardHasPhysicalGameControls = true;

    if (keyboardHasPhysicalGameControls)
        LOG_INFO(LOGCAT_SYSTEM, "Keyboard device has enough physical keys for full game controls.\n");
    else
        LOG_INFO(LOGCAT_SYSTEM, "Keyboard device does not have enough physical keys for full game controls.\n");

    m_keyboard = new MarmaladeKeyboard(keyboardHasPhysicalGameControls);
    ASSERT(m_keyboard != NULL);
    LOG_INFO(LOGCAT_SYSTEM, "Keyboard input device ready.\n");

    bool isMultitouchAvailable = false;
    if (s3ePointerGetInt(S3E_POINTER_AVAILABLE))
    {
        s3ePointerType pointerType = (s3ePointerType)s3ePointerGetInt(S3E_POINTER_TYPE);
        if (pointerType == S3E_POINTER_TYPE_INVALID)
            LOG_ERROR(LOGCAT_SYSTEM, "Pointer type = S3E_POINTER_TYPE_INVALID\n");
        else if (pointerType == S3E_POINTER_TYPE_MOUSE)
        {
            LOG_INFO(LOGCAT_SYSTEM, "Pointer device is a mouse.\n");

            m_mouse = new MarmaladeMouse();
            ASSERT(m_mouse != NULL);
            LOG_INFO(LOGCAT_SYSTEM, "Mouse input device ready.\n");
        }
        else if (pointerType == S3E_POINTER_TYPE_STYLUS)
        {
            s3eStylusType stylusType = (s3eStylusType)s3ePointerGetInt(S3E_POINTER_STYLUS_TYPE);
            if (stylusType == S3E_STYLUS_TYPE_INVALID)
                LOG_ERROR(LOGCAT_SYSTEM, "Stylus type = S3E_STYLUS_TYPE_INVALID\n");
            else
            {
                if (stylusType == S3E_STYLUS_TYPE_STYLUS)
                    LOG_INFO(LOGCAT_SYSTEM, "Pointer device is a touchscreen using a stylus.\n");
                else if (stylusType == S3E_STYLUS_TYPE_FINGER)
                    LOG_INFO(LOGCAT_SYSTEM, "Pointer device is a touchscreen.\n");

                if (s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE))
                {
                    LOG_INFO(LOGCAT_SYSTEM, "Pointer device supports multitouch.\n");
                    isMultitouchAvailable = true;
                }
                else
                    LOG_INFO(LOGCAT_SYSTEM, "Pointer device does not support multitouch.\n");

                m_touchscreen = new MarmaladeTouchscreen(this, isMultitouchAvailable);
                ASSERT(m_touchscreen != NULL);
                LOG_INFO(LOGCAT_SYSTEM, "Touchscreen input device ready.\n");
            }
        }
    }
    else
        LOG_WARN(LOGCAT_SYSTEM, "No pointer device is available.\n");

    s3eDeviceRegister(S3E_DEVICE_PAUSE, _MarmaladeEventCallback_Pause, this);
    s3eDeviceRegister(S3E_DEVICE_UNPAUSE, _MarmaladeEventCallback_Resume, this);
    s3eDeviceRegister(S3E_DEVICE_EXIT, _MarmaladeEventCallback_Exit, this);
    s3eGLRegister(S3E_GL_SUSPEND, _MarmaladeEventCallback_GLSuspend, this);
    s3eGLRegister(S3E_GL_RESUME, _MarmaladeEventCallback_GLResume, this);
    s3eSurfaceRegister(S3E_SURFACE_SCREENSIZE, _MarmaladeEventCallback_ScreenResize, this);
    s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT, _MarmaladeEventCallback_Key, this);
    s3eKeyboardRegister(S3E_KEYBOARD_CHAR_EVENT, _MarmaladeEventCallback_KeyChar, this);
    if (m_mouse != NULL || m_touchscreen != NULL)
    {
        if (isMultitouchAvailable)
        {
            s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, _MarmaladeEventCallback_PointerMultitouchButton, this);
            s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, _MarmaladeEventCallback_PointerMultitouchMotion, this);
        }
        else
        {
            s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, _MarmaladeEventCallback_PointerButton, this);
            s3ePointerRegister(S3E_POINTER_MOTION_EVENT, _MarmaladeEventCallback_PointerMotion, this);
        }
    }
    else
        LOG_WARN(LOGCAT_SYSTEM, "No mouse or touchscreen device was initialized.\n");

    LOG_INFO(LOGCAT_SYSTEM, "Registered S3E event callbacks.\n");

    LOG_INFO(LOGCAT_SYSTEM, "Initializing file system access.\n");
    m_filesystem = new MarmaladeFileSystem();
    ASSERT(m_filesystem != NULL);

    LOG_INFO(LOGCAT_SYSTEM, "Finished initialization.\n");

    return true;
}
Exemple #8
0
		void init(init_desc *desc_ptr)
		{
			Input::instance.__removeFromDebugList();

			log::messageln("initialize oxygine");
			if (desc_ptr)
				desc = *desc_ptr;

#ifdef __S3E__
			log::messageln("S3E build");
			if (!IwGLInit())
			{
				s3eDebugErrorShow(S3E_MESSAGE_CONTINUE, "IwGLInit failed");
				return;
			}
			//init_ext();

			int width = IwGLGetInt(IW_GL_WIDTH);
			int height = IwGLGetInt(IW_GL_HEIGHT);

			log::messageln("Screen BPP  : %d", s3eSurfaceGetInt(S3E_SURFACE_PIXEL_TYPE) & S3E_SURFACE_PIXEL_SIZE_MASK);
			log::messageln("Screen Size : %dx%d", width, height);
			log::messageln("Vendor      : %s", (const char*)glGetString( GL_VENDOR ) );
			log::messageln("Renderer    : %s", (const char*)glGetString( GL_RENDERER ));

			const char *version = (const char*)glGetString( GL_VERSION );
			log::messageln( "Version    : %s", version);

			s3ePointerUpdate();
			if (s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE))
			{
				s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, &pointerTouchEvent, 0);
				s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, &pointerTouchMotionEvent, 0);
			}
			else
			{
				s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, &pointerEvent, 0);
				s3ePointerRegister(S3E_POINTER_MOTION_EVENT, &pointerMotionEvent, 0);
			}	

			s3eDeviceRegister(S3E_DEVICE_UNPAUSE, applicationUnPause, 0);
			s3eDeviceRegister(S3E_DEVICE_PAUSE, applicationPause, 0);
#elif EMSCRIPTEN
			log::messageln("EMSCRIPTEN build");

			if (desc.w == -1 && desc.h == -1)
			{
				int fs = 0;
				emscripten_get_canvas_size(&desc.w, &desc.h, &fs);
			}

			if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) 
			{
				log::error("Unable to initialize SDL: %s\n", SDL_GetError());				
			}

			SDL_Surface *screen;
			screen = SDL_SetVideoMode(desc.w, desc.h, 32, SDL_OPENGL); 
			_displaySize = Point(desc.w, desc.h);

			emscripten_SDL_SetEventHandler(SDL_eventsHandler, 0);
#elif OXYGINE_SDL

			log::messageln("SDL build");
			

			SDL_Init(SDL_INIT_VIDEO);


			SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
			SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
			SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
			SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
			SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
			SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 0);
			//SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
			SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
			SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
			SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);

			int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;

#if TARGET_OS_IPHONE
			flags |= SDL_WINDOW_BORDERLESS;
#endif                

			SDL_DisplayMode mode;
			SDL_GetCurrentDisplayMode(0, &mode);
			log::messageln("display mode: %d %d", mode.w, mode.h);

			if (desc.w == -1 && desc.h == -1)
			{
				desc.w = 960;
				desc.h = 640;
			}

			if (desc.fullscreen)
				flags |= SDL_WINDOW_FULLSCREEN;

			log::messageln("creating window %d %d", desc.w, desc.h);

			_window = SDL_CreateWindow(desc.title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, desc.w, desc.h, flags);

			if (!_window)
			{
				log::error("can't create window: %s", SDL_GetError());
				return;
			}
			_context = SDL_GL_CreateContext(_window);
			if (!_context)
			{
				log::error("can't create gl context: %s", SDL_GetError());
				return;
			}

			SDL_GL_SetSwapInterval(desc.vsync ? 1 : 0);
			

			//SDL_SetEventFilter(eventsFilter, 0);

#endif
			file::init(desc.companyName, desc.appName);
			init2();
		}
void Initialise()
{
	// Initialise Marmalade modules
	IwGxInit();

	// Create a new CIwTexture and use it to load the GUI image file
	gpTexture = new CIwTexture;
	gpTexture->LoadFromFile("ui.png");
	gpTexture->Upload();

	// Check for Dolby Digital Plus support
	gDolbySupported = false;
	gDolbyInitialised = false;
	if (s3eDolbyAudioAvailable() == S3E_TRUE)
	{
		if (s3eDolbyAudioSupported() == S3E_TRUE)
		{
			gDolbySupported = true;
		}
		s3eDeviceYield(0);
	}

	// Initialise Pause/Resume callbacks
	s3eDeviceRegister(S3E_DEVICE_PAUSE, AppSuspended, NULL);
	s3eDeviceRegister(S3E_DEVICE_BACKGROUND, AppSuspended, NULL);
	s3eDeviceRegister(S3E_DEVICE_UNPAUSE, AppResumed, NULL);
	s3eDeviceRegister(S3E_DEVICE_FOREGROUND, AppResumed, NULL);

	// Create our interface buttons
	int32 lSize = IwGxGetScreenWidth() / 5;
	int32 lGap = (int32) ((float) lSize * 0.1f);
	lSize = (int32) ((float) lSize * 0.9f);

	int32 lRowSize = IwGxGetScreenHeight() / 4;
	int32 lTopRowX = (IwGxGetScreenWidth() - (4 * lSize) - (3 * lGap)) / 2;
	int32 lTopRowY = lRowSize - (lSize / 2);
	int32 lBottomRowX = (IwGxGetScreenWidth() - (5 * lSize) - (4 * lGap)) / 2;
	int32 lBottomRowY = (3 * lRowSize) - (lSize / 2);
	int32 lLabelWidth = (240 * lSize) / 160;
	int32 lLabelHeight = (42 * lSize) / 160;
	int32 lLabelX = (IwGxGetScreenWidth() - lLabelWidth) / 2;

	gButton[BUTTON_AUDIO_LABEL] = new Button(gpTexture, lLabelX, lTopRowY - lLabelHeight - 10, lLabelWidth, lLabelHeight, 4, 408, 240, 42, false);
	gButton[BUTTON_AUDIO_OFF] = new Button(gpTexture, lTopRowX, lTopRowY, lSize, lSize, 347, 3, 160, 160, true);
	gButton[BUTTON_AUDIO_MUSIC] = new Button(gpTexture, lTopRowX + (lSize + lGap), lTopRowY, lSize, lSize, 175, 3, 160, 160, true);
	gButton[BUTTON_AUDIO_SFX] = new Button(gpTexture, lTopRowX + (2 * (lSize + lGap)), lTopRowY, lSize, lSize, 2, 173, 160, 160, true);
	gButton[BUTTON_AUDIO_SPEECH] = new Button(gpTexture, lTopRowX + (3 * (lSize + lGap)), lTopRowY, lSize, lSize, 174, 173, 160, 160, true);
	gButton[BUTTON_FILTER_LABEL] = new Button(gpTexture, lLabelX, lBottomRowY - lLabelHeight - 10, lLabelWidth, lLabelHeight, 2, 353, 240, 42, false);
	gButton[BUTTON_FILTER_OFF] = new Button(gpTexture, lBottomRowX, lBottomRowY, lSize, lSize, 347, 3, 160, 160, gDolbySupported);
	gButton[BUTTON_FILTER_MOVIE] = new Button(gpTexture, lBottomRowX + (lSize + lGap), lBottomRowY, lSize, lSize, 2, 3, 160, 160, gDolbySupported);
	gButton[BUTTON_FILTER_MUSIC] = new Button(gpTexture, lBottomRowX + (2 * (lSize + lGap)), lBottomRowY, lSize, lSize, 175, 3, 160, 160, gDolbySupported);
	gButton[BUTTON_FILTER_GAME] = new Button(gpTexture, lBottomRowX + (3 * (lSize + lGap)), lBottomRowY, lSize, lSize, 2, 173, 160, 160, gDolbySupported);
	gButton[BUTTON_FILTER_VOICE] = new Button(gpTexture, lBottomRowX + (4 * (lSize + lGap)), lBottomRowY, lSize, lSize, 174, 173, 160, 160, gDolbySupported);

	// Load sound effects into memory
	gpGunBattleSound = new Sound("gun-battle.raw");
	gpFemaleCountingSound = new Sound("female-counting.raw");

	// Configure default sample rate for s3eSound
	s3eSoundSetInt(S3E_SOUND_DEFAULT_FREQ, 44100);
}
Exemple #10
0
void Streamer::Init()
{
    
    //Game* game = (Game*)g_pSceneManager->Find("game");
	initAudio("128.198.85.100", 8000);
	s3eDeviceRegister(S3E_DEVICE_EXIT, &exitCB, 0);
    
    facebook = new CSprite();
    facebook->SetImage(g_pResources->getFacebook());
    facebook->m_X = (float)IwGxGetScreenWidth() / 1.4;
    facebook->m_Y = (float)IwGxGetScreenHeight() / 16;
    facebook->m_W = facebook->GetImage()->GetWidth();
    facebook->m_H = facebook->GetImage()->GetHeight();
    facebook->m_AnchorX = 0.5;
    facebook->m_AnchorY = 0.5;
    facebook->m_ScaleX = (float)IwGxGetScreenWidth() / facebook->GetImage()->GetWidth() / 8;
    facebook->m_ScaleY = (float)IwGxGetScreenHeight() / facebook->GetImage()->GetHeight() / 12;
    
    twitter = new CSprite();
    twitter->SetImage(g_pResources->getTwitter());
    twitter->m_X = (float)IwGxGetScreenWidth() / 1.1;
    twitter->m_Y = (float)IwGxGetScreenHeight() / 16;
    twitter->m_W = twitter->GetImage()->GetWidth();
    twitter->m_H = twitter->GetImage()->GetHeight();
    twitter->m_AnchorX = 0.5;
    twitter->m_AnchorY = 0.5;
    twitter->m_ScaleX = (float)IwGxGetScreenWidth() / twitter->GetImage()->GetWidth() / 8;
    twitter->m_ScaleY = (float)IwGxGetScreenHeight() / twitter->GetImage()->GetHeight() / 12;

    // Create menu background
    header = new CSprite();
    header->SetImage(g_pResources->getHeader());
    header->m_X = (float)IwGxGetScreenWidth() / 3;
    header->m_Y = (float)IwGxGetScreenHeight() / 17;
    header->m_W = header->GetImage()->GetWidth();
    header->m_H = header->GetImage()->GetHeight();
    header->m_AnchorX = 0.5;
    header->m_AnchorY = 0.5;
    // Fit background to screen size
    header->m_ScaleX = (float)IwGxGetScreenWidth() / header->GetImage()->GetWidth() / 1.5;
    header->m_ScaleY = (float)IwGxGetScreenHeight() / header->GetImage()->GetHeight() / 5;
    
    // Create menu background
    CSprite* whiteBanner = new CSprite();
    whiteBanner->SetImage(g_pResources->getWhiteBanner());
    whiteBanner->m_X = (float)IwGxGetScreenWidth() / 2;
    whiteBanner->m_Y = (float)IwGxGetScreenHeight() / 17;
    
    whiteBanner->m_W = whiteBanner->GetImage()->GetWidth();
    whiteBanner->m_H = whiteBanner->GetImage()->GetHeight();
    whiteBanner->m_AnchorX = 0.5;
    whiteBanner->m_AnchorY = 0.5;
    // Fit background to screen size
    whiteBanner->m_ScaleX = (float)IwGxGetScreenWidth() / whiteBanner->GetImage()->GetWidth() / 1;
    whiteBanner->m_ScaleY = (float)IwGxGetScreenHeight() / whiteBanner->GetImage()->GetHeight() / 5;
    
    // Create menu background
    playWrapper = new CSprite();
    playWrapper->SetImage(g_pResources->getPlayWrapper());
    playWrapper->m_X = (float)IwGxGetScreenWidth() / 2;
    playWrapper->m_Y = (float)IwGxGetScreenHeight() / 1.09;
    playWrapper->m_W = playWrapper->GetImage()->GetWidth();
    playWrapper->m_H = playWrapper->GetImage()->GetHeight();
    playWrapper->m_AnchorX = 0.5;
    playWrapper->m_AnchorY = 0.5;
    //playWrapper->m_Alpha = 0.9;
    // Fit background to screen size
    playWrapper->m_ScaleX = (float)IwGxGetScreenWidth() / playWrapper->GetImage()->GetWidth() / 1;
    playWrapper->m_ScaleY = (float)IwGxGetScreenHeight() / playWrapper->GetImage()->GetHeight() / 6;

    playButton = new CSprite();
    playButton->SetImage(g_pResources->getPlayButton());
    playButton->m_X = (float)IwGxGetScreenWidth() / 2;
    playButton->m_Y = (float)IwGxGetScreenHeight() / 1.13;
    //buttonTop = (float)IwGxGetScreenHeight() / 1.14 - (playButton->GetImage()->GetHeight() / 8);
    playButton->m_W = playButton->GetImage()->GetWidth();
    playButton->m_H = playButton->GetImage()->GetHeight();
    playButton->m_AnchorX = 0.5;
    playButton->m_AnchorY = 0.5;
    // Fit background to screen size
    playButton->m_ScaleX = (float)IwGxGetScreenWidth() / playButton->GetImage()->GetWidth() / 3.2;
    playButton->m_ScaleY = (float)IwGxGetScreenHeight() / playButton->GetImage()->GetHeight() / 4.5;
    
    //buttonTop = ((float)IwGxGetScreenHeight() / 1.14) - (playButton->GetImage()->GetHeight() / 3.7);
    
    stopButton = new CSprite();
    stopButton->SetImage(g_pResources->getStopButton());
    stopButton->m_X = (float)IwGxGetScreenWidth() / 2;
    stopButton->m_Y = (float)IwGxGetScreenHeight() / 1.13;
    stopButton->m_W = stopButton->GetImage()->GetWidth();
    stopButton->m_H = stopButton->GetImage()->GetHeight();
    stopButton->m_AnchorX = 0.5;
    stopButton->m_AnchorY = 0.5;
    // Fit background to screen size
    stopButton->m_ScaleX = (float)IwGxGetScreenWidth() / stopButton->GetImage()->GetWidth() / 3.2;
    stopButton->m_ScaleY = (float)IwGxGetScreenHeight() / stopButton->GetImage()->GetHeight() / 4.5;
    
    banner = new CSprite();
    banner->SetImage(g_pResources->getGreyBanner());
    banner->m_X = (float)IwGxGetScreenWidth() / 2;
    banner->m_Y = (float)IwGxGetScreenHeight() /6;
    banner->m_W = banner->GetImage()->GetWidth();
    banner->m_H = banner->GetImage()->GetHeight();
    banner->m_AnchorX = 0.5;
    banner->m_AnchorY = 0.5;
    // Fit background to screen size
    banner->m_ScaleX = (float)IwGxGetScreenWidth() / banner->GetImage()->GetWidth() / 1;
    banner->m_ScaleY = (float)IwGxGetScreenHeight() / banner->GetImage()->GetHeight() / 8;
    
    buttonTop = IwGxGetScreenHeight() / 4;
    
    labelLeft = new CLabel();
	labelLeft->m_Font = g_pResources->getBannerFontSmall();
	labelLeft->m_Text = "Cal.";
    labelLeft->m_Y = IwGxGetDisplayHeight() / 6.5;
    labelLeft->m_W = IwGxGetDisplayWidth() / 2;
    labelLeft->m_ScaleX = 1.0;
    labelLeft->m_AlignHor = IW_2D_FONT_ALIGN_LEFT;
    labelLeft->m_X += 10;
    labelLeft->m_Color = CColor(114, 114, 114, 0xff);
    
    labelRight = new CLabel();
	labelRight->m_Font = g_pResources->getBannerFontSmall();
	labelRight->m_Text = "Events";
    labelRight->m_Y = IwGxGetDisplayHeight() / 6.5;
    labelRight->m_W = IwGxGetDisplayWidth() / 2;
    labelRight->m_AlignHor = IW_2D_FONT_ALIGN_RIGHT;
    labelRight->m_X += (IwGxGetDisplayWidth() / 2.0) -10;
    labelRight->m_Color = CColor(114, 114, 114, 0xff);
    
    labelMain = new CLabel();
	labelMain->m_Font = g_pResources->getBannerFontLarge();
	labelMain->m_Text = "News";
    labelMain->m_Y = IwGxGetDisplayHeight() / 7.5;
    labelMain->m_W = IwGxGetDisplayWidth();
    labelMain->m_AlignHor = IW_2D_FONT_ALIGN_CENTRE;
    
    AddChild(banner);
    AddChild(whiteBanner);
    AddChild(header);
    AddChild(labelRight);
    AddChild(labelLeft);
    AddChild(playWrapper);
    AddChild(playButton);
    AddChild(stopButton);
    AddChild(labelMain);
    AddChild(facebook);
    AddChild(twitter);
    
    stopButton->m_X = IwGxGetScreenWidth() * 2.0;
    currentPage = 0;
    
    
}
s3eResult FuseSDKInit_platform()
{
    // Get the environment from the pointer
    JNIEnv* env = s3eEdkJNIGetEnv();
    jobject obj = NULL;
    jmethodID cons = NULL;

	// callbacks
	const JNINativeMethod nativeMethodDefs[] =
    {
		{ "FuseSDKSessionStartReceived",				"()V",                              (void*)&FuseSDKSessionStartReceived },
		{ "FuseSDKLoginError",							"(I)V",                             (void*)&FuseSDKLoginError },
		{ "FuseSDKAdAvailabilityResponse",				"(II)V",                            (void*)&FuseSDKAdAvailabilityResponse },
		{ "FuseSDKAdWillClose",							"()V",                              (void*)&FuseSDKAdWillClose },
        { "FuseSDKAdFailedToDisplay",					"()V",                              (void*)&FuseSDKAdFailedToDisplay },
        { "FuseSDKAdDidShow",							"(II)V",                            (void*)&FuseSDKAdDidShow },
		{ "FuseSDKNotificationAction",	"(Ljava/lang/String;)V",                            (void*)&FuseSDKNotificationAction },
		{ "FuseSDKAccountLoginComplete","(ILjava/lang/String;)V",                           (void*)&FuseSDKAccountLoginComplete },
		{ "FuseSDKTimeUpdated",							"(I)V",                             (void*)&FuseSDKTimeUpdated },
		{ "FuseGameConfigurationStart",					"(I)V",                             (void*)&FuseGameConfigurationStart },
		{ "FuseGameConfigurationKeyValue", "(Ljava/lang/String;Ljava/lang/String;)V",       (void*)&FuseGameConfigurationKeyValue },
		{ "FuseGameConfigurationReceived",				"()V",                              (void*)&FuseGameConfigurationReceived },
        { "FuseSDKPurchaseVerification", "(ILjava/lang/String;Ljava/lang/String;)V",        (void*)&FuseSDKPurchaseVerification },
        { "FuseSDKRewardedAdComplete", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;II)V", (void*)&FuseSDKRewardedAdComplete },
        { "FuseSDKVirtualGoodsOfferAccepted", "(Ljava/lang/String;FLjava/lang/String;IIIII)V",  (void*)&FuseSDKVirtualGoodsOfferAccepted },
        { "FuseSDKIAPOfferAccepted", "(FILjava/lang/String;Ljava/lang/String;II)V",           (void*)&FuseSDKIAPOfferAccepted },
    };

    // Get the extension class
    jclass cls = s3eEdkAndroidFindClass("com/fuseextension/FuseWrapper");
    if (!cls)
        goto fail;

    // Get its constructor
    cons = env->GetMethodID(cls, "<init>", "()V");
    if (!cons)
        goto fail;

    // Construct the java class
    obj = env->NewObject(cls, cons);
    if (!obj)
        goto fail;

    // Get all the extension methods
    g_FuseSDKStartSession = env->GetMethodID(cls, "FuseSDKStartSession", "(Ljava/lang/String;)V");
    if (!g_FuseSDKStartSession)
        goto fail; 

	g_FuseSDKPauseSession = env->GetMethodID(cls, "FuseSDKPauseSession", "()V");
    if (!g_FuseSDKPauseSession)
        goto fail;

	g_FuseSDKResumeSession = env->GetMethodID(cls, "FuseSDKResumeSession", "()V");
    if (!g_FuseSDKResumeSession)
        goto fail;

	g_FuseSDKTerminateSession = env->GetMethodID(cls, "FuseSDKTerminateSession", "()V");
    if (!g_FuseSDKTerminateSession)
        goto fail;

    g_FuseSDKRegisterForPushNotifications = env->GetMethodID(cls, "FuseSDKRegisterForPushNotifications", "(Ljava/lang/String;)V");
    if (!g_FuseSDKRegisterForPushNotifications)
        goto fail;

    g_FuseSDKRegisterInAppPurchase = env->GetMethodID(cls, "FuseSDKRegisterInAppPurchase", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;DLjava/lang/String;)V");
    if (!g_FuseSDKRegisterInAppPurchase)
        goto fail;

    g_FuseSDKIsAdAvailableForZoneID = env->GetMethodID(cls, "FuseSDKIsAdAvailableForZoneID", "(Ljava/lang/String;)Z");
    if (!g_FuseSDKIsAdAvailableForZoneID)
        goto fail;

    g_FuseSDKShowAdForZoneID = env->GetMethodID(cls, "FuseSDKShowAdForZoneID", "(Ljava/lang/String;ZZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
    if (!g_FuseSDKShowAdForZoneID)
        goto fail;

	g_FuseSDKPreloadAdForZoneID = env->GetMethodID(cls, "FuseSDKPreloadAdForZoneID", "(Ljava/lang/String;)V");
    if (!g_FuseSDKPreloadAdForZoneID)
        goto fail;

    g_FuseSDKDisplayNotifications = env->GetMethodID(cls, "FuseSDKDisplayNotifications", "()V");
    if (!g_FuseSDKDisplayNotifications)
        goto fail;

    g_FuseSDKDisplayMoreGames = env->GetMethodID(cls, "FuseSDKDisplayMoreGames", "()V");
    if (!g_FuseSDKDisplayMoreGames)
        goto fail;

    g_FuseSDKRegisterGender = env->GetMethodID(cls, "FuseSDKRegisterGender", "(I)V");
    if (!g_FuseSDKRegisterGender)
        goto fail;

    g_FuseSDKFacebookLogin = env->GetMethodID(cls, "FuseSDKFacebookLogin", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
    if (!g_FuseSDKFacebookLogin)
        goto fail;

    g_FuseSDKTwitterLogin = env->GetMethodID(cls, "FuseSDKTwitterLogin", "(Ljava/lang/String;)V");
    if (!g_FuseSDKTwitterLogin)
        goto fail;

	g_FuseSDKDeviceLogin = env->GetMethodID(cls, "FuseSDKDeviceLogin", "(Ljava/lang/String;)V");
    if (!g_FuseSDKDeviceLogin)
        goto fail;	

    g_FuseSDKFuseLogin = env->GetMethodID(cls, "FuseSDKFuseLogin", "(Ljava/lang/String;Ljava/lang/String;)V");
    if (!g_FuseSDKFuseLogin)
        goto fail;

    g_FuseSDKGooglePlayLogin = env->GetMethodID(cls, "FuseSDKGooglePlayLogin", "(Ljava/lang/String;Ljava/lang/String;)V");
    if (!g_FuseSDKGooglePlayLogin)
        goto fail;

    g_FuseSDKGetOriginalAccountId = env->GetMethodID(cls, "FuseSDKGetOriginalAccountId", "()Ljava/lang/String;");
    if (!g_FuseSDKGetOriginalAccountId)
        goto fail;

    g_FuseSDKGetOriginalAccountAlias = env->GetMethodID(cls, "FuseSDKGetOriginalAccountAlias", "()Ljava/lang/String;");
    if (!g_FuseSDKGetOriginalAccountAlias)
        goto fail;

    g_FuseSDKGetOriginalAccountType = env->GetMethodID(cls, "FuseSDKGetOriginalAccountType", "()I");
    if (!g_FuseSDKGetOriginalAccountType)
        goto fail;

    g_FuseSDKGetFuseID = env->GetMethodID(cls, "FuseSDKGetFuseID", "()Ljava/lang/String;");
    if (!g_FuseSDKGetFuseID)
        goto fail;

    g_FuseSDKgamesPlayed = env->GetMethodID(cls, "FuseSDKgamesPlayed", "()I");
    if (!g_FuseSDKgamesPlayed)
        goto fail;

    g_FuseSDKLibraryVersion = env->GetMethodID(cls, "FuseSDKLibraryVersion", "()Ljava/lang/String;");
    if (!g_FuseSDKLibraryVersion)
        goto fail;

    g_FuseSDKConnected = env->GetMethodID(cls, "FuseSDKConnected", "()Z");
    if (!g_FuseSDKConnected)
        goto fail;

	g_FuseSDKTimeFromServer = env->GetMethodID(cls, "FuseSDKTimeFromServer", "()V");
    if (!g_FuseSDKTimeFromServer)
        goto fail;

    g_FuseSDKEnableData = env->GetMethodID(cls, "FuseSDKEnableData", "(Z)V");
    if (!g_FuseSDKEnableData)
        goto fail;

    g_FuseSDKGetGameConfigurationValue = env->GetMethodID(cls, "FuseSDKGetGameConfigurationValue", "(Ljava/lang/String;)Ljava/lang/String;");
    if (!g_FuseSDKGetGameConfigurationValue)
        goto fail;

    g_FuseSDKRegisterLevel = env->GetMethodID(cls, "FuseSDKRegisterLevel", "(I)V");
    if (!g_FuseSDKRegisterLevel)
        goto fail;

    g_FuseSDKRegisterCurrency = env->GetMethodID(cls, "FuseSDKRegisterCurrency", "(II)V");
    if (!g_FuseSDKRegisterCurrency)
        goto fail;
    
    g_FuseSDKRegisterVirtualGoodsPurchase = env->GetMethodID(cls, "FuseSDKRegisterVirtualGoodsPurchase", "(III)V");
    if (!g_FuseSDKRegisterVirtualGoodsPurchase)
        goto fail;
    
    g_FuseSDKRegisterParentalConsent = env->GetMethodID(cls, "FuseSDKRegisterParentalConsent", "(Z)V");
    if (!g_FuseSDKRegisterParentalConsent)
        goto fail;
    
    g_FuseSDKRegisterCustomEventInt = env->GetMethodID(cls, "FuseSDKRegisterCustomEventInt", "(II)Z");
    if (!g_FuseSDKRegisterCustomEventInt)
        goto fail;
    
    g_FuseSDKRegisterCustomEventString = env->GetMethodID(cls, "FuseSDKRegisterCustomEventString", "(ILjava/lang/String;)Z");
    if (!g_FuseSDKRegisterCustomEventString)
        goto fail;
    
    g_FuseSDKSetRewardedVideoUserID = env->GetMethodID(cls, "FuseSDKSetRewardedVideoUserID", "(Ljava/lang/String;)V");
    if (!g_FuseSDKSetRewardedVideoUserID)
        goto fail;

	if(env->RegisterNatives(cls, nativeMethodDefs, sizeof(nativeMethodDefs)/sizeof(nativeMethodDefs[0])))
		goto fail;

    IwTrace(FUSESDK, ("FUSESDK init success"));
    g_Obj = env->NewGlobalRef(obj);
    env->DeleteLocalRef(obj);
    env->DeleteGlobalRef(cls);

    // Add any platform-specific initialisation code here
	s3eDeviceRegister(S3E_DEVICE_PAUSE, &FusePause, 0);
	s3eDeviceRegister(S3E_DEVICE_UNPAUSE, &FuseResume, 0);

    return S3E_RESULT_SUCCESS;

fail:
    jthrowable exc = env->ExceptionOccurred();
    if (exc)
    {
        env->ExceptionDescribe();
        env->ExceptionClear();
        IwTrace(FuseSDK, ("One or more java methods could not be found"));
    }
    return S3E_RESULT_ERROR;

}