OPENNI实践-体感方向盘玩赛车游戏(2)

这一篇是关于获取到的数据与虚拟手柄之间通信的过程。首先设置要发送的指令,然后通过WriteFile将指令发送给设备。

DWORD WINAPI SendofBody_left(LPVOID lpParam)
{
	DWORD dwWaitResult_Event=1;
	static bool mmm=true;
	while(true)
	{
		dwWaitResult_Event=WaitForSingleObject(hEvent_send,INFINITE);
		if (dwWaitResult_Event==WAIT_OBJECT_0)
		{
			*(WORD*)(g_controlreport+LEFTJOYSTICK_X_POS)=nMove_LetfJoystic_X;
			*(WORD*)(g_controlreport+LEFTJOYSTICK_Y_POS)=nMove_LetfJoystic_Y;

			if (0==nMove_RightJoystic_X)
			{
				*(UCHAR*)(g_controlreport+Xtion_GamePad_Button)=1;//放氮气
			}
			*(WORD*)(g_controlreport+LEFTJOYSTICK_X_POS)=nMove_LetfJoystic_X;
			*(WORD*)(g_controlreport+LEFTJOYSTICK_Y_POS)=nMove_LetfJoystic_Y;
			WriteControlData(g_controlreport);
			nMove_LetfJoystic_X=0;
			nMove_LetfJoystic_Y=0
			nMove_RightJoystic_X=0x80;
			nMove_RightJoystic_Y=0x80;

			memset(g_controlreport,0,sizeof(g_controlreport));
			g_controlreport[0]=REPORTID_CONTROL;
			g_controlreport[1]=REPORTLEN_GAMEPAD;
			g_controlreport[2]=REPORTID_GAMEPAD;
			g_controlreport[6]=0x100;
			g_controlreport[7]=0x100;
		}
		ResetEvent(hEvent_send);
	}
}

DWORD WritContorlData(UCHAR* pData)
{
	DWORD dwInfo;
	WriteFile(g_hControlDevice,g_controlreport,REPORTLEN_CONTROLDEVICE,&dwInfo,NULL);
	return GetLastError();
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值