Ejemplo n.º 1
0
// draws the focus screen's active button
void AnsiWidget::drawActiveButton() {
#if defined(_FLTK)
  maUpdateScreen();
#elif defined(_SDL)
  if (_focus != NULL && !_activeButton->hasHover()) {
    MAHandle currentHandle = maSetDrawTarget(HANDLE_SCREEN);
    _focus->drawShape(_activeButton);
    _focus->drawLabel();
    maUpdateScreen();
    maSetDrawTarget(currentHandle);
  }
#else
  if (_activeButton->hasHover()) {
    int dx = _front->_x;
    int dy = _front->_y - _front->_scrollY;
    _activeButton->drawHover(dx, dy, _activeButton->_pressed);
  } else if (_focus != NULL) {
    MAHandle currentHandle = maSetDrawTarget(HANDLE_SCREEN);
    _focus->drawShape(_activeButton);
    _focus->drawLabel();
    maUpdateScreen();
    maSetDrawTarget(currentHandle);
  }
#endif
}
Ejemplo n.º 2
0
extern "C" int MAMain()
{
	bool run = true;

	updateScreenDimensions();
	registerSensors();
	setFont();

	while (run)
	{
		/// Get any available events.
		/// On back press close program.
		MAEvent event;
		while(maGetEvent(&event))
		{
			if(event.type == EVENT_TYPE_SENSOR)
			{
				memcpy(gSensorValue[event.sensor.type],
						event.sensor.values, SENSOR_VALUES * sizeof(float));
			}
			else if((event.type == EVENT_TYPE_KEY_PRESSED) &&
					(event.key == MAK_BACK))
			{
				run = false;
			}

			drawSensorOutput();

			maUpdateScreen();
		}
	}

	unregisterSensors();
};
Ejemplo n.º 3
0
	/**
	 * This function will be called whenever the moblet has nothing else to do,
	 * drawing rectangles with the touchIds where the fingers touches the
	 * screen. The amount of touches possible on a device is platform dependent.
	 *
	 * In the MoRE emulator you can simulate multitouch by right-clicking the screen.
	 * This will simulate two touches, mirrored around the center of the screen.
	 * Each of these two touches will be marked with a blue circle.
	 */
	void idle()
	{

		// Clear the screen by drawing a black rectangle covering the visible area.
		maSetColor(0);
		int screenSize = maGetScrSize();
		maFillRect(0, 0, EXTENT_X(screenSize), EXTENT_Y(screenSize));

		// Loop through all the current touches and draw for each a rectangle
		// and the touch id.
		for(MAUtil::Map<int, MAPoint2d>::Iterator iterator = mTouches.begin();
			iterator != mTouches.end();
			iterator++)
		{
			MAPoint2d point = iterator->second;
			int touchId = iterator->first;

			char touchStr[16];
			sprintf(touchStr, "%d", touchId);

			// Draw a red rectangle, centred around the touch position
			maSetColor(0xff0000);
			maFillRect(point.x - (MARKER_SIZE/2), point.y - (MARKER_SIZE/2),
					MARKER_SIZE, MARKER_SIZE);

			// Draw the touch id to the top-left of each red rectangle.
			maSetColor(0xffffff);
			maDrawText(point.x + (MARKER_SIZE/2), point.y - (MARKER_SIZE/2),
					touchStr);
		}

		maUpdateScreen();
	}
//de main functie
extern "C" int MAMain()
{
    MAEvent event;

    //nieuw sneeuwlandschap
    SneeuwLandschap* sneeuwLandschap = new SneeuwLandschap();

    //oneindige loop laat onze app in werking
    while (TRUE)
    {
        //run met 1 frame per 100 ms
        maWait(100);

        //kijk of er events hebben plaatsgevonden, sla die info op in MAEvent event.
        maGetEvent(&event);

        //als een event de app wil sluiten...
        if (EVENT_TYPE_CLOSE == event.type)
        {
            // Exit while loop.
            break;
        }

        //handel alle logica van sneeuwlandschap af
        sneeuwLandschap->run( event );

        //teken het sneeuwlandschap
        sneeuwLandschap->draw();

        //vergeet het scherm niet te updaten!
        maUpdateScreen();
    }

    return 0;
}
Ejemplo n.º 5
0
void TestMoblet::testLoadWithName()
{
	mShowing = 2;

	maSetColor(0x000000);
	MAExtent size = maGetScrSize();
	maFillRect(0,0,EXTENT_X(size),EXTENT_Y(size) );

	maSetColor(0xCD5555);

	int top = 0;
	maDrawText(10,top,"--------- Test maFontLoadWithName(test each name from list) --------- ");
	top += 20;

	for (int i=0; i<fontNames.size(); i++)
	{
		top += 20;
		int handle = maFontLoadWithName(fontNames[i].c_str(), 15);
		if ( handle == RES_FONT_NAME_NONEXISTENT )
		{
			message = "Font nonexistent: " + fontNames[i];
			maDrawText(10,top, message.c_str());
		}
		else
		{
			maFontSetCurrent(handle);
			message =  "Font " + fontNames[i] + " has handle = " + MAUtil::integerToString(handle);
			maDrawText(10, top, message.c_str());
		}
	}

	maDrawText(10, top+40, "Tap screen to test maFontLoadDefault for some combinations");
	maUpdateScreen();
}
Ejemplo n.º 6
0
void KeyBaseCase::showErrorScreen(int errorCode)
{
	MAExtent e = maGetScrSize();
	Dimensions screen;
	screen.width = EXTENT_X(e);
	screen.height = EXTENT_Y(e);
	maSetClipRect(0, 0, screen.width, screen.height);

	maSetColor(BLACK);
	maFillRect(0, 0, screen.width, screen.height);

	int oldCol = maSetColor(0xff0000);
	const char* testName = name.c_str();
	maDrawText(4, 0, testName);

	int testNameHeight = EXTENT_Y(maGetTextSize(testName));

	if(FUNC_OUT_OF_MEMORY_ALLOC == errorCode)
		maDrawText(4, testNameHeight+2, "Out of Memory");
	else if(FUNC_OUT_OF_MEMORY_RESOURCE == errorCode)
		maDrawText(4, testNameHeight+2, "Couldn't create resource");
	else if(FUNC_SYSCALL_ERROR == errorCode)
		maDrawText(4, testNameHeight+2, "A syscall wasn't called correctly");
	else if(FUNC_SYSCALL_NOT_SUPPORTED == errorCode)
		maDrawText(4, testNameHeight+2, "Unsupported feature");
	else
		maDrawText(4, testNameHeight+2, "Unknown error!");

	maDrawText(4, testNameHeight*2+4, "press key or screen to continue");

	maUpdateScreen();
	maSetColor(oldCol);	
}
Ejemplo n.º 7
0
int main() {
    char bigAssBuffer[BIGASSBUFFERSIZE];
    char* hello = "HTTP GET test";
    Extent screenSize, textSize;
    screenSize = maGetScrSize();

    //Draw centered text
    println("");
    textSize = maDrawText(0, 0, hello);
    maSetColor(0);
    maFillRect(0, 0, EXTENT_X(textSize), EXTENT_Y(textSize));  //erase test text
    maDrawText((EXTENT_X(screenSize) - EXTENT_X(textSize)) / 2, 0, hello);
    maUpdateScreen();

    println("Connecting...");
    int res = maHttpGet("link.astando.se"
                        "/guido/LvRouting.asmx/GenerateRouteGuido?fromX=100502&fromY=77476&toX=100591&toY=77368",
                        //"wap.mopix.se/test/test.comb",
                        bigAssBuffer, BIGASSBUFFERSIZE);

    printiln("Got %i bytes", res);
    println(bigAssBuffer);
    println("PAK to quit");

    PAKAndRelease();
    maExit(0);
}
Ejemplo n.º 8
0
	void start()
	{
		currentLength = 0;
		MAUtil::Environment::getEnvironment().addKeyListener(this);
		clearScreen();
		renderCurrent();
		maUpdateScreen();
	}
Ejemplo n.º 9
0
void VW_UpdateScreen()
{
// do palettized gfxbuf > frameBuffer conversion here..

	FrameBuffer_copyRect(0, 0, 320, 200, 0, 0, gfxbuf, 320);
	maResetBacklight();
	maUpdateScreen();
	//INL_Update();
}
Ejemplo n.º 10
0
void TestMoblet::testLoadDefault()
{
	mShowing = 3;

	maSetColor(0x000000);
	MAExtent size = maGetScrSize();
	maFillRect(0,0,EXTENT_X(size),EXTENT_Y(size) );

	maSetColor(0xCD5555);

	int top = 0;
	maDrawText(10,top,"--------- Test maFontLoadDefault ---------");

	top += 20;
	maDrawText(10,top,"Test Monospace Normal -10");
	testFont(FONT_TYPE_MONOSPACE,FONT_STYLE_NORMAL,-10,top);

	top += 20;
	maDrawText(10, top, "Test Monospace Bold 15");
	testFont(FONT_TYPE_MONOSPACE, FONT_STYLE_BOLD, 15, top);

	top += 20;
	maDrawText(10, top, "Test Monospace Italic 15");
	testFont(FONT_TYPE_MONOSPACE, FONT_STYLE_ITALIC, 15, top);

	top += 20;
	maDrawText(10, top, "Test SansSerif Normal 15");
	testFont(FONT_TYPE_SANS_SERIF, FONT_STYLE_NORMAL, 15, top);

	top += 20;
	maDrawText(10, top, "Test SansSerif Bold 15");
	testFont(FONT_TYPE_SANS_SERIF, FONT_STYLE_BOLD, 15, top);

	top += 20;
	maDrawText(10, top, "Test SansSerif Italic 15");
	testFont(FONT_TYPE_SANS_SERIF, FONT_STYLE_ITALIC, 15, top);

	top += 20;
	maDrawText(10, top, "Test Serif Normal 15");
	testFont(FONT_TYPE_SERIF, FONT_STYLE_NORMAL, 15, top);

	top += 20;
	maDrawText(10, top, "Test Serif Bold 15");
	testFont(FONT_TYPE_SERIF, FONT_STYLE_BOLD, 15, top);

	top += 20;
	maDrawText(10, top, "Test Serif Italic 15");
	testFont(FONT_TYPE_SERIF, FONT_STYLE_ITALIC, 15, top);

	maDrawText(10, top+40, "Tap screen to EXIT");
	maUpdateScreen();
}
Ejemplo n.º 11
0
Archivo: main.c Proyecto: Felard/MoSync
int MAMain() {
	int x=0, y=0, dx=1, dy=1;
	int scrW, scrH;
	int srcW, srcH;
	{
		int srcSize = maGetImageSize(SIMG);
		srcW = EXTENT_X(srcSize);
		srcH = EXTENT_Y(srcSize);
	}
	maCreateDrawableImage(TIMG, srcW,srcH);
	maSetDrawTarget(TIMG);

	maSetColor(0);	//black
	maFillRect(0,0, srcW,srcH);
	maDrawImage(SIMG, 0,0);
	maSetColor(0xff0000);	//red
	maLine(0,0, srcW,srcH);
	maLine(srcW,0, 0,srcH);

	maSetDrawTarget(HANDLE_SCREEN);
	{
		int scrSize = maGetScrSize();
		scrW = EXTENT_X(scrSize);
		scrH = EXTENT_Y(scrSize);
	}
	while(1) {
		//int then = maGetMilliSecondCount();

		maSetColor(0);	//black
		maFillRect(0,0, scrW,scrH);

		maDrawImage(TIMG, x, y);
		if((dx > 0 && x + srcW > scrW) || (dx < 0 && x < 0)) {
			dx = -dx;
		}
		if((dy > 0 && y + srcH > scrH) || (dy < 0 && y < 0)) {
			dy = -dy;
		}
		x += dx;
		y += dy;
		maUpdateScreen();
		/*{
		int now = maGetMilliSecondCount();
		int time_padding = 10 - (now - then);
		if(time_padding > 0)
		maSleep(time_padding);
		}*/
	}
}
Ejemplo n.º 12
0
void Freeze(int val) {
	maUpdateScreen();
	for(;;) {
		MAEvent event;
		while(maGetEvent(&event)) {
			if(event.type == EVENT_TYPE_CLOSE ||
				(event.type == EVENT_TYPE_KEY_PRESSED &&
				(event.key == MAK_0 || event.key == MAK_BACK)))
			{
				maExit(val);
			}
		}
		maWait(0);
	}
}
Ejemplo n.º 13
0
void CompareScreen::keyPressEvent(int keyCode) {
	switch (keyCode) {
		case MAK_UP:
		case MAK_DOWN:
		case MAK_FIRE:
			Util::updateSoftKeyLayout("", "Back", "Flip", mainLayout);
			imge->refreshWidget();
			imge->statAdded = false;
			currentSelectedStat = -1;

			flip=!flip;
			if (imge->getResource() != NULL) {
				maDestroyObject(imge->getResource());
			}
			if (cmpge->getResource() != NULL) {
				maDestroyObject(cmpge->getResource());
			}
			imge->setResource(Util::loadImageFromResource(RES_LOADING_FLIP1));
			imge->update();
			imge->requestRepaint();

			cmpge->setResource(Util::loadImageFromResource(RES_LOADING_FLIP1));
			cmpge->update();
			cmpge->requestRepaint();

			maUpdateScreen();
			if (flip) {
				Util::retrieveBackFlip(imge, card, height-PADDING*2, imageCache);
				Util::retrieveBackFlip(cmpge, compare, height-PADDING*2, imageCache);
			} else {
				Util::retrieveFrontFlip(imge, card, height-PADDING*2, imageCache);
				Util::retrieveFrontFlip(cmpge, compare, height-PADDING*2, imageCache);
			}
			currentSelectedStat = -1;
			break;
		case MAK_RIGHT:
			break;
		case MAK_LEFT:
			break;
		case MAK_SOFTLEFT:
			break;
		case MAK_BACK:
		case MAK_SOFTRIGHT:
			previous->show();
			break;
	}
}
Ejemplo n.º 14
0
/*
 * ctor
 */
TestMoblet::TestMoblet()
{
	mShowing = 1;

	maSetColor(0xC1FFC1);

	int top = 10;
	maDrawText(10,top, "--------- Display number of fonts with current font ---------");
	nrFonts = maFontGetCount();
	MAUtil::String tempNrFonts;
	char buf1[10];
	char buf2[256];
	itoa(nrFonts,buf1, 10);
	tempNrFonts += buf1;
	tempNrFonts += " fonts.";
	top += 20;
	maDrawText(10,top,tempNrFonts.c_str());

	maSetColor(0x00FFFF);
	top+=40;
	maDrawText(10,top,"--------- Display list of fonts with default font size --------- ");
	MAUtil::String tempFont;
	int getNameError;

	for ( int i=0; i<nrFonts; i++)
	{
		char buf[256];
		getNameError = maFontGetName(i, buf, 256);
		if ( getNameError >= 0 )
		{
			top += 20;
			fontNames.add(buf);
			maDrawText(10,top, buf);
		}
		else
		{
			top += 20;
			message = "Font on index:" + MAUtil::integerToString(i) + "returned error:" + MAUtil::integerToString(getNameError);
			maDrawText(10, top, message.c_str());
		}
	}

	maDrawText(10, top+40, "Tap screen to test maLoadWithName for each font");
	maUpdateScreen();
}
Ejemplo n.º 15
0
	void testGetImageData() {
		printf("testing maGetImageData\n");

		const unsigned int NUMCOLORS = sizeof(sColors)/sizeof(int);
		unsigned int colors2[NUMCOLORS];
		MAExtent e1 = maGetImageSize(ARGB_PNG);

		assert("maGetImageSize", e1 == EXTENT(NUMCOLORS,1));

		MARect rect = {0, 0, NUMCOLORS, 1};
		maGetImageData(ARGB_PNG, colors2, &rect, NUMCOLORS);

		assert("image: getData from PNG",
			(memcmp(sColors, colors2, sizeof(sColors)) == 0)
		);
		maDrawImage(ARGB_PNG, 0, 0);
		maUpdateScreen();
		//FREEZE;
	}
Ejemplo n.º 16
0
int MAMain() {
	Extent screenSize;
	int midX, midY;
	int width, height;
	int scrW, scrH;

	screenSize = maGetScrSize();
	scrW = EXTENT_X(screenSize);
	scrH = EXTENT_Y(screenSize);
	midX = scrW >> 1;
	midY = scrH >> 1;
#ifdef RECT_SIZE_TEST
	width = 1;
	height = 1;
#else	//normal color test
	width = midX - 2;
	height = midY / 2 - 2;
#endif

	maSetColor(0x800080);	//deep purple
	maFillRect(0, 0, scrW, scrH);

	maSetColor(RGB(255, 0, 0));				//RED
	maFillRect(1, 1, width, height);
	maSetColor(RGB(255, 255, 0));				//YELLA
	maFillRect(1+width+2, 1, width, height);
	maSetColor(RGB(0, 255, 0));				//GREEN
	maFillRect(1, 1+height+2, width, height);
	maSetColor(RGB(0, 255, 255));				//TORQUOISE
	maFillRect(1+width+2, 1+height+2, width, height);
	maSetColor(RGB(0, 0, 255));				//BLUE
	maFillRect(1, 1+(height+2)*2, width, height);
	maSetColor(RGB(255, 0, 255));				//PURPLE
	maFillRect(1+width+2, 1+(height+2)*2, width, height);
	maSetColor(RGB(255, 255, 255));				//WHITE
	maFillRect(1, 1+(height+2)*3, width, height);
	maSetColor(0);				//BLACK
	maFillRect(1+width+2, 1+(height+2)*3, width, height);

	maUpdateScreen();
	FREEZE;
}
Ejemplo n.º 17
0
int MAMain() {
	maSetColor(0xFFFFFF);
	maDrawText(0,0, "Hello World!");
	maUpdateScreen();

	//Freeze
	while(1) {
		maWait(0);
		EVENT event;
		if(maGetEvent(&event)) {
			if(event.type == EVENT_TYPE_CLOSE)
				break;
			if(event.type == EVENT_TYPE_KEY_PRESSED) {
				if(event.key == MAK_0)
					break;
			}
		}
	}
	return 0;

}
Ejemplo n.º 18
0
	/**
	 * Method that draws display data to the screen.
	 */
	void drawScreen()
	{
		MAExtent screenSize = maGetScrSize();
		int width = EXTENT_X(screenSize);
		int height = EXTENT_Y(screenSize);
		int x = 20;
		int y = height / 2;
		char orientationText[128];

		if (width > height) // Landscape
		{
			// Set the background color.
			maSetColor(0x000099);

			// Set text.
			sprintf(orientationText, "Landscape %d %d", width, height);
		}
		else // Portrait
		{
			// Set the background color.
			maSetColor(0x009900);

			// Set text.
			sprintf(orientationText, "Portrait %d %d", width, height);
		}

		// Fill background
		maFillRect(0, 0, width, height);

		// Use white to display the text.
		maSetColor(0xFFFFFF);

		// Draw the text.
		maDrawText(x, y, orientationText);

		// Redraw the screen.
		maUpdateScreen();
	}
Ejemplo n.º 19
0
void DisplayConsole(void)
{
	int n, index;

	if (gConsoleDisplay == 0)
		return;

	maSetClipRect(0, 0, EXTENT_X(sConsole.screenSize), EXTENT_Y(sConsole.screenSize));

	if(gConsoleDrawBackground) {
		maSetColor(gConsoleBackgroundColor);
		maFillRect(0, 0, EXTENT_X(sConsole.screenSize), EXTENT_Y(sConsole.screenSize));
	}
	
	maSetColor(gConsoleTextColor);
	for (n = 0;  n < sConsole.height;  n++)
	{
		index = (n + sConsole.firstLine) % sConsole.height;
		maDrawTextW(0, n * sConsole.fontHeight, sConsole.lines[index].line);
	}

	maUpdateScreen();
}
Ejemplo n.º 20
0
void MoSyncStub::updateScreen(uint8 shakeOffset) {
	if (shakeOffset == 0) {
		for (int i = 0; i < _numBlitRects; ++i) {
			blitRect(&_blitRects[i], _blitRects[i].left, _blitRects[i].top);
		}
	} else {

		MARect bsr, bdr;
		bdr.left = 0;
		bdr.top = 0;
		bdr.width = _screenW;
		bdr.height = shakeOffset;

		bsr.left = 0;
		bsr.top = 0;
		bsr.width = _screenW;
		bsr.height = (_screenH - shakeOffset);
		blitRect(&bsr, 0, shakeOffset);
	}
	_numBlitRects = 0;

	maUpdateScreen();
	maResetBacklight();
}
Ejemplo n.º 21
0
static void ogl_updateScreen(void) {
	if(sNativeUIOpenGLView == -1)
		maUpdateScreen();
	else
		maWidgetSetProperty(sNativeUIOpenGLView, "invalidate", "");
}
Ejemplo n.º 22
0
Archivo: t8.c Proyecto: Felard/MoSync
int MAMain() {
	const MAExtent scrSize = maGetScrSize();
	const int scrHeight = EXTENT_Y(scrSize);
	const int scrWidth = EXTENT_X(scrSize);
start:	maSetColor(0x808080);
	maFillRect(0, 0, scrWidth, scrHeight);

	maSetColor(0xffffff);
#ifdef STDTEST
	maLine(50, 50, 100, 100);
	maUpdateScreen();
	maLine(50, -50, 100, -100);
	maUpdateScreen();
	maLine(-50, 50, -100, 100);
	maUpdateScreen();
	maLine(-50, -50, -100, -100);
	maUpdateScreen();
	maLine(-10, 20, 20, -10);	//5
	maUpdateScreen();
	maLine(-1, 1, 1, -1);	//6-7
	maUpdateScreen();
	maLine(-20, 10, 10, -20);	//8
	maUpdateScreen();
	maLine(-40, 40, 50, -100);	//9
	maUpdateScreen();
	maLine(172, 226, 176, 205);	//crash test dummy
	maUpdateScreen();
	maLine(-5, 1, 2, -1);
	maUpdateScreen();
#else	//Line pixel test
	maLine(1, 1, 1, 5);
	maUpdateScreen();
	maSetColor(0x00ffff);
	maLine(1, 2, 3, 2);
	maUpdateScreen();
	maSetColor(0xff00ff);
	maLine(2, 3, 0, 3);
	maUpdateScreen();
	maSetColor(0xff80ff);
	maLine(0, 4, 2, 4);
	maUpdateScreen();
	maSetColor(0xffffff);
	maLine(4, 5, 4, 1);
	maUpdateScreen();
#endif

	//Freeze
	while(1) {
		maWait(0);
		MAEvent event;
		if(maGetEvent(&event)) {
			if(event.type == EVENT_TYPE_CLOSE)
				break;
			if(event.type == EVENT_TYPE_KEY_PRESSED) {
				if(event.key == MAK_0)
					break;
			}
		}
		goto start;
	}
	return 0;
}
Ejemplo n.º 23
0
static int DUMMY_FlipHWSurface(_THIS, SDL_Surface *surface) {
	maUpdateScreen();
    return(0);
}
Ejemplo n.º 24
0
void LoadScreen::drawText(int y, const char *string, int rgb)
{
	maSetColor(rgb);
	maDrawText(PADDING*2, y, string);
	maUpdateScreen();
}
Ejemplo n.º 25
0
	void renderCursor(int h, int w)
	{
		maLine(w, h, w+8, h);
		maUpdateScreen();
	}
Ejemplo n.º 26
0
Archivo: main.c Proyecto: Felard/MoSync
int MAMain() {
	Handle conn;
	char ping[] = "ping\n";
	char buffer[1024];
	int res;

#ifdef CONPRINT
	InitConsole();
	gConsoleLogging = 1;
#endif

	//println("Socket test");
retry:
	printlnf("Connecting...");
	conn = maConnect("socket://130.237.3.104:6666");	//test DNS resolution
	res = AnimatedConnWait();
	if(res <= 0) {
		printlnf("err %i", res);
		goto exit;
	}
	/*conn = maConnect("socket://217.25.35.146:81");	//test IP address reading
	res = AnimatedConnWait();
	if(res <= 0) {
		printlnf("err %i", res);
		goto exit;
	}*/

	println("Writing...");
	maConnWrite(conn, ping, sizeof(ping));
	res = AnimatedConnWait();
	if(res <= 0) {
		printlnf("err %i", res);
		goto exit;
	}

	println("Reading...");

	res = ConnReadAtLeast(conn, 4, sizeof(buffer), buffer);
	if(res <= 0) {
		printlnf("err %i", res);
		goto exit;
	}
	maConnClose(conn);

	printlnf("Got %i bytes", res);

	buffer[res] = 0;
	println(buffer);
	maUpdateScreen();

exit:
	println("Press a key");
	for(;;) {
		EVENT event;
		while(maGetEvent(&event)) {
			if(event.type == EVENT_TYPE_CLOSE ||
				(event.type == EVENT_TYPE_KEY_PRESSED && event.key == MAK_0))
			{
				maExit(0);
			} else if(event.type == EVENT_TYPE_KEY_PRESSED) {
				goto retry;
			}
		}
		maWait(0);
	}
}
Ejemplo n.º 27
0
static void soft_updateScreen(void) {
	maUpdateScreen();
}
Ejemplo n.º 28
0
int RenderMain ( void )
{
	int 			tmrLast = 0;
	int 			currFps = 0,
					lastFps = 0;
	int 			frameIndex = 0;
	float 			frameInterp = 0;
	float			rotRadY = 0.0f,
					rotRadX = 0.0f;
	char			textBuffer[128];
	bool 			keyTable[4] = { false };
	bool focus = true;

	Matrix4fi		transMatrix( false );
	MAExtent		size = maGetScrSize( );
	MDLFixed 		model( RES_MODEL_OGRE );
	TransformPipe	pipe( EXTENT_X( size ), EXTENT_Y( size ) );


	// Center model
	model.centerModel( );

	tmrLast = maGetMilliSecondCount( );

	//
	// Rendering loop
	//
	while ( true )
	{
		//
		// Handle input
		//
		MAEvent e;
		while ( maGetEvent( &e ) )
		{
			if ( e.type == EVENT_TYPE_CLOSE ||
				 e.type == EVENT_TYPE_KEY_PRESSED ||
				 e.type == EVENT_TYPE_POINTER_PRESSED )
				maExit(0);
			else if(e.type == EVENT_TYPE_FOCUS_LOST)
				focus = false;
			else if(e.type == EVENT_TYPE_FOCUS_GAINED)
				focus = true;

			else if ( e.type == EVENT_TYPE_KEY_PRESSED )
			{
				if ( e.key == MAK_LEFT )
					keyTable[MAK_LEFT-MAK_UP] = true;
				else if ( e.key == MAK_RIGHT )
					keyTable[MAK_RIGHT-MAK_UP] = true;
				else if ( e.key == MAK_UP )
					keyTable[MAK_UP-MAK_UP] = true;
				else if ( e.key == MAK_DOWN )
					keyTable[MAK_DOWN-MAK_UP] = true;
			}
			else if ( e.type == EVENT_TYPE_KEY_RELEASED )
			{
				if ( e.key == MAK_LEFT )
					keyTable[MAK_LEFT-MAK_UP] = false;
				else if ( e.key == MAK_RIGHT )
					keyTable[MAK_RIGHT-MAK_UP] = false;
				else if ( e.key == MAK_UP )
					keyTable[MAK_UP-MAK_UP] = false;
				else if ( e.key == MAK_DOWN )
					keyTable[MAK_DOWN-MAK_UP] = false;
			}
		}

		if(focus) {
			if ( keyTable[MAK_LEFT-MAK_UP] )
				rotRadY -= (float)M_PI / 60;
			else if ( keyTable[MAK_RIGHT-MAK_UP] )
				rotRadY += (float)M_PI / 60;
			else if ( keyTable[MAK_UP-MAK_UP] )
				rotRadX -= (float)M_PI / 60;
			else if ( keyTable[MAK_DOWN-MAK_UP] )
				rotRadX += (float)M_PI / 60;

			rotRadX = (rotRadX >= 2*(float)M_PI) ? rotRadX-2*(float)M_PI : rotRadX;
			rotRadY = (rotRadY >= 2*(float)M_PI) ? rotRadY-2*(float)M_PI : rotRadY;

			//
			// Construct transformation pipe
			//
			pipe.resetPipe( );

			transMatrix.rotateX( (float)-M_PI/2 );
			pipe.addTransform( transMatrix );
			transMatrix.rotateY( (float)M_PI/4 );
			pipe.addTransform( transMatrix );

			transMatrix.rotateX( rotRadX );
			pipe.addTransform( transMatrix );
			transMatrix.rotateY( rotRadY );
			pipe.addTransform( transMatrix );
			transMatrix.translate( 0, 0, 130 );
			pipe.addTransform( transMatrix );


			// Clear screen
			maSetColor( 0 );
			maFillRect( 0, 0, EXTENT_X( size ), EXTENT_Y( size ) );

			//
			// Animate and render model
			//
			maSetColor( 0xffffff );
			model.drawFrameLerp( frameIndex, FLT2FIX( frameInterp ), pipe );
			frameInterp += 0.25f;
			if ( frameInterp >= 1.0f )
			{
				frameIndex  = (frameIndex+1) % model.getFrameCount( );
				frameInterp = 0.0f;
			}

			// Draw fps to screen
			sprintf( textBuffer, "fps: %d", lastFps );
			maDrawText( 0, 0, textBuffer );

			// Update screen and keep backlight on
			maUpdateScreen( );
			maResetBacklight( );

			// FPS counter
			currFps++;
			if ( tmrLast+1000 <= maGetMilliSecondCount( ) )
			{
				lastFps = currFps;
				currFps = 0;
				tmrLast = maGetMilliSecondCount( );
				lprintfln( "fps: %d", lastFps );
			}
		} else {	// no focus
			maWait(0);
		}
	}
}
Ejemplo n.º 29
0
void MoSyncStub::copyRect(uint16 x, uint16 y, uint16 w, uint16 h, const uint8 *buf, uint32 pitch) {
	FrameBuffer_copyRect(x, y, w, h, x, y, buf, pitch);
	maResetBacklight();
	maUpdateScreen();
}
Ejemplo n.º 30
0
void ImageScreen::keyPressEvent(int keyCode) {
	if (strcmp(Card::ORIENTATION_LANDSCAPE, card->getOrientation().c_str()) == 0) {
		//if it is a landscape card, the orientation must be switched
		switch(keyCode) {
			case MAK_UP:
			case MAK_DOWN:
				keyCode = MAK_LEFT;
				break;
			case MAK_LEFT:
				keyCode = MAK_DOWN;
				break;
			case MAK_RIGHT:
				keyCode = MAK_UP;
				break;
		}
	}

	switch (keyCode) {
		case MAK_LEFT:
		case MAK_RIGHT:
			imge->refreshWidget();
			imge->statAdded = false;
			currentSelectedStat = -1;

			flip=!flip;
			if (imge->getResource() != NULL) {
				maDestroyObject(imge->getResource());
			}
			imge->setResource(Util::loadImageFromResource(RES_LOADING1));
			imge->update();
			imge->requestRepaint();
			maUpdateScreen();
			if (flip) {
				Util::retrieveBack(imge, card, height-PADDING*2, imageCacheBack);
				Util::retrieveFront(NULL, card, height-PADDING*2, imageCacheFront);
			} else {
				Util::retrieveFront(imge, card, height-PADDING*2, imageCacheFront);
				Util::retrieveBack(NULL, card, height-PADDING*2, imageCacheBack);
			}
			currentSelectedStat = -1;
			break;
		case MAK_UP:
			if (imge->getResource() != RES_TEMP) {
				if(card->getStats().size()>0){
					selectStat(-1);
					if (currentSelectedStat == -1) {
						if (screenType == ST_NEW_CARD) {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Accept":"", "Reject", "Flip", layout);
						} else if (screenType == Util::AT_SHARE) {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Share":"", "Back", "Flip", layout);
						} else {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Options":"", "Back", "Flip", layout);
						}
						imge->refreshWidget();
						imge->statAdded = false;
					} else {
						if (screenType == ST_NEW_CARD) {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Accept":"", "Reject", "Flip", layout);
						} else if (screenType == Util::AT_SHARE) {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Share":"", "Back", "Flip", layout);
						} else {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Options":"", "Back", "Flip", layout);
						}
						imge->refreshWidget();
						if(flip==card->getStats()[currentSelectedStat]->getFrontOrBack()){
							imge->selectStat(card->getStats()[currentSelectedStat]->getLeft(),card->getStats()[currentSelectedStat]->getTop(),
									card->getStats()[currentSelectedStat]->getWidth(),card->getStats()[currentSelectedStat]->getHeight(),
									card->getStats()[currentSelectedStat]->getColorRed(), card->getStats()[currentSelectedStat]->getColorGreen(),
									card->getStats()[currentSelectedStat]->getColorBlue(), MobImage::PORTRAIT);
						}
					}
				}
			}
			break;
		case MAK_DOWN:
			if (imge->getResource() != RES_TEMP) {
				if(card->getStats().size()>0){
					selectStat(1);
					if (currentSelectedStat == -1) {
						if (screenType == ST_NEW_CARD) {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Accept":"", "Reject", "Flip", layout);
						} else if (screenType == Util::AT_SHARE) {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Share":"", "Back", "Flip", layout);
						} else {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Options":"", "Back", "Flip", layout);
						}
						imge->refreshWidget();
						imge->statAdded = false;
					} else {
						if (screenType == ST_NEW_CARD) {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Accept":"", "Reject", "Flip", layout);
						} else if (screenType == Util::AT_SHARE) {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Share":"", "Back", "Flip", layout);
						} else {
							Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Options":"", "Back", "Flip", layout);
						}
						imge->refreshWidget();
						if(flip==card->getStats()[currentSelectedStat]->getFrontOrBack()){
							imge->selectStat(card->getStats()[currentSelectedStat]->getLeft(),card->getStats()[currentSelectedStat]->getTop(),
									card->getStats()[currentSelectedStat]->getWidth(),card->getStats()[currentSelectedStat]->getHeight(),
									card->getStats()[currentSelectedStat]->getColorRed(), card->getStats()[currentSelectedStat]->getColorGreen(),
									card->getStats()[currentSelectedStat]->getColorBlue(), MobImage::PORTRAIT);
						} else {
							while((flip!=card->getStats()[currentSelectedStat]->getFrontOrBack())&&(currentSelectedStat <= card->getStats().size())){
								selectStat(1);
							}
							imge->selectStat(card->getStats()[currentSelectedStat]->getLeft(),card->getStats()[currentSelectedStat]->getTop(),
																card->getStats()[currentSelectedStat]->getWidth(),card->getStats()[currentSelectedStat]->getHeight(),
																card->getStats()[currentSelectedStat]->getColorRed(), card->getStats()[currentSelectedStat]->getColorGreen(),
																card->getStats()[currentSelectedStat]->getColorBlue(), MobImage::PORTRAIT);
						}
					}
				}
			}
			break;
		case MAK_SOFTLEFT:
			if (screenType == ST_NEW_CARD) {
				busy = true;
				acceptCard();
			} else if (screenType == Util::AT_SHARE) {
				if (next != NULL) {
					feed->remHttp();
					delete next;
				}
				next = new TradeFriendDetailScreen(this, feed, card);
				next->show();
			} else if (screenType == ST_VIEW_CARD) {

			} else {
				if (card != NULL && hasConnection && canAuction) {
					if (next != NULL) {
						feed->remHttp();
						delete next;
					}
					next = new OptionsScreen(feed,
							OptionsScreen::ST_CARD_OPTIONS, this, card);
					next->show();
				}
			}
			break;
		case MAK_BACK:
		case MAK_SOFTRIGHT:
			if (screenType == ST_NEW_CARD) {
				busy = true;
				rejectCard();
			}
			else {
				previous->show();
			}
			break;
		case MAK_FIRE:
			if (card != NULL) {
				if(((flipOrSelect && tapped)&&(currentSelectedStat == -1)) ||
						(!tapped && currentSelectedStat == -1)){
					flip=!flip;
					imge->refreshWidget();
					imge->statAdded = false;
					currentSelectedStat = -1;
					if (imge->getResource() != NULL) {
						maDestroyObject(imge->getResource());
					}
					imge->setResource(Util::loadImageFromResource(RES_LOADING1));
					imge->update();
					imge->requestRepaint();
					maUpdateScreen();
					if (flip) {
						if ((imageCacheBack != NULL)&&(imge != NULL)) {
							Util::retrieveBack(imge, card, height-PADDING*2, imageCacheBack);
							Util::retrieveFront(NULL, card, height-PADDING*2, imageCacheFront);
						}
					} else {
						if ((imageCacheFront != NULL)&&(imge != NULL)) {
							Util::retrieveFront(imge, card, height-PADDING*2, imageCacheFront);
							Util::retrieveBack(NULL, card, height-PADDING*2, imageCacheBack);
						}
					}
					flipOrSelect=0;
					currentSelectedStat = -1;
					tapped = false;
				}else{
					if (imge->getResource() != RES_TEMP) {
						if(currentSelectedStat>-1){
							if(flip==card->getStats()[currentSelectedStat]->getFrontOrBack()){
								imge->refreshWidget();
								imge->selectStat(card->getStats()[currentSelectedStat]->getLeft(),card->getStats()[currentSelectedStat]->getTop(),
										card->getStats()[currentSelectedStat]->getWidth(),card->getStats()[currentSelectedStat]->getHeight(),
										card->getStats()[currentSelectedStat]->getColorRed(), card->getStats()[currentSelectedStat]->getColorGreen(),
										card->getStats()[currentSelectedStat]->getColorBlue(), MobImage::PORTRAIT);
								Stat *stat = card->getStats()[currentSelectedStat];
								if ((strcmp(stat->getDesc().c_str(), "Mobile No") == 0)||
									(strcmp(stat->getDesc().c_str(), "Tel No") == 0) ){
									if (next != NULL) {
										feed->remHttp();
										delete next;
										next == NULL;
									}
									next = new OptionsScreen(feed, OptionsScreen::ST_NUMBER_OPTIONS, this, card, stat->getDisplay());
									next->show();
								} else if (strcmp(stat->getDesc().c_str(), "Email") == 0) {
									String email = stat->getDisplay();
									int ret = maPlatformRequest(("mailto:"+email).c_str());
									if (ret < 0 ) {
										ret = maPlatformRequest(email.c_str());
									}
									if (ret < 0) {
										MenuScreen *confirmation = new MenuScreen(RES_BLANK, "Feature currently not supported on device.");
										confirmation->setMenuWidth(170);
										confirmation->setMarginX(5);
										confirmation->setMarginY(5);
										confirmation->setDock(MenuScreen::MD_CENTER);
										confirmation->setListener(this);
										confirmation->setMenuFontSel(Util::getDefaultFont());
										confirmation->setMenuFontUnsel(Util::getDefaultFont());
										confirmation->setMenuSkin(Util::getSkinDropDownItem());
										confirmation->addItem("Ok");
										confirmation->show();
									}
								}
								else if ((strcmp(stat->getDesc().c_str(), "Web Address") == 0)||
										(strcmp(stat->getDesc().c_str(), "Social Media Link 1") == 0)||
										(strcmp(stat->getDesc().c_str(), "Social Media Link 1") == 0)||
										(strcmp(stat->getDesc().c_str(), "Social Media Link 1") == 0)||
										(strcmp(stat->getDesc().c_str(), "Social Media Link 1") == 0)||
										(strcmp(stat->getDesc().c_str(), "Social Media Link 1") == 0)) {
									String url = stat->getDisplay();
									//maPlatformRequest will only work if the url starts with http://
									//so we need to check for it, and add it if it isnt there
									if (url.find("http://") != 0) {
										url = "http://"+url;
									}
									int ret = maPlatformRequest(url.c_str());
									if (ret < 0) {
										MenuScreen *confirmation = new MenuScreen(RES_BLANK, "Feature currently not supported on device.");
										confirmation->setMenuWidth(170);
										confirmation->setMarginX(5);
										confirmation->setMarginY(5);
										confirmation->setDock(MenuScreen::MD_CENTER);
										confirmation->setListener(this);
										confirmation->setMenuFontSel(Util::getDefaultFont());
										confirmation->setMenuFontUnsel(Util::getDefaultFont());
										confirmation->setMenuSkin(Util::getSkinDropDownItem());
										confirmation->addItem("Ok");
										confirmation->show();
									}
								}
							}
						}
					}
				}
			} else {
				previous->show();
			}
			break;
	}
}