------------------------------------------------------------------------------
| 265 | |
| 266 | //------------------------------------------------------------------------------ |
| 267 | bool DInputDevice::acquire() |
| 268 | { |
| 269 | if ( mDevice ) |
| 270 | { |
| 271 | if ( mAcquired ) |
| 272 | return( true ); |
| 273 | |
| 274 | bool result = false; |
| 275 | // Set the cooperative level: |
| 276 | // (do this here so that we have a valid app window) |
| 277 | DWORD coopLevel = DISCL_BACKGROUND; |
| 278 | if ( mDeviceType == JoystickDeviceType |
| 279 | // #ifndef DEBUG |
| 280 | // || mDeviceType == MouseDeviceType |
| 281 | // #endif |
| 282 | ) |
| 283 | // Exclusive access is required in order to perform force feedback |
| 284 | coopLevel = DISCL_EXCLUSIVE | DISCL_FOREGROUND; |
| 285 | else |
| 286 | coopLevel |= DISCL_NONEXCLUSIVE; |
| 287 | |
| 288 | result = mDevice->SetCooperativeLevel( getWin32WindowHandle(), coopLevel ); |
| 289 | if ( FAILED( result ) ) |
| 290 | { |
| 291 | Con::errorf( "Failed to set the cooperative level for the %s input device.", mName ); |
| 292 | #ifdef LOG_INPUT |
| 293 | Input::log( "Failed to set the cooperative level for %s!\n", mName ); |
| 294 | #endif |
| 295 | return false; |
| 296 | } |
| 297 | |
| 298 | // Enumerate joystick axes to enable force feedback |
| 299 | if ( NULL == mForceFeedbackEffect && JoystickDeviceType == mDeviceType) |
| 300 | { |
| 301 | // Since we will be playing force feedback effects, we should disable the auto-centering spring. |
| 302 | DIPROPDWORD dipdw; |
| 303 | dipdw.diph.dwSize = sizeof(DIPROPDWORD); |
| 304 | dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); |
| 305 | dipdw.diph.dwObj = 0; |
| 306 | dipdw.diph.dwHow = DIPH_DEVICE; |
| 307 | dipdw.dwData = FALSE; |
| 308 | |
| 309 | if( FAILED( result = mDevice->SetProperty( DIPROP_AUTOCENTER, &dipdw.diph ) ) ) |
| 310 | return false; |
| 311 | } |
| 312 | |
| 313 | S32 code = mDevice->Acquire(); |
| 314 | result = SUCCEEDED( code ); |
| 315 | if ( result ) |
| 316 | { |
| 317 | Con::printf( "%s input device acquired.", mName ); |
| 318 | #ifdef LOG_INPUT |
| 319 | Input::log( "%s acquired.\n", mName ); |
| 320 | #endif |
| 321 | mAcquired = true; |
| 322 | |
| 323 | // If we were previously playing a force feedback effect, before |
| 324 | // losing acquisition, we do not automatically restart it. This is |
nothing calls this directly
no test coverage detected