DLL problems (again)

BlitzMax Forums/BlitzMax Programming/DLL problems (again)

Kistjes(Posted 2008) [#1]
Here is me again with a troublesome problem.

I bought a Stantum Multitouch 15.4" display panel & development kit. One of the very first true multitouch products commercially available at the moment.
With the product comes a driver, a dll and some documentation. Since I'm one of the fist customers I can get all technical support I need but Stantum cannot answer my questions about connecting the device with BlitzMax. And that is exactly what I would like to achieve.

So, is anyone willing to have a look at the documentation and give me advice how to make the interface between BlitzMax and the dll?

Ok, for anyone interested in this case:
I made something myself already and in general it works.
There is one important call "SMT_Open()"
This call return a opaque pointer (?) to a SMT_SENSOR struct.
I tried to use Int Ptr as the return type. I also tried Byte Ptr and even tried a pointer to a blitzmax "equivilent" of the SMT_SENSOR struct. None of them give a proper result value.
Is anyone of you able to figure out what kind of return value I need to get from SMT_Open().
The same problem probably occurs when I need to have a pointer to the SMT_CURSOR struct and the SMT_DIMENSION struct.

This is what I have written so far:

B.t.w. The applications starts, prints "Opend device". Even a callback to MySMTcallback() is executed resulting in a "Sensor connect" message.
Then the counter starts within the repeat/until loop.
But as soon as I touch the surface of the device UpdateSMT() will block the application.

The SMT reference (this is acually a html page, but I'm not able to upload it, so I just copy past it in a code box (sorry for that)):



Digital Anime(Posted 2008) [#2]
I tried to use Int Ptr as the return type. I also tried Byte Ptr and even tried a pointer to a blitzmax "equivilent" of the SMT_SENSOR struct. None of them give a proper result value.


Did you try just only Int as well without the Ptr to see what returns?

I don't have the device so I cannot test anything, but I was struggling as well with my first project concerning a dll receiving and writing the correct values to and from a relais interface, here is the link :

http://www.blitzmax.com/Community/posts.php?topic=75763#847093

Cannot be of much help further, but hope some of this can help.


SebHoll(Posted 2008) [#3]
Firstly, the SMT_Sensor Type you created is unlikely to work as you have pointers to other types in there. Blitz handles types within types differently to C/C++ as it just stores a pointer instead of the entire struct in the parent type's memory space. If you would like help with creating the SMT_Sensor type, you'll need to post the original C/C++ structs for us including the ones for SMT_Dimensions etc.

Secondly, I think you should be returning a byte pointer and when it is returned, you'll have to copy the memory into a new type instance.

For example:

Local tmpPointer:Byte Ptr = SMT_Open(id,width,height,callbackFunc)
Local tmpSensor:TSMT_Sensor = New TSMT_Sensor
MemCopy Byte Ptr tmpSensor, tmpPointer, SizeOf(tmpSensor)



Kistjes(Posted 2008) [#4]
@Digital Anime: I tried 'Int' but that doesn's work either.

Firstly, the SMT_Sensor Type you created is unlikely to work as you have pointers to other types in there.
I didn't know that.

If you would like help with creating the SMT_Sensor type, you'll need to post the original C/C++ structs for us including the ones for SMT_Dimensions etc.

Here is the documentation found in the API-1 reference:



Brucey(Posted 2008) [#5]
Oooh... new toys :-)

You may find wrapping (some of) the API up in your own C/C++ functions will make your life easier.

Interesting that SMT_Open returns a normal object rather than a pointer to one - which might make your life a bit more interesting.
You could try expecting a Byte Ptr, but it may not work as expected.

If you want access to the fields within the struct, the *easiest* way is to wrap the access in C/C++ calls. Well, that's how I would do it... most the rest will likely try to do everything in BlitzMax... each to their own!

At least the API is nice and small :-)

Good luck !

If you get really stuck (which I'm sure you won't given time), and if you are allowed, maybe you'd like to mail me the Mac version of the SDK, just for fun.


Kistjes(Posted 2008) [#6]
Oooh... new toys :-)

Imagine the new kind of games you can make with a multitouch device (well look at some ideas on the internet ;-)
Can't wait designing my own with BlitzMax! Unfortunetly it's not working yet.

You may find wrapping (some of) the API up in your own C/C++ functions will make your life easier.

I've no idea how to do that (I'm not into C/C++).

If you want access to the fields within the struct

The documentation says the field are all READONLY. Besides that, there are export functions to get the values of these fields. So, no I do not want to access the fields within the struct.

If you get really stuck (which I'm sure you won't given time), and if you are allowed, maybe you'd like to mail me the Mac version of the SDK, just for fun.

Well... I am.
I'll ask Stantum permission to send you the software. But on a Mac everythings works differently, doesn't it? (no dll-stuff). If I send you the "SDK" do you think you can help me out (even without the required hardware)? That would be great!


Brucey(Posted 2008) [#7]
Imagine the new kind of games you can make with a multitouch device

Indeed! Another reason Mark should make some time for ARM :-p

But on a Mac everythings works differently, doesn't it?

A wrapper can be built in such a way that it is cross-platform, and you simply bolt on the appropriate shared library/dll for the relevant platform.
Since the API is so small, it wouldn't take much effort to get something up and running, even without the hardware... since the hard part is getting everything compiling and linking - after that, and assuming the wrap is okay, it should all "just work".

The only reason I mentioned doing some of the wrapping in C/C++ is that it gets away with having to deal with struct offsets and the likes - better to handle those kind of things in native C, rather than kludge something in BlitzMax.


Kistjes(Posted 2008) [#8]
Another reason Mark should make some time for ARM

Perhaps a silly question but what is ARM?


LAB[au](Posted 2008) [#9]
A CPU architecture. http://en.wikipedia.org/wiki/ARM_architecture


Kistjes(Posted 2008) [#10]
Thanks to Brucey the problem is solved.
Now I have a smooth working multi-touch device. I even implemented my first multi-touch game! And people are very enthusiastic!