Hi folks,
I didn't know where to post it so feel free to move it. Here is the first directinput module for joystick support and a text file with the syntax of the 5 commands in it. Just 5, some will ask? Don't worry, I just got PowerBasic to do what I want.
I thought I needed a conversion of a C macro but no, I had false examples. After a look inside the MS SDK docu I found the bug and voila, now joystick behaves like a good boy. I would like you to test it temporary inside TopDown and let me know if it works or crashes. Before someone asks, copy the DLL inside the thinBasic lib folder.
After more tests are done and I added more stuff to it, I will ask Eros to include this module into the official distribution and hand it over to him.
Here is some code that has to be added to TopDown:
[code=thinbasic] USES "TBDI"
'...
DIM But1 as integer
dim direturn as long
dim joyX as integer
dim joyY as integer
...
'Initialize DirectInput Joystick support
direturn = tbdi_init(0)
'...
'Check the state of both axxis and the button no.1
joyX = tbdi_joyX
joyY = tbdi_joyy
but1 = tbdi_joybutton(1)
'...
if GetAsyncKeyState(%VK_SPACE) or but1 then
'...
if GetAsyncKeyState(%VK_UP) or joyY < 0 then
'...
if GetAsyncKeyState(%VK_DOWN) or joyY> 0 then
'...
'Don't forget to release the joystick
tbdi_close
[/code]
I think it is easy to use, or? I hope it works on your machines.
Cheers
Michael Hartlef
Bookmarks