32 #include <scolPlugin.h> 33 #include <scolMemoryHelper.hpp> 45 int TUIO_CURSOR_ADD_CB;
46 int SCOL_TUIO_CURSOR_ADD_CB = 0;
47 int TUIO_CURSOR_REMOVE_CB;
48 int SCOL_TUIO_CURSOR_REMOVE_CB = 1;
49 int TUIO_CURSOR_UPDATE_CB;
50 int SCOL_TUIO_CURSOR_UPDATE_CB = 2;
52 int TUIO_OBJECT_ADD_CB;
53 int SCOL_TUIO_OBJECT_ADD_CB = 3;
54 int TUIO_OBJECT_REMOVE_CB;
55 int SCOL_TUIO_OBJECT_REMOVE_CB = 4;
56 int TUIO_OBJECT_UPDATE_CB;
57 int SCOL_TUIO_OBJECT_UPDATE_CB = 5;
81 int destroyTuioObj(mmachine m, SCOL_PTR_TYPE handsys,
int handscol) {
83 STuioClient* tuioobj = MMgetPointer<STuioClient*>(m, MTOP(handscol));
86 MMsetPointer(m, MTOP(handscol), NULL);
89 MMechostr(MSKDEBUG,
"ObjTUIO destroyed.\n");
106 MMechostr(0,
"_CRTuioClient\n");
111 int sPort = MMpull(m);
114 int channel = MMget(m, 0);
119 MMechostr(MSKDEBUG,
"Channel NIL\n");
131 MMechostr(MSKDEBUG,
"tuioObj failed\n");
132 SAFE_DELETE(tuioObj);
138 if ((MMpushPointer(m, tuioObj) != 0))
140 SAFE_DELETE(tuioObj);
146 k = OBJcreate(m, OBJTUIOSCOL, SCOL_PTR tuioObj, NULL, NULL);
165 MMechostr(MSKDEBUG,
"_DSTuioClient\n");
168 int objTab = MMget(m, 0);
175 OBJdelTM(m, OBJTUIOSCOL, objTab);
176 MMset(m, 0, ITOM(0));
179 MMechostr(MSKDEBUG,
"ok\n");
194 MMechostr(MSKDEBUG,
"_CONNECTTuioClient\n");
197 int objTab = MMget(m, 0);
204 STuioClient* tuioObj = MMgetPointer<STuioClient*>(m, MTOP(objTab));
212 MMset(m, 0, ITOM(1));
214 MMset(m, 0, ITOM(0));
217 MMechostr(MSKDEBUG,
"ok\n");
232 MMechostr(MSKDEBUG,
"_DISCONNECTTuioClient\n");
235 int objTab = MMget(m, 0);
242 STuioClient* tuioObj = MMgetPointer<STuioClient*>(m, MTOP(objTab));
250 MMset(m, 0, ITOM(1));
253 MMechostr(MSKDEBUG,
"ok\n");
276 return OBJaddreflex (m, OBJTUIOSCOL, SCOL_TUIO_CURSOR_ADD_CB);
283 int getTUIOCursorAddCb(mmachine m, SCOL_PTR_TYPE wParam, LONG lParam)
288 if (OBJbeginreflex(m, OBJTUIOSCOL, SCOL_PTR wParam, SCOL_TUIO_CURSOR_ADD_CB))
290 MMechostr(MSKDEBUG,
"ObjTUIO callback not found\n");
295 MMpush(m, ITOM(tuioData->id));
296 MMpush(m, FTOM(tuioData->x));
297 MMpush(m, FTOM(tuioData->y));
298 MMpush(m, FTOM(tuioData->xvel));
299 MMpush(m, FTOM(tuioData->yvel));
302 int k = OBJcallreflex(m, 5 );
327 return OBJaddreflex (m, OBJTUIOSCOL, SCOL_TUIO_CURSOR_UPDATE_CB);
334 int getTUIOCursorUpdateCb(mmachine m, SCOL_PTR_TYPE wParam, LONG lParam)
339 if (OBJbeginreflex(m, OBJTUIOSCOL, SCOL_PTR wParam, SCOL_TUIO_CURSOR_UPDATE_CB))
341 MMechostr(MSKDEBUG,
"ObjTUIO callback not found\n");
346 MMpush(m, ITOM(tuioData->id));
347 MMpush(m, FTOM(tuioData->x));
348 MMpush(m, FTOM(tuioData->y));
349 MMpush(m, FTOM(tuioData->xvel));
350 MMpush(m, FTOM(tuioData->yvel));
353 int k = OBJcallreflex(m, 5 );
373 return OBJaddreflex (m, OBJTUIOSCOL, SCOL_TUIO_CURSOR_REMOVE_CB);
380 int getTUIOCursorRemoveCb(mmachine m, SCOL_PTR_TYPE wParam, LONG lParam)
382 int id = (int)lParam;
385 if (OBJbeginreflex(m, OBJTUIOSCOL, SCOL_PTR wParam, SCOL_TUIO_CURSOR_REMOVE_CB))
387 MMechostr(MSKDEBUG,
"ObjTUIO callback not found\n");
395 int k = OBJcallreflex(m, 1 );
419 return OBJaddreflex (m, OBJTUIOSCOL, SCOL_TUIO_OBJECT_ADD_CB);
426 int getTUIOObjectAddCb(mmachine m, SCOL_PTR_TYPE wParam, LONG lParam)
431 if (OBJbeginreflex(m, OBJTUIOSCOL, SCOL_PTR wParam, SCOL_TUIO_OBJECT_ADD_CB))
433 MMechostr(MSKDEBUG,
"ObjTUIO callback not found\n");
438 MMpush(m, ITOM(tuioData->id));
439 MMpush(m, FTOM(tuioData->x));
440 MMpush(m, FTOM(tuioData->y));
441 MMpush(m, FTOM(tuioData->ang));
442 MMpush(m, FTOM(tuioData->xvel));
443 MMpush(m, FTOM(tuioData->yvel));
444 MMpush(m, FTOM(tuioData->angvel));
447 int k = OBJcallreflex(m, 7 );
474 return OBJaddreflex(m, OBJTUIOSCOL, SCOL_TUIO_OBJECT_UPDATE_CB);
481 int getTUIOObjectUpdateCb(mmachine m, SCOL_PTR_TYPE wParam, LONG lParam)
486 if (OBJbeginreflex(m, OBJTUIOSCOL, SCOL_PTR wParam, SCOL_TUIO_OBJECT_UPDATE_CB))
488 MMechostr(MSKDEBUG,
"ObjTUIO callback not found\n");
493 MMpush(m, ITOM(tuioData->id));
494 MMpush(m, FTOM(tuioData->x));
495 MMpush(m, FTOM(tuioData->y));
496 MMpush(m, FTOM(tuioData->ang));
497 MMpush(m, FTOM(tuioData->xvel));
498 MMpush(m, FTOM(tuioData->yvel));
499 MMpush(m, FTOM(tuioData->angvel));
502 int k = OBJcallreflex(m, 7 );
522 return OBJaddreflex(m, OBJTUIOSCOL, SCOL_TUIO_OBJECT_REMOVE_CB);
529 int getTUIOObjectRemoveCb(mmachine m, SCOL_PTR_TYPE wParam, LONG lParam)
531 int id = (int)lParam;
534 if (OBJbeginreflex(m, OBJTUIOSCOL, SCOL_PTR wParam, SCOL_TUIO_OBJECT_REMOVE_CB))
536 MMechostr(MSKDEBUG,
"ObjTUIO callback not found\n");
544 int k = OBJcallreflex(m, 1 );
558 "_CONNECTTuioClient",
559 "_DISCONNECTTuioClient",
561 "_CBTuioUpdateCursor",
562 "_CBTuioRemoveCursor",
564 "_CBTuioUpdateObject",
565 "_CBTuioRemoveObject" 571 #define NTUIOPKG (sizeof(mTUIOname)/sizeof(char*)) 576 int (*mTUIOfun[NTUIOPKG])(mmachine m)=
596 int mTUIOnarg[NTUIOPKG]=
615 char* mTUIOtype[NTUIOPKG]=
619 "fun [Chn I] ObjTUIO",
623 "fun [ObjTUIO fun [ObjTUIO u0 I F F F F] u1 u0] ObjTUIO",
624 "fun [ObjTUIO fun [ObjTUIO u0 I F F F F] u1 u0] ObjTUIO",
625 "fun [ObjTUIO fun [ObjTUIO u0 I] u1 u0] ObjTUIO",
626 "fun [ObjTUIO fun [ObjTUIO u0 I F F F F F F] u1 u0] ObjTUIO",
627 "fun [ObjTUIO fun [ObjTUIO u0 I F F F F F F] u1 u0] ObjTUIO",
628 "fun [ObjTUIO fun [ObjTUIO u0 I] u1 u0] ObjTUIO" 639 int LoadTUIO(mmachine m)
643 MMechostr(MSKDEBUG,
"\n" );
644 MMechostr(MSKDEBUG,
" > Loading TUIO Support\n");
647 OBJTUIOSCOL = OBJregister(6 , 0, destroyTuioObj,
"OBJTUIOSCOL");
648 k = PKhardpak(m,
"mTUIO.pkg-1.0", NTUIOPKG, mTUIOname, mTUIOfun, mTUIOnarg, mTUIOtype);
651 TUIO_CURSOR_ADD_CB = OBJgetUserEvent();
652 OBJdefEvent(TUIO_CURSOR_ADD_CB, getTUIOCursorAddCb);
654 TUIO_CURSOR_REMOVE_CB = OBJgetUserEvent();
655 OBJdefEvent(TUIO_CURSOR_REMOVE_CB, getTUIOCursorRemoveCb);
657 TUIO_CURSOR_UPDATE_CB = OBJgetUserEvent();
658 OBJdefEvent(TUIO_CURSOR_UPDATE_CB, getTUIOCursorUpdateCb);
660 TUIO_OBJECT_ADD_CB = OBJgetUserEvent();
661 OBJdefEvent(TUIO_OBJECT_ADD_CB, getTUIOObjectAddCb);
663 TUIO_OBJECT_REMOVE_CB = OBJgetUserEvent();
664 OBJdefEvent(TUIO_OBJECT_REMOVE_CB, getTUIOObjectRemoveCb);
666 TUIO_OBJECT_UPDATE_CB = OBJgetUserEvent();
667 OBJdefEvent(TUIO_OBJECT_UPDATE_CB, getTUIOObjectUpdateCb);
669 MMechostr(MSKDEBUG,
" > Successfully Loaded\n\n");
675 MMechostr(MSKDEBUG,
"\n" );
676 MMechostr(MSKDEBUG,
" > Unloading TUIO Support\n");
677 MMechostr(MSKDEBUG,
" > Successfully unloaded\n\n");
689 extern "C" SCOL_EXPORT
int ScolLoadPlugin(mmachine m, cbmachine w)
691 extern "C" SCOL_EXPORT
int ScolStuioLoadPlugin(mmachine m, cbmachine w)
703 extern "C" SCOL_EXPORT
int ScolUnloadPlugin()
705 extern "C" SCOL_EXPORT
int ScolStuioUnloadPlugin()
int _CBTuioAddCursor(mmachine m)
_CBTuioAddCursor : defines callback for TUIO add cursor event
int _DSTuioClient(mmachine m)
_DSTuioClient : Destroy TUIO object
int _CBTuioRemoveObject(mmachine m)
_CBTuioRemoveObject : defines callback for TUIO remove object event
int _CONNECTTuioClient(mmachine m)
_CONNECTTuioClient : This function connect the TUIO client
int _CBTuioAddObject(mmachine m)
_CBTuioAddObject : defines callback for TUIO add object event
int _CBTuioUpdateObject(mmachine m)
_CBTuioUpdateObject : defines callback for TUIO update cursor event
int _CBTuioRemoveCursor(mmachine m)
_CBTuioRemoveCursor : defines callback for TUIO remove cursor event
int _DISCONNECTTuioClient(mmachine m)
_DISCONNECTTuioClient : This function disconnect the TUIO client
int _CBTuioUpdateCursor(mmachine m)
_CBTuioUpdateCursor : defines callback for TUIO update cursor event
int _CRTuioClient(mmachine m)
_CRTuioClient : This function create a TUIO object