Exemple #1
0
void HandleEvent(SDL_Event* pEvt)
{
	switch(pEvt->type)
	{
	case SDL_QUIT:
		g_nQuit = true;
		break;
	case SDL_KEYUP:
		if(pEvt->key.keysym.scancode == SDL_SCANCODE_ESCAPE)
		{
			g_nQuit = 1;
		}
		if(pEvt->key.keysym.sym == 'z')
		{
			MicroProfileToggleDisplayMode();
		}
		if(pEvt->key.keysym.sym == 'x')
		{
			bool bForceEnable = MicroProfileGetForceEnable();
			MicroProfileSetForceEnable(!bForceEnable);
			printf("force enable is %d\n", !bForceEnable);
		}
		if(pEvt->key.keysym.sym == 'c')
		{
			bool bEnable = MicroProfileGetEnableAllGroups();
			MicroProfileSetEnableAllGroups(!bEnable);
			printf("enable all groups is %d\n", !bEnable);
		}
		if(pEvt->key.keysym.scancode == SDL_SCANCODE_RSHIFT)
		{
			MicroProfileTogglePause();
		}
		if(pEvt->key.keysym.scancode == SDL_SCANCODE_LCTRL)
		{
			MicroProfileModKey(0);
		}
		if(pEvt->key.keysym.sym == 'a')
		{
			MicroProfileDumpTimers();
		}
#if MICROPROFILE_WEBSERVER
		if(pEvt->key.keysym.sym == 'd')
		{
			MicroProfileDumpFile("../dump.html", "../dump.csv");
		}
#endif
		if(pEvt->key.keysym.sym == 'l')
		{
			MicroProfileCustomGroupToggle("Custom1");
		}

		if(pEvt->key.keysym.sym == 't')
		{
			static bool toggle = false;
			if(toggle)
			{
				MicroProfileEnableCategory("ThreaDS");
			}
			else
			{
				MicroProfileDisableCategory("ThreaDS");
			}
			toggle = !toggle;
		}
		break;


		break;
	case SDL_KEYDOWN:
		if(pEvt->key.keysym.scancode == SDL_SCANCODE_LCTRL)
		{
			MicroProfileModKey(1);
		}
		break;
	case SDL_MOUSEMOTION:
		g_MouseX = pEvt->motion.x;
		g_MouseY = pEvt->motion.y;
		break;
	case SDL_MOUSEBUTTONDOWN:
		if(pEvt->button.button == 1)
			g_MouseDown0 = 1;
		else if(pEvt->button.button == 3)
			g_MouseDown1 = 1;
		break;
	case SDL_MOUSEBUTTONUP:
		if(pEvt->button.button == 1)
		{
			g_MouseDown0 = 0;
		}
		else if(pEvt->button.button == 3)
		{
			g_MouseDown1 = 0;
		}
		break;
	case SDL_MOUSEWHEEL:
			g_MouseDelta -= pEvt->wheel.y;
		break;
	}



}
Exemple #2
0
void HandleEvent(SDL_Event* pEvt)
{
	switch(pEvt->type)
	{
	case SDL_QUIT:
		g_nQuit = true;
		break;
	case SDL_KEYUP:
		if(pEvt->key.keysym.scancode == SDL_SCANCODE_ESCAPE)
		{
			g_nQuit = 1;
		}
		if(pEvt->key.keysym.sym == 'z')
		{
			MicroProfileToggleDisplayMode();
		}
		if(pEvt->key.keysym.sym == 'x')
		{
			bool bForceEnable = MicroProfileGetForceEnable();
			MicroProfileSetForceEnable(!bForceEnable);
			printf("force enable is %d\n", !bForceEnable);
		}
		if(pEvt->key.keysym.sym == 'c')
		{
			bool bEnable = MicroProfileGetEnableAllGroups();
			MicroProfileSetEnableAllGroups(!bEnable);
			printf("enable all groups is %d\n", !bEnable);
		}
		if(pEvt->key.keysym.scancode == SDL_SCANCODE_RSHIFT)
		{
			MicroProfileTogglePause();
		}
		if(pEvt->key.keysym.scancode == SDL_SCANCODE_LCTRL)
		{
			MicroProfileModKey(0);
		}
		if(pEvt->key.keysym.sym == 'a')
		{
			MicroProfileDumpTimers();
		}
		if(pEvt->key.keysym.sym == 'd')
		{
			MicroProfileDumpHtml("../dump.html");
		}
		break;


		break;
	case SDL_KEYDOWN:
		if(pEvt->key.keysym.scancode == SDL_SCANCODE_LCTRL)
		{
			MicroProfileModKey(1);
		}
		break;
	case SDL_MOUSEMOTION:
		g_MouseX = pEvt->motion.x;
		g_MouseY = pEvt->motion.y;
		break;
	case SDL_MOUSEBUTTONDOWN:
		if(pEvt->button.button == 1)
			g_MouseDown0 = 1;
		else if(pEvt->button.button == 3)
			g_MouseDown1 = 1;
		break;
	case SDL_MOUSEBUTTONUP:
		if(pEvt->button.button == 1)
		{
			g_MouseDown0 = 0;
		}
		else if(pEvt->button.button == 3)
		{
			g_MouseDown1 = 0;
		}
		break;
	case SDL_MOUSEWHEEL:
			g_MouseDelta -= pEvt->wheel.y;
		break;
	}



}