Refactor structures and make them public
The exu doesn't contain the old scenario entries (Variant_st) but the new (Exactness_Action). The recorder doesn't create old rec file but only exu. The player/inspector support rec files by converting them to the new format internally. The structures have been tried to be simpler.
This commit is contained in:
parent
ffe0659fbe
commit
dc891a41e1
|
@ -4,11 +4,11 @@ bin_PROGRAMS = exactness exactness_inspect exactness_play exactness_record
|
|||
|
||||
exactness_SOURCES = exactness.c ../lib/tsuite_file_data.c ../lib/tsuite_common.c
|
||||
|
||||
exactness_inspect_SOURCES = inspect.c ../lib/tsuite_file_data.c ../lib/tsuite_common.c
|
||||
exactness_inspect_SOURCES = inspect.c ../lib/tsuite_file_data.c ../lib/tsuite_common.c ../lib/file.c
|
||||
|
||||
exactness_play_SOURCES = player.c ../lib/tsuite_file_data.c ../lib/tsuite_common.c
|
||||
exactness_play_SOURCES = player.c ../lib/tsuite_file_data.c ../lib/tsuite_common.c ../lib/file.c
|
||||
|
||||
exactness_record_SOURCES = recorder.c ../lib/tsuite_file_data.c ../lib/tsuite_common.c
|
||||
exactness_record_SOURCES = recorder.c ../lib/tsuite_file_data.c ../lib/tsuite_common.c ../lib/file.c
|
||||
|
||||
exactness_LDADD = @EFL_LIBS@
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#include <Ecore_Getopt.h>
|
||||
#include <Ecore_Evas.h>
|
||||
#include <Elementary.h>
|
||||
#include <Exactness.h>
|
||||
|
||||
#include "tsuite_file_data.h"
|
||||
|
||||
#include "exactness_private.h"
|
||||
#define LDIFF(x) "<b><color=#F0F>"#x"</color></b>"
|
||||
#define RDIFF(x) "<b><color=#0FF>"#x"</color></b>"
|
||||
|
||||
|
@ -48,89 +48,67 @@ static Eina_Bool _show_only_diffs = EINA_FALSE;
|
|||
static Eina_List *_comp_vvs = NULL;
|
||||
|
||||
static const char *
|
||||
_event_name_get(const Variant_st *v)
|
||||
_action_name_get(Exactness_Action *act)
|
||||
{
|
||||
if (!v) return NULL;
|
||||
switch(tsuite_event_mapping_type_get(v->t.type))
|
||||
if (!act) return NULL;
|
||||
switch(act->type)
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_IN: return "Mouse In";
|
||||
case TSUITE_EVENT_MOUSE_OUT: return "Mouse Out";
|
||||
case TSUITE_EVENT_MOUSE_DOWN: return "Mouse Down";
|
||||
case TSUITE_EVENT_MOUSE_UP: return "Mouse Up";
|
||||
case TSUITE_EVENT_MOUSE_MOVE: return "Mouse Move";
|
||||
case TSUITE_EVENT_MOUSE_WHEEL: return "Mouse Wheel";
|
||||
case TSUITE_EVENT_MULTI_DOWN: return "Multi Down";
|
||||
case TSUITE_EVENT_MULTI_UP: return "Multi Up";
|
||||
case TSUITE_EVENT_MULTI_MOVE: return "Multi Move";
|
||||
case TSUITE_EVENT_KEY_DOWN: return "Key Down";
|
||||
case TSUITE_EVENT_KEY_UP: return "Key Up";
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE: return "Key Down with Keycode";
|
||||
case TSUITE_EVENT_KEY_UP_WITH_KEYCODE: return "Key Up with Keycode";
|
||||
case TSUITE_EVENT_TAKE_SHOT: return "Take shot";
|
||||
case EXACTNESS_ACTION_MOUSE_IN: return "Mouse In";
|
||||
case EXACTNESS_ACTION_MOUSE_OUT: return "Mouse Out";
|
||||
case EXACTNESS_ACTION_MOUSE_WHEEL: return "Mouse Wheel";
|
||||
case EXACTNESS_ACTION_MULTI_DOWN: return "Multi Down";
|
||||
case EXACTNESS_ACTION_MULTI_UP: return "Multi Up";
|
||||
case EXACTNESS_ACTION_MULTI_MOVE: return "Multi Move";
|
||||
case EXACTNESS_ACTION_KEY_DOWN: return "Key Down";
|
||||
case EXACTNESS_ACTION_KEY_UP: return "Key Up";
|
||||
case EXACTNESS_ACTION_TAKE_SHOT: return "Take shot";
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_event_struct_len_get(Tsuite_Event_Type type)
|
||||
_event_struct_len_get(Exactness_Action_Type type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_IN: case TSUITE_EVENT_MOUSE_OUT: return sizeof(mouse_in_mouse_out);
|
||||
case TSUITE_EVENT_MOUSE_DOWN: case TSUITE_EVENT_MOUSE_UP: return sizeof(mouse_down_mouse_up);
|
||||
case TSUITE_EVENT_MOUSE_MOVE: return sizeof(mouse_move);
|
||||
case TSUITE_EVENT_MOUSE_WHEEL: return sizeof(mouse_wheel);
|
||||
case TSUITE_EVENT_MULTI_DOWN: case TSUITE_EVENT_MULTI_UP: return sizeof(multi_move);
|
||||
case TSUITE_EVENT_MULTI_MOVE: return sizeof(multi_event);
|
||||
case TSUITE_EVENT_KEY_DOWN: case TSUITE_EVENT_KEY_UP: return sizeof(key_down_key_up);
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE: case TSUITE_EVENT_KEY_UP_WITH_KEYCODE: return sizeof(key_down_key_up_with_keycode);
|
||||
case TSUITE_EVENT_TAKE_SHOT: return sizeof(take_screenshot);
|
||||
case EXACTNESS_ACTION_MOUSE_WHEEL:
|
||||
return sizeof(Exactness_Action_Mouse_Wheel);
|
||||
case EXACTNESS_ACTION_MULTI_DOWN:
|
||||
case EXACTNESS_ACTION_MULTI_UP:
|
||||
return sizeof(Exactness_Action_Multi_Event);
|
||||
case EXACTNESS_ACTION_MULTI_MOVE:
|
||||
return sizeof(Exactness_Action_Multi_Move);
|
||||
case EXACTNESS_ACTION_KEY_DOWN:
|
||||
case EXACTNESS_ACTION_KEY_UP:
|
||||
return sizeof(Exactness_Action_Key_Down_Up);
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_event_specific_info_get(const Variant_st *v, char output[1024])
|
||||
_action_specific_info_get(const Exactness_Action *act, char output[1024])
|
||||
{
|
||||
switch(tsuite_event_mapping_type_get(v->t.type))
|
||||
switch(act->type)
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_DOWN:
|
||||
case EXACTNESS_ACTION_MOUSE_WHEEL:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
sprintf(output, "Button %d Flags %d", t->b, t->flags);
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_UP:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
sprintf(output, "Button %d Flags %d", t->b, t->flags);
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_MOVE:
|
||||
{
|
||||
mouse_move *t = v->data;
|
||||
sprintf(output, "X %d Y %d", t->x, t->y);
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_WHEEL:
|
||||
{
|
||||
mouse_wheel *t = v->data;
|
||||
Exactness_Action_Mouse_Wheel *t = act->data;
|
||||
sprintf(output, "Direction %d Z %d", t->direction, t->z);
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_DOWN: case TSUITE_EVENT_MULTI_UP:
|
||||
case EXACTNESS_ACTION_MULTI_UP: case EXACTNESS_ACTION_MULTI_DOWN:
|
||||
{
|
||||
multi_event *t = v->data;
|
||||
Exactness_Action_Multi_Event *t = act->data;
|
||||
if (!t->d)
|
||||
sprintf(output, "Button %d Flags %d", t->b, t->flags);
|
||||
else
|
||||
sprintf(output, "D %d X %d Y %d Rad %f RadX %f RadY %f Pres %f Ang %f FX %f FY %f Flags %d",
|
||||
t->d, t->x, t->y, t->rad, t->radx, t->rady, t->pres, t->ang, t->fx, t->fy, t->flags);
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_MOVE:
|
||||
}
|
||||
case EXACTNESS_ACTION_MULTI_MOVE:
|
||||
{
|
||||
multi_move *t = v->data;
|
||||
Exactness_Action_Multi_Move *t = act->data;
|
||||
if (!t->d)
|
||||
sprintf(output, "X %d Y %d", t->x, t->y);
|
||||
else
|
||||
|
@ -138,16 +116,9 @@ _event_specific_info_get(const Variant_st *v, char output[1024])
|
|||
t->d, t->x, t->y, t->rad, t->radx, t->rady, t->pres, t->ang, t->fx, t->fy);
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_UP: case TSUITE_EVENT_KEY_DOWN:
|
||||
case EXACTNESS_ACTION_KEY_UP: case EXACTNESS_ACTION_KEY_DOWN:
|
||||
{
|
||||
key_down_key_up *t = v->data;
|
||||
sprintf(output, "Keyname %s Key %s String %s Compose %s",
|
||||
t->keyname, t->key, t->string, t->compose);
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE: case TSUITE_EVENT_KEY_UP_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *t = v->data;
|
||||
Exactness_Action_Key_Down_Up *t = act->data;
|
||||
sprintf(output, "Keyname %s Key %s String %s Compose %s Keycode %d",
|
||||
t->keyname, t->key, t->string, t->compose, t->keycode);
|
||||
break;
|
||||
|
@ -161,38 +132,32 @@ _event_specific_info_get(const Variant_st *v, char output[1024])
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_is_hook_duplicate(const Variant_st *cur_v, const Variant_st *prev_v)
|
||||
_is_hook_duplicate(const Exactness_Action *cur_act, const Exactness_Action *prev_act)
|
||||
{
|
||||
if (!prev_v) return EINA_FALSE;
|
||||
Tsuite_Event_Type cur_type = tsuite_event_mapping_type_get(cur_v->t.type);
|
||||
Tsuite_Event_Type prev_type = tsuite_event_mapping_type_get(prev_v->t.type);
|
||||
if (cur_type == prev_type &&
|
||||
!memcmp(cur_v->data, prev_v->data, _event_struct_len_get(cur_type))) return EINA_TRUE;
|
||||
if (!prev_act) return EINA_FALSE;
|
||||
if (cur_act->type == prev_act->type)
|
||||
{
|
||||
int len = _event_struct_len_get(cur_act->type);
|
||||
return (!len || !memcmp(cur_act->data, prev_act->data, len));
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_are_scenario_entries_different(Variant_st *v1, Variant_st *v2)
|
||||
_are_scenario_entries_different(Exactness_Action *act1, Exactness_Action *act2)
|
||||
{
|
||||
if (!v1 ^ !v2) return EINA_TRUE;
|
||||
if (strcmp(v1->t.type, v2->t.type)) return EINA_TRUE;
|
||||
switch(tsuite_event_mapping_type_get(v1->t.type))
|
||||
if (!act1 ^ !act2) return EINA_TRUE;
|
||||
if (act1->type != act2->type) return EINA_TRUE;
|
||||
switch(act1->type)
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_UP:
|
||||
case TSUITE_EVENT_MOUSE_DOWN:
|
||||
return !!memcmp(v1->data, v2->data, sizeof(mouse_down_mouse_up));
|
||||
case TSUITE_EVENT_MOUSE_MOVE:
|
||||
return !!memcmp(v1->data, v2->data, sizeof(mouse_move));
|
||||
case TSUITE_EVENT_MOUSE_WHEEL:
|
||||
return !!memcmp(v1->data, v2->data, sizeof(mouse_wheel));
|
||||
case TSUITE_EVENT_MULTI_DOWN: case TSUITE_EVENT_MULTI_UP:
|
||||
return !!memcmp(v1->data, v2->data, sizeof(multi_event));
|
||||
case TSUITE_EVENT_MULTI_MOVE:
|
||||
return !!memcmp(v1->data, v2->data, sizeof(multi_move));
|
||||
case TSUITE_EVENT_KEY_UP: case TSUITE_EVENT_KEY_DOWN:
|
||||
return !!memcmp(v1->data, v2->data, sizeof(key_down_key_up));
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE: case TSUITE_EVENT_KEY_UP_WITH_KEYCODE:
|
||||
return !!memcmp(v1->data, v2->data, sizeof(key_down_key_up_with_keycode));
|
||||
case EXACTNESS_ACTION_MOUSE_WHEEL:
|
||||
return !!memcmp(act1->data, act2->data, sizeof(Exactness_Action_Mouse_Wheel));
|
||||
case EXACTNESS_ACTION_MULTI_DOWN: case EXACTNESS_ACTION_MULTI_UP:
|
||||
return !!memcmp(act1->data, act2->data, sizeof(Exactness_Action_Multi_Event));
|
||||
case EXACTNESS_ACTION_MULTI_MOVE:
|
||||
return !!memcmp(act1->data, act2->data, sizeof(Exactness_Action_Multi_Move));
|
||||
case EXACTNESS_ACTION_KEY_UP: case EXACTNESS_ACTION_KEY_DOWN:
|
||||
return !!memcmp(act1->data, act2->data, sizeof(Exactness_Action_Key_Down_Up));
|
||||
default:
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
@ -390,26 +355,22 @@ _scn_text_get(void *data, Evas_Object *gl, const char *part EINA_UNUSED)
|
|||
if (compare)
|
||||
{
|
||||
_Compare_Item_Data *vv = data;
|
||||
Variant_st *v1 = vv->p1;
|
||||
Variant_st *v2 = vv->p2;
|
||||
int tm1 = evt_time_get(0, v1);
|
||||
int tm2 = evt_time_get(0, v2);
|
||||
Tsuite_Event_Type t1 = v1 ? tsuite_event_mapping_type_get(v1->t.type) : TSUITE_EVENT_NOT_SUPPORTED;
|
||||
Tsuite_Event_Type t2 = v2 ? tsuite_event_mapping_type_get(v2->t.type) : TSUITE_EVENT_NOT_SUPPORTED;
|
||||
Exactness_Action *a1 = vv->p1;
|
||||
Exactness_Action *a2 = vv->p2;
|
||||
|
||||
if (tm1 != tm2) eina_strbuf_append_printf(buf, "["LDIFF(%.3f)"/"RDIFF(%.3f)"]: ", tm1/1000.0, tm2/1000.0);
|
||||
else eina_strbuf_append_printf(buf, "%.3f: ", tm1 / 1000.0);
|
||||
if (a1->timestamp != a2->timestamp) eina_strbuf_append_printf(buf, "["LDIFF(%.3f)"/"RDIFF(%.3f)"]: ", a1->timestamp/1000.0, a2->timestamp/1000.0);
|
||||
else eina_strbuf_append_printf(buf, "%.3f: ", a1->timestamp / 1000.0);
|
||||
|
||||
if (t1 != t2)
|
||||
eina_strbuf_append_printf(buf, "["LDIFF(%s)"/"RDIFF(%s)"] - XXXXXX", _event_name_get(v1), _event_name_get(v2));
|
||||
if (a1->type != a2->type)
|
||||
eina_strbuf_append_printf(buf, "["LDIFF(%s)"/"RDIFF(%s)"] - XXXXXX", _action_name_get(a1), _action_name_get(a2));
|
||||
else
|
||||
{
|
||||
char params1[1024];
|
||||
char params2[2024];
|
||||
_event_specific_info_get(v1, params1);
|
||||
_event_specific_info_get(v2, params2);
|
||||
_action_specific_info_get(a1, params1);
|
||||
_action_specific_info_get(a2, params2);
|
||||
|
||||
eina_strbuf_append_printf(buf, "%s", _event_name_get(v1));
|
||||
eina_strbuf_append_printf(buf, "%s", _action_name_get(a1));
|
||||
if (*params1 || *params2)
|
||||
{
|
||||
if (strcmp(params1, params2))
|
||||
|
@ -421,14 +382,13 @@ _scn_text_get(void *data, Evas_Object *gl, const char *part EINA_UNUSED)
|
|||
}
|
||||
else
|
||||
{
|
||||
Variant_st *v = data;
|
||||
unsigned int timestamp = evt_time_get(0, v);
|
||||
Exactness_Action *act = data;
|
||||
char specific_output[1024];
|
||||
if (v)
|
||||
if (act)
|
||||
{
|
||||
eina_strbuf_append_printf(buf, "%.3f: ", timestamp / 1000.0);
|
||||
eina_strbuf_append_printf(buf, "%s", _event_name_get(v));
|
||||
_event_specific_info_get(v, specific_output);
|
||||
eina_strbuf_append_printf(buf, "%.3f: ", act->timestamp / 1000.0);
|
||||
eina_strbuf_append_printf(buf, "%s", _action_name_get(act));
|
||||
_action_specific_info_get(act, specific_output);
|
||||
if (*specific_output) eina_strbuf_append_printf(buf, " - %s", specific_output);
|
||||
}
|
||||
else
|
||||
|
@ -441,17 +401,17 @@ _scn_text_get(void *data, Evas_Object *gl, const char *part EINA_UNUSED)
|
|||
}
|
||||
|
||||
static int
|
||||
_unit_shot_no_get(Exactness_Unit *unit, Variant_st *v_ref)
|
||||
_unit_shot_no_get(Exactness_Unit *unit, Exactness_Action *act_ref)
|
||||
{
|
||||
Eina_List *itr;
|
||||
Variant_st *v;
|
||||
Exactness_Action *act;
|
||||
int ret = 0;
|
||||
if (!unit) return -1;
|
||||
EINA_LIST_FOREACH(unit->events, itr, v)
|
||||
EINA_LIST_FOREACH(unit->actions, itr, act)
|
||||
{
|
||||
if (tsuite_event_mapping_type_get(v->t.type) == TSUITE_EVENT_TAKE_SHOT)
|
||||
if (act->type == EXACTNESS_ACTION_TAKE_SHOT)
|
||||
{
|
||||
if (v == v_ref) return ret;
|
||||
if (act == act_ref) return ret;
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
|
@ -505,10 +465,10 @@ _scn_content_get(void *data, Evas_Object *gl, const char *part)
|
|||
if (!strcmp(part, "elm.swallow.end"))
|
||||
{
|
||||
_Compare_Item_Data *vv = data;
|
||||
Variant_st *v1 = vv->p1;
|
||||
Variant_st *v2 = vv->p2;
|
||||
if (tsuite_event_mapping_type_get(v1->t.type) == TSUITE_EVENT_TAKE_SHOT &&
|
||||
tsuite_event_mapping_type_get(v2->t.type) == TSUITE_EVENT_TAKE_SHOT)
|
||||
Exactness_Action *v1 = vv->p1;
|
||||
Exactness_Action *v2 = vv->p2;
|
||||
if (v1->type == EXACTNESS_ACTION_TAKE_SHOT &&
|
||||
v2->type == EXACTNESS_ACTION_TAKE_SHOT)
|
||||
{
|
||||
Eo *gl1 = eina_list_nth(_gls, 0);
|
||||
Eo *gl2 = eina_list_nth(_gls, 1);
|
||||
|
@ -548,7 +508,7 @@ _scn_content_get(void *data, Evas_Object *gl, const char *part)
|
|||
{
|
||||
if (!strcmp(part, "elm.swallow.end"))
|
||||
{
|
||||
Variant_st *v = data;
|
||||
Exactness_Action *v = data;
|
||||
Exactness_Unit *unit = efl_key_data_get(gl, "unit");
|
||||
int shot_no = _unit_shot_no_get(unit, v);
|
||||
Exactness_Image *ex_img = shot_no != -1 ? eina_list_nth(unit->imgs, shot_no) : NULL;
|
||||
|
@ -988,8 +948,8 @@ _gui_unit_display(Exactness_Unit *unit1, Exactness_Unit *unit2)
|
|||
}
|
||||
_itc_init();
|
||||
|
||||
itr1 = unit1 ? unit1->events : NULL;
|
||||
itr2 = unit2 ? unit2->events : NULL;
|
||||
itr1 = unit1 ? unit1->actions : NULL;
|
||||
itr2 = unit2 ? unit2->actions : NULL;
|
||||
|
||||
if (itr1)
|
||||
elm_genlist_item_append(gl1, _grp_itc, (void *)EX_SCENARIO, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
|
||||
|
@ -1000,8 +960,8 @@ _gui_unit_display(Exactness_Unit *unit1, Exactness_Unit *unit2)
|
|||
}
|
||||
while (itr1 || itr2)
|
||||
{
|
||||
Variant_st *v1 = itr1 ? eina_list_data_get(itr1) : NULL;
|
||||
Variant_st *v2 = itr2 ? eina_list_data_get(itr2) : NULL;
|
||||
Exactness_Action *v1 = itr1 ? eina_list_data_get(itr1) : NULL;
|
||||
Exactness_Action *v2 = itr2 ? eina_list_data_get(itr2) : NULL;
|
||||
if (!_show_only_diffs || _are_scenario_entries_different(v1, v2))
|
||||
{
|
||||
_Item_Info *ii = calloc(1, sizeof(*ii));
|
||||
|
@ -1145,11 +1105,11 @@ static const Ecore_Getopt optdesc = {
|
|||
0,
|
||||
{
|
||||
ECORE_GETOPT_STORE_USHORT('d', "delay", "Delay the given recording by a given time (in milliseconds)."),
|
||||
ECORE_GETOPT_STORE_TRUE('c', "clean", "Clean the given recording from wrong events."),
|
||||
ECORE_GETOPT_STORE_TRUE('l', "list", "List the events of the given recording."),
|
||||
ECORE_GETOPT_STORE_TRUE('c', "clean", "Clean the given recording from wrong actions."),
|
||||
ECORE_GETOPT_STORE_TRUE('l', "list", "List the actions of the given recording."),
|
||||
ECORE_GETOPT_STORE_TRUE('C', "compare", "Compare given files (images files or objects eet files)."),
|
||||
ECORE_GETOPT_STORE_TRUE(0, "show-only-diffs", "Show only differences during comparison."),
|
||||
ECORE_GETOPT_STORE_STR('o', "compare_output", "Output of the comparison."),
|
||||
ECORE_GETOPT_STORE_STR('o', "output", "Output."),
|
||||
ECORE_GETOPT_STORE_USHORT('s', "shot", "Select a specific shot (1 = 1st shot...)."),
|
||||
|
||||
ECORE_GETOPT_LICENSE('L', "license"),
|
||||
|
@ -1165,19 +1125,21 @@ main(int argc, char *argv[])
|
|||
{
|
||||
const char *ext = NULL;
|
||||
const char *rec_file = NULL;
|
||||
char *compare_output = NULL;
|
||||
char *output = NULL;
|
||||
Exactness_Unit *unit = NULL;
|
||||
int ret = 1, args = 0;
|
||||
unsigned short delay = 0, shot = 0;
|
||||
Eina_Bool write_file = EINA_FALSE;
|
||||
Eina_Bool want_quit, clean = EINA_FALSE, list_get = EINA_FALSE, compare_files = EINA_FALSE;
|
||||
Eina_Bool show_only_diffs = EINA_FALSE, gui_needed = EINA_TRUE;
|
||||
|
||||
Ecore_Getopt_Value values[] = {
|
||||
ECORE_GETOPT_VALUE_USHORT(delay),
|
||||
ECORE_GETOPT_VALUE_BOOL(clean),
|
||||
ECORE_GETOPT_VALUE_BOOL(list_get),
|
||||
ECORE_GETOPT_VALUE_BOOL(compare_files),
|
||||
ECORE_GETOPT_VALUE_BOOL(show_only_diffs),
|
||||
ECORE_GETOPT_VALUE_STR(compare_output),
|
||||
ECORE_GETOPT_VALUE_STR(output),
|
||||
ECORE_GETOPT_VALUE_USHORT(shot),
|
||||
|
||||
ECORE_GETOPT_VALUE_BOOL(want_quit),
|
||||
|
@ -1225,25 +1187,23 @@ main(int argc, char *argv[])
|
|||
fprintf(stderr, "--show-only-diffs is available with --compare only");
|
||||
goto end;
|
||||
}
|
||||
if (show_only_diffs && compare_output)
|
||||
if (show_only_diffs && output)
|
||||
{
|
||||
fprintf(stderr, "--show-only-diffs works in GUI only");
|
||||
goto end;
|
||||
}
|
||||
_show_only_diffs = show_only_diffs;
|
||||
|
||||
Lists_st *list = NULL;
|
||||
if (clean || delay || list_get)
|
||||
{
|
||||
rec_file = argv[args];
|
||||
Timer_Data td;
|
||||
gui_needed = EINA_FALSE;
|
||||
list = read_events(rec_file, &td);
|
||||
unit = legacy_rec_file_read(rec_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
int arg;
|
||||
if (compare_output) gui_needed = EINA_FALSE;
|
||||
if (output) gui_needed = EINA_FALSE;
|
||||
for (arg = args; arg < argc; arg++)
|
||||
{
|
||||
if (!ext) ext = strrchr(argv[arg], '.');
|
||||
|
@ -1254,20 +1214,17 @@ main(int argc, char *argv[])
|
|||
}
|
||||
if (!strcmp(ext, ".exu"))
|
||||
{
|
||||
Exactness_Unit *ex_unit= unit_eet_read(argv[arg]);
|
||||
Exactness_Unit *ex_unit = exactness_unit_file_read(argv[arg]);
|
||||
_units = eina_list_append(_units, ex_unit);
|
||||
}
|
||||
else if (!strcmp(ext, ".rec"))
|
||||
{
|
||||
Exactness_Unit *ex_unit = calloc(1, sizeof(*ex_unit));
|
||||
Timer_Data td;
|
||||
list = read_events(argv[arg], &td);
|
||||
if (!list)
|
||||
Exactness_Unit *ex_unit = legacy_rec_file_read(argv[arg]);
|
||||
if (!ex_unit)
|
||||
{
|
||||
fprintf(stderr, "Issue while reading %s\n", argv[arg]);
|
||||
goto end;
|
||||
}
|
||||
ex_unit->events = list->variant_list;
|
||||
_units = eina_list_append(_units, ex_unit);
|
||||
}
|
||||
else if (!strcmp(ext, ".png"))
|
||||
|
@ -1287,16 +1244,16 @@ main(int argc, char *argv[])
|
|||
|
||||
if (clean)
|
||||
{
|
||||
Variant_st *v;
|
||||
Exactness_Action *act;
|
||||
Eina_List *itr, *itr2;
|
||||
EINA_LIST_FOREACH_SAFE(list->variant_list, itr, itr2, v)
|
||||
EINA_LIST_FOREACH_SAFE(unit->actions, itr, itr2, act)
|
||||
{
|
||||
if (!evt_time_get(0, v))
|
||||
list->variant_list = eina_list_remove_list(list->variant_list, itr);
|
||||
if (!act->timestamp)
|
||||
unit->actions = eina_list_remove_list(unit->actions, itr);
|
||||
else
|
||||
{
|
||||
if (_is_hook_duplicate(v, eina_list_data_get(eina_list_prev(itr))))
|
||||
list->variant_list = eina_list_remove_list(list->variant_list, itr);
|
||||
if (_is_hook_duplicate(act, eina_list_data_get(eina_list_prev(itr))))
|
||||
unit->actions = eina_list_remove_list(unit->actions, itr);
|
||||
}
|
||||
}
|
||||
write_file = EINA_TRUE;
|
||||
|
@ -1306,26 +1263,20 @@ main(int argc, char *argv[])
|
|||
{
|
||||
if (!shot)
|
||||
{
|
||||
if (!list->first_timestamp)
|
||||
{
|
||||
list->first_timestamp = evt_time_get(0, eina_list_data_get(list->variant_list));
|
||||
}
|
||||
list->first_timestamp -= delay;
|
||||
}
|
||||
else
|
||||
{
|
||||
Variant_st *v;
|
||||
Exactness_Action *act;
|
||||
Eina_List *itr;
|
||||
unsigned int cur_shot = 0;
|
||||
EINA_LIST_FOREACH(list->variant_list, itr, v)
|
||||
EINA_LIST_FOREACH(unit->actions, itr, act)
|
||||
{
|
||||
if (tsuite_event_mapping_type_get(v->t.type) == TSUITE_EVENT_TAKE_SHOT)
|
||||
if (act->type == EXACTNESS_ACTION_TAKE_SHOT)
|
||||
{
|
||||
cur_shot++;
|
||||
if (cur_shot == shot)
|
||||
{
|
||||
take_screenshot *t = v->data;
|
||||
t->timestamp += delay;
|
||||
act->timestamp += delay;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1336,24 +1287,23 @@ main(int argc, char *argv[])
|
|||
|
||||
if (list_get)
|
||||
{
|
||||
Variant_st *v;
|
||||
Exactness_Action *act;
|
||||
Eina_List *itr;
|
||||
EINA_LIST_FOREACH(list->variant_list, itr, v)
|
||||
EINA_LIST_FOREACH(unit->actions, itr, act)
|
||||
{
|
||||
char specific_output[1024];
|
||||
unsigned int timestamp = evt_time_get(0, v);
|
||||
printf("%.3f: %s", timestamp / 1000.0, _event_name_get(v));
|
||||
_event_specific_info_get(v, specific_output);
|
||||
unsigned int timestamp = act->timestamp;
|
||||
printf("%.3f: %s", timestamp / 1000.0, _action_name_get(act));
|
||||
_action_specific_info_get(act, specific_output);
|
||||
if (*specific_output) printf(" - %s", specific_output);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (compare_files && compare_output)
|
||||
if (compare_files && output)
|
||||
{
|
||||
Exactness_Unit *unit1 = NULL, *unit2 = NULL;
|
||||
Eina_List *itr;
|
||||
Exactness_Unit *unit;
|
||||
EINA_LIST_FOREACH(_units, itr, unit)
|
||||
{
|
||||
if (!unit1) unit1 = unit;
|
||||
|
@ -1381,7 +1331,7 @@ main(int argc, char *argv[])
|
|||
img = evas_object_image_add(e);
|
||||
evas_object_image_size_set(img, ex_imgO->w, ex_imgO->h);
|
||||
evas_object_image_data_set(img, ex_imgO->pixels);
|
||||
evas_object_image_save(img, compare_output, NULL, NULL);
|
||||
evas_object_image_save(img, output, NULL, NULL);
|
||||
ecore_evas_free(ee);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1389,12 +1339,12 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
ret = 0;
|
||||
if (rec_file && write_file) write_events(rec_file, list);
|
||||
if (output && write_file) exactness_unit_file_write(unit, output);
|
||||
|
||||
if (gui_needed)
|
||||
{
|
||||
Eina_List *itr;
|
||||
Exactness_Unit *unit, *unit1 = NULL, *unit2 = NULL;
|
||||
Exactness_Unit *unit1 = NULL, *unit2 = NULL;
|
||||
Eina_Bool need_compare = compare_files && eina_list_count(_units) == 2;
|
||||
_item_infos_hash = eina_hash_pointer_new(NULL);
|
||||
_gui_win_create();
|
||||
|
|
226
src/bin/player.c
226
src/bin/player.c
|
@ -20,8 +20,8 @@
|
|||
#include <Ecore_File.h>
|
||||
#include <Ecore_Con.h>
|
||||
#include <Elementary.h>
|
||||
#include <Exactness.h>
|
||||
|
||||
#include "tsuite_file_data.h"
|
||||
#include "exactness_private.h"
|
||||
|
||||
#define MAX_PATH 1024
|
||||
|
@ -173,97 +173,58 @@ _shot_do(Evas *e)
|
|||
static Eina_Bool
|
||||
_feed_event(void *data EINA_UNUSED)
|
||||
{
|
||||
time_t evt_time;
|
||||
static Evas_Object *rect = NULL;
|
||||
static unsigned int rect_evas;
|
||||
|
||||
Exactness_Action *act = eina_list_data_get(_cur_event_list);
|
||||
Eo *e = eina_list_nth(_evas_list, act->n_evas);
|
||||
time_t evt_time = act->timestamp;
|
||||
|
||||
if (rect && rect_evas != act->n_evas)
|
||||
{
|
||||
efl_del(rect);
|
||||
rect = NULL;
|
||||
}
|
||||
if (_verbose && !rect)
|
||||
{
|
||||
rect = evas_object_rectangle_add(eina_list_data_get(_evas_list));
|
||||
rect = evas_object_rectangle_add(e);
|
||||
evas_object_repeat_events_set(rect, EINA_TRUE);
|
||||
evas_object_color_set(rect, 255, 0, 0, 255);
|
||||
evas_object_resize(rect, 15, 15);
|
||||
evas_object_layer_set(rect, 100);
|
||||
evas_object_show(rect);
|
||||
rect_evas = act->n_evas;
|
||||
}
|
||||
|
||||
Variant_st *v = eina_list_data_get(_cur_event_list);
|
||||
switch(tsuite_event_mapping_type_get(v->t.type))
|
||||
switch (act->type)
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_IN:
|
||||
case EXACTNESS_ACTION_MOUSE_IN:
|
||||
{
|
||||
mouse_in_mouse_out *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(1, "Mouse in\n");
|
||||
_printf(2, "%s evas_event_feed_mouse_in timestamp=<%u> t->n_evas=<%d>\n", __func__, t->timestamp, t->n_evas);
|
||||
_printf(2, "%s evas_event_feed_mouse_in timestamp=<%u> n_evas=<%d>\n", __func__, act->timestamp, act->n_evas);
|
||||
if (e) evas_event_feed_mouse_in(e, time(NULL), NULL);
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_OUT:
|
||||
case EXACTNESS_ACTION_MOUSE_OUT:
|
||||
{
|
||||
mouse_in_mouse_out *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(1, "Mouse out\n");
|
||||
_printf(2, "%s evas_event_feed_mouse_out timestamp=<%u> t->n_evas=<%d>\n", __func__, t->timestamp,t->n_evas);
|
||||
_printf(2, "%s evas_event_feed_mouse_out timestamp=<%u> n_evas=<%d>\n", __func__, act->timestamp,act->n_evas);
|
||||
if (e) evas_event_feed_mouse_out(e, time(NULL), NULL);
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_DOWN:
|
||||
case EXACTNESS_ACTION_MOUSE_WHEEL:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(1, "Mouse down\n");
|
||||
_printf(2, "%s evas_event_feed_mouse_down timestamp=<%u> t->n_evas=<%d>\n", __func__, t->timestamp, t->n_evas);
|
||||
if (rect) evas_object_color_set(rect, 255, 255, 0, 255);
|
||||
if (e) evas_event_feed_mouse_down(e, t->b, t->flags, time(NULL), NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_UP:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(1, "Mouse up\n");
|
||||
_printf(2, "%s evas_event_feed_mouse_up timestamp=<%u> t->n_evas=<%d>\n", __func__, t->timestamp,t->n_evas);
|
||||
if (e) evas_event_feed_mouse_up(e, t->b, t->flags, time(NULL), NULL);
|
||||
if (rect) evas_object_color_set(rect, 255, 0, 0, 255);
|
||||
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_MOVE:
|
||||
{
|
||||
mouse_move *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(2, "%s evas_event_feed_mouse_move (x,y)=(%d,%d) timestamp=<%u> t->n_evas=<%d>\n", __func__, t->x, t->y, t->timestamp,t->n_evas);
|
||||
if (e) evas_event_feed_mouse_move(e, t->x, t->y, time(NULL), NULL);
|
||||
|
||||
if (rect)
|
||||
{
|
||||
evas_object_move(rect, t->x, t->y);
|
||||
evas_object_color_set(rect, 255, 0, 0, 255);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_WHEEL:
|
||||
{
|
||||
mouse_wheel *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
Exactness_Action_Mouse_Wheel *t = act->data;
|
||||
_printf(1, "Mouse wheel\n");
|
||||
_printf(2, "%s evas_event_feed_mouse_wheel timestamp=<%u> t->n_evas=<%d>\n", __func__, t->timestamp, t->n_evas);
|
||||
_printf(2, "%s evas_event_feed_mouse_wheel timestamp=<%u> n_evas=<%d>\n", __func__, act->timestamp, act->n_evas);
|
||||
if (e) evas_event_feed_mouse_wheel(e, t->direction, t->z, time(NULL), NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_DOWN:
|
||||
case EXACTNESS_ACTION_MULTI_DOWN:
|
||||
{
|
||||
multi_event *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(2, "%s evas_event_feed_multi_down timestamp=<%u>, t->n_evas=<%d>\n", __func__, t->timestamp,t->n_evas);
|
||||
Exactness_Action_Multi_Event *t = act->data;
|
||||
_printf(2, "%s evas_event_feed_multi_down timestamp=<%u>, n_evas=<%d>\n", __func__, act->timestamp, act->n_evas);
|
||||
if (!t->d)
|
||||
{
|
||||
if (e) evas_event_feed_mouse_down(e, t->b, t->flags, time(NULL), NULL);
|
||||
|
@ -279,12 +240,10 @@ _feed_event(void *data EINA_UNUSED)
|
|||
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_UP:
|
||||
case EXACTNESS_ACTION_MULTI_UP:
|
||||
{
|
||||
multi_event *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(2, "%s evas_event_feed_multi_up timestamp=<%u> t->n_evas=<%d>\n", __func__, t->timestamp,t->n_evas);
|
||||
Exactness_Action_Multi_Event *t = act->data;
|
||||
_printf(2, "%s evas_event_feed_multi_up timestamp=<%u> n_evas=<%d>\n", __func__, act->timestamp,act->n_evas);
|
||||
if (!t->d)
|
||||
{
|
||||
if (e) evas_event_feed_mouse_up(e, t->b, t->flags, time(NULL), NULL);
|
||||
|
@ -300,12 +259,10 @@ _feed_event(void *data EINA_UNUSED)
|
|||
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_MOVE:
|
||||
case EXACTNESS_ACTION_MULTI_MOVE:
|
||||
{
|
||||
multi_move *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(2, "%s evas_event_feed_multi_move timestamp=<%u> t->n_evas=<%d>\n", __func__, t->timestamp, t->n_evas);
|
||||
Exactness_Action_Multi_Move *t = act->data;
|
||||
_printf(2, "%s evas_event_feed_multi_move timestamp=<%u> n_evas=<%d>\n", __func__, act->timestamp, act->n_evas);
|
||||
if (!t->d)
|
||||
{
|
||||
if (e) evas_event_feed_mouse_move(e, t->x, t->y, time(NULL), NULL);
|
||||
|
@ -325,138 +282,91 @@ _feed_event(void *data EINA_UNUSED)
|
|||
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN:
|
||||
case EXACTNESS_ACTION_KEY_DOWN:
|
||||
{
|
||||
key_down_key_up *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(2, "%s evas_event_feed_key_down timestamp=<%u> t->n_evas=<%d>\n", __func__, t->timestamp, t->n_evas);
|
||||
if (e) evas_event_feed_key_down(e,
|
||||
t->keyname, t->key, t->string,
|
||||
t->compose, time(NULL), NULL);
|
||||
|
||||
Exactness_Action_Key_Down_Up *t = act->data;
|
||||
_printf(2, "%s evas_event_feed_key_down timestamp=<%u> n_evas=<%d>\n", __func__, act->timestamp, act->n_evas);
|
||||
if (e)
|
||||
evas_event_feed_key_down_with_keycode(e,
|
||||
t->keyname, t->key, t->string,
|
||||
t->compose, time(NULL), NULL, t->keycode);
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_UP:
|
||||
case EXACTNESS_ACTION_KEY_UP:
|
||||
{
|
||||
key_down_key_up *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(2, "%s evas_event_feed_key_up timestamp=<%u> t->n_evas=<%d>\n", __func__, t->timestamp, t->n_evas);
|
||||
if (e) evas_event_feed_key_up(e,
|
||||
t->keyname, t->key, t->string,
|
||||
t->compose, time(NULL), NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(2, "%s evas_event_feed_key_down_with_keycode timestamp=<%u> t->n_evas=<%d> t->keycode=<%u>\n", __func__, t->timestamp, t->n_evas, t->keycode);
|
||||
if (e) evas_event_feed_key_down_with_keycode(e,
|
||||
Exactness_Action_Key_Down_Up *t = act->data;
|
||||
_printf(2, "%s evas_event_feed_key_up timestamp=<%u> n_evas=<%d>\n", __func__, act->timestamp, act->n_evas);
|
||||
if (e) evas_event_feed_key_up_with_keycode(e,
|
||||
t->keyname, t->key, t->string,
|
||||
t->compose, time(NULL), NULL, t->keycode);
|
||||
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_UP_WITH_KEYCODE:
|
||||
case EXACTNESS_ACTION_TAKE_SHOT:
|
||||
{
|
||||
key_down_key_up_with_keycode *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(2, "%s evas_event_feed_key_up_with_keycode timestamp=<%u> t->n_evas=<%d> t->keycode=<%u>\n", __func__, t->timestamp, t->n_evas, t->keycode);
|
||||
if (e) evas_event_feed_key_up(e,
|
||||
t->keyname, t->key, t->string,
|
||||
t->compose, time(NULL), NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case TSUITE_EVENT_TAKE_SHOT:
|
||||
{
|
||||
take_screenshot *t = v->data;
|
||||
Eo *e = eina_list_nth(_evas_list, t->n_evas);
|
||||
evt_time = t->timestamp;
|
||||
_printf(2, "%s take shot timestamp=<%u> t->n_evas=<%d>\n", __func__, t->timestamp, t->n_evas);
|
||||
_printf(2, "%s take shot timestamp=<%u> n_evas=<%d>\n", __func__, act->timestamp, act->n_evas);
|
||||
if (rect) evas_object_color_set(rect, 0, 0, 255, 255);
|
||||
_cur_shot_id++;
|
||||
if (_dest_type != FTYPE_UNKNOWN && e) _shot_do(e);
|
||||
break;
|
||||
}
|
||||
default: /* All non-input events are not handeled */
|
||||
evt_time = _last_event_time;
|
||||
break;
|
||||
}
|
||||
|
||||
double timer_time;
|
||||
_cur_event_list = eina_list_next(_cur_event_list);
|
||||
|
||||
if (!_cur_event_list)
|
||||
{ /* Finished reading all events */
|
||||
ecore_main_loop_quit();
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
double timer_time;
|
||||
Exactness_Action *cur_act = eina_list_data_get(_cur_event_list);
|
||||
unsigned int current_event_time = cur_act->timestamp;
|
||||
_last_event_time = evt_time;
|
||||
|
||||
_last_event_time = evt_time;
|
||||
if (current_event_time < _last_event_time) /* Could happen with refeed event */
|
||||
current_event_time = _last_event_time;
|
||||
|
||||
unsigned int current_event_time = evt_time_get(evt_time, eina_list_data_get(_cur_event_list));
|
||||
_printf(2, " %s _last_event_time=<%u> current_event_time=<%u>\n", __func__, _last_event_time, current_event_time);
|
||||
timer_time = (current_event_time - _last_event_time) / 1000.0;
|
||||
|
||||
if (current_event_time < _last_event_time) /* Could happen with refeed event */
|
||||
current_event_time = _last_event_time;
|
||||
|
||||
_printf(2, " %s _last_event_time=<%u> current_event_time=<%u>\n", __func__, _last_event_time, current_event_time);
|
||||
timer_time = (current_event_time - _last_event_time) / 1000.0;
|
||||
|
||||
if (!_last_event_time) timer_time = 0.0;
|
||||
|
||||
_printf(2, " %s timer_time=<%f>\n", __func__, timer_time);
|
||||
ecore_timer_add(timer_time, _feed_event, NULL);
|
||||
if (!_last_event_time) timer_time = 0.0;
|
||||
|
||||
_printf(2, " %s timer_time=<%f>\n", __func__, timer_time);
|
||||
ecore_timer_add(timer_time, _feed_event, NULL);
|
||||
}
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_src_open()
|
||||
{
|
||||
unsigned int first_tm = 0;
|
||||
double diff_time = 0; /* Time to wait before feeding the first event */
|
||||
_printf(2, "<%s> Source file is <%s>\n", __func__, _src_filename);
|
||||
if (_src_type == FTYPE_EXU)
|
||||
{
|
||||
_src_unit = unit_eet_read(_src_filename);
|
||||
_src_unit = exactness_unit_file_read(_src_filename);
|
||||
}
|
||||
else if (_src_type == FTYPE_REC)
|
||||
{
|
||||
_src_unit = calloc(1, sizeof(*_src_unit));
|
||||
Lists_st *events_list = read_events(_src_filename, NULL);
|
||||
if (!events_list)
|
||||
{
|
||||
free(_src_unit);
|
||||
_src_unit = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
_src_unit->events = events_list->variant_list;
|
||||
first_tm = events_list->first_timestamp;
|
||||
}
|
||||
_src_unit = legacy_rec_file_read(_src_filename);
|
||||
}
|
||||
if (!_src_unit) return EINA_FALSE;
|
||||
_cur_event_list = _src_unit->events;
|
||||
Variant_st *v = eina_list_data_get(_cur_event_list);
|
||||
_cur_event_list = _src_unit->actions;
|
||||
Exactness_Action *act = eina_list_data_get(_cur_event_list);
|
||||
|
||||
/* Calculate the time to wait before feeding the first event */
|
||||
unsigned int current_event_time = evt_time_get(0, v);
|
||||
if (current_event_time > first_tm)
|
||||
diff_time = (current_event_time - first_tm) / 1000.0;
|
||||
unsigned int current_event_time = act->timestamp;
|
||||
|
||||
_printf(2, "%s first_time_stamp=<%u> current_event_time=<%u>\n", __func__, first_tm, current_event_time);
|
||||
_printf(2, "%s current_event_time=<%u>\n", __func__, current_event_time);
|
||||
|
||||
if (diff_time)
|
||||
if (current_event_time)
|
||||
{
|
||||
_printf(2, " Waiting <%f>\n", diff_time);
|
||||
ecore_timer_add(diff_time, _feed_event, NULL);
|
||||
ecore_timer_add(current_event_time / 1000.0, _feed_event, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -759,8 +669,8 @@ int main(int argc, char **argv)
|
|||
|
||||
if (_dest && _dest_unit)
|
||||
{
|
||||
_dest_unit->events = _src_unit->events;
|
||||
unit_eet_write(_dest_unit, _dest);
|
||||
_dest_unit->actions = _src_unit->actions;
|
||||
exactness_unit_file_write(_dest_unit, _dest);
|
||||
}
|
||||
|
||||
end:
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#include <Ecore_Getopt.h>
|
||||
#include <Ecore_Con.h>
|
||||
#include <Elementary.h>
|
||||
#include <Exactness.h>
|
||||
|
||||
#include "tsuite_file_data.h"
|
||||
#include "exactness_private.h"
|
||||
|
||||
#define MAX_PATH 1024
|
||||
|
@ -34,11 +34,12 @@ static const char *_test_name = NULL;
|
|||
static int _verbose = 0;
|
||||
|
||||
static Eina_List *_evas_list = NULL;
|
||||
static int _last_evas_id = 0;
|
||||
static unsigned int _last_evas_id = 0;
|
||||
|
||||
static Lists_st *_events_list = NULL;
|
||||
static Exactness_Unit *_unit = NULL;
|
||||
|
||||
static char *_shot_key = NULL;
|
||||
static unsigned int _first_timestamp = 0.0;
|
||||
|
||||
static void
|
||||
_printf(int verbose, const char *fmt, ...)
|
||||
|
@ -51,87 +52,53 @@ _printf(int verbose, const char *fmt, ...)
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
static Tsuite_Event_Type
|
||||
static Exactness_Action_Type
|
||||
_event_pointer_type_get(Efl_Pointer_Action t)
|
||||
{
|
||||
switch(t)
|
||||
{
|
||||
case EFL_POINTER_ACTION_IN: return TSUITE_EVENT_MOUSE_IN;
|
||||
case EFL_POINTER_ACTION_OUT: return TSUITE_EVENT_MOUSE_OUT;
|
||||
case EFL_POINTER_ACTION_DOWN: return TSUITE_EVENT_MULTI_DOWN;
|
||||
case EFL_POINTER_ACTION_UP: return TSUITE_EVENT_MULTI_UP;
|
||||
case EFL_POINTER_ACTION_MOVE: return TSUITE_EVENT_MULTI_MOVE;
|
||||
case EFL_POINTER_ACTION_WHEEL: return TSUITE_EVENT_MOUSE_WHEEL;
|
||||
default:
|
||||
return TSUITE_EVENT_NOT_SUPPORTED;
|
||||
case EFL_POINTER_ACTION_IN: return EXACTNESS_ACTION_MOUSE_IN;
|
||||
case EFL_POINTER_ACTION_OUT: return EXACTNESS_ACTION_MOUSE_OUT;
|
||||
case EFL_POINTER_ACTION_DOWN: return EXACTNESS_ACTION_MULTI_DOWN;
|
||||
case EFL_POINTER_ACTION_UP: return EXACTNESS_ACTION_MULTI_UP;
|
||||
case EFL_POINTER_ACTION_MOVE: return EXACTNESS_ACTION_MULTI_MOVE;
|
||||
case EFL_POINTER_ACTION_WHEEL: return EXACTNESS_ACTION_MOUSE_WHEEL;
|
||||
default: return EXACTNESS_ACTION_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
_event_name_get(Tsuite_Event_Type type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_IN: return "Mouse In";
|
||||
case TSUITE_EVENT_MOUSE_OUT: return "Mouse Out";
|
||||
case TSUITE_EVENT_MOUSE_DOWN: return "Mouse Down";
|
||||
case TSUITE_EVENT_MOUSE_UP: return "Mouse Up";
|
||||
case TSUITE_EVENT_MOUSE_MOVE: return "Mouse Move";
|
||||
case TSUITE_EVENT_MOUSE_WHEEL: return "Mouse Wheel";
|
||||
case TSUITE_EVENT_MULTI_DOWN: return "Multi Down";
|
||||
case TSUITE_EVENT_MULTI_UP: return "Multi Up";
|
||||
case TSUITE_EVENT_MULTI_MOVE: return "Multi Move";
|
||||
case TSUITE_EVENT_KEY_DOWN: return "Key Down";
|
||||
case TSUITE_EVENT_KEY_UP: return "Key Up";
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE: return "Key Down with Keycode";
|
||||
case TSUITE_EVENT_KEY_UP_WITH_KEYCODE: return "Key Up with Keycode";
|
||||
case TSUITE_EVENT_TAKE_SHOT: return "Take shot";
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_is_hook_duplicate(const Variant_st *v, Tsuite_Event_Type ev_type, const void *info, int len)
|
||||
{
|
||||
if (v->t.type == tsuite_event_mapping_type_str_get(ev_type) &&
|
||||
!memcmp(v->data, info, len)) return EINA_TRUE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_output_write()
|
||||
{
|
||||
if (!strcmp(_out_filename + strlen(_out_filename) - 4,".exu"))
|
||||
{
|
||||
Exactness_Unit unit;
|
||||
unit.imgs = NULL;
|
||||
unit.events = _events_list->variant_list;
|
||||
unit_eet_write(&unit, _out_filename);
|
||||
}
|
||||
else if (!strcmp(_out_filename + strlen(_out_filename) - 4,".rec"))
|
||||
{
|
||||
write_events(_out_filename, _events_list);
|
||||
}
|
||||
if (_unit) exactness_unit_file_write(_unit, _out_filename);
|
||||
}
|
||||
|
||||
/* Adding variant to list, this list is later written to EET file */
|
||||
#define ADD_TO_LIST(EVT_TYPE, INFO) \
|
||||
do { /* This macro will add event to EET data list */ \
|
||||
if (_events_list) \
|
||||
{ \
|
||||
const Variant_st *prev_v = eina_list_last_data_get(_events_list->variant_list); \
|
||||
if (!prev_v || !_is_hook_duplicate(prev_v, EVT_TYPE, &INFO, sizeof(INFO))) \
|
||||
{ \
|
||||
_printf(1, "Recording %s\n", tsuite_event_mapping_type_str_get(EVT_TYPE)); \
|
||||
Variant_st *v = malloc(sizeof(Variant_st)); \
|
||||
v->data = malloc(sizeof(INFO)); \
|
||||
_variant_type_set(tsuite_event_mapping_type_str_get(EVT_TYPE), \
|
||||
&v->t, EINA_FALSE); \
|
||||
memcpy(v->data, &INFO, sizeof(INFO)); \
|
||||
_events_list->variant_list = eina_list_append(_events_list->variant_list, v); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
static void
|
||||
_add_to_list(Exactness_Action_Type type, unsigned int n_evas, unsigned int timestamp, void *data, int len)
|
||||
{
|
||||
if (_unit)
|
||||
{
|
||||
const Exactness_Action *prev_v = eina_list_last_data_get(_unit->actions);
|
||||
if (prev_v)
|
||||
{
|
||||
if (prev_v->type == type &&
|
||||
prev_v->timestamp + _first_timestamp == timestamp &&
|
||||
prev_v->n_evas == n_evas &&
|
||||
(!len || !memcmp(prev_v->data, data, len))) return;
|
||||
}
|
||||
_printf(1, "Recording %s\n", _exactness_action_type_to_string_get(type));
|
||||
Exactness_Action *act = malloc(sizeof(*act));
|
||||
act->type = type;
|
||||
act->n_evas = n_evas;
|
||||
act->timestamp = timestamp - _first_timestamp;
|
||||
if (len)
|
||||
{
|
||||
act->data = malloc(len);
|
||||
memcpy(act->data, data, len);
|
||||
}
|
||||
_unit->actions = eina_list_append(_unit->actions, act);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_evas_id_get(Evas *e)
|
||||
|
@ -149,11 +116,11 @@ _event_pointer_cb(void *data, const Efl_Event *event)
|
|||
int timestamp = efl_input_timestamp_get(evp);
|
||||
int n_evas = _evas_id_get(eo_e);
|
||||
Efl_Pointer_Action action = efl_input_pointer_action_get(evp);
|
||||
Tsuite_Event_Type evt = _event_pointer_type_get(action);
|
||||
Exactness_Action_Type evt = _event_pointer_type_get(action);
|
||||
|
||||
if (!timestamp) return;
|
||||
|
||||
_printf(2, "Calling \"%s\" timestamp=<%u>\n", _event_name_get(evt), timestamp);
|
||||
_printf(2, "Calling \"%s\" timestamp=<%u>\n", _exactness_action_type_to_string_get(evt), timestamp);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
|
@ -162,8 +129,8 @@ _event_pointer_cb(void *data, const Efl_Event *event)
|
|||
double rad = 0, radx = 0, rady = 0, pres = 0, ang = 0, fx = 0, fy = 0;
|
||||
int tool = efl_input_pointer_tool_get(evp);
|
||||
Eina_Position2D pos = efl_input_pointer_position_get(evp);
|
||||
multi_move t = { tool, pos.x, pos.y, rad, radx, rady, pres, ang, fx, fy, timestamp, n_evas };
|
||||
if (t.n_evas >= 0) ADD_TO_LIST(evt, t);
|
||||
Exactness_Action_Multi_Move t = { tool, pos.x, pos.y, rad, radx, rady, pres, ang, fx, fy };
|
||||
if (n_evas >= 0) _add_to_list(evt, n_evas, timestamp, &t, sizeof(t));
|
||||
break;
|
||||
}
|
||||
case EFL_POINTER_ACTION_DOWN: case EFL_POINTER_ACTION_UP:
|
||||
|
@ -173,23 +140,22 @@ _event_pointer_cb(void *data, const Efl_Event *event)
|
|||
int tool = efl_input_pointer_tool_get(evp);
|
||||
Eina_Position2D pos = efl_input_pointer_position_get(evp);
|
||||
Efl_Pointer_Flags flags = efl_input_pointer_button_flags_get(evp);
|
||||
multi_event t = { tool, b, pos.x, pos.y, rad, radx, rady, pres, ang,
|
||||
fx, fy, flags, timestamp, n_evas };
|
||||
if (t.n_evas >= 0) ADD_TO_LIST(evt, t);
|
||||
Exactness_Action_Multi_Event t = { tool, b, pos.x, pos.y, rad, radx, rady, pres, ang,
|
||||
fx, fy, flags };
|
||||
if (n_evas >= 0) _add_to_list(evt, n_evas, timestamp, &t, sizeof(t));
|
||||
break;
|
||||
}
|
||||
case EFL_POINTER_ACTION_IN: case EFL_POINTER_ACTION_OUT:
|
||||
{
|
||||
mouse_in_mouse_out t = { timestamp, n_evas };
|
||||
if (t.n_evas >= 0) ADD_TO_LIST(evt, t);
|
||||
if (n_evas >= 0) _add_to_list(evt, n_evas, timestamp, NULL, 0);
|
||||
break;
|
||||
}
|
||||
case EFL_POINTER_ACTION_WHEEL:
|
||||
{
|
||||
Eina_Bool horiz = efl_input_pointer_wheel_horizontal_get(evp);
|
||||
int z = efl_input_pointer_wheel_delta_get(evp);
|
||||
mouse_wheel t = { horiz, z, timestamp, n_evas };
|
||||
if (t.n_evas >= 0) ADD_TO_LIST(evt, t);
|
||||
Exactness_Action_Mouse_Wheel t = { horiz, z };
|
||||
if (n_evas >= 0) _add_to_list(evt, n_evas, timestamp, &t, sizeof(t));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -206,41 +172,37 @@ _event_key_cb(void *data, const Efl_Event *event)
|
|||
const char *key = efl_input_key_name_get(evk);
|
||||
int timestamp = efl_input_timestamp_get(evk);
|
||||
unsigned int n_evas = _evas_id_get(eo_e);
|
||||
Tsuite_Event_Type evt = TSUITE_EVENT_KEY_UP_WITH_KEYCODE;
|
||||
Exactness_Action_Type evt = EXACTNESS_ACTION_KEY_UP;
|
||||
|
||||
if (efl_input_key_pressed_get(evk))
|
||||
{
|
||||
if (!strcmp(key, _shot_key))
|
||||
{
|
||||
_printf(2, "Take Screenshot: %s timestamp=<%u>\n", __func__, timestamp);
|
||||
take_screenshot t = { timestamp, n_evas };
|
||||
if (t.n_evas >= 0) ADD_TO_LIST(TSUITE_EVENT_TAKE_SHOT, t);
|
||||
if (n_evas >= 0) _add_to_list(EXACTNESS_ACTION_TAKE_SHOT, n_evas, timestamp, NULL, 0);
|
||||
return;
|
||||
}
|
||||
if (!strcmp(key, SAVE_KEY_STR))
|
||||
{
|
||||
if (_events_list)
|
||||
_output_write();
|
||||
_output_write();
|
||||
_printf(2, "Save events: %s timestamp=<%u>\n", __func__, timestamp);
|
||||
return;
|
||||
}
|
||||
evt = TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE;
|
||||
evt = EXACTNESS_ACTION_KEY_DOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!strcmp(key, _shot_key) || !strcmp(key, SAVE_KEY_STR)) return;
|
||||
}
|
||||
if (_events_list)
|
||||
if (_unit)
|
||||
{ /* Construct duplicate strings, free them when list if freed */
|
||||
key_down_key_up_with_keycode t;
|
||||
t.timestamp = timestamp;
|
||||
Exactness_Action_Key_Down_Up t;
|
||||
t.keyname = eina_stringshare_add(key);
|
||||
t.key = eina_stringshare_add(efl_input_key_get(evk));
|
||||
t.string = eina_stringshare_add(efl_input_key_string_get(evk));
|
||||
t.compose = eina_stringshare_add(efl_input_key_compose_get(evk));
|
||||
t.keycode = efl_input_key_code_get(evk);
|
||||
t.n_evas = n_evas;
|
||||
if (t.n_evas >= 0) ADD_TO_LIST(evt, t);
|
||||
if (n_evas >= 0) _add_to_list(evt, n_evas, timestamp, &t, sizeof(t));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,6 +427,11 @@ int main(int argc, char **argv)
|
|||
*slash = '/';
|
||||
}
|
||||
}
|
||||
if (strcmp(_out_filename + strlen(_out_filename) - 4,".exu"))
|
||||
{
|
||||
fprintf(stderr, "A file with a exu extension is required - %s invalid\n", _out_filename);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (strcmp(_out_filename + strlen(_out_filename) - 4,".exu"))
|
||||
{
|
||||
|
@ -499,22 +466,20 @@ int main(int argc, char **argv)
|
|||
if (!_shot_key) _shot_key = getenv("SHOT_KEY");
|
||||
if (!_shot_key) _shot_key = SHOT_KEY_STR;
|
||||
|
||||
if (!_events_list)
|
||||
if (!_unit)
|
||||
{
|
||||
struct sysinfo s_info;
|
||||
sysinfo(&s_info);
|
||||
_events_list = calloc(1, sizeof(*_events_list));
|
||||
_events_list->first_timestamp = s_info.uptime * 1000;
|
||||
_printf(2, "Uptime=<%u>\n", _events_list->first_timestamp);
|
||||
_unit = calloc(1, sizeof(*_unit));
|
||||
}
|
||||
|
||||
ecore_evas_callback_new_set(_my_evas_new);
|
||||
_first_timestamp = ecore_time_get() * 1000;
|
||||
pret = _prg_invoke(_prg_full_path_guess(argv[0]), argc - opt_args, argv);
|
||||
|
||||
_output_write();
|
||||
free_events(_events_list, EINA_TRUE);
|
||||
_events_list = NULL;
|
||||
//free_events(_events_list, EINA_TRUE);
|
||||
//_events_list = NULL;
|
||||
|
||||
pret = 0;
|
||||
end:
|
||||
eina_shutdown();
|
||||
return pret;
|
||||
|
|
|
@ -0,0 +1,209 @@
|
|||
#ifndef _EXACTNESS_H
|
||||
#define _EXACTNESS_H
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef EXACTNESS_BUILD
|
||||
# ifdef DLL_EXPORT
|
||||
# define EAPI __declspec(dllexport)
|
||||
# else
|
||||
# define EAPI
|
||||
# endif /* ! DLL_EXPORT */
|
||||
# else
|
||||
# define EAPI __declspec(dllimport)
|
||||
# endif /* ! EXACTNESS_BUILD */
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
#endif /* ! _WIN32 */
|
||||
|
||||
#include <Evas.h>
|
||||
|
||||
/**
|
||||
* @page exactness_main Exactness
|
||||
*
|
||||
* @date 2018 (created)
|
||||
*
|
||||
* This page describes the public structures and APIs available for Exactness.
|
||||
*
|
||||
* @addtogroup Exactness
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Type
|
||||
* The type values for an Exactness action.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
EXACTNESS_ACTION_UNKNOWN = 0,
|
||||
EXACTNESS_ACTION_MOUSE_IN,
|
||||
EXACTNESS_ACTION_MOUSE_OUT,
|
||||
EXACTNESS_ACTION_MOUSE_WHEEL,
|
||||
EXACTNESS_ACTION_MULTI_DOWN,
|
||||
EXACTNESS_ACTION_MULTI_UP,
|
||||
EXACTNESS_ACTION_MULTI_MOVE,
|
||||
EXACTNESS_ACTION_KEY_DOWN,
|
||||
EXACTNESS_ACTION_KEY_UP,
|
||||
EXACTNESS_ACTION_TAKE_SHOT,
|
||||
EXACTNESS_ACTION_LAST = EXACTNESS_ACTION_TAKE_SHOT
|
||||
/* Add any supported actions here and update _LAST */
|
||||
} Exactness_Action_Type;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Mouse_Wheel
|
||||
* The type for the Exactness Mouse Wheel action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int direction;
|
||||
int z;
|
||||
} Exactness_Action_Mouse_Wheel;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Key_Down_Up
|
||||
* The type for the Exactness Key Down Up action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char *keyname;
|
||||
const char *key;
|
||||
const char *string;
|
||||
const char *compose;
|
||||
unsigned int keycode;
|
||||
} Exactness_Action_Key_Down_Up;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Multi_Event
|
||||
* The type for the Exactness Multi Event action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int d;
|
||||
int b; /* In case of simple mouse down/up, corresponds to the button */
|
||||
int x;
|
||||
int y;
|
||||
double rad;
|
||||
double radx;
|
||||
double rady;
|
||||
double pres;
|
||||
double ang;
|
||||
double fx;
|
||||
double fy;
|
||||
Evas_Button_Flags flags;
|
||||
} Exactness_Action_Multi_Event;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Multi_Move
|
||||
* The type for the Exactness Multi Move action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int d;
|
||||
int x;
|
||||
int y;
|
||||
double rad;
|
||||
double radx;
|
||||
double rady;
|
||||
double pres;
|
||||
double ang;
|
||||
double fx;
|
||||
double fy;
|
||||
} Exactness_Action_Multi_Move;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action
|
||||
* The type for the Exactness action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Exactness_Action_Type type; /**< The action type */
|
||||
unsigned int n_evas; /**< The evas number on which the action has to be applied */
|
||||
unsigned int timestamp; /**< The timestamp of the action */
|
||||
void *data; /**< The specific action data */
|
||||
} Exactness_Action;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Object
|
||||
* The type for the Exactness object.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
long long id; /**< The Eo pointer */
|
||||
long long parent_id; /**< The Eo parent pointer */
|
||||
const char *kl_name; /**< The class name */
|
||||
|
||||
Eina_List *children; /* NOT EET */
|
||||
|
||||
/* Evas stuff */
|
||||
int x; /**< The X coordinate */
|
||||
int y; /**< The Y coordinate */
|
||||
int w; /**< The object width */
|
||||
int h; /**< The object height */
|
||||
} Exactness_Object;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Objects
|
||||
* The type for the Exactness objects list.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Eina_List *objs; /**< List of all the objects */
|
||||
/* main_objs not in EET */
|
||||
Eina_List *main_objs; /**< List of the main objects */
|
||||
} Exactness_Objects;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Image
|
||||
* The type for the Exactness Image.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned int w; /**< Width of the image */
|
||||
unsigned int h; /**< Height of the image */
|
||||
int alpha; /**< Alpha of the image */
|
||||
void *pixels; /**< Pixels of the image */
|
||||
} Exactness_Image;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Eina_List *actions; /**< List of Exactness_Action */
|
||||
/* imgs not in EET */
|
||||
Eina_List *imgs; /**< List of Exactness_Image */
|
||||
Eina_List *objs; /**< List of Exactness_Objects */
|
||||
int nb_shots; /**< The number of shots present in the unit */
|
||||
} Exactness_Unit;
|
||||
|
||||
/**
|
||||
* @brief Read an unit from a given file
|
||||
*
|
||||
* @param filename Name of the file containing the unit
|
||||
*
|
||||
* @return the unit
|
||||
*/
|
||||
EAPI Exactness_Unit *exactness_unit_file_read(const char *filename);
|
||||
|
||||
/**
|
||||
* @brief Write an unit into the given file
|
||||
*
|
||||
* @param unit Unit to store
|
||||
* @param filename Name of the file containing the unit
|
||||
*
|
||||
* @return EINA_TRUE on success, EINA_FALSE otherwise
|
||||
*/
|
||||
EAPI Eina_Bool exactness_unit_file_write(Exactness_Unit *unit, const char *filename);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* _EXACTNESS_H */
|
|
@ -17,7 +17,8 @@ pkgdir = $(libdir)/exactness
|
|||
libexactness_recorder_la_SOURCES = \
|
||||
tsuite_hook_recorder.c \
|
||||
tsuite_common.c \
|
||||
tsuite_file_data.c
|
||||
tsuite_file_data.c \
|
||||
unit.c
|
||||
|
||||
libexactness_recorder_la_LDFLAGS = -avoid-version -rdynamic
|
||||
libexactness_recorder_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
@ -27,7 +28,8 @@ libexactness_recorder_la_CFLAGS = @EFL_CFLAGS@
|
|||
libexactness_player_la_SOURCES = \
|
||||
tsuite_hook_player.c \
|
||||
tsuite_common.c \
|
||||
tsuite_file_data.c
|
||||
tsuite_file_data.c \
|
||||
unit.c
|
||||
|
||||
libexactness_player_la_LDFLAGS = -avoid-version -rdynamic
|
||||
libexactness_player_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#ifndef _EXACTNESS_PRIVATE_H
|
||||
#define _EXACTNESS_PRIVATE_H
|
||||
|
||||
#include <Exactness.h>
|
||||
|
||||
/* private header */
|
||||
const char *_exactness_action_type_to_string_get(Exactness_Action_Type type);
|
||||
|
||||
Exactness_Unit *legacy_rec_file_read(const char *filename);
|
||||
|
||||
#define SHOT_DELIMITER '+'
|
||||
#endif
|
||||
|
|
|
@ -1,178 +1,2 @@
|
|||
#include "tsuite_file_data.h"
|
||||
|
||||
unsigned int
|
||||
evt_time_get(unsigned int tm, Variant_st *v)
|
||||
{
|
||||
if (!v) return tm;
|
||||
switch(tsuite_event_mapping_type_get(v->t.type))
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_IN:
|
||||
{
|
||||
mouse_in_mouse_out *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_OUT:
|
||||
{
|
||||
mouse_in_mouse_out *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_DOWN:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_UP:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_MOVE:
|
||||
{
|
||||
mouse_move *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_WHEEL:
|
||||
{
|
||||
mouse_wheel *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_DOWN:
|
||||
{
|
||||
multi_event *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_UP:
|
||||
{
|
||||
multi_event *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_MOVE:
|
||||
{
|
||||
multi_move *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN:
|
||||
{
|
||||
key_down_key_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_UP:
|
||||
{
|
||||
key_down_key_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_UP_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_TAKE_SHOT:
|
||||
{
|
||||
take_screenshot *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
default: /* All non-input events are not handeled */
|
||||
return tm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
evt_time_set(unsigned int tm, Variant_st *v)
|
||||
{
|
||||
switch(tsuite_event_mapping_type_get(v->t.type))
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_IN:
|
||||
{
|
||||
mouse_in_mouse_out *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_OUT:
|
||||
{
|
||||
mouse_in_mouse_out *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_DOWN:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_UP:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_MOVE:
|
||||
{
|
||||
mouse_move *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_WHEEL:
|
||||
{
|
||||
mouse_wheel *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_DOWN:
|
||||
{
|
||||
multi_event *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_UP:
|
||||
{
|
||||
multi_event *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_MOVE:
|
||||
{
|
||||
multi_move *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN:
|
||||
{
|
||||
key_down_key_up *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_UP:
|
||||
{
|
||||
key_down_key_up *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_UP_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_TAKE_SHOT:
|
||||
{
|
||||
take_screenshot *t = v->data;
|
||||
t->timestamp = tm;
|
||||
break;
|
||||
}
|
||||
default: /* All non-input events are not handeled */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <Evas.h>
|
||||
#include <Exactness.h>
|
||||
#include "tsuite_file_data.h"
|
||||
|
||||
static data_desc *_desc = NULL; /* this struct holds descs (alloc on init) */
|
||||
|
@ -28,6 +29,88 @@ static eet_event_type_mapping eet_mapping[] = {
|
|||
{ TSUITE_EVENT_NOT_SUPPORTED, NULL }
|
||||
};
|
||||
|
||||
static unsigned int
|
||||
evt_time_get(unsigned int tm, Variant_st *v)
|
||||
{
|
||||
if (!v) return tm;
|
||||
switch(tsuite_event_mapping_type_get(v->t.type))
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_IN:
|
||||
{
|
||||
mouse_in_mouse_out *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_OUT:
|
||||
{
|
||||
mouse_in_mouse_out *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_DOWN:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_UP:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_MOVE:
|
||||
{
|
||||
mouse_move *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_WHEEL:
|
||||
{
|
||||
mouse_wheel *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_DOWN:
|
||||
{
|
||||
multi_event *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_UP:
|
||||
{
|
||||
multi_event *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_MOVE:
|
||||
{
|
||||
multi_move *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN:
|
||||
{
|
||||
key_down_key_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_UP:
|
||||
{
|
||||
key_down_key_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_UP_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_TAKE_SHOT:
|
||||
{
|
||||
take_screenshot *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
default: /* All non-input events are not handeled */
|
||||
return tm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Tsuite_Event_Type
|
||||
tsuite_event_mapping_type_get(const char *name)
|
||||
{
|
||||
|
@ -189,6 +272,7 @@ print_events(Lists_st *vr_list)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
void
|
||||
write_events(const char *filename, Lists_st *vr_list)
|
||||
{
|
||||
|
@ -211,13 +295,15 @@ write_events(const char *filename, Lists_st *vr_list)
|
|||
|
||||
_data_descriptors_shutdown();
|
||||
}
|
||||
#endif
|
||||
|
||||
Lists_st *
|
||||
read_events(const char *filename, Timer_Data *td)
|
||||
Exactness_Unit *
|
||||
legacy_rec_file_read(const char *filename)
|
||||
{
|
||||
Lists_st *vr_list;
|
||||
Eina_List *itr;
|
||||
Variant_st *v;
|
||||
Exactness_Unit *unit = NULL;
|
||||
Eet_File *fp = eet_open(filename, EET_FILE_MODE_READ);
|
||||
if (!fp)
|
||||
{
|
||||
|
@ -230,24 +316,162 @@ read_events(const char *filename, Timer_Data *td)
|
|||
vr_list = eet_data_read(fp, _desc->_lists_descriptor, CACHE_FILE_ENTRY);
|
||||
eet_close(fp);
|
||||
_data_descriptors_shutdown();
|
||||
if (!vr_list->variant_list)
|
||||
return NULL;
|
||||
|
||||
unit = calloc(1, sizeof(*unit));
|
||||
|
||||
EINA_LIST_FOREACH(vr_list->variant_list, itr, v)
|
||||
{
|
||||
unsigned int tm = evt_time_get(0, v);
|
||||
if (tm) evt_time_set(tm - vr_list->first_timestamp, v);
|
||||
Exactness_Action *act = calloc(1, sizeof(*act));
|
||||
Tsuite_Event_Type old_type = tsuite_event_mapping_type_get(v->t.type);
|
||||
switch (old_type)
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_IN:
|
||||
{
|
||||
mouse_in_mouse_out *d_i = v->data;
|
||||
act->type = EXACTNESS_ACTION_MOUSE_IN;
|
||||
act->n_evas = d_i->n_evas;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_OUT:
|
||||
{
|
||||
mouse_in_mouse_out *d_i = v->data;
|
||||
act->type = EXACTNESS_ACTION_MOUSE_OUT;
|
||||
act->n_evas = d_i->n_evas;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_DOWN:
|
||||
case TSUITE_EVENT_MOUSE_UP:
|
||||
{
|
||||
mouse_down_mouse_up *d_i = v->data;
|
||||
Exactness_Action_Multi_Event *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->b = d_i->b;
|
||||
d_o->flags = d_i->flags;
|
||||
if (old_type == TSUITE_EVENT_MOUSE_DOWN)
|
||||
act->type = EXACTNESS_ACTION_MULTI_DOWN;
|
||||
else
|
||||
act->type = EXACTNESS_ACTION_MULTI_UP;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_MOVE:
|
||||
{
|
||||
mouse_move *d_i = v->data;
|
||||
Exactness_Action_Multi_Move *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->x = d_i->x;
|
||||
d_o->y = d_i->y;
|
||||
act->type = EXACTNESS_ACTION_MULTI_MOVE;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_WHEEL:
|
||||
{
|
||||
mouse_wheel *d_i = v->data;
|
||||
Exactness_Action_Mouse_Wheel *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->direction = d_i->direction;
|
||||
d_o->z = d_i->z;
|
||||
act->type = EXACTNESS_ACTION_MOUSE_WHEEL;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_DOWN:
|
||||
case TSUITE_EVENT_MULTI_UP:
|
||||
{
|
||||
multi_event *d_i = v->data;
|
||||
Exactness_Action_Multi_Event *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->d = d_i->d;
|
||||
d_o->b = d_i->b;
|
||||
d_o->x = d_i->x;
|
||||
d_o->y = d_i->y;
|
||||
d_o->rad = d_i->rad;
|
||||
d_o->radx = d_i->radx;
|
||||
d_o->rady = d_i->rady;
|
||||
d_o->pres = d_i->pres;
|
||||
d_o->ang = d_i->ang;
|
||||
d_o->fx = d_i->fx;
|
||||
d_o->fy = d_i->fy;
|
||||
d_o->flags = d_i->flags;
|
||||
if (old_type == TSUITE_EVENT_MULTI_DOWN)
|
||||
act->type = EXACTNESS_ACTION_MULTI_DOWN;
|
||||
else
|
||||
act->type = EXACTNESS_ACTION_MULTI_UP;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_MOVE:
|
||||
{
|
||||
multi_move *d_i = v->data;
|
||||
Exactness_Action_Multi_Move *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->d = d_i->d;
|
||||
d_o->x = d_i->x;
|
||||
d_o->y = d_i->y;
|
||||
d_o->rad = d_i->rad;
|
||||
d_o->radx = d_i->radx;
|
||||
d_o->rady = d_i->rady;
|
||||
d_o->pres = d_i->pres;
|
||||
d_o->ang = d_i->ang;
|
||||
d_o->fx = d_i->fx;
|
||||
d_o->fy = d_i->fy;
|
||||
act->type = EXACTNESS_ACTION_MULTI_MOVE;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN:
|
||||
case TSUITE_EVENT_KEY_UP:
|
||||
{
|
||||
key_down_key_up *d_i = v->data;
|
||||
Exactness_Action_Key_Down_Up *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->keyname = d_i->keyname;
|
||||
d_o->key = d_i->key;
|
||||
d_o->string = d_i->string;
|
||||
d_o->compose = d_i->compose;
|
||||
if (old_type == TSUITE_EVENT_KEY_DOWN)
|
||||
act->type = EXACTNESS_ACTION_KEY_DOWN;
|
||||
else
|
||||
act->type = EXACTNESS_ACTION_KEY_UP;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE:
|
||||
case TSUITE_EVENT_KEY_UP_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *d_i = v->data;
|
||||
Exactness_Action_Key_Down_Up *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->keyname = d_i->keyname;
|
||||
d_o->key = d_i->key;
|
||||
d_o->string = d_i->string;
|
||||
d_o->compose = d_i->compose;
|
||||
d_o->keycode = d_i->keycode;
|
||||
if (old_type == TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE)
|
||||
act->type = EXACTNESS_ACTION_KEY_DOWN;
|
||||
else
|
||||
act->type = EXACTNESS_ACTION_KEY_UP;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_TAKE_SHOT:
|
||||
{
|
||||
take_screenshot *d_i = v->data;
|
||||
act->type = EXACTNESS_ACTION_TAKE_SHOT;
|
||||
act->n_evas = d_i->n_evas;
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
act->timestamp = evt_time_get(0, v) - vr_list->first_timestamp;
|
||||
unit->actions = eina_list_append(unit->actions, act);
|
||||
}
|
||||
vr_list->first_timestamp = 0;
|
||||
#ifdef DEBUG_TSUITE
|
||||
print_events(vr_list);
|
||||
#endif
|
||||
if (td) td->current_event = eina_list_nth_list(vr_list->variant_list, 0);
|
||||
#ifdef DEBUG_TSUITE
|
||||
printf("%s list size is <%d>\n", __func__, eina_list_count(vr_list->variant_list));
|
||||
printf("%s number of actions in the scenario <%d>\n", __func__, eina_list_count(unit->actions));
|
||||
#endif
|
||||
|
||||
return vr_list;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const char *
|
||||
|
@ -933,111 +1157,3 @@ void _data_descriptors_shutdown(void)
|
|||
}
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_unit_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
static Eet_Data_Descriptor *unit_d = NULL;
|
||||
static Eet_Data_Descriptor *obj_d = NULL;
|
||||
static Eet_Data_Descriptor *objs_d = NULL;
|
||||
_data_descriptors_init();
|
||||
if (!obj_d)
|
||||
{
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Object);
|
||||
obj_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "kl_name", kl_name, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "id", id, EET_T_ULONG_LONG);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "parent_id", parent_id, EET_T_ULONG_LONG);
|
||||
/* Evas stuff */
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "x", x, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "y", y, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "w", w, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "h", h, EET_T_INT);
|
||||
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Objects);
|
||||
objs_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(objs_d, Exactness_Objects, "objs", objs, obj_d);
|
||||
}
|
||||
if (!unit_d)
|
||||
{
|
||||
/* Exactness_Unit */
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Unit);
|
||||
unit_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit,
|
||||
"events", events, _desc->_variant_descriptor);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit,
|
||||
"objs", objs, objs_d);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit,
|
||||
"nb_shots", nb_shots, EET_T_UINT);
|
||||
}
|
||||
|
||||
return unit_d;
|
||||
}
|
||||
/* END Event struct descriptors */
|
||||
|
||||
EAPI Exactness_Unit *
|
||||
unit_eet_read(const char *filename)
|
||||
{
|
||||
int i;
|
||||
Eina_List *itr, *itr2;
|
||||
Exactness_Objects *e_objs;
|
||||
Exactness_Object *e_obj, *e_parent;
|
||||
Exactness_Unit *unit = NULL;
|
||||
Eet_File *file = eet_open(filename, EET_FILE_MODE_READ);
|
||||
if (!file)
|
||||
{
|
||||
fprintf(stderr, "Impossible to extract EET from %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
unit = eet_data_read(file, _unit_desc_make(), CACHE_FILE_ENTRY);
|
||||
for (i = 0; i < unit->nb_shots; i++)
|
||||
{
|
||||
char entry[16];
|
||||
Exactness_Image *ex_img = malloc(sizeof(*ex_img));
|
||||
sprintf(entry, "images/%d", i + 1);
|
||||
ex_img->pixels = eet_data_image_read(file, entry,
|
||||
&ex_img->w, &ex_img->h, &ex_img->alpha,
|
||||
NULL, NULL, NULL);
|
||||
unit->imgs = eina_list_append(unit->imgs, ex_img);
|
||||
}
|
||||
EINA_LIST_FOREACH(unit->objs, itr, e_objs)
|
||||
{
|
||||
e_objs->hash = eina_hash_pointer_new(NULL);
|
||||
EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj)
|
||||
{
|
||||
eina_hash_set(e_objs->hash, &(e_obj->id), e_obj);
|
||||
}
|
||||
EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj)
|
||||
{
|
||||
if (!e_obj->parent_id)
|
||||
e_objs->main_objs = eina_list_append(e_objs->main_objs, e_obj);
|
||||
else
|
||||
{
|
||||
e_parent = eina_hash_find(e_objs->hash, &(e_obj->parent_id));
|
||||
if (e_parent) e_parent->children = eina_list_append(e_parent->children, e_obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
eet_close(file);
|
||||
return unit;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool unit_eet_write(Exactness_Unit *unit, const char *filename)
|
||||
{
|
||||
Eina_List *itr;
|
||||
Exactness_Image *ex_img;
|
||||
int i = 1;
|
||||
Eet_File *file = eet_open(filename, EET_FILE_MODE_WRITE);
|
||||
eet_data_write(file, _unit_desc_make(), CACHE_FILE_ENTRY, unit, EINA_TRUE);
|
||||
EINA_LIST_FOREACH(unit->imgs, itr, ex_img)
|
||||
{
|
||||
char entry[16];
|
||||
sprintf(entry, "images/%d", i++);
|
||||
eet_data_image_write(file, entry,
|
||||
ex_img->pixels, ex_img->w, ex_img->h, ex_img->alpha,
|
||||
0, 100, EET_IMAGE_LOSSLESS);
|
||||
}
|
||||
eet_close(file);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <Evas.h>
|
||||
#include <Eet.h>
|
||||
#include <Exactness.h>
|
||||
|
||||
#define CACHE_FILE_ENTRY "cache"
|
||||
|
||||
|
@ -245,59 +246,14 @@ data_desc *_data_descriptors_init(void);
|
|||
void _data_descriptors_shutdown(void);
|
||||
/* END Event struct descriptors */
|
||||
|
||||
/* START Unit desc */
|
||||
typedef struct
|
||||
{
|
||||
long long id;
|
||||
long long parent_id;
|
||||
const char *kl_name;
|
||||
|
||||
Eina_List *children; /* NOT EET */
|
||||
|
||||
/* Evas stuff */
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
} Exactness_Object;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Eina_List *objs;
|
||||
Eina_List *main_objs; /* NOT EET */
|
||||
Eina_Hash *hash; /* NOT EET */
|
||||
} Exactness_Objects;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int w;
|
||||
unsigned int h;
|
||||
int alpha;
|
||||
void *pixels;
|
||||
} Exactness_Image;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Eina_List *events; /* List of Variant_st */
|
||||
Eina_List *imgs; /* List of Exactness_Image */
|
||||
Eina_List *objs; /* List of Exactness_Objects */
|
||||
int nb_shots;
|
||||
} Exactness_Unit;
|
||||
|
||||
Eet_Data_Descriptor *unit_desc_make(void);
|
||||
EAPI Exactness_Unit *unit_eet_read(const char *filename);
|
||||
EAPI Eina_Bool unit_eet_write(Exactness_Unit *unit, const char *filename);
|
||||
/* END Unit desc */
|
||||
|
||||
Tsuite_Event_Type tsuite_event_mapping_type_get(const char *name);
|
||||
const char * tsuite_event_mapping_type_str_get(Tsuite_Event_Type t);
|
||||
const char * _variant_type_get(const void *data, Eina_Bool *unknow);
|
||||
Eina_Bool _variant_type_set(const char *type, void *data, Eina_Bool unknow);
|
||||
|
||||
EAPI Tsuite_Event_Type tsuite_event_mapping_type_get(const char *name);
|
||||
EAPI Lists_st * free_events(Lists_st *st, Eina_Bool recording);
|
||||
EAPI void write_events(const char *filename, Lists_st *vr_list);
|
||||
EAPI Lists_st *read_events(const char *filename, Timer_Data *td);
|
||||
EAPI unsigned int evt_time_get(unsigned int tm, Variant_st *v);
|
||||
EAPI void evt_time_set(unsigned int tm, Variant_st *v);
|
||||
Tsuite_Event_Type tsuite_event_mapping_type_get(const char *name);
|
||||
#if 0
|
||||
Lists_st * free_events(Lists_st *st, Eina_Bool recording);
|
||||
void write_events(const char *filename, Lists_st *vr_list);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,300 @@
|
|||
#include <Eet.h>
|
||||
#include <Exactness.h>
|
||||
|
||||
typedef struct _Dummy
|
||||
{
|
||||
} _Dummy;
|
||||
/*
|
||||
static Eet_Data_Descriptor *
|
||||
_mouse_in_out_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Mouse_In_Out);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_In_Out, "n_evas", n_evas, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
*/
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_mouse_wheel_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Mouse_Wheel);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "direction", direction, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "z", z, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_key_down_up_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Key_Down_Up);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keyname", keyname, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "key", key, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "string", string, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "compose", compose, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keycode", keycode, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_multi_event_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Event);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "d", d, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "b", b, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "x", x, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "y", y, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rad", rad, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "radx", radx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rady", rady, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "pres", pres, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "ang", ang, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fx", fx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fy", fy, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "flags", flags, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_multi_move_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Move);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "d", d, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "x", x, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "y", y, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rad", rad, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "radx", radx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rady", rady, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "pres", pres, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "ang", ang, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fx", fx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fy", fy, EET_T_DOUBLE);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_dummy_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, _Dummy);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
/* !!! SAME ORDER AS Exactness_Action_Type */
|
||||
static const char *_mapping[] =
|
||||
{
|
||||
"",
|
||||
"exactness_action_mouse_in",
|
||||
"exactness_action_mouse_out",
|
||||
"exactness_action_mouse_wheel",
|
||||
"exactness_action_multi_down",
|
||||
"exactness_action_multi_up",
|
||||
"exactness_action_multi_move",
|
||||
"exactness_action_key_down",
|
||||
"exactness_action_key_up",
|
||||
"exactness_action_take_shot"
|
||||
};
|
||||
|
||||
const char *
|
||||
_exactness_action_type_to_string_get(Exactness_Action_Type type)
|
||||
{
|
||||
if (type <= EXACTNESS_ACTION_LAST) return _mapping[type];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_variant_type_get(const void *data, Eina_Bool *unknow)
|
||||
{
|
||||
const Exactness_Action *act = data;
|
||||
|
||||
if (unknow) *unknow = EINA_FALSE;
|
||||
if (act->type <= EXACTNESS_ACTION_LAST) return _mapping[act->type];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_variant_type_set(const char *type,
|
||||
void *data,
|
||||
Eina_Bool unknow EINA_UNUSED)
|
||||
{
|
||||
int i;
|
||||
Exactness_Action *act = data;
|
||||
for (i = 0; i <= EXACTNESS_ACTION_LAST; i++)
|
||||
{
|
||||
if (!strcmp(_mapping[i], type)) act->type = i;
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_unit_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
static Eet_Data_Descriptor *unit_d = NULL;
|
||||
static Eet_Data_Descriptor *action_d = NULL, *action_variant_d = NULL;
|
||||
static Eet_Data_Descriptor *objs_d = NULL;
|
||||
static Eet_Data_Descriptor *obj_d = NULL;
|
||||
if (!obj_d)
|
||||
{
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Object);
|
||||
obj_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "kl_name", kl_name, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "id", id, EET_T_ULONG_LONG);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "parent_id", parent_id, EET_T_ULONG_LONG);
|
||||
/* Evas stuff */
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "x", x, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "y", y, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "w", w, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "h", h, EET_T_INT);
|
||||
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Objects);
|
||||
objs_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(objs_d, Exactness_Objects, "objs", objs, obj_d);
|
||||
}
|
||||
if (!unit_d)
|
||||
{
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action);
|
||||
action_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
|
||||
eddc.func.type_get = _variant_type_get;
|
||||
eddc.func.type_set = _variant_type_set;
|
||||
action_variant_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MOUSE_IN], _dummy_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MOUSE_OUT], _dummy_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MOUSE_WHEEL], _mouse_wheel_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MULTI_DOWN], _multi_event_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MULTI_UP], _multi_event_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MULTI_MOVE], _multi_move_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_KEY_DOWN], _key_down_up_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_KEY_UP], _key_down_up_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_TAKE_SHOT], _dummy_desc_make());
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "n_evas", n_evas, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "timestamp", timestamp, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_VARIANT(action_d, Exactness_Action, "data", data, type, action_variant_d);
|
||||
|
||||
/* Exactness_Unit */
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Unit);
|
||||
unit_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "actions", actions, action_d);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "objs", objs, objs_d);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "nb_shots", nb_shots, EET_T_UINT);
|
||||
}
|
||||
|
||||
return unit_d;
|
||||
}
|
||||
/* END Event struct descriptors */
|
||||
|
||||
EAPI Exactness_Unit *
|
||||
exactness_unit_file_read(const char *filename)
|
||||
{
|
||||
int i;
|
||||
Eina_List *itr, *itr2;
|
||||
Exactness_Objects *e_objs;
|
||||
Exactness_Object *e_obj, *e_parent;
|
||||
Exactness_Unit *unit = NULL;
|
||||
Eet_File *file;
|
||||
eet_init();
|
||||
file = eet_open(filename, EET_FILE_MODE_READ);
|
||||
if (!file)
|
||||
{
|
||||
fprintf(stderr, "Impossible to extract EET from %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
unit = eet_data_read(file, _unit_desc_make(), "cache");
|
||||
for (i = 0; i < unit->nb_shots; i++)
|
||||
{
|
||||
char entry[16];
|
||||
Exactness_Image *ex_img = malloc(sizeof(*ex_img));
|
||||
sprintf(entry, "images/%d", i + 1);
|
||||
ex_img->pixels = eet_data_image_read(file, entry,
|
||||
&ex_img->w, &ex_img->h, &ex_img->alpha,
|
||||
NULL, NULL, NULL);
|
||||
unit->imgs = eina_list_append(unit->imgs, ex_img);
|
||||
}
|
||||
EINA_LIST_FOREACH(unit->objs, itr, e_objs)
|
||||
{
|
||||
Eina_Hash *hash = eina_hash_pointer_new(NULL);
|
||||
EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj)
|
||||
{
|
||||
eina_hash_set(hash, &(e_obj->id), e_obj);
|
||||
}
|
||||
EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj)
|
||||
{
|
||||
if (!e_obj->parent_id)
|
||||
e_objs->main_objs = eina_list_append(e_objs->main_objs, e_obj);
|
||||
else
|
||||
{
|
||||
e_parent = eina_hash_find(hash, &(e_obj->parent_id));
|
||||
if (e_parent) e_parent->children = eina_list_append(e_parent->children, e_obj);
|
||||
}
|
||||
}
|
||||
eina_hash_free(hash);
|
||||
}
|
||||
eet_close(file);
|
||||
eet_shutdown();
|
||||
return unit;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
exactness_unit_file_write(Exactness_Unit *unit, const char *filename)
|
||||
{
|
||||
Eina_List *itr;
|
||||
Exactness_Image *ex_img;
|
||||
Eet_File *file;
|
||||
int i = 1;
|
||||
eet_init();
|
||||
file = eet_open(filename, EET_FILE_MODE_WRITE);
|
||||
eet_data_write(file, _unit_desc_make(), "cache", unit, EINA_TRUE);
|
||||
EINA_LIST_FOREACH(unit->imgs, itr, ex_img)
|
||||
{
|
||||
char entry[16];
|
||||
sprintf(entry, "images/%d", i++);
|
||||
eet_data_image_write(file, entry,
|
||||
ex_img->pixels, ex_img->w, ex_img->h, ex_img->alpha,
|
||||
0, 100, EET_IMAGE_LOSSLESS);
|
||||
}
|
||||
eet_close(file);
|
||||
eet_shutdown();
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue