OPENNI实践-体感方向盘玩赛车游戏
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OPENNI实践-体感方向盘玩赛车游戏相关的知识,希望对你有一定的参考价值。
这一篇是关于获取到的数据与虚拟手柄之间通信的过程。首先设置要发送的指令,然后通过WriteFile将指令发送给设备。
- <span style="font-size:14px;">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();
- }</span>
以上是关于OPENNI实践-体感方向盘玩赛车游戏的主要内容,如果未能解决你的问题,请参考以下文章