From a11322d5de7959e98695445ddb270e0f28c421d5 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Wed, 14 May 2014 09:04:07 +1000 Subject: Implement a half arsed touch_start() from extantz. --- src/extantz/extantz.c | 24 ++++++++++++++++++++ src/extantz/extantz.h | 2 ++ src/extantz/scenri.c | 2 ++ src/love/love.c | 61 +++++++++------------------------------------------ 4 files changed, 38 insertions(+), 51 deletions(-) diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index 848bc9a..e16db3c 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c @@ -83,6 +83,27 @@ static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev) return ECORE_CALLBACK_RENEW; } +static void _onWorldClick(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo) +{ + Evas_3D_Node *n = data; +// Evas_Event_Mouse_Down *ev = einfo; + + if (n) + { + char *name = NULL; + + name = evas_object_data_get(n, "Name"); + if (strcmp("cube", name) == 0) + { + char SID[64]; + + // CUBE_UUID.events.touch_start(1), but we just make one up for now. + snprintf(SID, sizeof(SID), "%08lx-%04lx-%04lx-%04lx-%012lx", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); + sendForth(ourGlobals.server, SID, "events.touch_start(1)"); + } + } +} + static void gldata_init(GLData *gld) { gld->useIrr = USE_IRR; @@ -644,6 +665,9 @@ EAPI_MAIN int elm_main(int argc, char **argv) else PC("Failed to connect to server!"); + // Setup our callback for clicking in world. + ourGlobals.scene->clickCb = _onWorldClick; + elm_run(); if (ourGlobals.server) ecore_con_server_del(ourGlobals.server); diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h index 0bbf76f..bfab4cb 100644 --- a/src/extantz/extantz.h +++ b/src/extantz/extantz.h @@ -158,6 +158,8 @@ typedef struct _Scene_Data Evas_3D_Texture *texture_diffuse; cameraMove *move; + + Evas_Object_Event_Cb clickCb; } Scene_Data; // Elm GL view related data here. diff --git a/src/extantz/scenri.c b/src/extantz/scenri.c index 051d39f..eaec88e 100644 --- a/src/extantz/scenri.c +++ b/src/extantz/scenri.c @@ -75,6 +75,7 @@ static void _on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void { name = evas_object_data_get(n, "Name"); printf("Picked : "); + if (scene->clickCb) scene->clickCb(n, e, o, einfo); } else printf("Not picked : "); @@ -83,6 +84,7 @@ static void _on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void printf("output(%d, %d) canvas(%d, %d) object(%d, %d) scene(%f, %f) texcoord(%f, %f) node(%p) %s mesh(%p)\n", ev->output.x, ev->output.y, ev->canvas.x, ev->canvas.y, obj_x, obj_y, scene_x, scene_y, s, t, n, name, m); + } Scene_Data *scenriAdd(Evas_Object *win) diff --git a/src/love/love.c b/src/love/love.c index e30c292..5fe3c84 100644 --- a/src/love/love.c +++ b/src/love/love.c @@ -372,7 +372,7 @@ static Eina_Bool _addClient(void *data, int type, Ecore_Con_Event_Client_Add *ev static Eina_Bool _dataClient(void *data, int type, Ecore_Con_Event_Client_Data *ev) { -// gameGlobals *ourGlobals = data; + gameGlobals *ourGlobals = data; // char buf[PATH_MAX]; char SID[PATH_MAX]; const char *command; @@ -393,63 +393,22 @@ static Eina_Bool _dataClient(void *data, int type, Ecore_Con_Event_Client_Data * ext[0] = '\0'; command = ext + 1; -#if 0 // Replace this with code to parse what viewers send. - if (0 == strncmp(command, "compile(", 8)) - { - char *temp; - char *file; - - strcpy(buf, &command[8]); - temp = buf; - file = temp; - while (')' != temp[0]) - temp++; - temp[0] = '\0'; - - PD("Compiling %s, %s.", SID, file); - if (compileLSL(ourGlobals, ev->client, SID, file, FALSE)) - { - script *me = calloc(1, sizeof(script)); - - gettimeofday(&me->startTime, NULL); - strncpy(me->SID, SID, sizeof(me->SID)); - strncpy(me->fileName, file, sizeof(me->fileName)); - me->game = ourGlobals; - me->client = ev->client; - eina_hash_add(ourGlobals->scripts, me->SID, me); - eina_hash_add(ourGlobals->names, me->fileName, me); - sendBack(ev->client, SID, "compiled(true)"); - } - else - sendBack(ev->client, SID, "compiled(false)"); - } - else if (0 == strcmp(command, "run()")) + if (0 == strncmp(command, "events.touch_start(", 19)) { + Eina_Iterator *scripts; script *me; - char buf[PATH_MAX]; - me = eina_hash_find(ourGlobals->scripts, SID); - if (me) + // TODO - For now, just send it to everyone. + scripts = eina_hash_iterator_data_new(ourGlobals->scripts); + while(eina_iterator_next(scripts, (void **) &me)) { - sprintf(buf, "%s.lua.out", me->fileName); - newProc(buf, TRUE, me); + sendForth(ourGlobals->serverLuaSL, me->SID, "events.detectedKeys({\"%s\"})", ownerKey); + sendForth(ourGlobals->serverLuaSL, me->SID, "events.detectedNames({\"%s\"})", ownerName); + sendForth(ourGlobals->serverLuaSL, me->SID, "events.touch_start(1)"); } } - else if (0 == strcmp(command, "exit()")) - { - PD("Told to exit."); - ecore_main_loop_quit(); - } else - { - const char *status = NULL; - - status = sendToChannel(ourGlobals, SID, command); - if (status) - PE("Error sending command %s to script %s : %s", command, SID, status); - } -#endif - + PW("Unknown command from client - %s", command); } // Get the next blob to check it. -- cgit v1.1