diff options
Diffstat (limited to 'ClientHamr/extantz/extantz.c')
-rw-r--r-- | ClientHamr/extantz/extantz.c | 121 |
1 files changed, 110 insertions, 11 deletions
diff --git a/ClientHamr/extantz/extantz.c b/ClientHamr/extantz/extantz.c index fb15019..46dc8a3 100644 --- a/ClientHamr/extantz/extantz.c +++ b/ClientHamr/extantz/extantz.c | |||
@@ -329,6 +329,107 @@ load_shader(GLData *gld, GLenum type, const char *shader_src) | |||
329 | return shader; | 329 | return shader; |
330 | } | 330 | } |
331 | 331 | ||
332 | static void _cb_mouse_down_GL(void *data, Evas *evas, Evas_Object *obj, void *event_info) | ||
333 | { | ||
334 | GLData *gld = data; | ||
335 | Evas_Event_Mouse_Down *ev = event_info; | ||
336 | |||
337 | if (1 == ev->button) | ||
338 | { | ||
339 | gld->camFocus = 1; | ||
340 | printf("Background GL object focused.\n"); | ||
341 | } | ||
342 | } | ||
343 | |||
344 | static void _cb_mouse_down_elm(void *data, Evas *evas, Evas_Object *obj, void *event_info) | ||
345 | { | ||
346 | GLData *gld = data; | ||
347 | Evas_Event_Mouse_Down *ev = event_info; | ||
348 | |||
349 | if (1 == ev->button) | ||
350 | { | ||
351 | gld->camFocus = 0; | ||
352 | // TODO - Yes we really DO need to figure out what was clicked on and set focus to it. sigh | ||
353 | // For now, we only got one window, focus on it's box. | ||
354 | elm_object_focus_set(gld->bx, EINA_TRUE); | ||
355 | printf("ELM object focused.\n"); | ||
356 | } | ||
357 | } | ||
358 | |||
359 | static Eina_Bool _on_camera_input(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info) | ||
360 | { | ||
361 | GLData *gld = data; | ||
362 | |||
363 | if (gld->camFocus) | ||
364 | { | ||
365 | if (gld->move) | ||
366 | { | ||
367 | // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't now at what point the camera animate routine is actually called. | ||
368 | Evas_Event_Key_Down *ev = event_info; | ||
369 | |||
370 | // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ... | ||
371 | // TODO - make this a hash lookup dammit. | ||
372 | // TODO - these are not working, coz Elm is grabbing the Left, Right, Up, and Down KEY_DOWNs. | ||
373 | if (EVAS_CALLBACK_KEY_DOWN == type) | ||
374 | { | ||
375 | if (0 == strcmp(ev->keyname, "Escape")) | ||
376 | { | ||
377 | } | ||
378 | else if (0 == strcmp(ev->key, "Left")) | ||
379 | gld->move->y = 1.0; | ||
380 | else if (0 == strcmp(ev->key, "Right")) | ||
381 | gld->move->y = -1.0; | ||
382 | else if (0 == strcmp(ev->key, "Up")) | ||
383 | gld->move->x = 1.0; | ||
384 | else if (0 == strcmp(ev->key, "Down")) | ||
385 | gld->move->x = -1.0; | ||
386 | else if (0 == strcmp(ev->key, "Prior")) | ||
387 | gld->move->x = 1.0; | ||
388 | else if (0 == strcmp(ev->key, "Next")) | ||
389 | gld->move->x = -1.0; | ||
390 | else if (0 == strcmp(ev->key, "Home")) | ||
391 | gld->move->y = 1.0; | ||
392 | else if (0 == strcmp(ev->key, "End")) | ||
393 | gld->move->y = -1.0; | ||
394 | else if (0 == strcmp(ev->key, "space")) | ||
395 | gld->move->jump = 1.0; | ||
396 | else | ||
397 | printf("Unexpected down keystroke - %s\n", ev->key); | ||
398 | } | ||
399 | else if (EVAS_CALLBACK_KEY_UP == type) | ||
400 | { | ||
401 | if (0 == strcmp(ev->keyname, "Escape")) | ||
402 | { | ||
403 | } | ||
404 | else if (0 == strcmp(ev->key, "Left")) | ||
405 | gld->move->y = 0.0; | ||
406 | else if (0 == strcmp(ev->key, "Right")) | ||
407 | gld->move->y = 0.0; | ||
408 | else if (0 == strcmp(ev->key, "Up")) | ||
409 | gld->move->x = 0.0; | ||
410 | else if (0 == strcmp(ev->key, "Down")) | ||
411 | gld->move->x = 0.0; | ||
412 | else if (0 == strcmp(ev->key, "Prior")) | ||
413 | gld->move->x = 0.0; | ||
414 | else if (0 == strcmp(ev->key, "Next")) | ||
415 | gld->move->x = 0.0; | ||
416 | else if (0 == strcmp(ev->key, "Home")) | ||
417 | gld->move->y = 0.0; | ||
418 | else if (0 == strcmp(ev->key, "End")) | ||
419 | gld->move->y = 0.0; | ||
420 | else if (0 == strcmp(ev->key, "space")) | ||
421 | gld->move->jump = 0.0; | ||
422 | else | ||
423 | printf("Unexpected up keystroke - %s\n", ev->key); | ||
424 | } | ||
425 | } | ||
426 | else | ||
427 | printf("Camera input not ready\n"); | ||
428 | } | ||
429 | |||
430 | return EINA_FALSE; // TRUE = event was processed here, don't propagate. FALSE = propagate event, not processed here. | ||
431 | } | ||
432 | |||
332 | static void _resize(GLData *gld) | 433 | static void _resize(GLData *gld) |
333 | { | 434 | { |
334 | Evas_GL_API *gl = gld->glapi; | 435 | Evas_GL_API *gl = gld->glapi; |
@@ -441,6 +542,7 @@ on_del(void *data, Evas *e, Evas_Object *obj, void *event_info) | |||
441 | if (!gld) return; | 542 | if (!gld) return; |
442 | Evas_GL_API *gl = gld->glapi; | 543 | Evas_GL_API *gl = gld->glapi; |
443 | 544 | ||
545 | elm_object_event_callback_del(gld->r1, _on_camera_input, gld); | ||
444 | ecore_animator_del(gld->animator); | 546 | ecore_animator_del(gld->animator); |
445 | 547 | ||
446 | if (gld->useEGL) | 548 | if (gld->useEGL) |
@@ -635,6 +737,11 @@ static void init_evas_gl(GLData *gld, int w, int h) | |||
635 | // ecore_animator_frametime_set(1.0); | 737 | // ecore_animator_frametime_set(1.0); |
636 | gld->animator = ecore_animator_add(doFrame, gld); // This animator will be called every frame tick, which defaults to 1/30 seconds. | 738 | gld->animator = ecore_animator_add(doFrame, gld); // This animator will be called every frame tick, which defaults to 1/30 seconds. |
637 | 739 | ||
740 | // In this code, we are making our own camera, so grab it's input when we are focused. | ||
741 | elm_object_event_callback_add(gld->win, _on_camera_input, gld); | ||
742 | evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_GL, gld); | ||
743 | gld->camFocus = 1; // Start with the GL camera focused. | ||
744 | |||
638 | return; | 745 | return; |
639 | } | 746 | } |
640 | 747 | ||
@@ -752,7 +859,8 @@ static void _grid_sel_cb(void *data, Evas_Object *obj, void *event_info) | |||
752 | // sprintf(buf, "dillo -f -g '%dx%d+%d+%d' %s &", w - (w / 5), h - 30, w / 5, y, thisGrid->splashPage); | 859 | // sprintf(buf, "dillo -f -g '%dx%d+%d+%d' %s &", w - (w / 5), h - 30, w / 5, y, thisGrid->splashPage); |
753 | sprintf(buf, "uzbl -g '%dx%d+%d+%d' -u %s &", w - (w / 5), h - 30, w / 5, y, thisGrid->splashPage); | 860 | sprintf(buf, "uzbl -g '%dx%d+%d+%d' -u %s &", w - (w / 5), h - 30, w / 5, y, thisGrid->splashPage); |
754 | printf("%s ### genlist obj [%p], item pointer [%p]\n", buf, obj, event_info); | 861 | printf("%s ### genlist obj [%p], item pointer [%p]\n", buf, obj, event_info); |
755 | system(buf); | 862 | // comment this out for now, busy dealing with input stuff, don't want to trigger this multiple times. |
863 | // system(buf); | ||
756 | } | 864 | } |
757 | 865 | ||
758 | static void | 866 | static void |
@@ -902,15 +1010,6 @@ fill(Evas_Object *win) | |||
902 | 1010 | ||
903 | evas_object_show(bx); | 1011 | evas_object_show(bx); |
904 | } | 1012 | } |
905 | |||
906 | static void | ||
907 | cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) | ||
908 | { | ||
909 | Evas_Event_Mouse_Down *ev = event_info; | ||
910 | |||
911 | if (ev->button == 1) elm_object_focus_set(obj, EINA_TRUE); | ||
912 | } | ||
913 | |||
914 | static void | 1013 | static void |
915 | cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info) | 1014 | cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info) |
916 | { | 1015 | { |
@@ -1043,7 +1142,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
1043 | 1142 | ||
1044 | win3 = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE); | 1143 | win3 = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE); |
1045 | elm_win_title_set(win3, "world manager"); | 1144 | elm_win_title_set(win3, "world manager"); |
1046 | evas_object_event_callback_add(elm_win_inlined_image_object_get(win3), EVAS_CALLBACK_MOUSE_DOWN, cb_mouse_down, NULL); | 1145 | evas_object_event_callback_add(elm_win_inlined_image_object_get(win3), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld); |
1047 | elm_win_alpha_set(win3, EINA_TRUE); | 1146 | elm_win_alpha_set(win3, EINA_TRUE); |
1048 | fill(win3); | 1147 | fill(win3); |
1049 | // Odd, it needs to be resized twice? | 1148 | // Odd, it needs to be resized twice? |