could someone explain how "g_bRight = (dwData !=0)" works, and the part about the axis threshold? (from sunlight's tutorials)Code:#define AXIS_THRESHOLD 20 void HandleAction(UINT nAction, DWORD dwData) { int nAxisPos = (int)dwData; switch (nAction) { case ACTIONS_LEFTRIGHT: if (nAxisPos < -AXIS_THRESHOLD) { g_bLeft = true; g_bRight = false; } else if (nAxisPos > AXIS_THRESHOLD) { g_bRight = true; g_bLeft = false; } else { g_bLeft = g_bRight = false; } break; case ACTIONS_LEFT: g_bLeft = (dwData != 0); break; case ACTIONS_RIGHT: g_bRight = (dwData != 0); break; case ACTIONS_QUIT: g_bQuit = true; break; default: break; } }
oh and if this helps:
Code:// Check each device for actions void CheckInput() { DIDEVICEOBJECTDATA pdidod[INPUT_DATA_LIMIT]; DWORD dwObjCount; if (g_pDeviceArray == NULL) return; for (int iDevice = 0; iDevice < g_nDevices; iDevice++) { // Poll the device for data. g_pDeviceArray[iDevice]->Poll(); // Retrieve the data. dwObjCount = INPUT_DATA_LIMIT; g_pDeviceArray[iDevice]->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), pdidod, &dwObjCount, 0); for (DWORD i = 0; i < dwObjCount; i++) // Handle the actions regardless of what device returned them. HandleAction(pdidod[i].uAppData, pdidod[i].dwData); } }



LinkBack URL
About LinkBacks


