Steering wheel, force feedback etc?

Blitz3D Forums/Blitz3D Programming/Steering wheel, force feedback etc?

Mustang(Posted 2007) [#1]
Anyone have any experience if or how Blitz3D can/could use steering wheel with force feedback? I found this but the author talks about "joystick"...

http://www.blitzbasic.co.nz/toolbox/toolbox.php?tool=81

Also can you tell me if Blitz3D supports Pad controller and how it differs from joystick - or can I think it as a analog joystick with many buttons... but how would I get the inputs from the two thumbsticks because wouldn't they be like two analog joysticks?

Any free code samples appreciated :)


Matty(Posted 2007) [#2]
Hi Mustang -

I've used joypad/gamepads a lot with Blitz3d and blitzplus (they work the same in both).

Usually the left thumbstick returns values to the joyx() and joyy() commands, the buttons are simply detected with joyhit/joydown as normal (except there are more buttons - abut 12 I think).

The right thumbstick varies from game pad to game pad as to what functions it uses to get the input. Not only that but it can return different values (ie not just from -1 to 1). It also depends if the gamepad is in analog or digital mode. Commonly the right thumbstick is polled using the joyz(), joyroll() commands although it may be joypitch() or joyyaw() sometimes (depending on controller). The values can range from being -1 to 1 or 0 to 1 or -180 to 180 - it depends a lot on the controller.

The little D-Pad is often the same as the left thumbstick in digital mode but in analog is polled using joyhat() which returns a single value between 0 and 360 depending on direction pushed.

Possibly the best free code sample is the one right in the docs themselves which simply outputs the value of each of the 'joyxxx'() commands to the screen:

it looks something like this:

Graphics 800,600,0,2

Repeat
Cls

Text 0,0,"X:"+JoyX()
Text 0,15,"Y:"+JoyY()
Text 0,30,"Z:"+JoyZ()
Text 0,45,"U:"+JoyU()
Text 0,60,"V:"+JoyV()
Text 0,75,"X Dir:"+JoyXDir()
Text 0,90,"Y Dir:"+JoyYDir()
Text 0,105,"Z Dir:"+JoyZDir()
Text 0,120,"U Dir:"+JoyUDir()
Text 0,135,"V Dir:"+JoyVDir()
Text 0,150,"Yaw:"+JoyYaw()
Text 0,165,"Pitch:"+JoyPitch()
Text 0,180,"Roll:"+JoyRoll()
Text 0,195,"Hat:"+JoyHat()

Flip


Until KeyDown(1)
EndGraphics
End


EDIT - sometimes in digital mode the right thumbstick actually causes the joydown() to return a '1' value for some buttons when moved (well it does on mine anyway - pushing it up/down causes joydown(1) to return a value.

Regarding force feedback - I've no idea if it works with a steering wheel, it does work with a single joypad but from memory I read a while ago in the forums there are problems with force feedback on multiple gamepads (not a concern to most people) and that it can be a little unreliable (although can't verify this).

EDIT 2:

Blitz doesn't seem to detect a gamepad or joystick which is connected after the game starts - it has to be connected to the PC before starting the game. A little annoying if you have a game where you want people to just plug their gamepad in and join in at any time.


Mustang(Posted 2007) [#3]
Hey,

Thanks Matty, very helpful post! I managed to find a free FF .DLL (made by Todd Riggins aka Pepsi) which has a problem when using multiple effects at once - not a critical for me.

I try to get my stuff working with generic gamepad first and then maybe add simple FF fx... might not bother to support wheel/pedal combos at all because not many have them but everyone has gamepads. Gamepads are better than keyboard at least.


Vorderman(Posted 2007) [#4]
Mustang - can you post a link to that DLL please? I'd like to give it a try in SRX. Thanks.


Mustang(Posted 2007) [#5]
Sure,

http://www.exodev.com/files/BB_DInput1_4.zip

Thread I found it was:

http://www.blitzbasic.co.nz/Community/posts.php?topic=61571#688932


Yes it's released as free. I dropped support for it as I couldn't figure out how to get multiple forcefeedback effects to play correctly on more than one game controller. Also, I've always wanted to write a more direct way of accessing the DirectInput functions through blitz, more of a wrapper dll around the DirectInput API so one can write the guts to control it all in blitz. Jest havent had the time as Im harldy ever home mostly.

I thought I had a newer version than 1.4, but here is v1.4 to download and it also includes the CPP source files for the dll. Hope it helps somehow...




Pepsi, the force feedback effect files are missing.

---

The effect files and the ffb effects tool comes with the DirectX SDK. I feel a little weary distributing seperate things like that as if Im breaking a Micro$oft law... probably was. I'll leave the zip as is.




IPete2(Posted 2007) [#6]
Mustang,

Please check your email.

IPete2.


Mustang(Posted 2007) [#7]
IPete2,

Will do once I get home (@work)! :)


Pepsi(Posted 2007) [#8]
Hi guys, this is Todd Riggins aka Pepsi :)

I really feel that I approached the FFB stuff in the wrong way. Those ffb effects that are played from the .ffb effect files are meant to be played by themselfs without any other effects interfearing with them. So trying to code it to play "multiple effects at once" was pretty much a lost cause. One fact that supports that is the ffb buffer for the game controller is limited. so trying to play more than one effect will fill that buffer up and then you get unexpected results.

I should of had coded the dll where you could create ffb effects during realtime. I strongly believe this is how AAA games that incoporate FFB does it. I have been toying with the idea of creating a new "rumble" dll... with the addition of XBox360 gamepad support(as a seperate dll)... hrmmm...


Vorderman(Posted 2007) [#9]
so there's no way to just pull the wheel to the left or the right?


Mustang(Posted 2007) [#10]

I have been toying with the idea of creating a new "rumble" dll... with the addition of XBox360 gamepad support(as a seperate dll)... hrmmm...



So what are you waiting for? Your free .DLL is cool and probably enough for me right now, but I have no problem actually paying for something that's even better. :)


MikeHart(Posted 2007) [#11]
Hi Todd, long time no see.

Just recently I did an DirectInput module for thinBasic, including playback of several loaded effects at the same time. It is written in PowerBasic. If you have interest in the sources to see how it is done, email me.

Cheers
Michael


Pepsi(Posted 2007) [#12]
Hiya Mike, but doesnt the FFB game controllers themselfs have a limited buffer to store loaded effects in??? I thought I remmember reading that in the DX SDK docs. Mabie Im wrong. If my new efforts dont pan out... I'll hit ya up for some info. thanks.

Now that I finally have a mini-vacation until I have to go back to work on Sunday, mabie I can get something knocked out finally.


Pepsi(Posted 2007) [#13]
ah.. the library will be free.


Mustang(Posted 2007) [#14]
Yesh! Great, thanks a bunch Coyote!


IPete2(Posted 2007) [#15]
cool stuff, look forward to seeing it - and trying it of course!

IPete2


Damien Sturdy(Posted 2007) [#16]
I paid for the last one and I'd pay for this one too :) Make it max-y too :)


Pepsi(Posted 2007) [#17]
Cygnus, U paid 4 the last 1???

I do have bmax, but never really got into it yet. Dont even have a clue where to begin with calling dlls from bmax. With bmax, if you could call a dll that works with userlibs/blitz3d then it shouldn't to hard to do that. Dunno... if I can just get all of my DX9 stuff done and make it bmax-y too...


MikeHart(Posted 2007) [#18]
Hi Todd,

in my DLL I can load several effect files and play them simutaniously. It is possible.

Michael


Pepsi(Posted 2007) [#19]
Sorry guys for taking so long. Im a truck driver so I hardly find the time I need. Also, I thought I could use the Aurora compiler to create the dll with, but I should of known why it wouldn't of worked...

I will break out my trusty msvc6 to get'r done. Im pretty excited about the Xbox controller. The dx sdk xinput example got me thinking of all the games that I'll never get to make with it.


Mustang(Posted 2007) [#20]

got me thinking of all the games that I'll never get to make with it.



:)

Take your time, no need to stress about it.


Pepsi(Posted 2007) [#21]
Hiya Im working on it right now... finally...

Well, it's down right specific to DirectX 7 DirectInput game controller stuff to keep it Blitz3D freindly. That will be the main feature of this dll. ( ie: Not requiring your DX7 game to have DX8 to use the FFB stuff )

also note: There will be no "added" mouse or keyboard functionality with this dll. Only game device related stuff...

di7=SystemProperty$("DirectInput7")
and
hwnd=SystemProperty$("AppHWND")
works a treat!

Downside for me is that the Rumble Effects from the XBox Controller dont work with the regular DirectInput Force Feed Back functionality. Suppose thats why it has it's own XInput dll. But at least the regular controls/buttons work from it.

I currently have the basics of the dll done and now starting to code in the FFB functionality stuff in.
My first focus is to be able to program your own FFB effects codewise and be able to change how the effects are played during realtime.
Then I will add the ability to load effect files.(ie: most likely NOT to be played simultaneously).

Current Functionality:
DX7RUMBLE_INIT%(hwnd%, LPDIRECTINPUT7%):"_DX7RUMBLE_INIT@8"
DX7RUMBLE_RELEASE():"_DX7RUMBLE_RELEASE@0"
DX7RUMBLE_TOTALGAMEDEVICES%():"_DX7RUMBLE_TOTALGAMEDEVICES@0"
DX7RUMBLE_GAMEDEVICENAME$(joynum%):"_DX7RUMBLE_GAMEDEVICENAME@4"
DX7RUMBLE_AVAIL%(joynum%):"_DX7RUMBLE_AVAIL@4"
DX7RUMBLE_AUTOCENTER%(joynum%,truefalse%):"_DX7RUMBLE_AUTOCENTER@8"
DX7RUMBLE_REAQUIRE(joynum%):"_DX7RUMBLE_REAQUIRE@4"
DX7RUMBLE_POLL():"_DX7RUMBLE_POLL@0"
DX7RUMBLE_RUNCONTROLPANEL%(joynum%):"_DX7RUMBLE_RUNCONTROLPANEL@4"
JOY_X_AXIS%(joynum%):"_JOY_X_AXIS@4"
JOY_Y_AXIS%(joynum%):"_JOY_Y_AXIS@4"
JOY_Z_AXIS%(joynum%):"_JOY_Z_AXIS@4"
JOY_RX_AXIS%(joynum%):"_JOY_RX_AXIS@4"
JOY_RY_AXIS%(joynum%):"_JOY_RY_AXIS@4"
JOY_RZ_AXIS%(joynum%):"_JOY_RZ_AXIS@4"
JOY_SLIDER%(joynum%,num%):"_JOY_SLIDER@8"
JOY_POV%(joynum%,num%):"_JOY_POV@8"
JOY_BUTTON%(joynum%,num%):"_JOY_BUTTON@8"
JOY_VX_AXIS%(joynum%):"_JOY_VX_AXIS@4"
JOY_VY_AXIS%(joynum%):"_JOY_VY_AXIS@4"
JOY_VZ_AXIS%(joynum%):"_JOY_VZ_AXIS@4"
JOY_VRX_AXIS%(joynum%):"_JOY_VRX_AXIS@4"
JOY_VRY_AXIS%(joynum%):"_JOY_VRY_AXIS@4"
JOY_VRZ_AXIS%(joynum%):"_JOY_VRZ_AXIS@4"
JOY_VSLIDER%(joynum%,num%):"_JOY_VSLIDER@8"
JOY_AX_AXIS%(joynum%):"_JOY_AX_AXIS@4"
JOY_AY_AXIS%(joynum%):"_JOY_AY_AXIS@4"
JOY_AZ_AXIS%(joynum%):"_JOY_AZ_AXIS@4"
JOY_ARX_AXIS%(joynum%):"_JOY_ARX_AXIS@4"
JOY_ARY_AXIS%(joynum%):"_JOY_ARY_AXIS@4"
JOY_ARZ_AXIS%(joynum%):"_JOY_ARZ_AXIS@4"
JOY_ASLIDER%(joynum%,num%):"_JOY_ASLIDER@8"
JOY_FX_AXIS%(joynum%):"_JOY_FX_AXIS@4"
JOY_FY_AXIS%(joynum%):"_JOY_FY_AXIS@4"
JOY_FZ_AXIS%(joynum%):"_JOY_FZ_AXIS@4"
JOY_FRX_AXIS%(joynum%):"_JOY_FRX_AXIS@4"
JOY_FRY_AXIS%(joynum%):"_JOY_FRY_AXIS@4"
JOY_FRZ_AXIS%(joynum%):"_JOY_FRZ_AXIS@4"
JOY_FSLIDER%(joynum%,num%):"_JOY_FSLIDER@8"


Are there any suggestions, features that you want to see in this dll?


Banshee(Posted 2007) [#22]
might not bother to support wheel/pedal combos at all because not many have them but everyone has gamepads

Um, I dont have a gamepad, but I do have an FFB wheel plugged in permanently :).

Are there any suggestions, features that you want to see in this dll?

Just the ability to create realtime effects, I dont care about the canned effects. As you've covered that, I would also like to carry your abortions. :D

EDIT:
Did I read correctly that once initialised the keyboard and mouse wont work?


Pepsi(Posted 2007) [#23]
I havent tested that yet, but logic should be that since I'm using the DirectInput Object that Blitz3D itself has created things should NOT break regular blitz3d input commands.

The old BB_DInput1_4.dll would take over the Blitz3D mouse , keyboard and joystick stuff because I had to create my own instance of DirectInput. Shouldnt have to worry about that with this new dll.


Pepsi(Posted 2007) [#24]
Hey! Im about to post in the blitz3d userlib section to share my new dll... well... it will be a beta version. Trying to get beta documentation done! So mabie later tonight or tommorrow... :)

Got ta think'n 'bout wot Cygnus said...

Make it max-y too :)



I do have max-y, but I never gave myself a chance to get familuar with it. question is...

Can bmax return a windows hwnd handle and a directx 7 directinput handle like blitz3d can? Like for an example...
di7=SystemProperty$("DirectInput7")
hwnd=SystemProperty$("AppHWND")

If so, a dll bmax professional could access this dll i'm making and spread the news. Just curious thx...