コード例 #1
0
void FIOSApplication::PollGameDeviceState( const float TimeDelta )
{
	// initialize any externally-implemented input devices (we delay load initialize the array so any plugins have had time to load)
	if (!bHasLoadedInputPlugins)
	{
		TArray<IInputDeviceModule*> PluginImplementations = IModularFeatures::Get().GetModularFeatureImplementations<IInputDeviceModule>(IInputDeviceModule::GetModularFeatureName());
		for (auto InputPluginIt = PluginImplementations.CreateIterator(); InputPluginIt; ++InputPluginIt)
		{
			TSharedPtr<IInputDevice> Device = (*InputPluginIt)->CreateInputDevice(MessageHandler);
			AddExternalInputDevice(Device);
		}

		bHasLoadedInputPlugins = true;
	}

	// Poll game device state and send new events
	InputInterface->Tick(TimeDelta);
	InputInterface->SendControllerEvents();

	// Poll externally-implemented devices
	for (auto DeviceIt = ExternalInputDevices.CreateIterator(); DeviceIt; ++DeviceIt)
	{
		(*DeviceIt)->Tick(TimeDelta);
		(*DeviceIt)->SendControllerEvents();
	}

	FScopeLock Lock(&CriticalSection);
	if(bOrientationChanged && Windows.Num() > 0)
	{
		int32 WindowX,WindowY, WindowWidth,WindowHeight;
		Windows[0]->GetFullScreenInfo(WindowX, WindowY, WindowWidth, WindowHeight);

		GenericApplication::GetMessageHandler()->OnSizeChanged(Windows[0],WindowWidth,WindowHeight, false);
		GenericApplication::GetMessageHandler()->OnResizingWindow(Windows[0]);
		FDisplayMetrics DisplayMetrics;
		FDisplayMetrics::GetDisplayMetrics(DisplayMetrics);
		BroadcastDisplayMetricsChanged(DisplayMetrics);
		bOrientationChanged = false;
	}
}
コード例 #2
0
void FAndroidApplication::PollGameDeviceState( const float TimeDelta )
{
	// Poll game device state and send new events
	InputInterface->Tick( TimeDelta );
	InputInterface->SendControllerEvents();
	
	if (bWindowSizeChanged && 
		Windows.Num() > 0 && 
		FPlatformMisc::GetHardwareWindow() != nullptr)
	{
		FAndroidWindow::InvalidateCachedScreenRect();
		FAndroidAppEntry::ReInitWindow();
				
		int32 WindowX,WindowY, WindowWidth,WindowHeight;
		Windows[0]->GetFullScreenInfo(WindowX, WindowY, WindowWidth, WindowHeight);
		GenericApplication::GetMessageHandler()->OnSizeChanged(Windows[0],WindowWidth,WindowHeight, false);
		GenericApplication::GetMessageHandler()->OnResizingWindow(Windows[0]);
		
		FDisplayMetrics DisplayMetrics;
		FDisplayMetrics::GetDisplayMetrics(DisplayMetrics);
		BroadcastDisplayMetricsChanged(DisplayMetrics);
		bWindowSizeChanged = false;
	}
}
コード例 #3
0
void FHTML5Application::PollGameDeviceState( const float TimeDelta )
{
    SDL_Event Event;
    while (SDL_PollEvent(&Event))
    {
        // Tick Input Interface.
        switch (Event.type)
        {
        case SDL_WINDOWEVENT:
        {
            SDL_WindowEvent windowEvent = Event.window;


            // ignore resized client Height/Width
#if PLATFORM_HTML5_BROWSER
            int fs;
            emscripten_get_canvas_size(&WindowWidth, &WindowHeight, &fs);
            UE_LOG(LogHTML5Application, Verbose, TEXT("emscripten_get_canvas_size: Width:%d, Height:%d, Fullscreen:%d"), WindowWidth, WindowHeight, fs);
#endif

#if PLATFORM_HTML5_WIN32
            WindowWidth = windowEvent.data1;
            WindowHeight = windowEvent.data2;
#endif

            switch (windowEvent.event)
            {
            case SDL_WINDOWEVENT_SIZE_CHANGED:
            {
                UE_LOG(LogHTML5Application, Verbose, TEXT("WindowSizeChanged: Width:%d, Height:%d"), WindowWidth, WindowHeight);
                MessageHandler->OnSizeChanged(ApplicationWindow,WindowWidth,WindowHeight, false);
                MessageHandler->OnResizingWindow(ApplicationWindow);

                FDisplayMetrics DisplayMetrics;
                FDisplayMetrics::GetDisplayMetrics(DisplayMetrics);
                BroadcastDisplayMetricsChanged(DisplayMetrics);
            }
            break;
            case SDL_WINDOWEVENT_RESIZED:
            {
                UE_LOG(LogHTML5Application, Verbose, TEXT("WindowResized: Width:%d, Height:%d"), WindowWidth, WindowHeight);
                MessageHandler->OnResizingWindow(ApplicationWindow);

                FDisplayMetrics DisplayMetrics;
                FDisplayMetrics::GetDisplayMetrics(DisplayMetrics);
                BroadcastDisplayMetricsChanged(DisplayMetrics);
            }
            break;
            case SDL_WINDOWEVENT_ENTER:
            {
                UE_LOG(LogHTML5Application, Verbose, TEXT("WindowEnter"));
                MessageHandler->OnCursorSet();
                MessageHandler->OnWindowActivationChanged(ApplicationWindow, EWindowActivation::Activate);
                WarmUpTicks = 0;
            }
            break;
            case SDL_WINDOWEVENT_LEAVE:
            {
                UE_LOG(LogHTML5Application, Verbose, TEXT("WindowLeave"));
                MessageHandler->OnWindowActivationChanged(ApplicationWindow, EWindowActivation::Deactivate);
            }
            break;
            case SDL_WINDOWEVENT_FOCUS_GAINED:
            {
                UE_LOG(LogHTML5Application, Verbose, TEXT("WindowFocusGained"));
                MessageHandler->OnWindowActivationChanged(ApplicationWindow, EWindowActivation::Activate);
                WarmUpTicks = 0;
            }
            break;
            case SDL_WINDOWEVENT_FOCUS_LOST:
            {
                UE_LOG(LogHTML5Application, Verbose, TEXT("WindowFocusLost"));
                MessageHandler->OnWindowActivationChanged(ApplicationWindow, EWindowActivation::Deactivate);
            }
            break;
            default:
                break;
            }
        }
        default:
        {
            InputInterface->Tick( TimeDelta,Event, ApplicationWindow);
        }
        }
    }
    InputInterface->SendControllerEvents();


    if ( WarmUpTicks >= 0)
        WarmUpTicks ++;


    if ( WarmUpTicks == MaxWarmUpTicks  )
    {
        // browsers don't allow locking and hiding to work independently. use warmup ticks after the application has settled
        // on its mouse lock/visibility status.  This is necessary even in cases where the game doesn't want to locking because
        // the lock status oscillates for few ticks before settling down. This causes a Browser UI pop even when we don't intend to lock.
        // see http://www.w3.org/TR/pointerlock more for information.
#if PLATFORM_HTML5_WIN32
        SDL_Window* WindowHandle= SDL_GL_GetCurrentWindow();
        if (((FHTML5Cursor*)Cursor.Get())->LockStatus && !((FHTML5Cursor*)Cursor.Get())->CursorStatus)
        {
            SDL_SetWindowGrab(WindowHandle, SDL_TRUE);
            SDL_ShowCursor(SDL_DISABLE);
            SDL_SetRelativeMouseMode(SDL_TRUE);
        }
        else
        {
            SDL_SetRelativeMouseMode(SDL_FALSE);
            SDL_ShowCursor(SDL_ENABLE);
            SDL_SetWindowGrab(WindowHandle, SDL_FALSE);
        }
#endif

#if PLATFORM_HTML5_BROWSER
        if (((FHTML5Cursor*)Cursor.Get())->LockStatus && !((FHTML5Cursor*)Cursor.Get())->CursorStatus)
        {
            UE_LOG(LogHTML5Application, Verbose, TEXT("Request pointer lock"));
            emscripten_request_pointerlock ( "#canvas" , true);
        }
        else
        {
            UE_LOG(LogHTML5Application, Verbose, TEXT("Exit pointer lock"));
            emscripten_exit_pointerlock();
        }
#endif

        WarmUpTicks = -1;
    }
}