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

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

 

[cpp]  view plain  copy
 
 在CODE上查看代码片派生到我的代码片
  1. <span style="font-size:14px;">DWORD WINAPI SendofBody_left(LPVOID lpParam)  
  2. {  
  3.     DWORD dwWaitResult_Event=1;  
  4.     static bool mmm=true;  
  5.     while(true)  
  6.     {  
  7.         dwWaitResult_Event=WaitForSingleObject(hEvent_send,INFINITE);  
  8.         if (dwWaitResult_Event==WAIT_OBJECT_0)  
  9.         {  
  10.             *(WORD*)(g_controlreport+LEFTJOYSTICK_X_POS)=nMove_LetfJoystic_X;  
  11.             *(WORD*)(g_controlreport+LEFTJOYSTICK_Y_POS)=nMove_LetfJoystic_Y;  
  12.   
  13.             if (0==nMove_RightJoystic_X)  
  14.             {  
  15.                 *(UCHAR*)(g_controlreport+Xtion_GamePad_Button)=1;//放氮气  
  16.             }  
  17.             *(WORD*)(g_controlreport+LEFTJOYSTICK_X_POS)=nMove_LetfJoystic_X;  
  18.             *(WORD*)(g_controlreport+LEFTJOYSTICK_Y_POS)=nMove_LetfJoystic_Y;  
  19.             WriteControlData(g_controlreport);  
  20.             nMove_LetfJoystic_X=0;  
  21.             nMove_LetfJoystic_Y=0  
  22.             nMove_RightJoystic_X=0x80;  
  23.             nMove_RightJoystic_Y=0x80;  
  24.   
  25.             memset(g_controlreport,0,sizeof(g_controlreport));  
  26.             g_controlreport[0]=REPORTID_CONTROL;  
  27.             g_controlreport[1]=REPORTLEN_GAMEPAD;  
  28.             g_controlreport[2]=REPORTID_GAMEPAD;  
  29.             g_controlreport[6]=0x100;  
  30.             g_controlreport[7]=0x100;  
  31.         }  
  32.         ResetEvent(hEvent_send);  
  33.     }  
  34. }  
  35.   
  36. DWORD WritContorlData(UCHAR* pData)  
  37. {  
  38.     DWORD dwInfo;  
  39.     WriteFile(g_hControlDevice,g_controlreport,REPORTLEN_CONTROLDEVICE,&dwInfo,NULL);  
  40.     return GetLastError();  
  41. }</span>  

转载于:https://www.cnblogs.com/Trove/p/6844784.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值