| 1042 | } |
| 1043 | |
| 1044 | void DInputDevice::rumble(F32 x, F32 y) |
| 1045 | { |
| 1046 | LONG rglDirection[2] = { 0, 0 }; |
| 1047 | DICONSTANTFORCE cf = { 0 }; |
| 1048 | HRESULT result; |
| 1049 | |
| 1050 | // Now set the new parameters and start the effect immediately. |
| 1051 | if (!mForceFeedbackEffect) |
| 1052 | { |
| 1053 | #ifdef LOG_INPUT |
| 1054 | Input::log("DInputDevice::rumbleJoystick - creating constant force feeback effect\n"); |
| 1055 | #endif |
| 1056 | DIEFFECT eff; |
| 1057 | ZeroMemory( &eff, sizeof(eff) ); |
| 1058 | eff.dwSize = sizeof(DIEFFECT); |
| 1059 | eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS; |
| 1060 | eff.dwDuration = INFINITE; |
| 1061 | eff.dwSamplePeriod = 0; |
| 1062 | eff.dwGain = DI_FFNOMINALMAX; |
| 1063 | eff.dwTriggerButton = DIEB_NOTRIGGER; |
| 1064 | eff.dwTriggerRepeatInterval = 0; |
| 1065 | eff.cAxes = mNumForceFeedbackAxes; |
| 1066 | eff.rgdwAxes = mForceFeedbackAxes; |
| 1067 | eff.rglDirection = rglDirection; |
| 1068 | eff.lpEnvelope = 0; |
| 1069 | eff.cbTypeSpecificParams = sizeof(DICONSTANTFORCE); |
| 1070 | eff.lpvTypeSpecificParams = &cf; |
| 1071 | eff.dwStartDelay = 0; |
| 1072 | |
| 1073 | // Create the prepared effect |
| 1074 | if ( FAILED( result = mDevice->CreateEffect( GUID_ConstantForce, &eff, &mForceFeedbackEffect, NULL ) ) ) |
| 1075 | { |
| 1076 | #ifdef LOG_INPUT |
| 1077 | Input::log( "DInputDevice::rumbleJoystick - %s does not support force feedback.\n", mName ); |
| 1078 | #endif |
| 1079 | Con::errorf( "DInputDevice::rumbleJoystick - %s does not support force feedback.\n", mName ); |
| 1080 | return; |
| 1081 | } |
| 1082 | else |
| 1083 | { |
| 1084 | #ifdef LOG_INPUT |
| 1085 | Input::log( "DInputDevice::rumbleJoystick - %s supports force feedback.\n", mName ); |
| 1086 | #endif |
| 1087 | Con::printf( "DInputDevice::rumbleJoystick - %s supports force feedback.\n", mName ); |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | // Clamp the input floats to [0 - 1] |
| 1092 | x = max(0, min(1, x)); |
| 1093 | y = max(0, min(1, y)); |
| 1094 | |
| 1095 | if ( 1 == mNumForceFeedbackAxes ) |
| 1096 | { |
| 1097 | cf.lMagnitude = (DWORD)( x * DI_FFNOMINALMAX ); |
| 1098 | } |
| 1099 | else |
| 1100 | { |
| 1101 | rglDirection[0] = (DWORD)( x * DI_FFNOMINALMAX ); |
nothing calls this directly
no test coverage detected