コード例 #1
0
void ExamplesMainInit()
{
#ifdef EXAMPLE_DEBUG_ONLY
    // Test for Debug only examples
#ifndef IW_DEBUG
    DisplayMessage("This example is designed to run from a Debug build. Please build the example in Debug mode and run it again.");
    return 0;
#endif
#endif

    IwGxInit();

    //IwResManagerInit();
    //IwGxFontInit();

    // Set screen clear colour
    IwGxSetColClear(0xff, 0xff, 0xff, 0xff); // white background
    IwGxPrintSetColour(0, 0, 0);             // black font

    // Determine if the device has a keyboard
    if (s3eKeyboardGetInt(S3E_KEYBOARD_HAS_KEYPAD) || s3eKeyboardGetInt(S3E_KEYBOARD_HAS_ALPHA))
        g_DeviceHasKeyboard = true;

    // User code init
    ExampleInit();
}
コード例 #2
0
ファイル: IwGameInput.cpp プロジェクト: Ser40/IwGameAds
bool CIwGameInput::Init()
{
	Tapped = false;
	Dragging = false;
	PreviousNumTouches = 0;
	BackPressed = false;
	MenuPressed = false;

	// Check to see if the device that we are running on supports the pointer
    PointerAvailable = s3ePointerGetInt(S3E_POINTER_AVAILABLE) ? true : false;

	if (PointerAvailable)
	{
		// Clear out the touches array
		for (int t = 0; t < MAX_TOUCHES; t++)
		{
			Touches[t].active = false;
			Touches[t].id = 0;
		}

		// Determine if the device supports multi-touch
		IsMultiTouch = s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE) ? true : false;

		// For multi-touch devices we handle touch and motion events using different callbacks
		if (IsMultiTouch)
		{
			s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, (s3eCallback)HandleMultiTouchButtonCB, NULL);
			s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, (s3eCallback)HandleMultiTouchMotionCB, NULL);
		}
		else
		{
			s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, (s3eCallback)HandleSingleTouchButtonCB, NULL);
			s3ePointerRegister(S3E_POINTER_MOTION_EVENT, (s3eCallback)HandleSingleTouchMotionCB, NULL);
		}
	}

	// Check to see if the device that we are running on supports the keyboard
    KeysAvailable = ((s3eKeyboardGetInt(S3E_KEYBOARD_HAS_KEYPAD) || s3eKeyboardGetInt(S3E_KEYBOARD_HAS_ALPHA))) ? true : false;

	// Check to see if the device that we are running on supports the on screen keyboard
	OSKeyboardAvailable = s3eOSReadStringAvailable() == S3E_TRUE; 

	// Check accelerometer availability
	if (s3eAccelerometerGetInt(S3E_ACCELEROMETER_AVAILABLE))
		AccelerometerAvailable = true;
	else
		AccelerometerAvailable = false;

	// Check compass availability
	if (s3eCompassAvailable())
		CompassAvailable = true;
	else
		CompassAvailable = false;

	return true; // Pointer support
}
コード例 #3
0
Button* NewButton(const char *name, ButtonCallback callback)
{
    Button* button = (Button*)malloc(sizeof(Button));

    button->m_Next = 0;
    button->m_Name = strdup(name);
    button->m_Enabled = true;
    button->m_Display = true;
    button->m_Index = g_NumButtons;
    button->m_Callback = callback;
    button->m_Key = S3E_KEY_INVALID;
    button->m_XPos = 0;
    button->m_YPos = 0;
    button->m_Width = 0;
    button->m_Height = 0;

    if (g_NumButtons <= 10)
    {
        if (s3eKeyboardGetInt(S3E_KEYBOARD_HAS_NUMPAD))
            button->m_Key = (s3eKey)((int)s3eKey1 + g_NumButtons++);
        else if (!s3ePointerGetInt(S3E_POINTER_AVAILABLE))
            button->m_Key = (s3eKey)((int)s3eKeyAbsGameA + g_NumButtons++);
    }

    if (g_ButtonsTail)
        g_ButtonsTail->m_Next = button;
    else
        g_ButtonsHead = button;

    g_ButtonsTail = button;
    return button;
}
コード例 #4
0
ファイル: input.cpp プロジェクト: dblo/XTD
bool CInput::Init()
{
	// Check to see if the device that we are running on supports the pointer
    PointerAvailable = s3ePointerGetInt(S3E_POINTER_AVAILABLE) ? true : false;
	if (!PointerAvailable)
		return false;	// No pointer support

	if (PointerAvailable)
	{
		// Clear out the touches array
		for (int t = 0; t < MAX_TOUCHES; t++)
		{
			Touches[t].active = false;
			Touches[t].id = 0;
		}

		// Determine if the device supports multi-touch
		IsMultiTouch = s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE) ? true : false;

		// For multi-touch devices we handle touch and motion events using different callbacks
		if (IsMultiTouch)
		{
			s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, (s3eCallback)HandleMultiTouchButtonCB, NULL);
			s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, (s3eCallback)HandleMultiTouchMotionCB, NULL);
		}
		else
		{
			s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, (s3eCallback)HandleSingleTouchButtonCB, NULL);
			s3ePointerRegister(S3E_POINTER_MOTION_EVENT, (s3eCallback)HandleSingleTouchMotionCB, NULL);
		}
	}

	// Check to see if the device that we are running on supports the keyboard
    KeysAvailable = (s3eKeyboardGetInt(S3E_KEYBOARD_HAS_KEYPAD) || s3eKeyboardGetInt(S3E_KEYBOARD_HAS_ALPHA));

	// Check to see if the device that we are running on supports the on screen keyboard
	OSKeyboardAvailable = s3eOSReadStringAvailable() == S3E_TRUE; 

	return true; // Pointer support
}
コード例 #5
0
void LevelSelectMainInit()
{
    // Determine if the device has a keyboard
    if (s3eKeyboardGetInt(S3E_KEYBOARD_HAS_KEYPAD) || s3eKeyboardGetInt(S3E_KEYBOARD_HAS_ALPHA))
        g_DeviceHasKeyboard = true;

    int scale = 1;
    // Set default button size relative to screen resolution
    if (s3eSurfaceGetInt(S3E_SURFACE_WIDTH) < 320 || s3eSurfaceGetInt(S3E_SURFACE_HEIGHT) < 320)
        scale = 1;
    else if (s3eSurfaceGetInt(S3E_SURFACE_WIDTH) < 480 || s3eSurfaceGetInt(S3E_SURFACE_HEIGHT) < 480)
        scale = 2;
    else
        scale = 3;

    SetButtonScale(scale);

    // Scale font up to be easier to read
    int fontScale = scale > 1 ? scale-1 : 1;
    s3eDebugSetInt(S3E_DEBUG_FONT_SCALE, fontScale);
    LevelInit();
}
コード例 #6
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;
}