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)):
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.