summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjet-plane <avion.bg@gmail.com>2008-05-22 21:15:16 +0000
committerjet-plane <avion.bg@gmail.com>2008-05-22 21:15:16 +0000
commit0b279a21bdd242f692af611e3d752491ab532020 (patch)
tree0a2f520d43ef84084dce9eb5d0c58a1e5f591141
parent50886f42ec7e629a7c162be728c0dea47e13aaa0 (diff)
downloadmultitouch-0b279a21bdd242f692af611e3d752491ab532020.tar.gz
multitouch-0b279a21bdd242f692af611e3d752491ab532020.tar.bz2
Completed tuio forwarding code
-rw-r--r--multitouch.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/multitouch.c b/multitouch.c
index 5f8da64..3b5fad3 100644
--- a/multitouch.c
+++ b/multitouch.c
@@ -83,7 +83,7 @@ typedef struct _MultitouchDisplay
{
int screenPrivateIndex;
char port[6];
- int fwdport;
+ char fwdport[6];
Bool enabled;
Bool Debug;
Bool Wm;
@@ -109,7 +109,9 @@ MultitouchDisplay *md = GET_MULTITOUCH_DISPLAY (d)
#define MULTITOUCH_SCREEN(s) \
MultitouchScreen *ms = GET_MULTITOUCH_SCREEN (s, GET_MULTITOUCH_DISPLAY (s->display))
-static int findWindowAtPoint( int x, int y)
+/* TODO: draw debug info on cairo, animated effect for each blob, pie (radial) menu */
+
+static int findWindowAtPoint ( int x, int y)
{
char *display_name;
Display *d;
@@ -210,6 +212,7 @@ sendInfoToPlugin (CompDisplay * d, CompOption * argument, int nArgument,
return TRUE;
}
+/* TODO: doesn't work at the moment 4 unknown reason */
static void
multitouchDisplayOptionChanged (CompDisplay *d,
CompOption *opt,
@@ -229,9 +232,9 @@ multitouchDisplayOptionChanged (CompDisplay *d,
printf ("notify fwd:%d\n",md->TuioFwd);
break;
case MultitouchDisplayOptionFwdport:
- md->fwdport = multitouchGetFwdport(d);
+ sprintf (md->fwdport,"%d",multitouchGetFwdport (d));
if (md->Debug)
- printf ("notify portfwd:%d\n",md->fwdport);
+ printf ("notify portfwd:%s\n",md->fwdport);
break;
default:
break;
@@ -537,7 +540,7 @@ static void click_handler(mtEvent event, CompDisplay * d,int BlobID)
break;
case EventDown:
if (md->Wm)
- wid = findWindowAtPoint((int) s->width * blobs[BlobID].x,(int) s->height * blobs[BlobID].y);
+ wid = findWindowAtPoint ((int) s->width * blobs[BlobID].x,(int) s->height * blobs[BlobID].y);
if (md->Debug)
printf("Down handler - blobID: %d WindowID: %d\n",blobs[BlobID].id, wid);
if (wid)
@@ -576,13 +579,25 @@ static void loerror(int num, const char *msg, const char *path)
static int tuioFwd_handler(const char *path, const char *types, lo_arg **argv, int argc,
void *data, void *display)
{
+ CompDisplay *d = (CompDisplay *) display;
+ MULTITOUCH_DISPLAY (d);
+ lo_address t = lo_address_new(NULL, md->fwdport);
+ lo_message fwd = lo_message_new();
int j;
for (j=0; j<argc; j++)
{
- printf("arg %d '%c' ", j, types[j]);
- lo_arg_pp(types[j], argv[j]);
- printf("\n");
+ if ( types[j] == 115 )
+ lo_message_add_string( fwd, (char *) argv[j]);
+ else if ( types[j] == 105 )
+ lo_message_add_int32 (fwd, (int) argv[j]->i);
+ else if ( types[j] == 102 )
+ lo_message_add_float (fwd, (float) argv[j]->f);
+ }
+ if (lo_send_message (t, path, fwd) == -1 && md->Debug)
+ {
+ printf("OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));
}
+ lo_message_free(fwd);
return 0;
}
@@ -734,9 +749,9 @@ multitouchToggleMultitouch (CompDisplay *d,
int unsigned short *fillcolor;
fillcolor = multitouchGetFillColor(s);
sprintf (md->port,"%d",multitouchGetPort (d));
+ sprintf (md->fwdport,"%d",multitouchGetFwdport (d));
ms->CurrentEffect = multitouchGetEffect(d);
md->TuioFwd = multitouchGetEnableFwd(d);
- md->fwdport = multitouchGetFwdport(d);
md->color.R = fillcolor[0];
md->color.G = fillcolor[1];
md->color.B = fillcolor[2];
@@ -754,7 +769,7 @@ multitouchToggleMultitouch (CompDisplay *d,
lo_server_thread_add_method(md->st, NULL, NULL, tuioFwd_handler, d);
lo_server_thread_start(md->st);
if (md->Debug)
- printf ("Multitouch enabled Port: %s Forwarding: %d Port-fwd: %d color RGBA: %d %d %d %d\n",md->port, (int) md->TuioFwd, (int) md->fwdport,fillcolor[0],fillcolor[1],fillcolor[2],fillcolor[3]);
+ printf ("Multitouch enabled Port: %s Forwarding: %d Port-fwd: %s color RGBA: %d %d %d %d\n",md->port, (int) md->TuioFwd, md->fwdport,fillcolor[0],fillcolor[1],fillcolor[2],fillcolor[3]);
}
else
{
@@ -818,7 +833,6 @@ multitouchInitDisplay (CompPlugin * p, CompDisplay * d)
return FALSE;
}
d->base.privates[displayPrivateIndex].ptr = md;
- // For some reason lines above won't works
//multitouchSetPortNotify (d, multitouchDisplayOptionChanged);
//multitouchSetEnableFwdNotify (d, multitouchDisplayOptionChanged);
//multitouchSetFwdportNotify (d, multitouchDisplayOptionChanged);
@@ -850,7 +864,7 @@ multitouchInitObject (CompPlugin * p, CompObject * o)
{
static InitPluginObjectProc dispTab[] =
{
- (InitPluginObjectProc) multitouchInitCore, /* InitCore */
+ (InitPluginObjectProc) multitouchInitCore,
(InitPluginObjectProc) multitouchInitDisplay,
(InitPluginObjectProc) multitouchInitScreen
};