利用XInput实现获取XBox游戏手柄数据,如下:
//读取游戏手柄的线程
UINT _cdecl CMFC_GameHandle2Dlg::ReadJoystickThread(LPVOID lpParm)
{
CMFC_GameHandle2Dlg *dlg = (CMFC_GameHandle2Dlg*)lpParm;
XINPUT_GAMEPAD gamepad;
CString temp;
//识别游戏手柄是否插入,并读取数据
while (XInputGetState(0,&(dlg->m_ControllerState)) == ERROR_SUCCESS )
{
gamepad = dlg->m_ControllerState.Gamepad;
..................
............
}
}
1