If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: TBDI - DirectInput Joystick module

Hi Mike,

I don't understand if TBDI_Close is your internal function or thinBASIC keyword.

I think for de-initialization part of thinBASIC module is dedicated function called UnLoadLocalSymbols.
It looks something like this in SDK template:
[code=thinbasic]
'----------------------------------------------------------------------------
FUNCTION UnLoadLocalSymbols ALIAS "UnLoadLocalSymbols" () EXPORT AS LONG
' This function is automatically called by thinCore whenever this DLL is unloaded.
' This function CAN be present but it is not necessary. If present, this function
' will be executed by thinBasic core when module will be released.
' Use this function to perform uninitialize process, if needed.
'----------------------------------------------------------------------------

Re: TBDI - DirectInput Joystick module

Dooo :

You are right. Instead of using the attach and detach processes, I could probably use the load and unload functions to initialize it. Thanks for the tip. If it still not works, then I bite into the table

Re: TBDI - DirectInput Joystick module

Using LIBMAIN can be too late or too early because thinCore is not aware of what is going on at that precise time.
That's why we introduced LoadLocalSymbols and UnLoadLocalSymbols. thinCore is responsible to call them exactly when needed. And at that time all global variables inside the script are already there.

Another reason is to hide internal module development to users trying to check internal functions. Only LoadLocalSymbols and UnLoadLocalSymbols are exported. This will keep thinBasic modules usable only by thinBasic interface because all is internal executed by code pointers to functions.

Now, I'm using a XBox 360 USB Controller. I've amended TopDown3D (see attached) and seems working fine.
I do not know if it is normal but when I move cursor left or right or top or bottom, it continue moving till the edge of limits even if I stop moving gamepad.

Forgive the thread necromancy, but since this was never properly answered, I am answering it for any newcomers who may stumble on this issue.

Although I have not played with the DI commands, Mike's coding is always very solid and reliable.

The problem is DirectInput was not designed for the controller you are trying to use. NexGen (X360) controllers do not work properly under DirectInput. One example (from memory), is left and right buttons are handled as a single axis. Vibration usually does not work properly and there are many other issues which I can't remember.

As of 2005, you should be using XInput for all X360 controllers. XInput is compatible with XP SP1/DirectX 9 and above, so it should work with pretty much any system out there.

DirectInput can still be used for non-X360 controllers, but DirectInput was officially deprecated in 2011, and WM_INPUT should be able to handle most non-X360 controllers just fine.

Since 2011, Microsoft has strongly recommended that you do not use DirectInput for mouse or keyboard control. Microsoft now requires you to solely use WM_INPUT for keyboard and mouse. DirectInput never properly handled mouse and keyboard in all instances anyway, which is why Mark Sibly had to drop DirectInput in early versions of Blitz Plus and used WM_INPUT instead for keyboard/mouse input. DirectInput does not queue actions and was very problematic when using multiple windows.

Hopefully, this helps any newcomers who may encounter a problem and stumble on this thread when searching for a solution.