Ejemplo n.º 1
0
 void onActivityEvent(int inVal)
 {
     __android_log_print(ANDROID_LOG_INFO, "NME", "Activity action %d", inVal);
     if (inVal==1 || inVal==2)
     {
         Event evt( inVal==1 ? etActivate : etDeactivate );
         HandleEvent(evt);
     }
 }
bool EdgeBarrierController::Impl::HandleEventCB(XEvent xevent, void* data)
{
  auto edge_barrier_controller = static_cast<EdgeBarrierController::Impl*>(data);
  int const xi2_opcode = edge_barrier_controller->xi2_opcode_;

  if (xevent.type != GenericEvent || xevent.xcookie.extension != xi2_opcode)
    return false;

  return edge_barrier_controller->HandleEvent(xevent);
}
Ejemplo n.º 3
0
// == OIS INPUT ==
bool Client::mouseMoved(const OIS::MouseEvent &arg) {
    if(!mGameStateManager.GetCurrentState()->GetGUI()->injectMouseMove(arg.state.X.abs, arg.state.Y.abs, arg.state.Z.abs)) {
        Event e("input:mouse:moved");
        e.WriteData(arg.state.buttonDown(OIS::MB_Left));
        e.WriteData(arg.state.buttonDown(OIS::MB_Right));
        e.WriteData(arg.state.X.rel);
        e.WriteData(arg.state.Y.rel);
        HandleEvent(e);
    }
}
Ejemplo n.º 4
0
bool Client::mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id) {
    if(!mGameStateManager.GetCurrentState()->GetGUI()->injectMouseRelease(arg.state.X.abs, arg.state.Y.abs, MyGUI::MouseButton::Enum(id))) {
        Event e("input:mouse:released");
        e.WriteData(arg.state.buttonDown(OIS::MB_Left));
        e.WriteData(arg.state.buttonDown(OIS::MB_Right));
        e.WriteData(arg.state.X.abs);
        e.WriteData(arg.state.Y.abs);
        HandleEvent(e);
    }
}
Ejemplo n.º 5
0
void Client::MainLoop(void)
{
    GLenum statusGL;
    SDL_Event event;
    Uint32 ticks0 = SDL_GetTicks(), ticks;
    float dt;
    char errorString[260];

    while (!done)
    {
#ifdef DEBUG
        // Check for openGL errors
        while ((statusGL = glGetError()) != GL_NO_ERROR)
        {
            GLErrorString(errorString, statusGL);
            fprintf (stderr, "GL Error during main loop: %s\n", errorString);
        }
#endif // DEBUG

        // Handle all events in queue
        SDL_Event event;
        while (SDL_PollEvent (&event)) {

            HandleEvent (&event);
        }

        while(SDLNet_UDP_Recv(udp_socket, fromServer))
        {
            if (fromServer->address.host == serverAddress.host &&
                fromServer->address.port == serverAddress.port)
            {
                if(pScene)
                    pScene->OnServerMessage (fromServer->data, fromServer->len);
            }
        }

        // determine how much time passed since last iteration:
        ticks = SDL_GetTicks();
        dt = float(ticks - ticks0) / 1000;
        ticks0 = ticks;

        if (dt > 0.05f)
            dt = 0.05f;

        if (pScene)
        {
            pScene->Update (dt);
            pScene->Render ();
        }

        // Show whatever is rendered in the main window
        SDL_GL_SwapWindow (mainWindow);
    }
}
Ejemplo n.º 6
0
bool
X11EventQueue::OnFileEvent(FileDescriptor fd, unsigned mask)
{
  while(XPending(display)) {
    XEvent event;
    XNextEvent(display, &event);
    HandleEvent(event);
  }

  return true;
}
Ejemplo n.º 7
0
void AsyncRequests::PullEventsInternal()
{
  // This is only called if the queue isn't empty.
  // So just flush the pipeline to get accurate results.
  g_vertex_manager->Flush();

  std::unique_lock<std::mutex> lock(m_mutex);
  m_empty.Set();

  while (!m_queue.empty())
  {
    Event e = m_queue.front();

    // try to merge as many efb pokes as possible
    // it's a bit hacky, but some games render a complete frame in this way
    if ((e.type == Event::EFB_POKE_COLOR || e.type == Event::EFB_POKE_Z))
    {
      m_merged_efb_pokes.clear();
      Event first_event = m_queue.front();
      const auto t = first_event.type == Event::EFB_POKE_COLOR ? EFBAccessType::PokeColor :
                                                                 EFBAccessType::PokeZ;

      do
      {
        e = m_queue.front();

        EfbPokeData d;
        d.data = e.efb_poke.data;
        d.x = e.efb_poke.x;
        d.y = e.efb_poke.y;
        m_merged_efb_pokes.push_back(d);

        m_queue.pop();
      } while (!m_queue.empty() && m_queue.front().type == first_event.type);

      lock.unlock();
      g_renderer->PokeEFB(t, m_merged_efb_pokes.data(), m_merged_efb_pokes.size());
      lock.lock();
      continue;
    }

    lock.unlock();
    HandleEvent(e);
    lock.lock();

    m_queue.pop();
  }

  if (m_wake_me_up_again)
  {
    m_wake_me_up_again = false;
    m_cond.notify_all();
  }
}
Ejemplo n.º 8
0
void Demo::Loop() {

    while (Running)
    {
        // message processing loop
        while(SDL_PollEvent(&event)) {
            HandleEvent(&event);
        }

        Render();
    }
}
int CBPlatform::MessageLoop()
{
	bool done = false;

	while (!done)
	{
		SDL_Event event;
		while (SDL_PollEvent(&event))
		{
			HandleEvent(&event);
		}

		if(Game && Game->m_Renderer->m_Active && Game->m_Renderer->m_Ready)
		{

			Game->DisplayContent();
			Game->DisplayQuickMsg();

			Game->DisplayDebugInfo();
			Game->m_Renderer->SendRenderingHintSceneComplete();

			// ***** flip
			
			if(!Game->m_SuspendedRendering) Game->m_Renderer->Flip();
			if(Game->m_Loading) Game->LoadGame(Game->m_ScheduledLoadSlot);
		}
		if(Game->m_Quitting) break;

	}

	if(Game)
	{
		// remember previous window position
		/*
		if(Game->m_Renderer && Game->m_Renderer->m_Windowed)
		{
			if(!::IsIconic(Game->m_Renderer->m_Window))
			{
				int PosX = Game->m_Renderer->m_WindowRect.left;
				int PosY = Game->m_Renderer->m_WindowRect.top;
				PosX -= Game->m_Renderer->m_MonitorRect.left;
				PosY -= Game->m_Renderer->m_MonitorRect.top;

				Game->m_Registry->WriteInt("Video", "WindowPosX", PosX);
				Game->m_Registry->WriteInt("Video", "WindowPosY", PosY);
			}
		}
		*/

		SAFE_DELETE(Game);
	}
	return 0;
}
Ejemplo n.º 10
0
bool InputEventController::OnKeyPressed(const SDL_KeyboardEvent& arg)
{
	SDL_Keycode kc = arg.keysym.sym;
	auto textInputActive = SDL_IsTextInputActive();

	if (textInputActive) {
		SDL_Keycode nkc = kc;

		// Map numpad enter to the "normal" enter so action subscribers don't need to
		// check for both.
		if (nkc == SDLK_KP_ENTER)
			nkc = SDLK_RETURN;

		switch (nkc) {
			case SDLK_BACKSPACE:
			case SDLK_RETURN:
				// For now, key_t values are mapped directly to SDL keycodes for
				// convenience.
				(*actions.ui.control)(static_cast<TextControl::key_t>(nkc));
				break;
		}
	}

	// make left and right modifiers equal
	if (kc == SDLK_RSHIFT)
		kc = SDLK_LSHIFT;
	else if (kc == SDLK_RCTRL)
		kc = SDLK_LCTRL;
	else if (kc == SDLK_RGUI)
		kc = SDLK_LGUI;

	// Hotkeys are fired in addition to the normal bound action, but we don't
	// want to interfere with text input.
	if (!textInputActive) {
		auto iter = hotkeys.find(kc);
		if (iter != hotkeys.end()) {
			(*(iter->second))(1);
		}
	}

	auto hash = HashKeyboardEvent(kc);

	// Flip the meaning of menuNext if shift is held down.
	if (IsMapActive(ActionMapId::MENU) &&
		hash == actions.ui.menuNext->GetPrimaryTrigger() &&
		(SDL_GetModState() & KMOD_SHIFT))
	{
		hash = actions.ui.menuPrev->GetPrimaryTrigger();
	}

	HandleEvent(hash, 1);
	return true;
}
Ejemplo n.º 11
0
void main()
{
	FATFS fs;
	FIL file;

	InitMCU();
	//VS_SinTest(0x74);
	VS_Init();

	if(disk_initialize(0))
		ConsoleWrite("Disk Initialization FAILED. :(\n");
	else
		ConsoleWrite("Disk Initialization Complete.\n");

	if(f_mount(0,&fs))
		ConsoleWrite("Mount FieSystem Failed\n");
	else
		ConsoleWrite("Mount FileSystem Success!\n");

	ConsoleWrite("Scaning Music Files...\n\n");
	if(scan_files("/",&(Player.TotalSongNum)))
		ConsoleWrite("Scan Files Failed\n");
	else{
		ConsoleWrite("\nScan Files Accomplished.\ntotal files: ");
		ConsolePutUInt (Player.TotalSongNum);
		ConsoleWrite ("\n\n");}

	if(scan_files_open (&file,"/",1))       // Start node to be scanned and opened
		ConsoleWrite("Open File Error\n");  //Playing mp3/track001.mp3 ... will apear in function		

	
	Player.currFile	= &file;
	Player.SongNum	= 1;
	Player.Status	= PS_PLAYING;
	Player.Mode		= SM_SONG;
	Player.Volume	= 170;
	Player.Bass		= 7;
	Player.Treble	= 0;

	VS_SetBassTreble(Player.Bass,Player.Treble);

	BufCnt = 0;
//	GenerateEvent(EV_BUFEMPTY);

	//Main loop
	while(1)
	{
		//Get system event
		Player.Event = GetEvent();
		//Handle Events
		HandleEvent();
	}
}
Ejemplo n.º 12
0
	bool SDLApplication::Update () {
		
		SDL_Event event;
		event.type = -1;
			
		if (active && (firstTime || SDL_WaitEvent (&event))) {
			
			firstTime = false;
			
			HandleEvent (&event);
			event.type = -1;
			if (!active)
				return active;
			
			if (SDL_PollEvent (&event)) {
				
				HandleEvent (&event);
				event.type = -1;
				
			}
			
			currentUpdate = SDL_GetTicks ();
			
			if (currentUpdate >= nextUpdate) {
				
				SDL_RemoveTimer (timerID);
				OnTimer (0, 0);
				
			} else if (!timerActive) {
				
				timerActive = true;
				timerID = SDL_AddTimer (nextUpdate - currentUpdate, OnTimer, 0);
				
			}
			
		}
		
		return active;
		
	}
Ejemplo n.º 13
0
DllExport 
PF_Err 
EntryPointFunc (	
	PF_Cmd				cmd,
	PF_InData			*in_data,
	PF_OutData			*out_data,
	PF_ParamDef			*params[],
	PF_LayerDef			*output,
	void				*extra)
{
	PF_Err		err = PF_Err_NONE;
	
	try {
		switch (cmd) {

		case PF_Cmd_ABOUT:
			err = About(in_data, out_data, params, output);
			break;

		case PF_Cmd_GLOBAL_SETUP:
			err = GlobalSetup(	in_data, out_data, params, output);
			break;

		case PF_Cmd_PARAMS_SETUP:
			err = ParamsSetup(	in_data, out_data, params, output);
			break;

		case PF_Cmd_RENDER:
			err = Render(	in_data, out_data, params, output);
			break;

		case PF_Cmd_EVENT:
			err = HandleEvent(	in_data, out_data, params, output, reinterpret_cast<PF_EventExtra*>(extra));
			break;

		case PF_Cmd_ARBITRARY_CALLBACK:
			err = HandleArbitrary(	in_data, out_data, params, output, reinterpret_cast<PF_ArbParamsExtra*>(extra));
			break;
			
		case  PF_Cmd_SMART_PRE_RENDER:
			err = PreRender(in_data, out_data, reinterpret_cast<PF_PreRenderExtra*>(extra));
			break;

		case  PF_Cmd_SMART_RENDER:
			err = SmartRender(	in_data, out_data, reinterpret_cast<PF_SmartRenderExtra*>(extra));
			break;
		}
	} catch (PF_Err &thrown_err) {
		err = thrown_err;
	}
	return err;
}
int OPLMIDIDevice::PlayTick()
{
	DWORD delay = 0;

	while (delay == 0 && Events != NULL)
	{
		DWORD *event = (DWORD *)(Events->lpData + Position);
		if (MEVT_EVENTTYPE(event[2]) == MEVT_TEMPO)
		{
			SetTempo(MEVT_EVENTPARM(event[2]));
		}
		else if (MEVT_EVENTTYPE(event[2]) == MEVT_LONGMSG)
		{ // Should I handle master volume changes?
		}
		else if (MEVT_EVENTTYPE(event[2]) == 0)
		{ // Short MIDI event
			int status = event[2] & 0xff;
			int parm1 = (event[2] >> 8) & 0x7f;
			int parm2 = (event[2] >> 16) & 0x7f;
			HandleEvent(status, parm1, parm2);
		}

		// Advance to next event.
		if (event[2] < 0x80000000)
		{ // Short message
			Position += 12;
		}
		else
		{ // Long message
			Position += 12 + ((MEVT_EVENTPARM(event[2]) + 3) & ~3);
		}

		// Did we use up this buffer?
		if (Position >= Events->dwBytesRecorded)
		{
			Events = Events->lpNext;
			Position = 0;

			if (Callback != NULL)
			{
				Callback(MOM_DONE, CallbackData, 0, 0);
			}
		}

		if (Events == NULL)
		{ // No more events. Just return something to keep the song playing
		  // while we wait for more to be submitted.
			return int(Division);
		}

		delay = *(DWORD *)(Events->lpData + Position);
	}
Ejemplo n.º 15
0
void wxAppConsoleBase::CallEventHandler(wxEvtHandler *handler,
                                        wxEventFunctor& functor,
                                        wxEvent& event) const
{
    // If the functor holds a method then, for backward compatibility, call
    // HandleEvent():
    wxEventFunction eventFunction = functor.GetMethod();

    if ( eventFunction )
        HandleEvent(handler, eventFunction, event);
    else
        functor(handler, event);
}
Ejemplo n.º 16
0
GUI_Status Window::EventLoop( void ) {
  SDL_Event event;
  GUI_Status rc;

  do {
    rc = view->FetchEvent( event );

    if ( (rc != GUI_QUIT) && (rc != GUI_ERROR) )
      rc = HandleEvent( event );
  } while ( rc == GUI_OK );

  return rc;
}
Ejemplo n.º 17
0
void GMApplication::Run()
{
	bool quit = false;
	SDL_Event e;

	FrameTimer.start();
	int oldticks = 0;
    fps.start();
	while( !quit )
	{
		//Handle events on queue
		while( SDL_PollEvent( &e ) != 0 )
		{
			if( e.type == SDL_QUIT )
			{
				quit = true;
			}

			HandleEvent(e);
		}

		int tick = FrameTimer.getTicks();
		Update((float)(tick - oldticks)/1000.f);

		SDL_SetRenderDrawColor( Renderer, 0x00, 0x00, 0x00, 0xff);
		SDL_RenderClear( Renderer );
		Draw((float)(tick - oldticks)/1000.f);
		SDL_RenderPresent( Renderer );

        framecount++;

        if (fps.getTicks() > 1000)
        {
            int FPS = framecount / (tick/1000.f);

            if (Settings::Debug)
            {
                std::stringstream _fpstitle;
                _fpstitle << Title << " FPS: " << FPS;
                SDL_SetWindowTitle(Window,_fpstitle.str().c_str());
            }
            else
                SDL_SetWindowTitle(Window, Title.c_str());


            fps.start();
        }

        oldticks = tick;
	}
}
Ejemplo n.º 18
0
   void OnTouch(int inType,double inX, double inY, int inID, float sizeX, float sizeY)
   {
         if (mSingleTouchID==NO_TOUCH || inID==mSingleTouchID || mMultiTouch)
         {
            EventType type = (EventType)inType;
            if (!mMultiTouch)
            {
               switch(inType)
               {
                  case  etTouchBegin: type = etMouseDown; break;
                  case  etTouchEnd:   type = etMouseUp; break;
                  case  etTouchMove : type = etMouseMove; break;
                  case  etTouchTap:   return; break;
               }
            }

               Event mouse(type, inX, inY);
               if (mSingleTouchID==NO_TOUCH || inID==mSingleTouchID || !mMultiTouch)
                  mouse.flags |= efPrimaryTouch;

               if (inType==etTouchBegin)
               {
                  if (mSingleTouchID==NO_TOUCH)
                     mSingleTouchID = inID;
                  mouse.flags |= efLeftDown;
                  mDownX = inX;
                  mDownY = inY;
               }
               else if (inType==etTouchEnd)
               {
                  if (mSingleTouchID==inID)
                     mSingleTouchID = NO_TOUCH;
               }
               else if (inType==etTouchMove)
               {
                  mouse.flags |= efLeftDown;
               }
               mouse.value = inID;
               
               mouse.sx = sizeX;
               mouse.sy = sizeY;

               //if (inType==etTouchBegin)
                  //ELOG("DOWN %d %f,%f (%s) %f,%f", inID, inX, inY, (mouse.flags & efPrimaryTouch) ? "P":"S", sizeX, sizeY );

               //if (inType==etTouchEnd)
                  //ELOG("UP %d %f,%f (%s) %f,%f", inID, inX, inY, (mouse.flags & efPrimaryTouch) ? "P":"S", sizeX, sizeY );

               HandleEvent(mouse);
         }
   }
static pascal void MyPrivateEventProc( const NavEventCallbackMessage callbackSelector,
                                       NavCBRecPtr callbackParms,
                                       NavCallBackUserData callbackUD )
{
    switch ( callbackSelector )
    {
    case kNavCBEvent:
    {
        switch (callbackParms->eventData.eventDataParms.event->what)
        {
        case updateEvt:
        case activateEvt:
            HandleEvent(callbackParms->eventData.eventDataParms.event);
            break;
        }
    }
    break;

    case kNavCBUserAction:
    {
        if ( callbackParms->userAction == kNavUserActionOpen )
        {
            // This is an open files action, send an AppleEvent
            NavReplyRecord	reply;
            OSStatus		status;

            status = NavDialogGetReply( callbackParms->context, &reply );
            if ( status == noErr )
            {
                SendOpenAE( reply.selection );
                NavDisposeReply( &reply );
            }
        }
    }
    break;

    case kNavCBTerminate:
    {
        if ( callbackParms->context == gOpenFileDialog )
        {
            NavDialogDispose( gOpenFileDialog );
            gOpenFileDialog = NULL;
        }

        // if after dismissing the dialog SimpleText has no windows open (so Activate event will not be sent) -
        // call AdjustMenus ourselves to have at right menus enabled
        if (FrontWindow() == nil) AdjustMenus(nil, true, false);
    }
    break;
    }
}
Ejemplo n.º 20
0
    void GUIMgr::Update(a_uint64 t_diff)
    {
        /**/

        if(m_veEvents.empty() || m_vwWidget.empty())
            return;
        
        for(a_uint32 i = 0; i < m_veEvents.size(); i++)
        {
            HandleEvent(m_veEvents[i]);
        }

        m_veEvents.clear();
    }
Ejemplo n.º 21
0
bool InputEventController::OnMouseMoved(const SDL_MouseMotionEvent& evt)
{
	int x = evt.xrel;
	int y = evt.yrel;

	int ax = abs(x);
	int ay = abs(y);

	if (ax > 0)
		HandleEvent(HashMouseAxisEvent(AXIS_X, (x > 0) ? 1 : 0), ax);
	if (ay > 0)
		HandleEvent(HashMouseAxisEvent(AXIS_Y, (y > 0) ? 1 : 0), ay);

	// For some events (e.g. mouse wheel), we want to pass the mouse position
	// but the SDL event doesn't pass it along.  So, we just keep track of the
	// last recorded mouse position and use that.
	mousePos.x = evt.x;
	mousePos.y = evt.y;

	(*actions.ui.mouseMoved)(mousePos);

	return true;
}
Ejemplo n.º 22
0
void Arti3DApp::Run()
{
	while (m_bRunning)
	{
		SDL_Event event;
		while (SDL_PollEvent(&event))
			HandleEvent(event, this);

		RenderScene();
		CalculateFPS();

		m_pWindow->UpdateSurface();
	}
}
Ejemplo n.º 23
0
void AsyncRequests::PullEventsInternal()
{
	std::unique_lock<std::mutex> lock(m_mutex);
	m_empty.store(true);

	while (!m_queue.empty())
	{
		Event e = m_queue.front();

		// try to merge as many efb pokes as possible
		// it's a bit hacky, but some games render a complete frame in this way
		if ((e.type == Event::EFB_POKE_COLOR || e.type == Event::EFB_POKE_Z))
		{
			m_merged_efb_pokes.clear();
			Event first_event = m_queue.front();
			EFBAccessType t = first_event.type == Event::EFB_POKE_COLOR ? POKE_COLOR : POKE_Z;

			do
			{
				e = m_queue.front();

				EfbPokeData d;
				d.data = e.efb_poke.data;
				d.x = e.efb_poke.x;
				d.y = e.efb_poke.y;
				m_merged_efb_pokes.push_back(d);

				m_queue.pop();
			} while(!m_queue.empty() && m_queue.front().type == first_event.type);

			lock.unlock();
			g_renderer->PokeEFB(t, m_merged_efb_pokes.data(), m_merged_efb_pokes.size());
			lock.lock();
			continue;
		}

		lock.unlock();
		HandleEvent(e);
		lock.lock();

		m_queue.pop();
	}

	if (m_wake_me_up_again)
	{
		m_wake_me_up_again = false;
		m_cond.notify_all();
	}
}
Ejemplo n.º 24
0
    HRESULT Player_::Invoke(IMFAsyncResult *pResult)
    {
      MediaEventType meType = MEUnknown;  // Event type

      IMFMediaEventPtr pEvent;

      try {
        // Get the event from the event queue.
        THROW_IF_ERR(m_pSession->EndGetEvent(pResult, pEvent.GetAddressOf()));

        // Get the event type. 
        THROW_IF_ERR(pEvent->GetType(&meType));

        if (meType == MESessionClosed)
        {
          // The session was closed. 
          // The application is waiting on the m_hCloseEvent event handle. 
          SetEvent(m_hCloseEvent);
        }
        else
        {
          // For all other events, get the next event in the queue.
          THROW_IF_ERR(m_pSession->BeginGetEvent(this, NULL));
        }

        // Check the application state. 

        // If a call to IMFMediaSession::Close is pending, it means the 
        // application is waiting on the m_hCloseEvent event and
        // the application's message loop is blocked. 

        // Otherwise, post a private window message to the application. 

        //if (m_state != Closing)
        //{
        //  // Leave a reference count on the event.

        //  //PostMessage(m_hwndEvent, WM_APP_PLAYER_EVENT, 
        //  //  (WPARAM) pEvent.Detach(), (LPARAM)meType);
        //}

        HandleEvent((UINT_PTR)pEvent.Detach());

        return S_OK;
      } catch (win32_error_exception& e) 
      {
        return e.hresult();
      }
    }
Ejemplo n.º 25
0
void BOCTX::Sweep(SEGM2 * aSegms, UINT32 nSegms)
{
	CollectEvents(aSegms, nSegms);

	while (not m_E.empty())
	{
		// store the current state of main active list
		SAVE_LIST save_list;
		save_list.reserve(32);
		
		for (SEGM_LIST::iterator segm = m_S.begin(); segm != m_S.end(); ++segm)
			save_list.push_back(&*segm);

		// do Pass 1
		EVENT e = m_E.top();
		m_E.pop();
		EVENTLIST elist;
		elist.reserve(8);

		assert(INT20_MIN <= e.x and e.x <= INT20_MAX);

			AddEvent(&elist, e);
			HandleEvent(e);

		while (not m_E.empty() and m_E.top().x == e.x)
		{
			e = m_E.top();
			m_E.pop();
			AddEvent(&elist, e);
			HandleEvent(e);
		}

		// do Pass 2
		Pass2(&elist, &save_list);
	}
} // Sweep
Ejemplo n.º 26
0
void ZoomPicture (SDL_Surface *screen, SDL_Surface *picture, int smooth) 
{
	SDL_Surface *rotozoom_picture;
	SDL_Rect dest;
	int framecount, framemax, frameinc;
	double zoomxf,zoomyf;

	fprintf(stderr, "%s\n", messageText);

	/* Zoom and display the picture */
	framemax=4*360; frameinc=1;
	for (framecount=360; framecount<framemax; framecount += frameinc) {
		if ((framecount % 360)==0) frameinc++;
		HandleEvent();
		ClearScreen(screen);
		zoomxf=(float)framecount/(float)framemax;
		zoomxf=1.5*zoomxf*zoomxf;
		zoomyf=0.5+fabs(1.0*sin((double)framecount/80.0));
		if ((framecount % 120)==0) {
			printf ("  Frame: %i   Zoom: x=%.2f y=%.2f\n",framecount,zoomxf,zoomyf);
		}
		if ((rotozoom_picture=zoomSurface (picture, zoomxf, zoomyf, smooth))!=NULL) {
			dest.x = (screen->w - rotozoom_picture->w)/2;;
			dest.y = (screen->h - rotozoom_picture->h)/2;
			dest.w = rotozoom_picture->w;
			dest.h = rotozoom_picture->h;
			if ( SDL_BlitSurface(rotozoom_picture, NULL, screen, &dest) < 0 ) {
				fprintf(stderr, "Blit failed: %s\n", SDL_GetError());
				break;
			}
			SDL_FreeSurface(rotozoom_picture);
		}

		stringRGBA(screen, 8, 8, messageText, 255, 255, 255, 255);
		
		/* Display by flipping screens */
		SDL_Flip(screen);

		/* Maybe delay */
		if (delay>0) {
			SDL_Delay(delay);
		}
	}

	/* Pause for a sec */
	SDL_Delay(1000);
}
Ejemplo n.º 27
0
void RotatePicture90Degrees (SDL_Surface *screen, SDL_Surface *picture) 
{
	SDL_Surface *rotozoom_picture;
	SDL_Rect dest;
	int framecount, framemax, frameinc;
	int numClockwiseTurns;

	fprintf(stderr, "%s\n", messageText);

	/* Rotate and display the picture */
	framemax = 21;
	frameinc = 1;
	numClockwiseTurns = -4;
	for (framecount=0; framecount<framemax; framecount += frameinc) {
		HandleEvent();
		ClearScreen(screen);
		printf ("  Frame: %i   Rotate90: %i clockwise turns\n",framecount,numClockwiseTurns+4);
		if ((rotozoom_picture=rotateSurface90Degrees(picture, numClockwiseTurns))!=NULL) {
			dest.x = (screen->w - rotozoom_picture->w)/2;;
			dest.y = (screen->h - rotozoom_picture->h)/2;
			dest.w = rotozoom_picture->w;
			dest.h = rotozoom_picture->h;
			if ( SDL_BlitSurface(rotozoom_picture, NULL, screen, &dest) < 0 ) {
				fprintf(stderr, "Blit failed: %s\n", SDL_GetError());
				break;
			}
			SDL_FreeSurface(rotozoom_picture);
		}

		stringRGBA(screen, 8, 8, messageText, 255, 255, 255, 255);

		/* Display by flipping screens */
		SDL_Flip(screen);

		/* Always delay */
		SDL_Delay(333);
		if (delay>0) {
			SDL_Delay(delay);
		}

		numClockwiseTurns++;
	}

	/* Pause for a sec */
	SDL_Delay(1000);
}
Ejemplo n.º 28
0
EmptyEventQueue()
{
    XEvent event;
    emptying = TRUE;
    do {
	while (XPending()) {
	    XPeekEvent(&event);
	    if (event.type & (KeyPressed | KeyReleased | MouseMoved |
			      ButtonPressed | ButtonReleased))
		XNextEvent(&event);
	    else
		HandleEvent();
	}
	XSync(0);
    } while (XPending());
    emptying = FALSE;
}
Ejemplo n.º 29
0
// protected:
status_t AbstractFileInterfaceNode::HandleStart(
						const media_timed_event *event,
						bigtime_t lateness,
						bool realTimeEvent)
{
	CALLED();

	if (RunState() != B_STARTED) {
		// XXX: Either use the following line or the lines that are not commented.
		// There doesn't seem to be a practical difference that i can tell.
		//		HandleBuffer(event,lateness,realTimeEvent);
		media_timed_event firstBufferEvent(event->event_time, BTimedEventQueue::B_HANDLE_BUFFER);
		HandleEvent(&firstBufferEvent, 0, false);
		EventQueue()->AddEvent(firstBufferEvent);
	}
	return B_OK;
}
Ejemplo n.º 30
0
void Client::windowResized(Ogre::RenderWindow* rw) {
	unsigned int width, height, depth;
	int left, top;
	rw->getMetrics(width, height, depth, left, top);

	const OIS::MouseState &ms = mMouse->getMouseState();
	ms.width = width;
	ms.height = height;

	Event e("window:resized");
	e.WriteData(width);
	e.WriteData(height);
	e.WriteData(depth);
	e.WriteData(left);
	e.WriteData(top);
	HandleEvent(e);
}