DLL problems (again)

BlitzMax Forums/BlitzMax Programming/DLL problems (again)

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:
SuperStrict

Import pub.Win32

rem 
	'I tried to make a BlitzMax version of the SMT_Sensor type. No result.
	Type TSMT_Sensor
		Field piID:Short
		Field pasSerialNbr:Byte[8]
		Field poWindow:TSMT_Dimension = New TSMT_Dimension
		Field poDimension:TSMT_Dimension = New TSMT_Dimension
		Field poCallback()
		Field poUserData:Int Ptr
	End Type
	
	Type TSMT_Dimension
		Field piWidth:Short
		Field piHeight:Short
	End Type
	
	Type TSMT_Cursor
		Field piID:Short
		Field piX:Short
		Field piY:Short
		Field piState:Short
		Field piClickNbr:Short
		Field poUserdate:Int Ptr
	End Type
end rem

Global SMT_Open:Int Ptr(id:Short, width:Short, height:Short, callback(iMsg:Int, sensor:Int Ptr, oCursor:Int Ptr), userdata:Int Ptr) "Win32"
Global SMT_Close(sensor:Int Ptr) "Win32"
Global SMT_Update:Int(sensor:Int Ptr) "Win32"
Global SMT_GetSensorID:Int(sensor:Int Ptr) "Win32"
Global SMT_GetSensorCursors:Int Ptr(sensor:Int Ptr) "Win32"
Global SMT_GetCursorNext:Int Ptr(cursor:Int Ptr) "Win32"
Global SMT_GetCursorPrev:Int Ptr(cursor:Int Ptr) "Win32"
Global SMT_GetCursorID:Int(cursor:Int Ptr) "Win32"
Global SMT_GetCursorSensor:Int Ptr(cursor:Int Ptr) "Win32"
Global SMT_GetCursorX:Int(cursor:Int Ptr) "Win32"
Global SMT_GetCursorY:Int(cursor:Int Ptr) "Win32"
Global SMT_GetCursorState:Int(cursor:Int Ptr) "Win32"
Global SMT_GetCursorClickNbr:Int(cursor:Int Ptr) "Win32"

Global goCallback(msg:Int, cursor:Int Ptr)


Global giSMTdll:Int = LoadLibraryA("c:\windows\system32\libSMT.dll")


If giSMTdll Then
	Print "DLL found."
	SMT_Open = GetProcAddress(giSMTdll, "SMT_Open")
	SMT_Close = GetProcAddress(giSMTdll, "SMT_Close")
	SMT_Update = GetProcAddress(giSMTdll, "SMT_Update")
	SMT_GetSensorID = GetProcAddress(giSMTdll, "SMT_GetSensorID")
	SMT_GetSensorCursors = GetProcAddress(giSMTdll, "SMT_GetSensorCursors")
	SMT_GetCursorNext = GetProcAddress(giSMTdll, "SMT_GetCursorNext")
	SMT_GetCursorPrev = GetProcAddress(giSMTdll, "SMT_GetCursorPrev")
	SMT_GetCursorID = GetProcAddress(giSMTdll, "SMT_GetCursorID")
	SMT_GetCursorSensor = GetProcAddress(giSMTdll, "SMT_GetCursorSensor")
	SMT_GetCursorX = GetProcAddress(giSMTdll, "SMT_GetCursorX")
	SMT_GetCursorY = GetProcAddress(giSMTdll, "SMT_GetCursorY")
	SMT_GetCursorState = GetProcAddress(giSMTdll, "SMT_GetCursorState")
	SMT_GetCursorClickNbr = GetProcAddress(giSMTdll, "SMT_GetCursorClickNbr")
Else
	Print "Oops, no dll init."
End If

'Global goSensorObj:Object
Global goSensorObjPtr:Int Ptr' = Varptr(goSensorObj)


Function OpenSMT:Int(iWidth%, iHeight%)
	goSensorObjPtr = SMT_Open(0, Short(iWidth), Short(iHeight), SMT_Callback, Null)
'	DebugStop()
	Return (goSensorObjPtr <> Null)
End Function

Function CloseSMT()
	SMT_Close(goSensorObjPtr)
End Function


Function UpdateSMT:Int()
	Local bRunning% = SMT_Update(goSensorObjPtr)
	Return bRunning
End Function


Function SMT_Callback(iMsg:Int, sensor:Int Ptr, iCursor:Int Ptr)
	goCallback(iMsg, iCursor)
End Function

Function SetSMTCallback(cb(iMgs:Int, iCursor:Int Ptr))
	goCallback = cb
End Function

'end module

Rem	
'external dll functions
SMT_GetCursorClickNbr
SMT_GetCursorID
SMT_GetCursorNext
SMT_GetCursorPrev
SMT_GetCursorSensor
SMT_GetCursorState
SMT_GetCursorUserData
SMT_GetCursorX
SMT_GetCursorY
SMT_GetSensorCallback
SMT_GetSensorCursors
SMT_GetSensorID
SMT_GetSensorMatrixDimension
SMT_GetSensorSerialNbr
SMT_GetSensorUserData
SMT_GetSensorWindowDimension
 
SMT_SetCursorUserData
SMT_SetSensorCallback
SMT_SetSensorUserData
SMT_SetSensorWindowDimension
SMT_Update
End Rem

SetSMTCallback(MySMTcallback)
Print "Callback function set."

If OpenSMT(1280, 800)
	Print "Opened device"
	Print SMT_GetSensorID(goSensorObjPtr)
	Graphics 1280, 800, 0
	SetColor(255, 255, 255)
	Local bRunning% = True
	Local i% = 0
	Repeat
		Cls
		DrawText("running... " + i, 10, 10)
		i:+1
		bRunning = UpdateSMT()
		Flip
	Until KeyHit(KEY_ESCAPE) Or Not bRunning
	EndGraphics()
	
	CloseSMT()
Else
	Print "No device found."
End If

End


Function MySMTcallback(iMsg:Int, iCursor:Int Ptr)
	Select iMsg
		Case 1 Print "Cursor Up: " '+ oCursor.piID
		Case 2 Print "Cursor Down: "' + oCursor.piID
		Case 3 Print "Cursor Move: " '+ oCursor.piID
		Case 4 Print "Cursor Create: " ' + oCursor.piID
		Case 5 Print "Cursor Destroy: " '+ oCursor.piID
		Case 6 Print "Sensor Connect"
		Case 7 Print "Sensor Disconnect"
		Default
			Print "Other message: " + iMsg
	End Select
End Function

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)):
Classes 
struct   SMT_DIMENSION 
  A data type that packs dimension infos for the sensor. More...
 


Typedefs 
typedef struct SMT_SENSOR_PRIVATE *  SMT_SENSOR 
  Type of a Sensor object. It is an opaque pointer to a private structure. 
 
typedef struct SMT_CURSOR_PRIVATE *  SMT_CURSOR 
  Type of a Cursor object. It is an opaque pointer to a private structure. 
 
typedef void(*  SMT_CALLBACK )(SMT_EVENT msg, SMT_SENSOR sensor, SMT_CURSOR cursor) 
  Prototype for the User Callback that will receive all SMK 15.4 events. 
 


Enumerations 
enum   SMT_EVENT { 
  SMT_CURSOR_UP = 1, 
  SMT_CURSOR_DOWN, 
  SMT_CURSOR_MOVE, 
  SMT_CURSOR_CREATE, 
  SMT_CURSOR_DESTROY, 
  SMT_SENSOR_CONNECT, 
  SMT_SENSOR_DISCONNECT 
} 
  Type of Event. This will be passed to the user callback at each incoming event. More...
 


Functions 
SMT Connection management 
int  SMT_Enum (int *smt_id, int size) 
  A function that enumerates the list of SMK sensors attached to the platform. 
 
SMT_SENSOR  SMT_Open (int id, int width, int height, SMT_CALLBACK callback, void *userdata) 
  A function that creates a connection to an SMK device attached to the platform, and returns a sensor object to be used in subsequent calls relating to this device. 
 
void  SMT_Close (SMT_SENSOR sensor) 
  A function that closes the connection to an SMK device. 
 
int  SMT_Update (SMT_SENSOR sensor) 
  A function that fetches a frame of data from a sensor object. 
 
SMT Sensor attributes 
int  SMT_GetSensorID (SMT_SENSOR sensor) 
  A function that returns the ID of a sensor object. 
 
int  SMT_GetSensorSerialNbr (SMT_SENSOR sensor, unsigned char serial_nbr[8]) 
  A function that fetches the serial number of a sensor object. 
 
int  SMT_GetSensorWindowDimension (SMT_SENSOR sensor, SMT_DIMENSION *dim) 
  A function that fetches the dimensions of the virtual window associated with the sensor. 
 
int  SMT_SetSensorWindowDimension (SMT_SENSOR sensor, int width, int height) 
  A function that changes the dimensions of the virtual window associated with the sensor. 
 
int  SMT_GetSensorMatrixDimension (SMT_SENSOR sensor, SMT_DIMENSION *dim) 
  A function that fetches the dimensions of the SMK device in millimeters. The result is stored in an SMT_DIMENSION structure.. 
 
SMT_CALLBACK  SMT_GetSensorCallback (SMT_SENSOR sensor) 
  A function that fetches the user callback associated with the sensor object. 
 
int  SMT_SetSensorCallback (SMT_SENSOR sensor, SMT_CALLBACK callback) 
  A function that sets the user callback for a sensor object. 
 
void *  SMT_GetSensorUserData (SMT_SENSOR sensor) 
  A function that returns the user data associated with a sensor. 
 
int  SMT_SetSensorUserData (SMT_SENSOR sensor, void *userdata) 
  A function that sets the user data associated with a sensor. 
 
SMT Cursors management 
SMT_CURSOR  SMT_GetSensorCursors (SMT_SENSOR sensor) 
  A function that returns the first of all cursors associated with the sensor. 
 
SMT_CURSOR  SMT_GetCursorNext (SMT_CURSOR cursor) 
  A function that returns the next cursor in the cursors list. 
 
SMT_CURSOR  SMT_GetCursorPrev (SMT_CURSOR cursor) 
  A function that returns the previous cursor in the cursors list. 
 
int  SMT_GetCursorID (SMT_CURSOR cursor) 
  A function that returns an integer ID that uniquely identifies a cursor. 
 
SMT_SENSOR  SMT_GetCursorSensor (SMT_CURSOR cursor) 
  A function that returns the sensor object a cursor belongs to. 
 
int  SMT_GetCursorX (SMT_CURSOR cursor) 
  A function that returns the X coordinate of a cursor. 
 
int  SMT_GetCursorY (SMT_CURSOR cursor) 
  A function that returns the Y coordinate of a cursor. 
 
SMT_EVENT  SMT_GetCursorState (SMT_CURSOR cursor) 
  A function that returns the current state of a cursor. 
 
int  SMT_GetCursorClickNbr (SMT_CURSOR cursor) 
  A function that returns the number of clicks that occured for a cursor since its creation or its last SMT_EVENT::SMT_CURSOR_MOVE event. 
 
void *  SMT_GetCursorUserData (SMT_CURSOR cursor) 
  A function that returns the user data associated with a cursor. 
 
int  SMT_SetCursorUserData (SMT_CURSOR cursor, void *userdata) 
  A function that sets the user data associated with a cursor. 
 



--------------------------------------------------------------------------------

Detailed Description
Low level API for communication with Stantum MultiTouch sensors. 

Author:
Stantum 
Version:
1.0 
Date:
March 13th, 2008 

--------------------------------------------------------------------------------

Typedef Documentation
typedef void(* SMT_CALLBACK)(SMT_EVENT msg, SMT_SENSOR sensor, SMT_CURSOR cursor)  

Prototype for the User Callback that will receive all SMK 15.4 events. 


Parameters:
 msg  The event that occurred  
 sensor  The sensor object associated with the event  
 cursor  The cursor object associated with the event. NULL if event is SMT_EVENT::SMT_SENSOR_CONNECT or SMT_EVENT::SMT_SENSOR_DISCONNECT  



--------------------------------------------------------------------------------

Enumeration Type Documentation
enum SMT_EVENT  

Type of Event. This will be passed to the user callback at each incoming event. 


Enumerator: 
SMT_CURSOR_UP  Contact released from touchscreen  
SMT_CURSOR_DOWN  Contact on touchscreen  
SMT_CURSOR_MOVE  Contact moved across touchscreen  
SMT_CURSOR_CREATE  New cursor created  
SMT_CURSOR_DESTROY  Cursor destroyed  
SMT_SENSOR_CONNECT  Connection made to a SMT sensor  
SMT_SENSOR_DISCONNECT  Connection lost to a SMT sensor  



--------------------------------------------------------------------------------

Function Documentation
int SMT_Enum  ( int *  smt_id,  
  int  size   
 )    

A function that enumerates the list of SMK sensors attached to the platform. 


Parameters:
 smt_id  A pointer to an array of int. This will be filled on return with the IDs of existing sensors. If NULL, no array is filled, and the function returns the number of attached sensors.  
 size  The maximum size of the smt_ids array, in terms of how many int values it can contain. If size is not large enough to hold the sensor list, the function does not fill the array and returns the number of attached sensors.  

Returns:
Number of attached sensors 

SMT_SENSOR SMT_Open  ( int  id,  
  int  width,  
  int  height,  
  SMT_CALLBACK  callback,  
  void *  userdata   
 )    

A function that creates a connection to an SMK device attached to the platform, and returns a sensor object to be used in subsequent calls relating to this device. 


Parameters:
 id  The ID of the device to connect to. If 0, the first device found on the platform USB busses is chosen.  
 width  The width for the device touchscreen area. All cursors belonging to this sensor will have their X coordinate scaled between 0 and width-1. If 0, function returns 0.  
 height  The height for the device touchscreen area. All cursors belonging to this sensor will have their Y coordinate scaled between 0 and height-1. If 0, function returns 0.  
 callback  The user callback that will be called for all multitouch events related to this SMK device. This can be NULL.  
 userdata  Optional user data to be associated with the sensor. This will be stored in the sensor object and can be retrieved in subsequent calls.  

Returns:
A sensor object associated with the SMK device. NULL if the device wasn’t found, or if the connection could not be made, or the passed scaling factors were invalid. 

void SMT_Close  ( SMT_SENSOR  sensor   )   

A function that closes the connection to an SMK device. 


Parameters:
 sensor  The sensor object whose connection should be closed. 

This call should be made to cleanly close the connection before the program exits, or to free the SMK device for a future connection. 

int SMT_Update  ( SMT_SENSOR  sensor   )   

A function that fetches a frame of data from a sensor object. 


Parameters:
 sensor  The sensor object that needs updating.  

Returns:
1 if update request was successful. 0 if failed.
This will update the internal list of cursors and their states. This will trigger a call to the user callback (if not NULL) for each event that was detected. This should be called in the application’s main loop. When SMT_Update(SMT_SENSOR sensor) returns 0, the user must call SMT_Close(SMT_SENSOR sensor) on the sensor object before attempting to recreate the connection. 

int SMT_GetSensorID  ( SMT_SENSOR  sensor   )   

A function that returns the ID of a sensor object. 


Parameters:
 sensor  The sensor object.  

Returns:
The ID of the sensor object. 0 is sensor is invalid. 

int SMT_GetSensorSerialNbr  ( SMT_SENSOR  sensor,  
  unsigned char  serial_nbr[8]   
 )    

A function that fetches the serial number of a sensor object. 


Parameters:
 sensor  The sensor object.  
 serial_nbr  An array that will store the serial number on return of the function.  

Returns:
1 if successful, 0 if failed. 

int SMT_GetSensorWindowDimension  ( SMT_SENSOR  sensor,  
  SMT_DIMENSION *  dim   
 )    

A function that fetches the dimensions of the virtual window associated with the sensor. 


Parameters:
 sensor  The sensor object.  
 dim  A structure that will hold the dimensions on return of the function.  

Returns:
1 if successful, 0 if failed. 

int SMT_SetSensorWindowDimension  ( SMT_SENSOR  sensor,  
  int  width,  
  int  height   
 )    

A function that changes the dimensions of the virtual window associated with the sensor. 


Parameters:
 sensor  The sensor object.  
 width  The width value for the sensor.  
 height  The height value for the sensor.  

Returns:
1 if successful, 0 if failed.
This will effectively change the coordinates of all existing cursors to the new range. No SMT_EVENT::SMT_CURSOR_MOVE event are triggered by this coordinate remapping. 

int SMT_GetSensorMatrixDimension  ( SMT_SENSOR  sensor,  
  SMT_DIMENSION *  dim   
 )    

A function that fetches the dimensions of the SMK device in millimeters. The result is stored in an SMT_DIMENSION structure.. 


Parameters:
 sensor  The sensor object.  
 dim  A structure that will hold the dimensions on return of the function.  

Returns:
1 if successful, 0 if failed. 

SMT_CALLBACK SMT_GetSensorCallback  ( SMT_SENSOR  sensor   )   

A function that fetches the user callback associated with the sensor object. 


Parameters:
 sensor  The sensor object.  

Returns:
The callback associated with the sensor. NULL if no callback exists for this sensor, or the sensor object is invalid. 

int SMT_SetSensorCallback  ( SMT_SENSOR  sensor,  
  SMT_CALLBACK  callback   
 )    

A function that sets the user callback for a sensor object. 


Parameters:
 sensor  The sensor object.  
 callback  The user callback to associate with the sensor.  

Returns:
1 if successful, 0 if failed.
The callback will be called for each event related to this sensor. If callback is NULL, the application will not be notified of any events. 

void* SMT_GetSensorUserData  ( SMT_SENSOR  sensor   )   

A function that returns the user data associated with a sensor. 


Parameters:
 sensor  The sensor object.  

Returns:
The user data associated with the sensor. NULL if sensor object is invalid. 

int SMT_SetSensorUserData  ( SMT_SENSOR  sensor,  
  void *  userdata   
 )    

A function that sets the user data associated with a sensor. 


Parameters:
 sensor  The sensor object.  
 userdata  The user data to associate with the sensor.  

Returns:
1 if successful, 0 if sensor object is invalid. 

SMT_CURSOR SMT_GetSensorCursors  ( SMT_SENSOR  sensor   )   

A function that returns the first of all cursors associated with the sensor. 


Parameters:
 sensor  The sensor object.  

Returns:
The first existing cursor object associated with the sensor. NULL if no cursors exist.
Cursors are stored in a linked list when created, and removed from the list upon destruction. 

SMT_CURSOR SMT_GetCursorNext  ( SMT_CURSOR  cursor   )   

A function that returns the next cursor in the cursors list. 


Parameters:
 cursor  The cursor object.  

Returns:
The next cursor object in the list. NULL if cursor is last in the list. 

SMT_CURSOR SMT_GetCursorPrev  ( SMT_CURSOR  cursor   )   

A function that returns the previous cursor in the cursors list. 


Parameters:
 cursor  The cursor object.  

Returns:
The previous cursor object in the list. NULL if cursor is first in the list. 

int SMT_GetCursorID  ( SMT_CURSOR  cursor   )   

A function that returns an integer ID that uniquely identifies a cursor. 


Parameters:
 cursor  The cursor object.  

Returns:
The ID for the cursor. 0 if cursor object is invalid. 

SMT_SENSOR SMT_GetCursorSensor  ( SMT_CURSOR  cursor   )   

A function that returns the sensor object a cursor belongs to. 


Parameters:
 cursor  The cursor object.  

Returns:
The sensor the cursor belongs to. NULL if cursor object is invalid. 

int SMT_GetCursorX  ( SMT_CURSOR  cursor   )   

A function that returns the X coordinate of a cursor. 


Parameters:
 cursor  The cursor object.  

Returns:
The X coordinate of the cursor. This is scaled by the virtual window associated with the parent sensor. X is between 0 and width-1 where width is the width of the virtual window. 0 is returned if cursor object is invalid. 

int SMT_GetCursorY  ( SMT_CURSOR  cursor   )   

A function that returns the Y coordinate of a cursor. 


Parameters:
 cursor  The cursor object.  

Returns:
The Y coordinate of the cursor. This is scaled by the virtual window associated with the parent sensor. Y is between 0 and height-1 where width is the width of the virtual window. 0 is returned if cursor object is invalid. 

SMT_EVENT SMT_GetCursorState  ( SMT_CURSOR  cursor   )   

A function that returns the current state of a cursor. 


Parameters:
 cursor  The cursor object.  

Returns:
The current state of the cursor. Possible return values are SMT_EVENT::SMT_CURSOR_UP, SMT_EVENT::SMT_CURSOR_DOWN, or 0 if cursor object is invalid. 

int SMT_GetCursorClickNbr  ( SMT_CURSOR  cursor   )   

A function that returns the number of clicks that occured for a cursor since its creation or its last SMT_EVENT::SMT_CURSOR_MOVE event. 


Parameters:
 cursor  The cursor object.  

Returns:
The number of clicks that occurred for the cursor.
The click number attribute allows differentiation between a click and a multiclick, which both trigger SMT_EVENT::SMT_CURSOR_DOWN events. 

void* SMT_GetCursorUserData  ( SMT_CURSOR  cursor   )   

A function that returns the user data associated with a cursor. 


Parameters:
 cursor  The cursor object.  

Returns:
The user data associated with the cursor. NULL if no user data was associated with the cursor, or if cursor object is invalid. 

int SMT_SetCursorUserData  ( SMT_CURSOR  cursor,  
  void *  userdata   
 )    

A function that sets the user data associated with a cursor. 


Parameters:
 cursor  The cursor object.  
 userdata  The user data to be associated with the cursor.  

Returns:
1 if successful, 0 if cursor object is invalid. 


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.

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)


@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:
1. Exposed types
The following types are defined by API-1

 enum SMT_EVENT
{
SMT_CURSOR_UP = 0,
SMT_CURSOR_DOWN,
SMT_CURSOR_MOVE,
SMT_CURSOR_CREATE,
SMT_CURSOR_DESTROY,
SMT_SENSOR_CONNECT,
SMT_SENSOR_DISCONNECT
};
Type of Event. This will be passed to the user callback at each new event.

 struct SMT_DIMENSION
{
int width;
int height;
};

 struct SMT_SENSOR
{
int id;
unsigned char serial_nbr[8];
SMT_DIMENSION window;
SMT_DIMENSION dimension;
smt_callback callback;
void *userdata;
};

Structure of a sensor object. The user MUST NOT modify the READ-ONLY parameters to avoid undocumented behaviour of the program.

Members :
int id : READ-ONLY : the id of the sensor.

unsigned char serial_nbr[8] : READ-ONLY : the unique serial number of the sensor. The two first bytes are 0 and reserved for future usage, the last 6 bytes are the STANTUM IEEE OUI unique identifier followed by the product serial number, also known as MAC address.

SMT_DIMENSION window : READ-ONLY : the X,Y dimensions of the sensor active area in pixels. The cursors belonging to this sensor will have X,Y coordinates scaled to the [0, width-1] and [0, height-1] range.

SMT_DIMENSION dimension : READ-ONLY : the X,Y dimensions of the sensor active area in millimetres.

smt_callback callback : READ-WRITE : pointer to the user callback to be called at each event or NULL.

void *userdata : READ-WRITE : an optional user data that will be associated with the sensor.


 struct SMT_CURSOR
{
int id;
int x;
int y;
SMT_EVENT state;
int clicknbr;
void *userdata;
};

Members :
int id : READ-ONLY : the unique id of the cursor. Note that id may be reused a long time after the corresponding cursor have been destroyed.

int x, y : READ-ONLY : the X,Y coordinates of the cursor in pixels.

int state : READ-ONLY : the current state of the cursor, contains either SMT_EVENT_UP or SMT_EVENT_DOWN. Note that cursors may be created in UP state and trigger the DOWN event only once it has
been validated by the system.

int clicknbr : READ-ONLY : when receiving SMT_CURSOR_DOWN event, this contain the number of successive click. 1 for single-click, 2 for double-click, and so on.

void *userdata : READ-WRITE : an optional user data that will be associated with the cursor. The user MUST NOT modify the READ-ONLY parameters to avoid undocumented behaviour of the program.

 typedef void (*smt_callback)(SMT_EVENT msg, SMT_SENSOR *sensor, SMT_CURSOR *cursor);
Prototype for the user callback. This function will be called at each event, so that the user can retrieve the kind of message and informations about the sensor and cursor.


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.

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!

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.

Another reason Mark should make some time for ARM

Perhaps a silly question but what is ARM?

A CPU architecture. http://en.wikipedia.org/wiki/ARM_architecture

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!