Help with input device
Blitz3D Forums/Blitz3D Userlibs/Help with input device
| ||
I'm trying to read a USB device that allows me to test rotary encoders. The device enumerates as a standard HID controller although not as joystick or mouse etc... I have a .dll from the manufacturer and have placed it in the userlibs dir. I have also created a .decls file which looks like this: .lib "spinkit.dll" SpinKitOpenDevice%():"SpinKitOpenDevice" SpinKitCloseDevice% (devHandle%):"SpinKitCloseDevice" SpinKitRead%(devHandle%,SpinData*):"SpinKitRead" SpinKitReadImmediate%(devHandle%,SpinData*):"SpinKitReadImmediate" SpinKitGetNumDevs%():"SpinKitGetNumDevs" SpinKitGetDeviceHandle%(numDevice%):"SpinKitGetDeviceHandle" SpinKitGetProductId%(devHandle%):"SpinKitGetProductId" SpinKitGetRevision%(devHandle%):"SpinKitGetRevision" SpinKitGetThreadHandle%(devHandle%):"SpinKitGetThreadHandle" SpinKitGetSerialNumber%(devHandle%):"SpinKitGetSerialNumber" SpinKitSetTimeout(devHandle%,timeout%):"SpinKitSetTimeout" SpinKitVersion%():"SpinKitVersion" All of the functions seem to work fine except I cant seem to figure out how to use SpinKitRead%(devHandle%,SpinData*) and SpinKitReadImmediate%(devHandle%,SpinData*). I'm sort of familliar with using a bank to point the data to as in GetCursorPos from user32.dll but it doesn't seem to work the same way. In the documentation for the device they give a data structure that looks like this: typedef struct _SPINKIT_DATA { SPINKIT_HANDLE Device; int Spins[6] BOOL Buttons[7] } SPINKIT_DATA, *PSPINKIT_DATA; I was also provided with a working example app with source code which runs fine but it is written in Delphi and I am not familliar with the syntax. It should be fairly straight foreward retrieve the data in Blitz and the SpinKitGetDeviceHandle%(numDevice%) function works fine but SpinKitRead%(devHandle%,SpinData*) returns zero when it should be nonzero and there is no data in the bank. Any help would be greatly appreciated. Thanks! |
| ||
I would wrap all the api functions in a dll and add an accessor function which reads the data from C and pass it to blitz. If you want to pass the bank pointer like you tried you will have to do some fancy tricks with memory, look for a blitz hack somewhere on these forums ... >> I suppose SpinKitReadImmediate is a callback. |
| ||
Well you seem to be barking up the right tree. Post some code so we can see what you have so far. |