} NTSTATUS status = HidP_GetCaps(pHidpPreparsedData,&hidPCaps); if (status == HIDP_STATUS_SUCCESS) { _tprintf("CAP信息如下:\n"); _tprintf(" InputReportByteLength %d\n", hidPCaps.InputReportByteLength); _tprintf(" OutputReportByteLength %d\n", hidPCaps.OutputReportByteLength); } DWORD nReadBytes = 0; BYTE *pInputReport = new BYTE[hidPCaps.InputReportByteLength]; memset(pInputReport,0,hidPCaps.InputReportByteLength); do { ReadFile(hDeviceHandle,pInputReport,hidPCaps.InputReportByteLength,&nReadBytes,NULL); if (hidPCaps.InputReportByteLength == nReadBytes) { for(unsigned int i=0; i<(nReadBytes-1);i++) _tprintf("%02x-",pInputReport[i]); _tprintf("%02x\r",pInputReport[nReadBytes-1]); } if (pInputReport[nReadBytes-2] == 0x20) //break the loop when pressing a specific key { _tprintf("\n"); break; } Sleep(10); }while(hidPCaps.InputReportByteLength == nReadBytes); //释放句柄资源 CloseHandle(hDeviceHandle); } MemberIndex++; }while(bSuccess); SetupDiDestroyDeviceInfoList(hDevInfo); } |
正在阅读:VC学习:获取游戏手柄的按键输入VC学习:获取游戏手柄的按键输入
2004-03-05 14:49
出处:CSDN
责任编辑:linjixiong
键盘也能翻页,试试“← →”键