Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/bin
Modified Files:
Tag: SPLIT
ecore_evas_test.c
Log Message:
working on making this go on my ipaq.. it does... now. i have to commit data
files. will do that once i have a better app design happening. right now it
starts and calibrates the touchscreen. that's it.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/bin/Attic/ecore_evas_test.c,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -3 -r1.1.2.3 -r1.1.2.4
--- ecore_evas_test.c 15 Feb 2003 14:55:21 -0000 1.1.2.3
+++ ecore_evas_test.c 16 Feb 2003 15:00:31 -0000 1.1.2.4
@@ -15,6 +15,7 @@
Ecore_Evas *ee = NULL;
Evas *evas = NULL;
Evas_Object *o_bg_rect = NULL;
+Evas_Object *o_logo = NULL;
int
app_signal_exit(int ev_type, void *ev, void *data)
@@ -127,6 +128,283 @@
#endif
}
+static Evas_Object *o_events = NULL;
+static Evas_Object *o_crosshair = NULL;
+static Evas_Object *o_text = NULL;
+static int cal_pos = 0;
+static int down = 0;
+
+static int cal_coords[] = {15, 15, -15, 15, 15, -15, -15, -15};
+static char *cal_lines[] =
+{
+ "Please click on the crosshair",
+ "Again please",
+ "And again",
+ "Last one, then calibration is complete"
+};
+static int cal_input[8];
+
+static int tmp_input_count = 0;
+static int tmp_input[16];
+
+void calibrate_cb_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
+void calibrate_cb_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
+void calibrate_cb_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
+void calibrate_pos_set(int pos);
+int calibrate_pos_get(void);
+void calibrate_finish(void);
+void calibrate_start(void);
+
+void
+calibrate_cb_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Mouse_Down *ev;
+
+ ev = event_info;
+
+ tmp_input_count = 0;
+ tmp_input[((tmp_input_count & 0x7) * 2) + 0] = ev->output.x;
+ tmp_input[((tmp_input_count & 0x7) * 2) + 1] = ev->output.y;
+ tmp_input_count++;
+ down = 1;
+}
+
+void
+calibrate_cb_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Mouse_Up *ev;
+ int n, i, avx, avy, c, mx, my;
+ int dists[8];
+ int indexes[8];
+ int sorted;
+
+ ev = event_info;
+ down = 0;
+ tmp_input[((tmp_input_count & 0x7) * 2) + 0] = ev->output.x;
+ tmp_input[((tmp_input_count & 0x7) * 2) + 1] = ev->output.y;
+ tmp_input_count++;
+ n = 8;
+ if (tmp_input_count < 8) n = tmp_input_count;
+ avx = 0; avy = 0; c = 0;
+ for (i = 0; i < n; i++)
+ {
+ dists[i] = tmp_input[(i * 2) + 0];
+ indexes[i] = i;
+ }
+ sorted = 0;
+ while (!sorted)
+ {
+ sorted = 1;
+ for (i = 0; i < n - 1; i++)
+ {
+ if (dists[i + 1] < dists[i])
+ {
+ int tmp;
+
+ sorted = 0;
+ tmp = dists[i];
+ dists[i] = dists[i + 1];
+ dists[i + 1] = tmp;
+ tmp = indexes[i];
+ indexes[i] = indexes[i + 1];
+ indexes[i + 1] = tmp;
+ }
+ }
+ }
+ mx = dists[(n + 1) / 2];
+ for (i = 0; i < n; i++)
+ {
+ dists[i] = tmp_input[(i * 2) + 1];
+ indexes[i] = i;
+ }
+ sorted = 0;
+ while (!sorted)
+ {
+ sorted = 1;
+ for (i = 0; i < n - 1; i++)
+ {
+ if (dists[i + 1] < dists[i])
+ {
+ int tmp;
+
+ sorted = 0;
+ tmp = dists[i];
+ dists[i] = dists[i + 1];
+ dists[i + 1] = tmp;
+ tmp = indexes[i];
+ indexes[i] = indexes[i + 1];
+ indexes[i + 1] = tmp;
+ }
+ }
+ }
+ my = dists[(n + 1) / 2];
+
+ for (i = 0; i < n; i++)
+ {
+ int x, y, dx, dy;
+
+ x = tmp_input[(i * 2) + 0];
+ y = tmp_input[(i * 2) + 1];
+ dx = x - mx;
+ dy = y - my;
+ if (dx < 0) dx = -dx;
+ if (dy < 0) dy = -dy;
+ if ((dx <= 8) && (dy <= 8))
+ {
+ avx += tmp_input[(i * 2) + 0];
+ avy += tmp_input[(i * 2) + 1];
+ c++;
+ }
+ }
+ cal_input[(cal_pos * 2) + 0] = avx / c;
+ cal_input[(cal_pos * 2) + 1] = avy / c;
+ n = calibrate_pos_get();
+ if (n < 3)
+ {
+ calibrate_pos_set(n + 1);
+ return;
+ }
+ calibrate_finish();
+}
+
+void
+calibrate_cb_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Mouse_Move *ev;
+
+ ev = event_info;
+ if (!down) return;
+ tmp_input[((tmp_input_count & 0x7) * 2) + 0] = ev->cur.output.x;
+ tmp_input[((tmp_input_count & 0x7) * 2) + 1] = ev->cur.output.y;
+ tmp_input_count++;
+}
+
+void
+calibrate_pos_set(int pos)
+{
+ double w, h;
+ int x, y, ow, oh;
+
+ cal_pos = pos;
+ evas_object_geometry_get(o_crosshair, NULL, NULL, &w, &h);
+ x = cal_coords[(cal_pos * 2) + 0];
+ y = cal_coords[(cal_pos * 2) + 1];
+ evas_output_size_get(evas, &ow, &oh);
+ if (x < 0) x = ow + x - 1;
+ if (y < 0) y = oh + y - 1;
+ cal_coords[(cal_pos * 2) + 0] = x;
+ cal_coords[(cal_pos * 2) + 1] = y;
+ evas_object_move(o_crosshair, x - (((int)w - 1) / 2), y - (((int)h - 1) / 2));
+ evas_object_text_text_set(o_text, cal_lines[cal_pos]);
+ evas_object_geometry_get(o_text, NULL, NULL, &w, &h);
+ evas_object_move(o_text, (ow - w) / 2, (oh - h) / 2);
+}
+
+int
+calibrate_pos_get(void)
+{
+ return cal_pos;
+}
+
+void
+calibrate_finish(void)
+{
+ int m0, m1;
+ int y0, y1;
+ int dx, dy;
+ int x[4], y[4], xi[4], yi[4];
+ int i, rot;
+
+ int xscale, xtrans, yscale, ytrans, xyswap;
+
+ rot = ecore_evas_rotation_get(ee);
+ for (i = 0; i < 4; i++)
+ {
+ x[i] = cal_coords[(i * 2) + 0];
+ y[i] = cal_coords[(i * 2) + 1];
+ xi[i] = cal_input[(i * 2) + 0];
+ yi[i] = cal_input[(i * 2) + 1];
+ }
+ xyswap = 0;
+
+ m0 = ((x[1] - x[0]) * 256) / (xi[1] - xi[0]);
+ y0 = ((x[1] - ((xi[1] * m0) / 256)) + (x[0] - ((xi[0] * m0) >> 8)) ) / 2;
+
+ m1 = ((x[3] - x[2]) * 256) / (xi[3] - xi[2]);
+ y1 = ((x[3] - ((xi[3] * m1) / 256)) + (x[2] - ((xi[2] * m1) >> 8)) ) / 2;
+
+ xscale = (m0 + m1) / 2;
+ xtrans = (y0 + y1) / 2;
+
+ m0 = ((y[2] - y[0]) * 256) / (yi[2] - yi[0]);
+ y0 = ((y[2] - ((yi[2] * m0) / 256)) + (y[0] - ((yi[0] * m0) >> 8)) ) / 2;
+
+ m1 = ((y[3] - y[1]) * 256) / (yi[3] - yi[1]);
+ y1 = ((y[3] - ((yi[3] * m1) / 256)) + (y[1] - ((yi[1] * m1) >> 8)) ) / 2;
+
+ yscale = (m0 + m1) / 2;
+ ytrans = (y0 + y1) / 2;
+
+ if (rot == 0)
+ {
+ ecore_fb_touch_screen_calibrate_set(xscale, xtrans, yscale, ytrans, xyswap);
+ }
+ else if (rot == 270)
+ {
+ int ow, oh;
+
+ evas_output_size_get(evas, &ow, &oh);
+ ytrans = oh - (ytrans + ((oh * yscale) / 256));
+ ecore_fb_touch_screen_calibrate_set(yscale, ytrans, xscale, xtrans, xyswap);
+ }
+
+ evas_object_del(o_crosshair);
+ evas_object_del(o_events);
+ evas_object_del(o_text);
+ o_crosshair = NULL;
+ o_events = NULL;
+ o_text = NULL;
+ cal_pos = 0;
+}
+
+void
+calibrate_start(void)
+{
+ Evas_Object *o;
+
+ ecore_fb_touch_screen_calibrate_set(256, 0, 256, 0, 0);
+
+ o = evas_object_rectangle_add(evas);
+ evas_object_layer_set(o, 1000000);
+ evas_object_color_set(o, 255, 255, 255, 120);
+ evas_object_move(o, -12000, -16000);
+ evas_object_resize(o, 24000, 32000);
+ evas_object_show(o);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, calibrate_cb_down, ee);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, calibrate_cb_up, ee);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, calibrate_cb_move, ee);
+ o_events = o;
+
+ o = evas_object_image_add(evas);
+ evas_object_layer_set(o, 1000001);
+ evas_object_image_file_set(o, IM"crosshair.png", NULL);
+ evas_object_resize(o, 31, 31);
+ evas_object_image_fill_set(o, 0, 0, 31, 31);
+ evas_object_pass_events_set(o, 1);
+ evas_object_show(o);
+ o_crosshair = o;
+
+ o = evas_object_text_add(evas);
+ evas_object_layer_set(o, 1000002);
+ evas_object_color_set(o, 0, 0, 0, 255);
+ evas_object_text_font_set(o, "helmet", 10);
+ evas_object_pass_events_set(o, 1);
+ evas_object_show(o);
+ o_text = o;
+
+ calibrate_pos_set(0);
+}
+
void
setup_ecore_evas_test(void)
{
@@ -144,14 +422,15 @@
o_bg_rect = o;
o = evas_object_image_add(evas);
- evas_object_image_file_set(o, IM"evas_logo.png", NULL);
- evas_object_resize(o, 200, 198);
- evas_object_image_fill_set(o, 0, 0, 200, 192);
- evas_object_move(o, (240 - 200) / 2, (320 -198) / 2);
+ evas_object_image_file_set(o, IM"e_logo.png", NULL);
+ evas_object_resize(o, 240, 280);
+ evas_object_image_fill_set(o, 0, 0, 240, 280);
+ evas_object_move(o, (240 - 240) / 2, (320 - 280) / 2);
evas_object_show(o);
+ o_logo = o;
/* add a timer to animate them */
- anim_timer = ecore_timer_add(0.01, app_animate_obj_timer, NULL);
+// anim_timer = ecore_timer_add(0.01, app_animate_obj_timer, NULL);
}
/**** MAIN */
@@ -167,7 +446,7 @@
/* create an evas */
if (!ecore_evas_init()) return -1;
if ((argc > 1) && (!strcmp(argv[1], "-fb")))
- ee = ecore_evas_fb_new(NULL, 270, 240, 320);
+ ee = ecore_evas_fb_new(NULL, 0, 240, 320);
else if ((argc > 1) && (!strcmp(argv[1], "-x")))
ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 240, 320);
else if ((argc > 1) && (!strcmp(argv[1], "-h")))
@@ -185,6 +464,7 @@
ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 240, 320);
#else if BUILD_ECORE_FB
ee = ecore_evas_fb_new(NULL, 270, 240, 320);
+// ecore_evas_fullscreen_set(ee, 1);
#endif
if (!ee) return -1;
ecore_evas_callback_delete_request_set(ee, app_delete_request);
@@ -198,6 +478,8 @@
evas_font_path_append(evas, FN);
setup_ecore_evas_test();
+
+ calibrate_start();
ecore_main_loop_begin();
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs