// enumerate the dinput devices int __stdcall plDInputMgr::EnumGamepadCallback(const DIDEVICEINSTANCE* device, void* pRef) { HRESULT hr; plDInput* pDI = (plDInput*)pRef; IDirectInputDevice8* fStick = nil; hr = pDI->fDInput->CreateDevice(device->guidInstance, &fStick, NULL); if(!FAILED(hr)) { pDI->fSticks.Append(new plDIDevice(fStick)); // the following code pertaining to the action map shouldn't be here. // in fact this shouldn't work at all according to MS, but this is // currently the only way this works. Whatever - the correct // code is here and commented out in case this ever gets fixed by MS // in a future release of dinput. HRESULT hr = fStick->BuildActionMap(pDI->fActionFormat, NULL, NULL); if (!FAILED(hr)) { hr = fStick->SetActionMap( pDI->fActionFormat, NULL, NULL ); DIPROPDWORD dipW; dipW.diph.dwSize = sizeof(DIPROPDWORD); dipW.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipW.diph.dwHow = DIPH_DEVICE; dipW.diph.dwObj = 0; dipW.dwData = 500; // 5% of axis range for deadzone hr = fStick->SetProperty(DIPROP_DEADZONE , &dipW.diph); } return DIENUM_CONTINUE; } return DIENUM_STOP; }
HRESULT _stdcall BuildActionMap(LPDIACTIONFORMATA a,LPCSTR b,DWORD c) { return RealDevice->BuildActionMap(a,b,c); }