Add new PLUGIN_RUN action type and new plugins.plugin handlers 1. If external library is commerical source and not opensource, we cannot include/build the library within edje. 2. If external library does not use general encodable sources, we...

Summary:
...cannot encode those things into edje.

In our case, we need vibration when longpressed. But those files are not
audio or image and cannot be encoded into edje. Also, this library is not
opensource so should not be linked directly with edje.
So we should call vibration API by using this plug-in.

Reviewers: raster, cedric, seoz, Hermet

CC: cedric

Differential Revision: https://phab.enlightenment.org/D588
This commit is contained in:
Tae-Hwan Kim 2014-03-20 13:00:20 +09:00 committed by Carsten Haitzler (Rasterman)
parent 079e5d3692
commit 3061a706c4
14 changed files with 509 additions and 4 deletions

View File

@ -237,6 +237,7 @@ native get_state_val(part_id, State_Param:p, ...);
/* Multisense */
native play_sample (sample_name[], Float:speed, ...);
native play_tone (tone_name[], Float:duration, ...);
native play_vibration (sample_name[], ...);
/***********************************************************/
/* Edje physics calls. */

View File

@ -13,6 +13,7 @@ static void main_help(void);
Eina_Prefix *pfx = NULL;
Eina_List *snd_dirs = NULL;
Eina_List *vibration_dirs = NULL;
Eina_List *img_dirs = NULL;
Eina_List *fnt_dirs = NULL;
Eina_List *data_dirs = NULL;
@ -91,6 +92,7 @@ main_help(void)
"-id image/directory Add a directory to look in for relative path images\n"
"-fd font/directory Add a directory to look in for relative path fonts\n"
"-sd sound/directory Add a directory to look in for relative path sounds samples\n"
"-vd vbiration/directory Add a directory to look in for relative path vibration samples\n"
"-dd data/directory Add a directory to look in for relative path data.file entries\n"
"-td temp/directory Directory to store temporary files\n"
"-l license Specify the license of a theme\n"
@ -188,6 +190,11 @@ main(int argc, char **argv)
i++;
snd_dirs = eina_list_append(snd_dirs, argv[i]);
}
else if ((!strcmp(argv[i], "-vd") || !strcmp(argv[i], "--vibration_dir")) && (i < (argc - 1)))
{
i++;
vibration_dirs = eina_list_append(vibration_dirs, argv[i]);
}
else if ((!strcmp(argv[i], "-dd") || !strcmp(argv[i], "--data_dir")) && (i < (argc - 1)))
{
i++;

View File

@ -222,6 +222,7 @@ extern Eina_List *ext_dirs;
extern Eina_List *img_dirs;
extern Eina_List *fnt_dirs;
extern Eina_List *snd_dirs;
extern Eina_List *vibration_dirs;
extern Eina_List *data_dirs;
extern char *file_in;
extern char *tmp_dir;

View File

@ -68,6 +68,10 @@
* <ul>
* <li>@ref sec_collections_sounds_sample "Sample"</li>
* </ul>
* <li>@ref sec_collections_vibrations "Vibrations"</li>
* <ul>
* <li>@ref sec_collections_vibrations_sample "Sample"</li>
* </ul>
* <li>@ref sec_collections_group "Group"</li>
* <ul>
* <li>@ref sec_collections_group_script "Script"</li>
@ -385,6 +389,8 @@ static void ob_collections_group_programs_program_script(void);
static void st_collections_group_sound_sample_name(void);
static void st_collections_group_sound_sample_source(void);
static void st_collections_group_sound_tone(void);
static void st_collections_group_vibration_sample_name(void);
static void st_collections_group_vibration_sample_source(void);
#ifdef HAVE_EPHYSICS
static void st_collections_group_physics_world_gravity(void);
@ -443,6 +449,10 @@ New_Statement_Handler statement_handlers[] =
{"collections.group.sounds.sample.source", st_collections_group_sound_sample_source}, /* dup */
{"collections.sounds.tone", st_collections_group_sound_tone},
{"collections.group.sounds.tone", st_collections_group_sound_tone}, /* dup */
{"collections.vibrations.sample.name", st_collections_group_vibration_sample_name},
{"collections.vibrations.sample.source", st_collections_group_vibration_sample_source},
{"collections.group.vibrations.sample.name", st_collections_group_vibration_sample_name}, /* dup */
{"collections.grpup.vibrations.sample.source", st_collections_group_vibration_sample_source}, /* dup */
{"collections.group.name", st_collections_group_name},
{"collections.group.inherit", st_collections_group_inherit},
{"collections.group.script_only", st_collections_group_script_only},
@ -886,6 +896,10 @@ New_Object_Handler object_handlers[] =
{"collections.group.sounds", NULL}, /* dup */
{"collections.sounds.sample", NULL},
{"collections.group.sounds.sample", NULL}, /* dup */
{"collections.vibrations", NULL},
{"collections.group.vibrations", NULL}, /* dup */
{"collections.vibrations.sample", NULL},
{"collections.group.vibrations.sample", NULL}, /* dup */
{"collections.group", ob_collections_group},
{"collections.group.data", NULL},
{"collections.group.limits", NULL},
@ -2285,6 +2299,7 @@ st_styles_style_tag(void)
collections {
..
sounds { }
vibrations { }
group { }
group { }
..
@ -2292,7 +2307,8 @@ st_styles_style_tag(void)
@description
The "collections" block is used to list the groups that compose the
theme. Additional "collections" blocks do not prevent overriding group
names. The "sounds" block comprises of all sound definitions.
names. The "sounds" block comprises of all sound definitions. The "vibrations"
block compriese all vibration definitions.
@endblock
*/
static void
@ -2522,6 +2538,126 @@ st_collections_group_sound_tone(void)
tone->id = edje_file->sound_dir->tones_count - 1;
}
/**
@edcsubsection{collections_vibrations,Vibrations}
*/
/**
@page edcref
@block
vibrations
@context
vibrations {
sample {
name: "vibration_file1";
source: "vibration_file1.xxx";
}
}
@description
The "vibrations" block contains a list of one or more vibration sample.
@endblock
@since 1.10
*/
/**
@edcsubsection{collections_vibrations_sample,Sample}
*/
/**
@page edcref
@block
sample
@context
sample {
name: "vibration_file1";
source: "vibration_file1.xxx";
}
@description
The sample block defines the vibration sample.
@endblock
@property
name
@parameters
[sample name]
@effect
Used to include each vibration file. The full path to the directory holding
the vibrations can be defined later with edje_cc's "-vd" option.
@endproperty
@since 1.10
*/
static void
st_collections_group_vibration_sample_name(void)
{
Edje_Vibration_Sample *sample;
const char *tmp;
unsigned int i;
if (!edje_file->vibration_dir)
edje_file->vibration_dir = mem_alloc(SZ(Edje_Vibration_Directory));
tmp = parse_str(0);
for (i = 0; i < edje_file->vibration_dir->samples_count; i++)
{
if (!strcmp(edje_file->vibration_dir->samples[i].name, tmp))
{
free((char *)tmp);
return;
}
}
edje_file->vibration_dir->samples_count++;
sample = realloc(edje_file->vibration_dir->samples,
sizeof(Edje_Vibration_Sample) *
edje_file->vibration_dir->samples_count);
if (!sample)
{
ERR("No enough memory.");
exit(-1);
}
edje_file->vibration_dir->samples = sample;
sample =
edje_file->vibration_dir->samples +
edje_file->vibration_dir->samples_count - 1;
memset(sample, 0, sizeof(Edje_Vibration_Sample));
sample->name = tmp;
sample->id = edje_file->vibration_dir->samples_count - 1;
check_arg_count(1);
}
/**
@page edcref
@property
source
@parameters
[vibration file name]
@effect
The Vibration source file name
@endproperty
@since 1.10
*/
static void
st_collections_group_vibration_sample_source(void)
{
Edje_Vibration_Sample *sample;
if (!edje_file->vibration_dir->samples)
{
ERR("Invalid vibration sample source definition.");
exit(-1);
}
sample =
edje_file->vibration_dir->samples +
edje_file->vibration_dir->samples_count - 1;
sample->src = parse_str(0);
check_arg_count(1);
}
/**
@edcsubsection{collections_group,Group}
*/
@ -9105,7 +9241,7 @@ st_collections_group_programs_program_in(void)
@effect
Action to be performed by the program. Valid actions are: STATE_SET,
ACTION_STOP, SIGNAL_EMIT, DRAG_VAL_SET, DRAG_VAL_STEP, DRAG_VAL_PAGE,
FOCUS_SET, PARAM_COPY, PARAM_SET, PLAY_SAMPLE, PLAY_TONE,
FOCUS_SET, PARAM_COPY, PARAM_SET, PLAY_SAMPLE, PLAY_TONE, PLAY_VIBRATION,
PHYSICS_IMPULSE, PHYSICS_TORQUE_IMPULSE, PHYSICS_FORCE, PHYSICS_TORQUE,
PHYSICS_FORCES_CLEAR, PHYSICS_VEL_SET, PHYSICS_ANG_VEL_SET,
PHYSICS_STOP, PHYSICS_ROT_SET
@ -9122,6 +9258,7 @@ st_collections_group_programs_program_in(void)
action: PARAM_SET "part" "param" "value";\n
action: PLAY_SAMPLE "sample name" speed (speed of sample - 1.0 is original speed - faster is higher pitch) [channel optional EFFECT/FX | BACKGROUND/BG | MUSIC/MUS | FOREGROUND/FG | INTERFACE/UI | INPUT | ALERT;\n
action: PLAY_TONE "tone name" duration in seconds ( Range 0.1 to 10.0 );\n
action: PLAY_VIBRATION "sample name" repeat (repeat count);\n
action: PHYSICS_IMPULSE 10 -23.4 0;\n
action: PHYSICS_TORQUE_IMPULSE 0 2.1 0.95;\n
action: PHYSICS_FORCE -20.8 0 30.85;\n
@ -9165,6 +9302,7 @@ st_collections_group_programs_program_action(void)
"PHYSICS_ANG_VEL_SET", EDJE_ACTION_TYPE_PHYSICS_ANG_VEL_SET,
"PHYSICS_STOP", EDJE_ACTION_TYPE_PHYSICS_STOP,
"PHYSICS_ROT_SET", EDJE_ACTION_TYPE_PHYSICS_ROT_SET,
"PLAY_VIBRATION", EDJE_ACTION_TYPE_VIBRATION_SAMPLE,
NULL);
if (ep->action == EDJE_ACTION_TYPE_STATE_SET)
{
@ -9219,6 +9357,21 @@ st_collections_group_programs_program_action(void)
}
ep->duration = parse_float_range(2, 0.1, 10.0);
}
else if (ep->action == EDJE_ACTION_TYPE_VIBRATION_SAMPLE)
{
ep->vibration_name = parse_str(1);
for (i = 0; i < (int)edje_file->vibration_dir->samples_count; i++)
{
if (!strcmp(edje_file->vibration_dir->samples[i].name, ep->vibration_name))
break;
if (i == (int)(edje_file->vibration_dir->samples_count - 1))
{
ERR("No Vibration Sample name %s exist.", ep->vibration_name);
exit(-1);
}
}
ep->vibration_repeat = parse_int(2);
}
else if (ep->action == EDJE_ACTION_TYPE_DRAG_VAL_SET)
{
ep->value = parse_float(1);
@ -9308,6 +9461,7 @@ st_collections_group_programs_program_action(void)
check_arg_count(5);
break;
case EDJE_ACTION_TYPE_SOUND_SAMPLE:
case EDJE_ACTION_TYPE_VIBRATION_SAMPLE:
break;
default:
check_arg_count(3);

View File

@ -122,6 +122,7 @@ typedef struct _Head_Write Head_Write;
typedef struct _Fonts_Write Fonts_Write;
typedef struct _Image_Write Image_Write;
typedef struct _Sound_Write Sound_Write;
typedef struct _Vibration_Write Vibration_Write;
typedef struct _Group_Write Group_Write;
typedef struct _License_Write License_Write;
@ -169,6 +170,13 @@ struct _Sound_Write
int i;
};
struct _Vibration_Write
{
Eet_File *ef;
Edje_Vibration_Sample *sample;
int i;
};
struct _Group_Write
{
Eet_File *ef;
@ -1083,6 +1091,96 @@ data_write_sounds(Eet_File *ef, int *sound_num)
}
}
static void
data_thread_vibrations(void *data, Ecore_Thread *thread EINA_UNUSED)
{
Vibration_Write *vw = data;
Eina_List *ll;
char *dir_path = NULL;
char path[PATH_MAX];
char id_str[30];
Eina_File *f = NULL;
void *m = NULL;
int bytes = 0;
EINA_LIST_FOREACH(vibration_dirs, ll, dir_path)
{
snprintf((char *)path, sizeof(path), "%s/%s", dir_path,
vw->sample->src);
f = eina_file_open(path, 0);
if (f) break;
}
if (!f)
{
snprintf((char *)path, sizeof(path), "%s",
vw->sample->src);
f = eina_file_open(path, 0);
}
if (f) using_file(path, 'S');
if (!f)
{
ERR("Unable to load vibration data of: %s", vw->sample->src);
exit(-1);
}
snprintf(id_str, sizeof(id_str), "edje/vibrations/%i", vw->sample->id);
m = eina_file_map_all(f, EINA_FILE_WILLNEED);
if (m)
{
bytes = eet_write(vw->ef, id_str, m, eina_file_size_get(f),
EET_COMPRESSION_NONE);
if (eina_file_map_faulted(f, m))
{
ERR("File access error when reading '%s'",
eina_file_filename_get(f));
exit(-1);
}
eina_file_map_free(f, m);
}
eina_file_close(f);
INF("Wrote %9i bytes (%4iKb) for \"%s\" %s vibration entry \"%s\"",
bytes, (bytes + 512) / 1024,
id_str, "RAW", vw->sample->name);
}
static void
data_thread_vibrations_end(void *data, Ecore_Thread *thread EINA_UNUSED)
{
Vibration_Write *sw = data;
pending_threads--;
if (pending_threads <= 0) ecore_main_loop_quit();
free(sw);
}
static void
data_write_vibrations(Eet_File *ef, int *num)
{
if ((edje_file) && (edje_file->vibration_dir))
{
int i;
for (i = 0; i < (int)edje_file->vibration_dir->samples_count; i++)
{
Vibration_Write *vw;
vw = calloc(1, sizeof(Vibration_Write));
if (!vw) continue;
vw->ef = ef;
vw->sample = &edje_file->vibration_dir->samples[i];
vw->i = i;
*num += 1;
pending_threads++;
if (threads)
ecore_thread_run(data_thread_vibrations, data_thread_vibrations_end, NULL, vw);
else
{
data_thread_vibrations(vw, NULL);
data_thread_vibrations_end(vw, NULL);
}
}
}
}
static void
check_groups(Eet_File *ef)
{
@ -1807,6 +1905,7 @@ data_write(void)
Eet_Error err;
int image_num = 0;
int sound_num = 0;
int vibration_num = 0;
int font_num = 0;
int collection_num = 0;
double t;
@ -1864,6 +1963,8 @@ data_write(void)
INF("fonts: %3.5f", ecore_time_get() - t); t = ecore_time_get();
data_write_sounds(ef, &sound_num);
INF("sounds: %3.5f", ecore_time_get() - t); t = ecore_time_get();
data_write_vibrations(ef, &vibration_num);
INF("vibrations: %3.5f", ecore_time_get() - t); t = ecore_time_get();
data_write_license(ef);
INF("license: %3.5f", ecore_time_get() - t); t = ecore_time_get();
if (authors)

View File

@ -521,6 +521,49 @@ output(void)
}
}
if (edje_file->vibration_dir)
{
Edje_Vibration_Sample *sample;
void *data;
char out[PATH_MAX];
char out1[PATH_MAX];
char *pp;
int data_size;
FILE *f;
int i;
for (i = 0; i < (int)edje_file->vibration_dir->samples_count; i++)
{
sample = &edje_file->vibration_dir->samples[i];
if ((!sample) || (!sample->name)) continue;
snprintf(out, sizeof(out), "edje/vibrations/%i", sample->id);
data = (void *)eet_read_direct(tef, out, &data_size);
if (data)
{
snprintf(out1, sizeof(out1), "%s/%s", outdir, sample->src);
pp = strdup(out1);
p = strrchr(pp, '/');
*p = 0;
if (strstr(pp, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit(-1);
}
ecore_file_mkpath(pp);
free(pp);
if (strstr(out, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit(-1);
}
f = fopen(out1, "wb");
if (fwrite(data, data_size, 1, f) != 1)
ERR("Could not write sound: %s", strerror(errno));
fclose(f);
}
}
}
eet_close(tef);
if (outdir) free(outdir);
}

View File

@ -66,6 +66,7 @@ struct _Edje_Pick_File_Params
Eina_List *imagesetlist; /* List of IDs (Edje_Pick_Data) for image sets */
Eina_List *samplelist;
Eina_List *tonelist;
Eina_List *vibrationlist;
};
typedef struct _Edje_Pick_File_Params Edje_Pick_File_Params;
@ -197,6 +198,13 @@ _edje_pick_out_file_free(Edje_File *out_file)
free(out_file->sound_dir);
}
if (out_file->vibration_dir)
{
if (out_file->vibration_dir->samples)
free(out_file->vibration_dir->samples);
free(out_file->vibration_dir);
}
eina_list_free(out_file->color_classes);
eina_hash_free_cb_set(out_file->collection, free);
@ -860,6 +868,57 @@ _edje_pick_sounds_add(Edje_File *edf)
return status;
}
static int
_edje_pick_vibrations_add(Edje_File *edf)
{
char buf[1024];
int size, k;
void *data;
Eina_Bool status = EDJE_PICK_NO_ERROR;
static int current_sample_id = 0;
if (edf->vibration_dir) /* Copy Sounds */
{
for (k = 0; k < (int) edf->vibration_dir->samples_count; k++)
{
Edje_Vibration_Sample *sample = &edf->vibration_dir->samples[k];
snprintf(buf, sizeof(buf), "edje/vibrations/%i", sample->id);
VERBOSE(EINA_LOG_INFO("Trying to read <%s>\n", sample->name));
data = eet_read(edf->ef, buf, &size);
if (size)
{
Edje_Pick_Data *smpl = malloc(sizeof(*smpl));
smpl->filename = eina_stringshare_add(sample->name);
smpl->data = data;
smpl->size = size;
smpl->entry = (void *) sample; /* for output file vibration dir */
smpl->id.old_id = sample->id;
sample->id = smpl->id.new_id = current_sample_id;
smpl->id.used = EINA_FALSE;
VERBOSE(EINA_LOG_INFO("Read <%s> sample data <%p> size <%d>\n",
buf, smpl->data, smpl->size));
current_sample_id++;
context.current_file->vibrationlist =
eina_list_append(context.current_file->vibrationlist, smpl);
}
else
{
EINA_LOG_ERR("Sample <%s> was not found in <%s> file.\n",
sample->name, context.current_file->name);
status = EDJE_PICK_SAMPLE_NOT_FOUND;
/* Should that really be freed? Or is some other handling needed? */
free(data);
}
}
}
return status;
}
static int
_font_cmp(const void *d1, const void *d2)
{
@ -977,7 +1036,7 @@ _edje_pick_lua_scripts_add(Edje_File *edf, int id, int new_id)
static void
_edje_pick_styles_update(Edje_File *o, Edje_File *edf)
{
/* Color Class in Edje_File */
/* Styles in Edje_File */
Eina_List *l;
Edje_Style *stl;
@ -1186,6 +1245,30 @@ _edje_pick_sound_dir_compose(Eina_List *samples, Eina_List *tones, Edje_File *o)
}
}
static void
_edje_pick_vibration_dir_compose(Eina_List *vibrations, Edje_File *o)
{ /* Compose vibrationdir array from all used vibrations */
if (vibrations)
{
Edje_Vibration_Sample *sample;
Edje_Vibration_Sample *p;
Eina_List *l;
o->vibration_dir = calloc(1, sizeof(*(o->vibration_dir)));
o->vibration_dir->samples = malloc(eina_list_count(vibrations) *
sizeof(Edje_Vibration_Sample));
p = o->vibration_dir->samples;
EINA_LIST_FOREACH(vibrations, l, sample)
{
memcpy(p, sample, sizeof(Edje_Vibration_Sample));
p++;
}
o->vibration_dir->samples_count = eina_list_count(vibrations);
}
}
int
main(int argc, char **argv)
{
@ -1196,6 +1279,7 @@ main(int argc, char **argv)
Eina_List *images = NULL;
Eina_List *samples = NULL;
Eina_List *tones = NULL;
Eina_List *vibrations = NULL;
Edje_Image_Directory_Set *sets = NULL; /* ALL files sets composed here */
Edje_Part_Collection *edc;
@ -1251,6 +1335,7 @@ main(int argc, char **argv)
/* Build lists of all images, samples and fonts of input files */
_edje_pick_images_add(edf, out_file); /* Add Images to imagelist */
_edje_pick_sounds_add(edf); /* Add Sounds to samplelist */
_edje_pick_vibrations_add(edf); /* Add Vibrations to samplelist */
_Edje_Pick_Fonts_add(edf); /* Add fonts from file to fonts list */
/* Copy styles, color class */
@ -1367,9 +1452,25 @@ main(int argc, char **argv)
if (context.current_file->append || tn->used)
tones = eina_list_append(tones, tn->tone);
}
EINA_LIST_FOREACH(context.current_file->vibrationlist, l, s)
{
if (context.current_file->append || s->id.used)
{ /* Write only used vibrations */
vibrations = eina_list_append(vibrations, s->entry);
snprintf(buf, sizeof(buf), "edje/vibrations/%i",
s->id.new_id);
eet_write(out_file->ef, buf,
s->data, s->size,EINA_TRUE);
VERBOSE(EINA_LOG_INFO("Wrote <%s> vibration data <%p> size <%d>\n",
buf, s->data, s->size));
}
}
}
_edje_pick_sound_dir_compose(samples, tones, out_file);
_edje_pick_vibration_dir_compose(vibrations, out_file);
/* Write file header after processing all groups */
if (out_file)

View File

@ -1713,7 +1713,8 @@ typedef enum _Edje_Action_Type
EDJE_ACTION_TYPE_PHYSICS_ANG_VEL_SET = 21, /**< @since 1.8 */
EDJE_ACTION_TYPE_PHYSICS_STOP = 22, /**< @since 1.8 */
EDJE_ACTION_TYPE_PHYSICS_ROT_SET = 23, /**< @since 1.8 */
EDJE_ACTION_TYPE_LAST = 24
EDJE_ACTION_TYPE_VIBRATION_SAMPLE = 24, /**< @since 1.10 */
EDJE_ACTION_TYPE_LAST = 25
} Edje_Action_Type;
/**

View File

@ -19,6 +19,8 @@ Eet_Data_Descriptor *_edje_edd_edje_limit_pointer = NULL;
Eet_Data_Descriptor *_edje_edd_edje_sound_sample = NULL;
Eet_Data_Descriptor *_edje_edd_edje_sound_tone = NULL;
Eet_Data_Descriptor *_edje_edd_edje_sound_directory = NULL;
Eet_Data_Descriptor *_edje_edd_edje_vibration_sample = NULL;
Eet_Data_Descriptor *_edje_edd_edje_vibration_directory = NULL;
Eet_Data_Descriptor *_edje_edd_edje_program = NULL;
Eet_Data_Descriptor *_edje_edd_edje_program_pointer = NULL;
Eet_Data_Descriptor *_edje_edd_edje_program_target = NULL;
@ -204,6 +206,8 @@ _edje_edd_shutdown(void)
FREED(_edje_edd_edje_sound_sample);
FREED(_edje_edd_edje_sound_tone);
FREED(_edje_edd_edje_sound_directory);
FREED(_edje_edd_edje_vibration_sample);
FREED(_edje_edd_edje_vibration_directory);
FREED(_edje_edd_edje_program);
FREED(_edje_edd_edje_program_pointer);
FREED(_edje_edd_edje_program_target);
@ -353,6 +357,19 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_sound_directory, Edje_Sound_Directory, "samples", samples, _edje_edd_edje_sound_sample);
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_sound_directory, Edje_Sound_Directory, "tones", tones, _edje_edd_edje_sound_tone);
/* Vibration */
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Vibration_Sample);
_edje_edd_edje_vibration_sample =
eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_vibration_sample, Edje_Vibration_Sample, "name", name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_vibration_sample, Edje_Vibration_Sample, "src", src, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_vibration_sample, Edje_Vibration_Sample, "id", id, EET_T_INT);
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Vibration_Directory);
_edje_edd_edje_vibration_directory =
eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_vibration_directory, Edje_Vibration_Directory, "samples", samples, _edje_edd_edje_vibration_sample);
/* collection directory */
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Collection_Directory_Entry);
_edje_edd_edje_part_collection_directory_entry =
@ -413,6 +430,7 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "external_dir", external_dir, _edje_edd_edje_external_directory);
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "image_dir", image_dir, _edje_edd_edje_image_directory);
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "sound_dir", sound_dir, _edje_edd_edje_sound_directory);
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "vibration_dir", vibration_dir, _edje_edd_edje_vibration_directory);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_file, Edje_File, "styles", styles, _edje_edd_edje_style);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_file, Edje_File, "color_classes", color_classes, _edje_edd_edje_color_class);
EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "data", data, _edje_edd_edje_string);
@ -453,6 +471,9 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "tone_name", tone_name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program ,"duration", duration, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program ,"speed", speed, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "vibration_name", vibration_name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "vibration_repeat", vibration_repeat, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "state", state, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "state2", state2, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "value", value, EET_T_DOUBLE);

View File

@ -75,6 +75,7 @@
* set_tween_state(part_id, Float:tween, state1[], Float:state1_val, state2[], Float:state2_val)
* play_sample(sample_name, speed, ...)
* play_tone(tone_name, duration, ...)
* play_vibration(sample_name, repeat)
* run_program(program_id)
* Direction:get_drag_dir(part_id)
* get_drag(part_id, &Float:dx, &Float:&dy)
@ -951,6 +952,26 @@ _edje_embryo_fn_play_tone(Embryo_Program *ep, Embryo_Cell *params)
return 0;
}
static Embryo_Cell
_edje_embryo_fn_play_vibration(Embryo_Program *ep, Embryo_Cell *params)
{
Edje *ed;
char *sample_name = NULL;
int repeat = 10;
if (params[0] < (int) (sizeof(Embryo_Cell) * 2)) return 0;
ed = embryo_program_data_get(ep);
GETSTR(sample_name, params[1]);
if ((!sample_name)) return 0;
if (params[0] == (int) (sizeof(Embryo_Cell) * 2))
GETINT(repeat, params[2]);
_edje_multisense_internal_vibration_sample_play(ed, sample_name,
repeat);
return 0;
}
/* set_state(part_id, state[], Float:state_val) */
static Embryo_Cell
_edje_embryo_fn_set_state(Embryo_Program *ep, Embryo_Cell *params)
@ -3754,6 +3775,7 @@ _edje_embryo_script_init(Edje_Part_Collection *edc)
embryo_program_native_call_add(ep, "set_max_size", _edje_embryo_fn_set_max_size);
embryo_program_native_call_add(ep, "play_sample", _edje_embryo_fn_play_sample);
embryo_program_native_call_add(ep, "play_tone", _edje_embryo_fn_play_tone);
embryo_program_native_call_add(ep, "play_vibration", _edje_embryo_fn_play_vibration);
embryo_program_native_call_add(ep, "send_message", _edje_embryo_fn_send_message);
embryo_program_native_call_add(ep, "get_geometry", _edje_embryo_fn_get_geometry);
embryo_program_native_call_add(ep, "custom_state", _edje_embryo_fn_custom_state);

View File

@ -1570,6 +1570,22 @@ _edje_file_free(Edje_File *edf)
free(edf->sound_dir);
}
if (edf->vibration_dir)
{
unsigned int i;
if (edf->free_strings)
{
for (i = 0; i < edf->vibration_dir->samples_count; ++i)
{
eina_stringshare_del(edf->vibration_dir->samples[i].name);
eina_stringshare_del(edf->vibration_dir->samples[i].src);
}
}
free(edf->vibration_dir->samples);
free(edf->vibration_dir);
}
if (edf->external_dir)
{
if (edf->external_dir->entries) free(edf->external_dir->entries);

View File

@ -295,6 +295,19 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const
}
Eina_Bool
_edje_multisense_internal_vibration_sample_play(Edje *ed EINA_UNUSED, const char *sample_name EINA_UNUSED, int repeat EINA_UNUSED)
{
#ifdef ENABLE_MULTISENSE
ERR("Vibration is not supported yet, name:%s, repeat:%d", sample_name, repeat);
return EINA_FALSE;
#else
(void) ed;
(void) repeat;
return EINA_FALSE;
#endif
}
void
_edje_multisense_init(void)
{

View File

@ -272,9 +272,12 @@ typedef struct _Edje_Image_Directory_Entry Edje_Image_Directory_Entry;
typedef struct _Edje_Image_Directory_Set Edje_Image_Directory_Set;
typedef struct _Edje_Image_Directory_Set_Entry Edje_Image_Directory_Set_Entry;
typedef struct _Edje_Limit Edje_Limit;
typedef struct _Edje_Plugin Edje_Plugin;
typedef struct _Edje_Sound_Sample Edje_Sound_Sample;
typedef struct _Edje_Sound_Tone Edje_Sound_Tone;
typedef struct _Edje_Sound_Directory Edje_Sound_Directory;
typedef struct _Edje_Vibration_Sample Edje_Vibration_Sample;
typedef struct _Edje_Vibration_Directory Edje_Vibration_Directory;
typedef struct _Edje_Program Edje_Program;
typedef struct _Edje_Program_Target Edje_Program_Target;
typedef struct _Edje_Program_After Edje_Program_After;
@ -461,6 +464,7 @@ struct _Edje_File
Edje_External_Directory *external_dir;
Edje_Image_Directory *image_dir;
Edje_Sound_Directory *sound_dir;
Edje_Vibration_Directory *vibration_dir;
Eina_List *styles;
@ -613,6 +617,18 @@ struct _Edje_Sound_Directory
unsigned int tones_count;
};
struct _Edje_Vibration_Sample
{
const char *name;
const char *src;
int id;
};
struct _Edje_Vibration_Directory
{
Edje_Vibration_Sample *samples; /* an array of Edje_Sound_Sample entries */
unsigned int samples_count;
};
/*----------*/
struct _Edje_Program /* a conditional program to be run */
@ -626,6 +642,8 @@ struct _Edje_Program /* a conditional program to be run */
const char *tone_name;
double duration;
double speed;
const char *vibration_name;
int vibration_repeat;
struct {
const char *part;
@ -2431,6 +2449,7 @@ void _edje_multisense_init(void);
void _edje_multisense_shutdown(void);
Eina_Bool _edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed, int channel);
Eina_Bool _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const double duration, int channel);
Eina_Bool _edje_multisense_internal_vibration_sample_play(Edje *ed, const char *sample_name, int repeat);
void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state);

View File

@ -874,6 +874,11 @@ low_mem_current:
goto break_prog;
_edje_multisense_internal_sound_tone_play(ed, pr->tone_name, pr->duration, pr->channel);
break;
case EDJE_ACTION_TYPE_VIBRATION_SAMPLE:
if (_edje_block_break(ed))
goto break_prog;
_edje_multisense_internal_vibration_sample_play(ed, pr->vibration_name, pr->vibration_repeat);
break;
case EDJE_ACTION_TYPE_PARAM_COPY:
{
Edje_Real_Part *src_part, *dst_part;