Esempio n. 1
0
/*!***********************************************************************
 @Function		OsInit
 @description	Initialisation for OS-specific code.
*************************************************************************/
void PVRShellInit::OsInit()
{
	XInitThreads();

    // set values to negative to mark that these are default values
    m_pShell->m_pShellData->nShellDimX = -240;
    m_pShell->m_pShellData->nShellDimY = -320;

	m_X11Display = NULL;
	m_X11Visual = NULL;

	// Pixmap support: init variables to 0
	m_X11Pixmap = BadValue;

	/*
		Construct the binary path for GetReadPath() and GetWritePath()
	*/
	// Get PID (Process ID)
	pid_t ourPid = getpid();
	char *pszExePath, pszSrcLink[64];
	int len = 64;
	int res;

	sprintf(pszSrcLink, "/proc/%d/exe", ourPid);
	pszExePath = 0;

	do
	{
		len *= 2;
		delete[] pszExePath;
		pszExePath = new char[len];
		res = readlink(pszSrcLink, pszExePath, len);

		if(res < 0)
		{
			m_pShell->PVRShellOutputDebug("Warning Readlink %s failed. The application name, read path and write path have not been set.\n", pszExePath);
			break;
		}
	} while(res >= len);

	if(res >= 0)
	{
		pszExePath[res] = '\0'; // Null-terminate readlink's result
		SetReadPath(pszExePath);
		SetWritePath(pszExePath);
		SetAppName(pszExePath);
	}

	delete[] pszExePath;

	m_u32ButtonState = 0;

	gettimeofday(&m_StartTime,NULL);
}
Esempio n. 2
0
/*!***********************************************************************
 @Function		OsInit
 @description	Initialisation for OS-specific code.
*************************************************************************/
void PVRShellInit::OsInit()
{
    // full screen is not a default behaviour on X11
	//m_pShell->m_pShellData->bFullScreen=true;	// linux overrides default to use fullscreen

    // set values to begative to mark that these are default values
    m_pShell->m_pShellData->nShellDimX = -240;
    m_pShell->m_pShellData->nShellDimY = -320;

	x11display = NULL;
	x11visual = NULL;

	// Pixmap support: init variables to 0
	x11pixmap = BadValue;

	/*
		Construct the binary path for GetReadPath() and GetWritePath()
	*/
	// Get PID
	pid_t ourPid = getpid();
	char *pszExePath, pszSrcLink[64];
	int len = 64;
	int res;

	sprintf(pszSrcLink, "/proc/%d/exe", ourPid);
	pszExePath = 0;
	do
	{
		len *= 2;
		delete[] pszExePath;
		pszExePath = new char[len];
		res = readlink(pszSrcLink, pszExePath, len);
	} while((res < 0) || (res >= len));
	pszExePath[res] = '\0'; // Null-terminate readlink's result
	SetReadPath(pszExePath);
	SetWritePath(pszExePath);
	SetAppName(pszExePath);
	delete[] pszExePath;
}
Esempio n. 3
0
/*!***********************************************************************
 @Function		OsInit
 @description	Initialisation for OS-specific code.
*************************************************************************/
void PVRShellInit::OsInit()
{

#if defined UNDER_CE
	m_pShell->m_pShellData->bFullScreen = true; // WinCE overrides default to use fullscreen
#endif

	m_hAccelTable = 0;

	m_pShell->m_pShellData->nShellDimX = SHELL_DISPLAY_DIM_X;
	m_pShell->m_pShellData->nShellDimY = SHELL_DISPLAY_DIM_Y;

	m_hDC = 0;
	m_hWnd = 0;

	// Pixmap support: init variables to 0
	m_hBmPixmap = 0;
	m_hBmPixmapOld = 0;
	m_hDcPixmap = 0;

	/*
		Construct the binary path for GetReadPath() and GetWritePath()
	*/
	{
		/* Allocate memory for strings and return 0 if allocation failed */
		TCHAR* exeNameTCHAR = new TCHAR[DIR_BUFFER_LEN];
		char* exeName = new char[DIR_BUFFER_LEN];
		if(exeNameTCHAR && exeName)
		{
			DWORD retSize;

			/*
				Get the data path and a default application name
			*/

			// Get full path of executable
			retSize = GetModuleFileName(NULL, exeNameTCHAR, DIR_BUFFER_LEN);

			if (DIR_BUFFER_LEN > (int)retSize)
			{
				/* Get string length in char */
				retSize = (DWORD)_tcslen(exeNameTCHAR);

				/* Convert TChar to char */
				for (DWORD i = 0; i <= retSize; i++)
				{
					exeName[i] = (char)exeNameTCHAR[i];
				}

				SetAppName(exeName);
				SetReadPath(exeName);
				SetWritePath(exeName);
			}
		}

		delete [] exeName;
		delete [] exeNameTCHAR;
	}

	m_bPointer = false;		// have no valid pointer location at startup
	m_u32ButtonState = 0;	// clear mouse button state at startup
}
Esempio n. 4
0
/*!***********************************************************************
 @Function		OsInit
 @description	Initialisation for OS-specific code.
*************************************************************************/
void PVRShellInit::OsInit()
{
	bcm_host_init();

	// In case we're in the background ignore SIGTTIN and SIGTTOU
	signal( SIGTTIN, SIG_IGN );
	signal( SIGTTOU, SIG_IGN );

	remote_fd = 0;

	m_pShell->m_pShellData->bFullScreen= true;	// linux overrides default to use fullscreen

	m_ui32NativeDisplay = 0;

	// Keyboard handling
	if((devfd=open(CONNAME, O_RDWR|O_NDELAY)) <= 0)
	{
		m_pShell->PVRShellOutputDebug("Can't open tty (%s)\n",CONNAME);
	}
	else
	{
		tcgetattr(devfd,&termio_orig);
		tcgetattr(devfd,&termio);
		cfmakeraw(&termio);
		termio.c_oflag |= OPOST | ONLCR; // Turn back on cr-lf expansion on output
		termio.c_cc[VMIN]=1;
		termio.c_cc[VTIME]=0;

		if(tcsetattr(devfd,TCSANOW,&termio) == -1)
		{
			m_pShell->PVRShellOutputDebug("Can't set tty attributes for %s\n",CONNAME);
		}
	}

	// Keypad handling.
	if ((keypad_fd = open(KEYPAD_INPUT, O_RDONLY | O_NDELAY)) <= 0)
	{
		m_pShell->PVRShellOutputDebug("Can't open keypad input device (%s)\n",KEYPAD_INPUT);
	}

#if defined(PVRSHELL_OMAP3_TS_SUPPORT)
	/*************************************************
	 * Touchscreen code
	 * NOTE: For the init code to work, these variables have to be set prior to the app launch.
	 *
	 * export TSLIB_TSDEVICE=/dev/input/event1
	 * export TSLIB_CONFFILE=/etc/ts.conf
	 * export TSLIB_CALIBFILE=/etc/pointercal
	 * export TSLIB_CONSOLEDEVICE=/dev/tty
	 * export TSLIB_FBDEVICE=/dev/fb0
	 *************************************************/

	ts = ts_open(TOUCHSCREEN_INPUT, 1);

	if (!ts)
	{
		m_pShell->PVRShellOutputDebug("Can't open the touchscreen input device\n");
	}
	else if (ts_config(ts))
	{
		m_pShell->PVRShellOutputDebug("Can't open the touchscreen input device\n");
	}
#endif

   // Remote Control handling
#if defined(PVRSHELL_INTEL_CE_PIC24_REMOTE)
	g_usRemoteLastKey = 0x0;
	pic_if.Init(REMOTE);
#else
    if((remote_fd = open(REMOTE, O_RDONLY|O_NDELAY)) <= 0)
	{
		m_pShell->PVRShellOutputDebug("Can't open remote control input device (%s)\n",REMOTE);
	}
    else
    {
		tcgetattr(remote_fd, &remios_orig);
		remios.c_cflag = B9600 | CRTSCTS | CS8 | CLOCAL | CREAD;
		remios.c_iflag = IGNPAR | ICRNL;
		remios.c_oflag = 0;
		remios.c_lflag = 0;
		remios.c_cc[VMIN] = 1;
		remios.c_cc[VTIME]= 0;

		tcflush(remote_fd, TCIFLUSH);
		tcsetattr(remote_fd, TCSANOW, &remios);
    }
#endif

	// Construct the binary path for GetReadPath() and GetWritePath()

	// Get PID (Process ID)
	pid_t ourPid = getpid();
	char *pszExePath, pszSrcLink[64];
	int len = 64;
	int res;

	sprintf(pszSrcLink, "/proc/%d/exe", ourPid);
	pszExePath = 0;

	do
	{
		len *= 2;
		delete[] pszExePath;
		pszExePath = new char[len];
		res = readlink(pszSrcLink, pszExePath, len);

		if(res < 0)
		{
			m_pShell->PVRShellOutputDebug("Warning Readlink %s failed. The application name, read path and write path have not been set.\n", pszExePath);
			break;
		}
	} while(res >= len);

	if(res >= 0)
	{
		pszExePath[res] = '\0'; // Null-terminate readlink's result
		SetReadPath(pszExePath);
		SetWritePath(pszExePath);
		SetAppName(pszExePath);
	}

	delete[] pszExePath;

	/*
	 Get rid of the blinking cursor on a screen.

	 It's an equivalent of:
	 <CODE> echo -n -e "\033[?25l" > /dev/tty0 </CODE>
	 if you do the above command then you can undo it with:
	 <CODE> echo -n -e "\033[?25h" > /dev/tty0 </CODE>
	*/
	FILE *tty = 0;
	tty = fopen("/dev/tty0", "w");
	if (tty != 0)
	{
		const char txt[] = { 27 /* the ESCAPE ASCII character */
						   , '['
						   , '?'
						   , '2'
						   , '5'
						   , 'l'
						   , 0
						   };

		fprintf(tty, "%s", txt);
		fclose(tty);
	}

	gettimeofday(&m_StartTime,NULL);

#if defined(USE_GDL_PLANE)
	gdl_init(0);

	// Set the width and height to fill the screen
	gdl_display_info_t di;
	gdl_get_display_info(GDL_DISPLAY_ID_0, &di);
	m_pShell->m_pShellData->nShellDimX = di.tvmode.width;
	m_pShell->m_pShellData->nShellDimY = di.tvmode.height;
#endif
}
Esempio n. 5
0
/*!***********************************************************************
 @Function		OsInit
 @description	Initialisation for OS-specific code.
*************************************************************************/
void PVRShellInit::OsInit()
{
	int retval;

	// In case we're in the background ignore SIGTTIN and SIGTTOU
	signal(SIGTTIN, SIG_IGN);
	signal(SIGTTOU, SIG_IGN);

	m_pShell->m_pShellData->bFullScreen= true;	// linux overrides default to use fullscreen

	m_ui32NativeDisplay = 0;

	// Keyboard handling
	if ((devfd = open(CONNAME, O_RDWR|O_NDELAY)) <= 0)
	{
		m_pShell->PVRShellOutputDebug("Can't open tty (%s)\n",CONNAME);
	}
	else
	{
		tcgetattr(devfd, &termio_orig);
		tcgetattr(devfd, &termio);
		cfmakeraw(&termio);
		termio.c_oflag |= OPOST | ONLCR; // Turn back on cr-lf expansion on output
		termio.c_cc[VMIN]=1;
		termio.c_cc[VTIME]=0;

		if (tcsetattr(devfd, TCSANOW, &termio) == -1)
		{
			m_pShell->PVRShellOutputDebug("Can't set tty attributes for %s\n",CONNAME);
		}
	}

	// Construct the binary path for GetReadPath() and GetWritePath()

	// Get PID (Process ID)
	pid_t ourPid = getpid();
	char *pszExePath, pszSrcLink[64];
	int len = 64;
	int res;

	sprintf(pszSrcLink, "/proc/%d/exe", ourPid);
	pszExePath = 0;

	do
	{
		len *= 2;
		delete[] pszExePath;
		pszExePath = new char[len];
		res = readlink(pszSrcLink, pszExePath, len);

		if(res < 0)
		{
			m_pShell->PVRShellOutputDebug("Warning Readlink %s failed. The application name, read path and write path have not been set.\n", pszExePath);
			break;
		}
	} while(res >= len);

	if(res >= 0)
	{
		pszExePath[res] = '\0'; // Null-terminate readlink's result
		SetReadPath(pszExePath);
		SetWritePath(pszExePath);
		SetAppName(pszExePath);
	}

	delete[] pszExePath;

	/*
	 Get rid of the blinking cursor on a screen.

	 It's an equivalent of:
	 <CODE> echo -n -e "\033[?25l" > /dev/tty0 </CODE>
	 if you do the above command then you can undo it with:
	 <CODE> echo -n -e "\033[?25h" > /dev/tty0 </CODE>
	*/
	const char txt[] = { 27 // the ESCAPE ASCII character
			   , '['
			   , '?'
			   , '2'
			   , '5'
			   , 'l'
			   , 0
		   };

	retval = write(devfd, &txt[0], 7);

	gettimeofday(&m_StartTime, NULL);

	m_pShell->m_pShellData->nShellDimX = -1;
	m_pShell->m_pShellData->nShellDimY = -1;
	m_ui32DrmDisplayId = 0;


}
Esempio n. 6
0
/*!***********************************************************************
 @Function		OsInit
 @description	Initialisation for OS-specific code.
*************************************************************************/
void PVRShellInit::OsInit()
{
	m_pShell->m_pShellData->bFullScreen= true;	// linux overrides default to use fullscreen

	// Get PID (Process ID)
	char* pszAppName=0, pszSrcLink[64];

	snprintf(pszSrcLink, 64, "/proc/%d/cmdline", getpid());

	FILE* pFile = fopen(pszSrcLink, "rb");

	if(pFile)
	{
		// Get the file size
		size_t size = 128;

		pszAppName = (char*) malloc(size);

		if(pszAppName)
		{
			size_t bytesRead = 0;
			char *ptr = pszAppName;

			while((bytesRead = fread(ptr, 1, 128, pFile)) == 128)
			{
				char *resized = (char*) realloc(pszAppName, size + 128);

				if(!resized)
				{
					free(pszAppName);
					pszAppName = 0;
					break;
				}

				size += 128;
				pszAppName = resized;
				ptr = pszAppName + size;
			}
		}

		fclose(pFile);
	}

	if(!pszAppName)
	{
		m_pShell->PVRShellOutputDebug("Warning: Unable to set app name.\n");
	}
	else
	{
		SetAppName(pszAppName);
		free(pszAppName);
	}

	// Setup the read/write path

	// Construct the binary path for GetReadPath() and GetWritePath()
	char* internalDataPath = (char*) m_pAndroidState->activity->internalDataPath;

	if(!internalDataPath) // Due to a bug in Gingerbread this will always be Null
	{
		m_pShell->PVRShellOutputDebug("Warning: The internal data path returned from Android is null. Attempting to generate from the app name..\n");

		pszAppName = m_pShell->m_pShellData->pszAppName;

		if(pszAppName)
		{
			size_t size = strlen("/data/data/") + strlen(pszAppName) + 2;

			internalDataPath = (char*) malloc(size);

			if(internalDataPath)
				snprintf(internalDataPath, size, "/data/data/%s/", pszAppName);
		}

		if(!internalDataPath)
			internalDataPath = (char*) "/sdcard/";

		SetWritePath(internalDataPath);

		if(pszAppName)
			free(internalDataPath);
	}
	else
	{
		SetWritePath(internalDataPath);
	}

	SetReadPath(""); // Empty, external files should be read from the .apk file

	gettimeofday(&m_StartTime,NULL);
}