UE4的PixelStreaming模块之设备驱动

UE4的PixelStreaming模块设备驱动


最近在写类似于云游戏客户端视频采集工作,其中设备的操作动作一直都是服装不是太好,准备参考UE4中设备驱动是怎么写的从中找出思路。目前我还没有完全看懂UE4的设备驱动模块。 时间又有点紧张,设备操作这边我已经花一个月左右的时间进行调研。大致方案有两种

  1. 原生的api
  2. 设备驱动

我目前采用三原生api来做的(个人能力有限,驱动写不了 哭了),原生api的有很多差的地方,设备驱动才是完美能解决设备操作的限制。

一, UE4的PixelStreaming模块设备驱动

UE4 使用WebRTC中引擎去做与浏览器之间的交互 , 类似于云游戏怎么一个东西,
InputDevice设备驱动类。

在UE4引擎中对设备驱动服装非常好,是一个模块形势。 在PixelStreamingModule模块中创建的时候转入设备驱动类的驱动模块

在PixelStreamingModule类中创建该类


TSharedPtr<class IInputDevice> FPixelStreamingModule::CreateInputDevice(const TSharedRef<FGenericApplicationMessageHandler>& InMessageHandler)
{
	InputDevice = MakeShareable(new FInputDevice(InMessageHandler));
	return InputDevice;
}

设备驱动是从对应平台模块的传入设备驱动的ApplicationCore中Private中Mac

以下类说明

MacApplication
WindowApplication

在对应平台的-Application中PollGameDeviceState方法进行模块设备传入的操作。


void FMacApplication::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 && GIsRunning)
	{
		TArray<IInputDeviceModule*> PluginImplementations = IModularFeatures::Get().GetModularFeatureImplementations<IInputDeviceModule>( IInputDeviceModule::GetModularFeatureName() );
		for( auto InputPluginIt = PluginImplementations.CreateIterator(); InputPluginIt; ++InputPluginIt )
		{
		   // 模块设备的初始化 
			TSharedPtr<IInputDevice> Device = (*InputPluginIt)->CreateInputDevice(MessageHandler);
			if (Device.IsValid())
			{
				UE_LOG(LogInit, Log, TEXT("Adding external input plugin."));
				ExternalInputDevices.Add(Device);
			}
		}

		bHasLoadedInputPlugins = true;
	}

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

	// Poll externally-implemented devices
	for( auto DeviceIt = ExternalInputDevices.CreateIterator(); DeviceIt; ++DeviceIt )
	{
		(*DeviceIt)->Tick( TimeDelta );
		(*DeviceIt)->SendControllerEvents();
	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值