Well given that the documentation for SendDeviceData() says:
"Applications should not use IDirectInputDevice8::SendDeviceData. Force
Feedback is the recommended way to send data to a device. If you want to
send other data to a device, such as changing LED or internal device
states, the HID application programming interface (API) is the
recommended way."
perhaps force feedback would be more appropriate. What happens if you
specify a single axis, does the vibration shift left and right as
appropriate?
The parameters for Start() are (unsurprisingly!) documented in the SDK
under IDirectInputEffect::Start.
Andrew
My code:
LPDIRECTINPUTEFFECT g_lpdiEffect; // global effect object
DIEFFECT diEffect; // general parameters
DWORD dwAxes = DIJOFS_X;
LONG lZero = 0;
DICONSTANTFORCE diConstantForce;
diConstantForce.lMagnitude = DI_FFNOMINALMAX; // Full force
diEffect.dwSize = sizeof(DIEFFECT);
diEffect.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
diEffect.dwDuration =INFINITE;
diEffect.dwSamplePeriod = 0; // = default
diEffect.dwGain = DI_FFNOMINALMAX; // no scaling
diEffect.dwTriggerButton = DIEB_NOTRIGGER;
diEffect.cAxes = 1;
diEffect.rgdwAxes = &dwAxes;
diEffect.rglDirection = &lZero;
diEffect.lpEnvelope = NULL;
diEffect.cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
diEffect.lpvTypeSpecificParams = &diConstantForce;
ret = pGamepad->CreateEffect(
GUID_ConstantForce, // GUID from enumeration
&diEffect, // where the data is
&g_lpdiEffect, // where to put interface pointer
NULL);
if (ret<0) return 7; // no aggregation
DIEFFECTINFO diEffectInfo;
diEffectInfo.dwSize = sizeof(DIEFFECTINFO);
pGamepad->GetEffectInfo(&diEffectInfo, GUID_ConstantForce );
ret = g_lpdiEffect->Start(1, 0);
return 0;
}
Does my code seem correct ? What should I try next ?
--
Thanks,
Patches
> Thanks for your response. I found the doc on start(). Code does not
> work
> because of error from start(). Here is additional information. The
> Error
> message from start is DIERR_NOTEXCLUSIVEACQUIRED. Data from
> diEffectInfo:
> guid 13541C20-8e33-11d0-9d0-00a0c9a06e35
> dwEffType 0x8601, dwStatic 0x3ed, dw Dynamic 0x3ed.
>
> [Snip]
>
> Does my code seem correct ? What should I try next ?
Did you actually acquire the device exclusively?
Andrew
long FindGamepad(HWND hWnd)
{
long ret;
ret =
DirectInput8Create(hInst,DIRECTINPUT_VERSION,IID_IDirectInput8,(VOID**)&pDI,NULL);
if (ret<0) return 1;
ret = pDI->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumGamepads,NULL,
DIEDFL_FORCEFEEDBACK | DIEDFL_ATTACHEDONLY);
if (ret<0) return 2;
if( pGamepad==NULL ) return 3;
ret = pGamepad->SetDataFormat( &c_dfDIJoystick );
if (ret<0) return 4;
ret = pGamepad->SetCooperativeLevel( hWnd, DISCL_EXCLUSIVE |
DISCL_BACKGROUND );
if (ret<0) return 5;
// Enumerate the Gamepad controls
strcpy(szText[1],"Axis=");
ret = pGamepad->EnumObjects( EnumGPControls, NULL, DIDFT_ALL );
if (ret<0) return 6;
sprintf(szText[2], "nButton=%i ",nButton);
sprintf(szText[3], "nPOV=%i " ,nPOV);
sprintf(szText[4], "nSlider=%i ",nSlider);
sprintf(szText[5], "nOutput=%i ",nOutput);
if (ret<0) return 8;
return 0;
}
--
Thanks,
patches
Glad I could help :-)
Andrew
It seems you both have successfully implemented the force feedback feature.
I am trying to get it to work with C# but the sample provided with the
DirectX9 doesnt seem to work. I am using Logitech WingMan Cordless Rumblepad
2.4 GHz. I am getting an error on a particular line of the sample (code on
this link:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_m_Oct_2004/directx/input/directinput_forcefeedback.asp)
// Create the effect, using the passed in guid.
eo = new EffectObject(ei.EffectGuid, e, joystick);
The error states something in the lines of... "the value is outside the
expected range".
I've searched the web for many days now but havent found a working sample
yet. I'll really really appreciate help from anyone who can get forcefeedback
to work with .Net.
Thanks,
Raza
Unfortunately I can't really help with the managed stuff; but if a sample's
not working that sounds like it could be a driver issue. Have you installed
up-to-date drivers for the device? If there are only generic ones installed
it may lack the rumble feature.
Also try asking in microsoft.win32.programmer.directx.managed, there may be
more help there.
--
Andrew
The old sample in MSDN Journal Article of 1998-06 ffb.exe is working!!!
(With the same device Rumblepad 2)
It's seem to be a problem with directX9...
The best solution is that MS buy a Logitech WingMan Cordless Rumblepad 2 to
make her software more robust!
Nicolas Schneider
Hewlett-Packard
"RazaRizvi" <Raza...@discussions.microsoft.com> wrote in message
news:18AFA426-8C4C-4B99...@microsoft.com...
Have been so long since you got a reply from this post.
I am working with a Logitech Rumblepad 2 and I have the same problem that
you had once:
In effectObjects -> "Value does not fall within the expected range"
I manage to read all the data from the gamepad, however I not able to send
feedback force to it. I have also directx9 and I'm writting my code in C#.
I wonder if you solved that problem, and if you can give me a handy in
putting to work my gamepad.
Thank you very much for your time.
Joao
P.S - Can someone send me the old sample in MSDN Journal Article of 1998-06
ffb.exe