首页 > 代码库 > OPENNI实践-体感方向盘玩赛车游戏(2)
OPENNI实践-体感方向盘玩赛车游戏(2)
这一篇是关于获取到的数据与虚拟手柄之间通信的过程。首先设置要发送的指令,然后通过WriteFile将指令发送给设备。
[cpp] view plain copy
- <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实践-体感方向盘玩赛车游戏(2)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。