summaryrefslogtreecommitdiff
path: root/src/bin/exactness/player.c
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2020-03-03 17:03:41 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2020-03-12 16:41:03 +0100
commitf8299e054234d73ba27b0bf7a6a07120279c92f1 (patch)
treeac48391850caef975393e5078358ee8fc964389a /src/bin/exactness/player.c
parent5c8942bf393f239d9860cb663d1bc6bcbee368e8 (diff)
exactness: factor out _printf() handling into common part
First step to do some re-factoring of the exactness binaries. We will share common parts from the different binaries in common.{c,h} to reduce the code duplication. The start makes _printf() used in various places. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D11456
Diffstat (limited to 'src/bin/exactness/player.c')
-rw-r--r--src/bin/exactness/player.c66
1 files changed, 28 insertions, 38 deletions
diff --git a/src/bin/exactness/player.c b/src/bin/exactness/player.c
index 260d433b46..9e5629aa5b 100644
--- a/src/bin/exactness/player.c
+++ b/src/bin/exactness/player.c
@@ -30,6 +30,7 @@
30#include <Exactness.h> 30#include <Exactness.h>
31 31
32#include "exactness_private.h" 32#include "exactness_private.h"
33#include "common.h"
33 34
34#define PATH_ 1024 35#define PATH_ 1024
35#define CMD_LINE_MAX 256 36#define CMD_LINE_MAX 256
@@ -152,17 +153,6 @@ static Eina_Bool _exit_required = EINA_FALSE;
152static Eina_Bool _pause_request = EINA_FALSE; 153static Eina_Bool _pause_request = EINA_FALSE;
153static Eina_Bool _playing_status = EINA_FALSE; 154static Eina_Bool _playing_status = EINA_FALSE;
154 155
155static void
156_printf(int verbose, const char *fmt, ...)
157{
158 va_list ap;
159 if (!_verbose || verbose > _verbose) return;
160
161 va_start(ap, fmt);
162 vprintf(fmt, ap);
163 va_end(ap);
164}
165
166static Exactness_Image * 156static Exactness_Image *
167_snapshot_shot_get(Evas *e) 157_snapshot_shot_get(Evas *e)
168{ 158{
@@ -226,7 +216,7 @@ _evas_render_post_cb(void *data EINA_UNUSED, const Efl_Event *event)
226 Eo *o = evas_object_image_add(event->object); 216 Eo *o = evas_object_image_add(event->object);
227 evas_object_image_size_set(o, ex_shot->w, ex_shot->h); 217 evas_object_image_size_set(o, ex_shot->w, ex_shot->h);
228 evas_object_image_data_set(o, ex_shot->pixels); 218 evas_object_image_data_set(o, ex_shot->pixels);
229 _printf(1, "Shot taken (%s).\n", filename); 219 ex_printf(1, "Shot taken (%s).\n", filename);
230 if (!evas_object_image_save(o, filename, NULL, NULL)) 220 if (!evas_object_image_save(o, filename, NULL, NULL))
231 { 221 {
232 printf("Cannot save widget to <%s>\n", filename); 222 printf("Cannot save widget to <%s>\n", filename);
@@ -238,7 +228,7 @@ _evas_render_post_cb(void *data EINA_UNUSED, const Efl_Event *event)
238 Exactness_Image *ex_img = e_data; 228 Exactness_Image *ex_img = e_data;
239 memcpy(ex_img, ex_shot, sizeof(Exactness_Image)); 229 memcpy(ex_img, ex_shot, sizeof(Exactness_Image));
240 ex_shot->pixels = NULL; 230 ex_shot->pixels = NULL;
241 _printf(1, "Shot taken (in %s).\n", _dest); 231 ex_printf(1, "Shot taken (in %s).\n", _dest);
242 } 232 }
243 else if (_dest_type == FTYPE_REMOTE) 233 else if (_dest_type == FTYPE_REMOTE)
244 { 234 {
@@ -369,23 +359,23 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
369 { 359 {
370 case EXACTNESS_ACTION_MOUSE_IN: 360 case EXACTNESS_ACTION_MOUSE_IN:
371 { 361 {
372 _printf(1, "Mouse in\n"); 362 ex_printf(1, "Mouse in\n");
373 _printf(2, "%s evas_event_feed_mouse_in n_evas=<%d>\n", __func__, n_evas); 363 ex_printf(2, "%s evas_event_feed_mouse_in n_evas=<%d>\n", __func__, n_evas);
374 if (e) evas_event_feed_mouse_in(e, time(NULL), NULL); 364 if (e) evas_event_feed_mouse_in(e, time(NULL), NULL);
375 break; 365 break;
376 } 366 }
377 case EXACTNESS_ACTION_MOUSE_OUT: 367 case EXACTNESS_ACTION_MOUSE_OUT:
378 { 368 {
379 _printf(1, "Mouse out\n"); 369 ex_printf(1, "Mouse out\n");
380 _printf(2, "%s evas_event_feed_mouse_out n_evas=<%d>\n", __func__, n_evas); 370 ex_printf(2, "%s evas_event_feed_mouse_out n_evas=<%d>\n", __func__, n_evas);
381 if (e) evas_event_feed_mouse_out(e, time(NULL), NULL); 371 if (e) evas_event_feed_mouse_out(e, time(NULL), NULL);
382 break; 372 break;
383 } 373 }
384 case EXACTNESS_ACTION_MOUSE_WHEEL: 374 case EXACTNESS_ACTION_MOUSE_WHEEL:
385 { 375 {
386 Exactness_Action_Mouse_Wheel *t = data; 376 Exactness_Action_Mouse_Wheel *t = data;
387 _printf(1, "Mouse wheel\n"); 377 ex_printf(1, "Mouse wheel\n");
388 _printf(2, "%s evas_event_feed_mouse_wheel n_evas=<%d>\n", __func__, n_evas); 378 ex_printf(2, "%s evas_event_feed_mouse_wheel n_evas=<%d>\n", __func__, n_evas);
389 if (e) evas_event_feed_mouse_wheel(e, t->direction, t->z, time(NULL), NULL); 379 if (e) evas_event_feed_mouse_wheel(e, t->direction, t->z, time(NULL), NULL);
390 380
391 break; 381 break;
@@ -393,7 +383,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
393 case EXACTNESS_ACTION_MULTI_DOWN: 383 case EXACTNESS_ACTION_MULTI_DOWN:
394 { 384 {
395 Exactness_Action_Multi_Event *t = data; 385 Exactness_Action_Multi_Event *t = data;
396 _printf(2, "%s evas_event_feed_multi_down n_evas=<%d>\n", __func__, n_evas); 386 ex_printf(2, "%s evas_event_feed_multi_down n_evas=<%d>\n", __func__, n_evas);
397 if (!t->d) 387 if (!t->d)
398 { 388 {
399 if (e) evas_event_feed_mouse_down(e, t->b, t->flags, time(NULL), NULL); 389 if (e) evas_event_feed_mouse_down(e, t->b, t->flags, time(NULL), NULL);
@@ -412,7 +402,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
412 case EXACTNESS_ACTION_MULTI_UP: 402 case EXACTNESS_ACTION_MULTI_UP:
413 { 403 {
414 Exactness_Action_Multi_Event *t = data; 404 Exactness_Action_Multi_Event *t = data;
415 _printf(2, "%s evas_event_feed_multi_up n_evas=<%d>\n", __func__, n_evas); 405 ex_printf(2, "%s evas_event_feed_multi_up n_evas=<%d>\n", __func__, n_evas);
416 if (!t->d) 406 if (!t->d)
417 { 407 {
418 if (e) evas_event_feed_mouse_up(e, t->b, t->flags, time(NULL), NULL); 408 if (e) evas_event_feed_mouse_up(e, t->b, t->flags, time(NULL), NULL);
@@ -431,7 +421,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
431 case EXACTNESS_ACTION_MULTI_MOVE: 421 case EXACTNESS_ACTION_MULTI_MOVE:
432 { 422 {
433 Exactness_Action_Multi_Move *t = data; 423 Exactness_Action_Multi_Move *t = data;
434 _printf(2, "%s evas_event_feed_multi_move n_evas=<%d>\n", __func__, n_evas); 424 ex_printf(2, "%s evas_event_feed_multi_move n_evas=<%d>\n", __func__, n_evas);
435 if (!t->d) 425 if (!t->d)
436 { 426 {
437 if (e) evas_event_feed_mouse_move(e, t->x, t->y, time(NULL), NULL); 427 if (e) evas_event_feed_mouse_move(e, t->x, t->y, time(NULL), NULL);
@@ -454,7 +444,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
454 case EXACTNESS_ACTION_KEY_DOWN: 444 case EXACTNESS_ACTION_KEY_DOWN:
455 { 445 {
456 Exactness_Action_Key_Down_Up *t = data; 446 Exactness_Action_Key_Down_Up *t = data;
457 _printf(2, "%s evas_event_feed_key_down n_evas=<%d>\n", __func__, n_evas); 447 ex_printf(2, "%s evas_event_feed_key_down n_evas=<%d>\n", __func__, n_evas);
458 if (e) 448 if (e)
459 evas_event_feed_key_down_with_keycode(e, 449 evas_event_feed_key_down_with_keycode(e,
460 t->keyname, t->key, t->string, 450 t->keyname, t->key, t->string,
@@ -464,7 +454,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
464 case EXACTNESS_ACTION_KEY_UP: 454 case EXACTNESS_ACTION_KEY_UP:
465 { 455 {
466 Exactness_Action_Key_Down_Up *t = data; 456 Exactness_Action_Key_Down_Up *t = data;
467 _printf(2, "%s evas_event_feed_key_up n_evas=<%d>\n", __func__, n_evas); 457 ex_printf(2, "%s evas_event_feed_key_up n_evas=<%d>\n", __func__, n_evas);
468 if (e) evas_event_feed_key_up_with_keycode(e, 458 if (e) evas_event_feed_key_up_with_keycode(e,
469 t->keyname, t->key, t->string, 459 t->keyname, t->key, t->string,
470 t->compose, time(NULL), NULL, t->keycode); 460 t->compose, time(NULL), NULL, t->keycode);
@@ -473,7 +463,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
473 } 463 }
474 case EXACTNESS_ACTION_TAKE_SHOT: 464 case EXACTNESS_ACTION_TAKE_SHOT:
475 { 465 {
476 _printf(2, "%s take shot n_evas=<%d>\n", __func__, n_evas); 466 ex_printf(2, "%s take shot n_evas=<%d>\n", __func__, n_evas);
477 if (rect) evas_object_color_set(rect, 0, 0, 255, 255); 467 if (rect) evas_object_color_set(rect, 0, 0, 255, 255);
478 _cur_shot_id++; 468 _cur_shot_id++;
479 if (_dest_type != FTYPE_UNKNOWN && e) _shot_do(e); 469 if (_dest_type != FTYPE_UNKNOWN && e) _shot_do(e);
@@ -489,7 +479,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
489 Eo *o = efl_name_find(e, t->wdg_name); 479 Eo *o = efl_name_find(e, t->wdg_name);
490 if (o) 480 if (o)
491 { 481 {
492 _printf(2, "%s EFL event invoke %s on %s\n", 482 ex_printf(2, "%s EFL event invoke %s on %s\n",
493 __func__, t->event_name, t->wdg_name); 483 __func__, t->event_name, t->wdg_name);
494 Efl_Event_Description d; 484 Efl_Event_Description d;
495 found = EINA_TRUE; 485 found = EINA_TRUE;
@@ -526,7 +516,7 @@ wdg_found:
526 Exactness_Action_Multi_Event *d_event = calloc(1, sizeof(*d_event)); 516 Exactness_Action_Multi_Event *d_event = calloc(1, sizeof(*d_event));
527 Exactness_Action *act, *prev_act = eina_list_data_get(_cur_event_list); 517 Exactness_Action *act, *prev_act = eina_list_data_get(_cur_event_list);
528 518
529 _printf(2, "%s click on %s\n", __func__, t->wdg_name); 519 ex_printf(2, "%s click on %s\n", __func__, t->wdg_name);
530 act = calloc(1, sizeof(*act)); 520 act = calloc(1, sizeof(*act));
531 act->type = EXACTNESS_ACTION_MULTI_MOVE; 521 act->type = EXACTNESS_ACTION_MULTI_MOVE;
532 act->delay_ms = 100; 522 act->delay_ms = 100;
@@ -563,7 +553,7 @@ wdg_found:
563 } 553 }
564 case EXACTNESS_ACTION_STABILIZE: 554 case EXACTNESS_ACTION_STABILIZE:
565 { 555 {
566 _printf(2, "%s stabilize\n", __func__); 556 ex_printf(2, "%s stabilize\n", __func__);
567 if (rect) evas_object_color_set(rect, 255, 165, 0, 255); 557 if (rect) evas_object_color_set(rect, 255, 165, 0, 255);
568 ecore_timer_add(0.1, _stabilization_timer_cb, NULL); 558 ecore_timer_add(0.1, _stabilization_timer_cb, NULL);
569 break; 559 break;
@@ -591,7 +581,7 @@ _feed_event_timer_cb(void *data EINA_UNUSED)
591 if (act->type != EXACTNESS_ACTION_STABILIZE) 581 if (act->type != EXACTNESS_ACTION_STABILIZE)
592 { 582 {
593 act = eina_list_data_get(_cur_event_list); 583 act = eina_list_data_get(_cur_event_list);
594 _printf(2, " %s timer_time=<%f>\n", __func__, act->delay_ms / 1000.0); 584 ex_printf(2, " %s timer_time=<%f>\n", __func__, act->delay_ms / 1000.0);
595 ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL); 585 ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL);
596 } 586 }
597 } 587 }
@@ -605,7 +595,7 @@ _stabilization_timer_cb(void *data EINA_UNUSED)
605 Evas *e; 595 Evas *e;
606#define STAB_MAX 5 596#define STAB_MAX 5
607 static int need_more = STAB_MAX; 597 static int need_more = STAB_MAX;
608 _printf(2, "Not stable yet!\n"); 598 ex_printf(2, "Not stable yet!\n");
609 EINA_LIST_FOREACH(_evas_list, itr, e) 599 EINA_LIST_FOREACH(_evas_list, itr, e)
610 { 600 {
611 if (!e) continue; 601 if (!e) continue;
@@ -629,7 +619,7 @@ _stabilization_timer_cb(void *data EINA_UNUSED)
629 if (_src_type != FTYPE_REMOTE && !_pause_request) 619 if (_src_type != FTYPE_REMOTE && !_pause_request)
630 { 620 {
631 Exactness_Action *act = eina_list_data_get(_cur_event_list); 621 Exactness_Action *act = eina_list_data_get(_cur_event_list);
632 _printf(2, " %s timer_time=<%f>\n", __func__, act->delay_ms / 1000.0); 622 ex_printf(2, " %s timer_time=<%f>\n", __func__, act->delay_ms / 1000.0);
633 ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL); 623 ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL);
634 } 624 }
635 need_more = STAB_MAX; 625 need_more = STAB_MAX;
@@ -836,7 +826,7 @@ _src_feed(void *data EINA_UNUSED)
836 826
837 if (act && act->delay_ms) 827 if (act && act->delay_ms)
838 { 828 {
839 _printf(2, " Waiting <%f>\n", act->delay_ms / 1000.0); 829 ex_printf(2, " Waiting <%f>\n", act->delay_ms / 1000.0);
840 ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL); 830 ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL);
841 } 831 }
842 else 832 else
@@ -853,7 +843,7 @@ _src_open()
853 { 843 {
854 Eina_List *itr, *itr2; 844 Eina_List *itr, *itr2;
855 Exactness_Action *act; 845 Exactness_Action *act;
856 _printf(2, "<%s> Source file is <%s>\n", __func__, _src_filename); 846 ex_printf(2, "<%s> Source file is <%s>\n", __func__, _src_filename);
857 if (_src_type == FTYPE_EXU) 847 if (_src_type == FTYPE_EXU)
858 { 848 {
859 _src_unit = exactness_unit_file_read(_src_filename); 849 _src_unit = exactness_unit_file_read(_src_filename);
@@ -1035,10 +1025,10 @@ _event_key_cb(void *data EINA_UNUSED, const Efl_Event *event)
1035 if (!strcmp(key, PAUSE_KEY_STR) && efl_input_key_pressed_get(evk)) 1025 if (!strcmp(key, PAUSE_KEY_STR) && efl_input_key_pressed_get(evk))
1036 { 1026 {
1037 _pause_request = !_pause_request; 1027 _pause_request = !_pause_request;
1038 if (_pause_request) _printf(1, "Pausing scenario\n"); 1028 if (_pause_request) ex_printf(1, "Pausing scenario\n");
1039 else 1029 else
1040 { 1030 {
1041 _printf(1, "Playing scenario\n"); 1031 ex_printf(1, "Playing scenario\n");
1042 if (!_playing_status) 1032 if (!_playing_status)
1043 _feed_event_timer_cb(NULL); 1033 _feed_event_timer_cb(NULL);
1044 } 1034 }
@@ -1060,7 +1050,7 @@ _my_evas_new(int w EINA_UNUSED, int h EINA_UNUSED)
1060 e = _evas_new(); 1050 e = _evas_new();
1061 if (e) 1051 if (e)
1062 { 1052 {
1063 _printf(1, "New Evas\n"); 1053 ex_printf(1, "New Evas\n");
1064 _evas_list = eina_list_append(_evas_list, e); 1054 _evas_list = eina_list_append(_evas_list, e);
1065 efl_event_callback_array_add(e, _evas_callbacks(), NULL); 1055 efl_event_callback_array_add(e, _evas_callbacks(), NULL);
1066 } 1056 }
@@ -1297,9 +1287,9 @@ int main(int argc, char **argv)
1297 { 1287 {
1298 argv[i - opt_args] = argv[0] + (argv[i] - argv[opt_args]); 1288 argv[i - opt_args] = argv[0] + (argv[i] - argv[opt_args]);
1299 } 1289 }
1300 _printf(1, "%s ", argv[i - opt_args]); 1290 ex_printf(1, "%s ", argv[i - opt_args]);
1301 } 1291 }
1302 _printf(1, "\n"); 1292 ex_printf(1, "\n");
1303 } 1293 }
1304 else 1294 else
1305 { 1295 {