Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Gamepad Vibration Control

67 views
Skip to first unread message

Patches

unread,
Jul 28, 2005, 9:37:37 PM7/28/05
to
I have written an application that can read all controls on a gamepad. I am
trying to add control of two vibration motors, one in each handle. Should I
use Force Feedback or SendDeviceData ? If Force Feedback, what do I use for
axes in diEffect structure since vibration is not associated with any axis ?
Also, I can find no documentation on g_lpdiEffect->Start(1, 0). What do the
two parameters do ? So far I have succeeded in getting effect pointer but
get error from Start command.
--
Thanks,
patches

Andrew McDonald

unread,
Jul 30, 2005, 10:16:46 AM7/30/05
to
"Patches" <Pat...@discussions.microsoft.com> wrote...

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


Patches

unread,
Jul 30, 2005, 11:16:01 AM7/30/05
to
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.


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

Andrew McDonald

unread,
Jul 31, 2005, 9:25:38 AM7/31/05
to
"Patches" <Pat...@discussions.microsoft.com> wrote...

> 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


Patches

unread,
Jul 31, 2005, 9:59:02 AM7/31/05
to
Andrew,
Yes, here is the whole "FindGamepad" routine. The EnumGPControls routine
finds all the controls and displays them correctly. The controls update
correctly when polled also. The Gamepad is a Gamers Factory G60310A.

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

Patches

unread,
Jul 31, 2005, 10:20:01 AM7/31/05
to
Andrew,
In case I am interpreting the code incorrectly, the actual return code from
Start() is: 80040205.
--
Thanks,
Patches,

Patches

unread,
Jul 31, 2005, 11:21:02 AM7/31/05
to
Andrew,
I added an Acquire() to code before call and no longer get any errors.
Thanks for helping me resolve that issue ! (I forgot I was bypassing the
original Acquire when I tested this feature) But I still am not getting the
motors to turn on. I tried the four axes that are available on the Gamepad,
other axis produce errors. So any additional ideas on what to experiment
with would be greatly appreciated. (The test code that came with the gamepad
works fine controlling the motors.)
--
Thanks,
Patches

Patches

unread,
Jul 31, 2005, 11:26:08 AM7/31/05
to
Andrew,
Found 1 more minor mistake. Code is working. You have helped a lot..

Andrew McDonald

unread,
Jul 31, 2005, 1:41:39 PM7/31/05
to
"Patches" <Pat...@discussions.microsoft.com> wrote...

> Andrew,
> Found 1 more minor mistake. Code is working. You have helped a
> lot..

Glad I could help :-)

Andrew


RazaRizvi

unread,
Oct 18, 2005, 10:20:06 AM10/18/05
to
Hi,

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

Andrew McDonald

unread,
Oct 18, 2005, 4:35:05 PM10/18/05
to
"RazaRizvi" <Raza...@discussions.microsoft.com> wrote...

> "Andrew McDonald" wrote:
>> "Patches" <Pat...@discussions.microsoft.com> wrote...
>>
>>> Andrew,
>>> Found 1 more minor mistake. Code is working. You have helped a
>>> lot..
>>
>> Glad I could help :-)
>
> 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.

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


Avrel

unread,
Dec 3, 2005, 5:22:21 AM12/3/05
to
Hi
I have exactely the same problem!!! on effect object

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...

Joao

unread,
Mar 15, 2010, 9:08:01 AM3/15/10
to
Hi all,

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

0 new messages