Example #1
0
	//! 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);
	}
CCEGLView::CCEGLView()
    : m_pDelegate(NULL)
    , m_fScreenScaleFactor(1.0)
    , m_bNotHVGA(false)

    , m_bCaptured(false)
    , m_bAccelState(false)
    , m_Key(s3eKeyFirst)
{
    IW_CALLSTACK("CCEGLView::CCEGLView");


    IwGLInit();

    m_sSizeInPixel.width = IwGLGetInt(IW_GL_WIDTH);
    m_sSizeInPixel.height = IwGLGetInt(IW_GL_HEIGHT);

    m_pSet      = new CCSet;
    m_pTouch    = new CCTouch;

    // Register pointer touch button event handler
    s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, &TouchEventHandler, this);

    // Register pointer motion button event handler
    s3ePointerRegister(S3E_POINTER_MOTION_EVENT, &MotionEventHandler, this);

    // Register keyboard event handler
    s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT, &KeyEventHandler, this);
}
Example #3
0
bool    ImGui_Marmalade_Init(bool install_callbacks)
{
    IwGxInit();

    ImGuiIO& io = ImGui::GetIO();
    io.KeyMap[ImGuiKey_Tab] = s3eKeyTab;                     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
    io.KeyMap[ImGuiKey_LeftArrow] = s3eKeyLeft;
    io.KeyMap[ImGuiKey_RightArrow] = s3eKeyRight;
    io.KeyMap[ImGuiKey_UpArrow] = s3eKeyUp;
    io.KeyMap[ImGuiKey_DownArrow] = s3eKeyDown;
    io.KeyMap[ImGuiKey_PageUp] = s3eKeyPageUp;
    io.KeyMap[ImGuiKey_PageDown] = s3eKeyPageDown;
    io.KeyMap[ImGuiKey_Home] = s3eKeyHome;
    io.KeyMap[ImGuiKey_End] = s3eKeyEnd;
    io.KeyMap[ImGuiKey_Delete] = s3eKeyDelete;
    io.KeyMap[ImGuiKey_Backspace] = s3eKeyBackspace;
    io.KeyMap[ImGuiKey_Enter] = s3eKeyEnter;
    io.KeyMap[ImGuiKey_Escape] = s3eKeyEsc;
    io.KeyMap[ImGuiKey_A] = s3eKeyA;
    io.KeyMap[ImGuiKey_C] = s3eKeyC;
    io.KeyMap[ImGuiKey_V] = s3eKeyV;
    io.KeyMap[ImGuiKey_X] = s3eKeyX;
    io.KeyMap[ImGuiKey_Y] = s3eKeyY;
    io.KeyMap[ImGuiKey_Z] = s3eKeyZ;

    io.RenderDrawListsFn = ImGui_Marmalade_RenderDrawLists;      // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
    io.SetClipboardTextFn = ImGui_Marmalade_SetClipboardText;
    io.GetClipboardTextFn = ImGui_Marmalade_GetClipboardText;

    if (install_callbacks)
    {
        s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, ImGui_Marmalade_PointerButtonEventCallback, 0);
        s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT, ImGui_Marmalade_KeyCallback, 0);
        s3eKeyboardRegister(S3E_KEYBOARD_CHAR_EVENT, ImGui_Marmalade_CharCallback, 0);
    }

    return true;
}
Example #4
0
bool    ImGui_Marmalade_Init(bool install_callbacks)
{
    ImGuiIO& io = ImGui::GetIO();
    io.KeyMap[ImGuiKey_Tab] = s3eKeyTab;                     // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
    io.KeyMap[ImGuiKey_LeftArrow] = s3eKeyLeft;
    io.KeyMap[ImGuiKey_RightArrow] = s3eKeyRight;
    io.KeyMap[ImGuiKey_UpArrow] = s3eKeyUp;
    io.KeyMap[ImGuiKey_DownArrow] = s3eKeyDown;
    io.KeyMap[ImGuiKey_PageUp] = s3eKeyPageUp;
    io.KeyMap[ImGuiKey_PageDown] = s3eKeyPageDown;
    io.KeyMap[ImGuiKey_Home] = s3eKeyHome;
    io.KeyMap[ImGuiKey_End] = s3eKeyEnd;
    io.KeyMap[ImGuiKey_Insert] = s3eKeyInsert;
    io.KeyMap[ImGuiKey_Delete] = s3eKeyDelete;
    io.KeyMap[ImGuiKey_Backspace] = s3eKeyBackspace;
    io.KeyMap[ImGuiKey_Space] = s3eKeySpace;
    io.KeyMap[ImGuiKey_Enter] = s3eKeyEnter;
    io.KeyMap[ImGuiKey_Escape] = s3eKeyEsc;
    io.KeyMap[ImGuiKey_A] = s3eKeyA;
    io.KeyMap[ImGuiKey_C] = s3eKeyC;
    io.KeyMap[ImGuiKey_V] = s3eKeyV;
    io.KeyMap[ImGuiKey_X] = s3eKeyX;
    io.KeyMap[ImGuiKey_Y] = s3eKeyY;
    io.KeyMap[ImGuiKey_Z] = s3eKeyZ;

    io.SetClipboardTextFn = ImGui_Marmalade_SetClipboardText;
    io.GetClipboardTextFn = ImGui_Marmalade_GetClipboardText;

    if (install_callbacks)
    {
        s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, ImGui_Marmalade_PointerButtonEventCallback, 0);
        s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT, ImGui_Marmalade_KeyCallback, 0);
        s3eKeyboardRegister(S3E_KEYBOARD_CHAR_EVENT, ImGui_Marmalade_CharCallback, 0);
    }

    return true;
}
Example #5
0
int main(int argc, char **argv)
{
	IwGLInit();
        AndroidInit();

	s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT, key_handler, NULL);

        while (!s3eDeviceCheckQuitRequest())
        {
                AndroidStep(IwGLGetInt(IW_GL_WIDTH), IwGLGetInt(IW_GL_HEIGHT));
                s3eDeviceYield(0);
                IwGLSwapBuffers();
        }

        AndroidQuit();
}
void registerInput()
{
	// Register pointer event handler
    s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, &ButtonEventHandler, NULL);

    // Register keyboard event handler
    s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT, &KeyEventHandler, NULL);

	// Register motion event handler
	s3ePointerRegister(S3E_POINTER_MOTION_EVENT, &MotionEventHandler, NULL);

	// Register touch event handler
	s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, &TouchEventHandler, NULL);

	// Register touch motion event handler
	s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, &TouchMotionEventHandler, NULL);

	
}
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;
}