summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2019-12-04 17:15:09 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-12-11 13:46:31 +0100
commit5888c7ee0052a84316759ffd48bce330fca41c81 (patch)
treef59f613b031b991d6aeae027c1326a983ec985c6
parent29438a5454f5998e76eeaa61474391b8c0f6dfb5 (diff)
eeze: remove tizen module support from eeze sensor
This has been disabled since the move to meson and unlikely to have built before with autotools either. Tizen never adopted this so we can ease our maintenance burden here. The Eeze sensor API itself is EAPI sadly and can't be removed. We will keep the udev backend (temperature only) and the fake backend for testing for now. Signed-off-by: Stefan Schmidt <s.schmidt@samsung.com> Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D10805
-rw-r--r--src/lib/eeze/eeze_sensor.c1
-rw-r--r--src/modules/eeze/meson.build1
-rw-r--r--src/modules/eeze/sensor/tizen/meson.build8
-rw-r--r--src/modules/eeze/sensor/tizen/tizen.c1383
4 files changed, 0 insertions, 1393 deletions
diff --git a/src/lib/eeze/eeze_sensor.c b/src/lib/eeze/eeze_sensor.c
index f147e8a..ee31b1e 100644
--- a/src/lib/eeze/eeze_sensor.c
+++ b/src/lib/eeze/eeze_sensor.c
@@ -42,7 +42,6 @@ static Eina_Prefix *pfx;
42 * re-think the priority handling, but we should do this when the need arise. 42 * re-think the priority handling, but we should do this when the need arise.
43 */ 43 */
44static const char *_module_priority[] = { 44static const char *_module_priority[] = {
45 "tizen",
46 "fake", 45 "fake",
47 "udev", 46 "udev",
48 NULL 47 NULL
diff --git a/src/modules/eeze/meson.build b/src/modules/eeze/meson.build
index e25ab50..919ff20 100644
--- a/src/modules/eeze/meson.build
+++ b/src/modules/eeze/meson.build
@@ -1,6 +1,5 @@
1sensors = [ 1sensors = [
2['fake', [ecore]], 2['fake', [ecore]],
3#['tizen', []],
4['udev', [ecore]], 3['udev', [ecore]],
5] 4]
6 5
diff --git a/src/modules/eeze/sensor/tizen/meson.build b/src/modules/eeze/sensor/tizen/meson.build
deleted file mode 100644
index c87f2cb..0000000
--- a/src/modules/eeze/sensor/tizen/meson.build
+++ /dev/null
@@ -1,8 +0,0 @@
1shared_module(module_name,
2 module_name+'.c',
3 dependencies: [eina, eeze, ecore],
4 install: true,
5 install_dir : join_paths(dir_package_modules, 'sensor', module_name, version_name),
6)
7
8module_files += join_paths(dir_package_modules, 'sensor', module_name, version_name, 'lib' + module_name + '.' + sys_lib_extension)
diff --git a/src/modules/eeze/sensor/tizen/tizen.c b/src/modules/eeze/sensor/tizen/tizen.c
deleted file mode 100644
index 93bea03..0000000
--- a/src/modules/eeze/sensor/tizen/tizen.c
+++ /dev/null
@@ -1,1383 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <system/sensors.h>
6
7#include <stdio.h>
8#include <stdlib.h>
9#include <stdbool.h>
10
11#include <Eina.h>
12#include <Ecore.h>
13#include <Eeze_Sensor.h>
14#include "eeze_sensor_private.h"
15
16static int _eeze_sensor_tizen_log_dom = -1;
17
18#ifdef ERR
19#undef ERR
20#endif
21#define ERR(...) EINA_LOG_DOM_ERR(_eeze_sensor_tizen_log_dom, __VA_ARGS__)
22
23static Eeze_Sensor_Module *esensor_module;
24/* Tizen sensor handle */
25static sensor_h sensor_handle;
26
27static void
28_dummy_free(void *user_data EINA_UNUSED, void *func_data EINA_UNUSED)
29{
30/* Don't free the event data after dispatching the event. We keep track of
31 * it on our own
32 */
33}
34
35
36/* The Tizen sensor type ENUM has shown to not be stable regarding its
37 * numbering scheme so we better translate between the Tizen types and the
38 * ones we use here.
39 */
40static sensor_type_e
41eeze_to_tizen(Eeze_Sensor_Type type)
42{
43 switch (type)
44 {
45 case EEZE_SENSOR_TYPE_ACCELEROMETER:
46 return SENSOR_ACCELEROMETER;
47
48 case EEZE_SENSOR_TYPE_GRAVITY:
49 return SENSOR_GRAVITY;
50
51 case EEZE_SENSOR_TYPE_LINEAR_ACCELERATION:
52 return SENSOR_LINEAR_ACCELERATION;
53
54 case EEZE_SENSOR_TYPE_DEVICE_ORIENTATION:
55 return SENSOR_DEVICE_ORIENTATION;
56
57 case EEZE_SENSOR_TYPE_MAGNETIC:
58 return SENSOR_MAGNETIC;
59
60 case EEZE_SENSOR_TYPE_ORIENTATION:
61 return SENSOR_ORIENTATION;
62
63 case EEZE_SENSOR_TYPE_GYROSCOPE:
64 return SENSOR_GYROSCOPE;
65
66 case EEZE_SENSOR_TYPE_LIGHT:
67 return SENSOR_LIGHT;
68
69 case EEZE_SENSOR_TYPE_PROXIMITY:
70 return SENSOR_PROXIMITY;
71
72 case EEZE_SENSOR_TYPE_MOTION_SNAP:
73 return SENSOR_MOTION_SNAP;
74
75 case EEZE_SENSOR_TYPE_MOTION_SHAKE:
76 return SENSOR_MOTION_SHAKE;
77
78 case EEZE_SENSOR_TYPE_MOTION_DOUBLETAP:
79 return SENSOR_MOTION_DOUBLETAP;
80
81 case EEZE_SENSOR_TYPE_MOTION_PANNING:
82 return SENSOR_MOTION_PANNING;
83
84 case EEZE_SENSOR_TYPE_MOTION_PANNING_BROWSE:
85 return SENSOR_MOTION_PANNING_BROWSE;
86
87 case EEZE_SENSOR_TYPE_MOTION_TILT:
88 return SENSOR_MOTION_TILT;
89
90 case EEZE_SENSOR_TYPE_MOTION_FACEDOWN:
91 return SENSOR_MOTION_FACEDOWN;
92
93 case EEZE_SENSOR_TYPE_MOTION_DIRECT_CALL:
94 return SENSOR_MOTION_DIRECTCALL;
95
96 case EEZE_SENSOR_TYPE_MOTION_SMART_ALERT:
97 return SENSOR_MOTION_SMART_ALERT;
98
99 case EEZE_SENSOR_TYPE_MOTION_NO_MOVE:
100 return SENSOR_MOTION_NO_MOVE;
101
102 default:
103 ERR("No matching Tizen sensor type available.");
104 return -1;
105 }
106}
107
108/* Reverse mapping from Tizen to eeze sensor types */
109static Eeze_Sensor_Type
110tizen_to_eeze(sensor_type_e type)
111{
112 switch (type)
113 {
114 case SENSOR_ACCELEROMETER:
115 return EEZE_SENSOR_TYPE_ACCELEROMETER;
116
117 case SENSOR_GRAVITY:
118 return EEZE_SENSOR_TYPE_GRAVITY;
119
120 case SENSOR_LINEAR_ACCELERATION:
121 return EEZE_SENSOR_TYPE_LINEAR_ACCELERATION;
122
123 case SENSOR_DEVICE_ORIENTATION:
124 return EEZE_SENSOR_TYPE_DEVICE_ORIENTATION;
125
126 case SENSOR_MAGNETIC:
127 return EEZE_SENSOR_TYPE_MAGNETIC;
128
129 case SENSOR_ORIENTATION:
130 return EEZE_SENSOR_TYPE_ORIENTATION;
131
132 case SENSOR_GYROSCOPE:
133 return EEZE_SENSOR_TYPE_GYROSCOPE;
134
135 case SENSOR_LIGHT:
136 return EEZE_SENSOR_TYPE_LIGHT;
137
138 case SENSOR_PROXIMITY:
139 return EEZE_SENSOR_TYPE_PROXIMITY;
140
141 case SENSOR_MOTION_SNAP:
142 return EEZE_SENSOR_TYPE_MOTION_SNAP;
143
144 case SENSOR_MOTION_SHAKE:
145 return EEZE_SENSOR_TYPE_MOTION_SHAKE;
146
147 case SENSOR_MOTION_DOUBLETAP:
148 return EEZE_SENSOR_TYPE_MOTION_DOUBLETAP;
149
150 case SENSOR_MOTION_PANNING:
151 return EEZE_SENSOR_TYPE_MOTION_PANNING;
152
153 case SENSOR_MOTION_PANNING_BROWSE:
154 return EEZE_SENSOR_TYPE_MOTION_PANNING_BROWSE;
155
156 case SENSOR_MOTION_TILT:
157 return EEZE_SENSOR_TYPE_MOTION_TILT;
158
159 case SENSOR_MOTION_FACEDOWN:
160 return EEZE_SENSOR_TYPE_MOTION_FACEDOWN;
161
162 case SENSOR_MOTION_DIRECTCALL:
163 return EEZE_SENSOR_TYPE_MOTION_DIRECT_CALL;
164
165 case SENSOR_MOTION_SMART_ALERT:
166 return EEZE_SENSOR_TYPE_MOTION_SMART_ALERT;
167
168 case SENSOR_MOTION_NO_MOVE:
169 return EEZE_SENSOR_TYPE_MOTION_NO_MOVE;
170
171 default:
172 ERR("No matching eeze sensor type available.");
173 return -1;
174 }
175}
176
177/* We receive the timestamp in nanoseconds from the Tizen system lib. Convert
178 * it to seconds as floating point value which is used in our public API.
179 */
180static double
181clock_convert(unsigned long long timestamp)
182{
183 return ((double)timestamp) / 1000000000.0;
184}
185
186/* All following callback function work with the same scheme.
187 * They are callbacks coming in from the tizen system sensor library. With the
188 * data we receive we update the matching sensor object to always have the
189 * latest data available. That includes updating the timestamp to show when the
190 * data was measured from the underlying system.
191 * After that we send out an ecore event to let all interested parties now that
192 * new data is available and then stop the sensor server to safe power. It will be
193 * started again the next time data gets requested.
194 */
195static void
196accelerometer_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
197{
198 Eeze_Sensor_Obj *obj = user_data;
199
200 if (obj == NULL)
201 {
202 ERR("No matching sensor object given.");
203 return;
204 }
205 obj->accuracy = accuracy;
206 obj->data[0] = x;
207 obj->data[1] = y;
208 obj->data[2] = z;
209 obj->timestamp = clock_convert(timestamp);
210 ecore_event_add(EEZE_SENSOR_EVENT_ACCELEROMETER, obj, _dummy_free, NULL);
211 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_ACCELEROMETER));
212}
213
214static void
215gravity_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
216{
217 Eeze_Sensor_Obj *obj = user_data;
218
219 if (obj == NULL)
220 {
221 ERR("No matching sensor object given.");
222 return;
223 }
224 obj->accuracy = accuracy;
225 obj->data[0] = x;
226 obj->data[1] = y;
227 obj->data[2] = z;
228 obj->timestamp = clock_convert(timestamp);
229 ecore_event_add(EEZE_SENSOR_EVENT_GRAVITY, obj, _dummy_free, NULL);
230 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_GRAVITY));
231}
232
233static void
234linear_acceleration_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
235{
236 Eeze_Sensor_Obj *obj = user_data;
237
238 if (obj == NULL)
239 {
240 ERR("No matching sensor object given.");
241 return;
242 }
243 obj->accuracy = accuracy;
244 obj->data[0] = x;
245 obj->data[1] = y;
246 obj->data[2] = z;
247 obj->timestamp = clock_convert(timestamp);
248 ecore_event_add(EEZE_SENSOR_EVENT_LINEAR_ACCELERATION, obj, _dummy_free, NULL);
249 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_LINEAR_ACCELERATION));
250}
251
252static void
253device_orientation_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float yaw,
254 float pitch, float roll, void *user_data)
255{
256 Eeze_Sensor_Obj *obj = user_data;
257
258 if (obj == NULL)
259 {
260 ERR("No matching sensor object given.");
261 return;
262 }
263 obj->accuracy = accuracy;
264 obj->data[0] = yaw;
265 obj->data[1] = pitch;
266 obj->data[2] = roll;
267 obj->timestamp = clock_convert(timestamp);
268 ecore_event_add(EEZE_SENSOR_EVENT_DEVICE_ORIENTATION, obj, _dummy_free, NULL);
269 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_DEVICE_ORIENTATION));
270}
271
272static void
273magnetic_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
274{
275 Eeze_Sensor_Obj *obj = user_data;
276
277 if (obj == NULL)
278 {
279 ERR("No matching sensor object given.");
280 return;
281 }
282 obj->accuracy = accuracy;
283 obj->data[0] = x;
284 obj->data[1] = y;
285 obj->data[2] = z;
286 obj->timestamp = clock_convert(timestamp);
287 ecore_event_add(EEZE_SENSOR_EVENT_MAGNETIC, obj, _dummy_free, NULL);
288 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MAGNETIC));
289}
290
291static void
292orientation_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float azimuth, float pitch, float roll, void *user_data)
293{
294 Eeze_Sensor_Obj *obj = user_data;
295
296 if (obj == NULL)
297 {
298 ERR("No matching sensor object given.");
299 return;
300 }
301 obj->accuracy = accuracy;
302 obj->data[0] = azimuth;
303 obj->data[1] = pitch;
304 obj->data[2] = roll;
305 obj->timestamp = clock_convert(timestamp);
306 ecore_event_add(EEZE_SENSOR_EVENT_ORIENTATION, obj, _dummy_free, NULL);
307 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_ORIENTATION));
308}
309
310static void
311gyroscope_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
312{
313 Eeze_Sensor_Obj *obj = user_data;
314
315 if (obj == NULL)
316 {
317 ERR("No matching sensor object given.");
318 return;
319 }
320 obj->accuracy = accuracy;
321 obj->data[0] = x;
322 obj->data[1] = y;
323 obj->data[2] = z;
324 obj->timestamp = clock_convert(timestamp);
325 ecore_event_add(EEZE_SENSOR_EVENT_GYROSCOPE, obj, _dummy_free, NULL);
326 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_GYROSCOPE));
327}
328
329static void
330light_cb(unsigned long long timestamp, float lux, void *user_data)
331{
332 Eeze_Sensor_Obj *obj = user_data;
333
334 if (obj == NULL)
335 {
336 ERR("No matching sensor object given.");
337 return;
338 }
339 /* We have to set this ourselves because we don't get it for this type */
340 obj->accuracy = -1;
341 obj->data[0] = lux;
342 obj->timestamp = clock_convert(timestamp);
343 ecore_event_add(EEZE_SENSOR_EVENT_LIGHT, obj, _dummy_free, NULL);
344 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_LIGHT));
345}
346
347static void
348proximity_cb(unsigned long long timestamp, float distance, void *user_data)
349{
350 Eeze_Sensor_Obj *obj = user_data;
351
352 if (obj == NULL)
353 {
354 ERR("No matching sensor object given.");
355 return;
356 }
357 /* We have to set this ourselves because we don't get it for this type */
358 obj->accuracy = -1;
359 obj->data[0] = distance;
360 obj->timestamp = clock_convert(timestamp);
361 ecore_event_add(EEZE_SENSOR_EVENT_PROXIMITY, obj, _dummy_free, NULL);
362 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_PROXIMITY));
363}
364
365static void
366snap_cb(unsigned long long timestamp, sensor_motion_snap_e snap, void *user_data)
367{
368 Eeze_Sensor_Obj *obj = user_data;
369
370 if (obj == NULL)
371 {
372 ERR("No matching sensor object given.");
373 return;
374 }
375 /* We have to set this ourselves because we don't get it for this type */
376 obj->accuracy = -1;
377 obj->data[0] = snap;
378 obj->timestamp = clock_convert(timestamp);
379 ecore_event_add(EEZE_SENSOR_EVENT_SNAP, obj, _dummy_free, NULL);
380 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_SNAP));
381}
382
383static void
384shake_cb(unsigned long long timestamp, sensor_motion_shake_e shake, void *user_data)
385{
386 Eeze_Sensor_Obj *obj = user_data;
387
388 if (obj == NULL)
389 {
390 ERR("No matching sensor object given.");
391 return;
392 }
393 /* We have to set this ourselves because we don't get it for this type */
394 obj->accuracy = -1;
395 obj->data[0] = shake;
396 obj->timestamp = clock_convert(timestamp);
397 ecore_event_add(EEZE_SENSOR_EVENT_SHAKE, obj, _dummy_free, NULL);
398 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_SHAKE));
399}
400
401static void
402panning_cb(unsigned long long timestamp, int x, int y, void *user_data)
403{
404 Eeze_Sensor_Obj *obj = user_data;
405
406 if (obj == NULL)
407 {
408 ERR("No matching sensor object given.");
409 return;
410 }
411 /* We have to set this ourselves because we don't get it for this type */
412 obj->accuracy = -1;
413 obj->data[0] = x;
414 obj->data[1] = y;
415 obj->timestamp = clock_convert(timestamp);
416 ecore_event_add(EEZE_SENSOR_EVENT_PANNING, obj, _dummy_free, NULL);
417 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_PANNING));
418}
419
420static void
421panning_browse_cb(unsigned long long timestamp, int x, int y, void *user_data)
422{
423 Eeze_Sensor_Obj *obj = user_data;
424
425 if (obj == NULL)
426 {
427 ERR("No matching sensor object given.");
428 return;
429 }
430 /* We have to set this ourselves because we don't get it for this type */
431 obj->accuracy = -1;
432 obj->data[0] = x;
433 obj->data[1] = y;
434 obj->timestamp = clock_convert(timestamp);
435 ecore_event_add(EEZE_SENSOR_EVENT_PANNING_BROWSE, obj, _dummy_free, NULL);
436 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_PANNING_BROWSE));
437}
438
439static void
440tilt_cb(unsigned long long timestamp, int x, int y, void *user_data)
441{
442 Eeze_Sensor_Obj *obj = user_data;
443
444 if (obj == NULL)
445 {
446 ERR("No matching sensor object given.");
447 return;
448 }
449 /* We have to set this ourselves because we don't get it for this type */
450 obj->accuracy = -1;
451 obj->data[0] = x;
452 obj->data[1] = y;
453 obj->timestamp = clock_convert(timestamp);
454 ecore_event_add(EEZE_SENSOR_EVENT_TILT, obj, _dummy_free, NULL);
455 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_TILT));
456}
457
458static void
459facedown_cb(unsigned long long timestamp, void *user_data)
460{
461 Eeze_Sensor_Obj *obj = user_data;
462
463 if (obj == NULL)
464 {
465 ERR("No matching sensor object given.");
466 return;
467 }
468 /* We have to set this ourselves because we don't get it for this type */
469 obj->accuracy = -1;
470 obj->timestamp = clock_convert(timestamp);
471 ecore_event_add(EEZE_SENSOR_EVENT_FACEDOWN, obj, _dummy_free, NULL);
472 /* We are not stopping the sensor here because we want to keep it as a motion
473 * event coming in at any time.
474 */
475}
476
477static void
478directcall_cb(unsigned long long timestamp, void *user_data)
479{
480 Eeze_Sensor_Obj *obj = user_data;
481
482 if (obj == NULL)
483 {
484 ERR("No matching sensor object given.");
485 return;
486 }
487 /* We have to set this ourselves because we don't get it for this type */
488 obj->accuracy = -1;
489 obj->timestamp = clock_convert(timestamp);
490 ecore_event_add(EEZE_SENSOR_EVENT_DIRECT_CALL, obj, _dummy_free, NULL);
491 /* We are not stopping the sensor here because we want to keep it as a motion
492 * event coming in at any time.
493 */
494}
495
496static void
497smart_alert_cb(unsigned long long timestamp, void *user_data)
498{
499 Eeze_Sensor_Obj *obj = user_data;
500
501 if (obj == NULL)
502 {
503 ERR("No matching sensor object given.");
504 return;
505 }
506 /* We have to set this ourselves because we don't get it for this type */
507 obj->accuracy = -1;
508 obj->timestamp = clock_convert(timestamp);
509 ecore_event_add(EEZE_SENSOR_EVENT_SMART_ALERT, obj, _dummy_free, NULL);
510 /* We are not stopping the sensor here because we want to keep it as a motion
511 * event coming in at any time.
512 */
513}
514
515static void
516no_move_cb(unsigned long long timestamp, void *user_data)
517{
518 Eeze_Sensor_Obj *obj = user_data;
519
520 if (obj == NULL)
521 {
522 ERR("No matching sensor object given.");
523 return;
524 }
525 /* We have to set this ourselves because we don't get it for this type */
526 obj->accuracy = -1;
527 obj->timestamp = clock_convert(timestamp);
528 ecore_event_add(EEZE_SENSOR_EVENT_NO_MOVE, obj, _dummy_free, NULL);
529 /* We are not stopping the sensor here because we want to keep it as a motion
530 * event coming in at any time.
531 */
532}
533
534static void
535doubletap_cb(unsigned long long timestamp, void *user_data)
536{
537 Eeze_Sensor_Obj *obj = user_data;
538
539 if (obj == NULL)
540 {
541 ERR("No matching sensor object given.");
542 return;
543 }
544 /* We have to set this ourselves because we don't get it for this type */
545 obj->accuracy = -1;
546 obj->timestamp = clock_convert(timestamp);
547 ecore_event_add(EEZE_SENSOR_EVENT_DOUBLETAP, obj, _dummy_free, NULL);
548 /* We are not stopping the sensor here because we want to keep it as a motion
549 * event coming in at any time.
550 */
551}
552
553static void
554accelerometer_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
555{
556 Eeze_Sensor_Obj *obj = user_data;
557
558 sensor_accelerometer_unset_cb(sensor_handle);
559
560 if (obj == NULL)
561 {
562 ERR("No matching sensor object given.");
563 return;
564 }
565 obj->accuracy = accuracy;
566 obj->data[0] = x;
567 obj->data[1] = y;
568 obj->data[2] = z;
569 obj->timestamp = clock_convert(timestamp);
570 ecore_event_add(EEZE_SENSOR_EVENT_ACCELEROMETER, obj, _dummy_free, NULL);
571 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_ACCELEROMETER));
572}
573
574static void
575gravity_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
576{
577 Eeze_Sensor_Obj *obj = user_data;
578
579 sensor_gravity_unset_cb(sensor_handle);
580
581 if (obj == NULL)
582 {
583 ERR("No matching sensor object given.");
584 return;
585 }
586 obj->accuracy = accuracy;
587 obj->data[0] = x;
588 obj->data[1] = y;
589 obj->data[2] = z;
590 obj->timestamp = clock_convert(timestamp);
591 ecore_event_add(EEZE_SENSOR_EVENT_GRAVITY, obj, _dummy_free, NULL);
592 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_GRAVITY));
593}
594
595static void
596linear_acceleration_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
597{
598 Eeze_Sensor_Obj *obj = user_data;
599
600 sensor_linear_acceleration_unset_cb(sensor_handle);
601
602 if (obj == NULL)
603 {
604 ERR("No matching sensor object given.");
605 return;
606 }
607 obj->accuracy = accuracy;
608 obj->data[0] = x;
609 obj->data[1] = y;
610 obj->data[2] = z;
611 obj->timestamp = clock_convert(timestamp);
612 ecore_event_add(EEZE_SENSOR_EVENT_LINEAR_ACCELERATION, obj, _dummy_free, NULL);
613 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_LINEAR_ACCELERATION));
614}
615
616static void
617device_orientation_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float yaw,
618 float pitch, float roll, void *user_data)
619{
620 Eeze_Sensor_Obj *obj = user_data;
621
622 sensor_device_orientation_unset_cb(sensor_handle);
623
624 if (obj == NULL)
625 {
626 ERR("No matching sensor object given.");
627 return;
628 }
629 obj->accuracy = accuracy;
630 obj->data[0] = yaw;
631 obj->data[1] = pitch;
632 obj->data[2] = roll;
633 obj->timestamp = clock_convert(timestamp);
634 ecore_event_add(EEZE_SENSOR_EVENT_DEVICE_ORIENTATION, obj, _dummy_free, NULL);
635 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_DEVICE_ORIENTATION));
636}
637
638static void
639magnetic_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
640{
641 Eeze_Sensor_Obj *obj = user_data;
642
643 sensor_magnetic_unset_cb(sensor_handle);
644
645 if (obj == NULL)
646 {
647 ERR("No matching sensor object given.");
648 return;
649 }
650 obj->accuracy = accuracy;
651 obj->data[0] = x;
652 obj->data[1] = y;
653 obj->data[2] = z;
654 obj->timestamp = clock_convert(timestamp);
655 ecore_event_add(EEZE_SENSOR_EVENT_MAGNETIC, obj, _dummy_free, NULL);
656 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MAGNETIC));
657}
658
659static void
660orientation_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float azimuth, float pitch, float roll, void *user_data)
661{
662 Eeze_Sensor_Obj *obj = user_data;
663
664 sensor_orientation_unset_cb(sensor_handle);
665
666 if (obj == NULL)
667 {
668 ERR("No matching sensor object given.");
669 return;
670 }
671 obj->accuracy = accuracy;
672 obj->data[0] = azimuth;
673 obj->data[1] = pitch;
674 obj->data[2] = roll;
675 obj->timestamp = clock_convert(timestamp);
676 ecore_event_add(EEZE_SENSOR_EVENT_ORIENTATION, obj, _dummy_free, NULL);
677 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_ORIENTATION));
678}
679
680static void
681gyroscope_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
682{
683 Eeze_Sensor_Obj *obj = user_data;
684
685 sensor_gyroscope_unset_cb(sensor_handle);
686
687 if (obj == NULL)
688 {
689 ERR("No matching sensor object given.");
690 return;
691 }
692 obj->accuracy = accuracy;
693 obj->data[0] = x;
694 obj->data[1] = y;
695 obj->data[2] = z;
696 obj->timestamp = clock_convert(timestamp);
697 ecore_event_add(EEZE_SENSOR_EVENT_GYROSCOPE, obj, _dummy_free, NULL);
698 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_GYROSCOPE));
699}
700
701static void
702light_read_cb(unsigned long long timestamp, float lux, void *user_data)
703{
704 Eeze_Sensor_Obj *obj = user_data;
705
706 sensor_light_unset_cb(sensor_handle);
707
708 if (obj == NULL)
709 {
710 ERR("No matching sensor object given.");
711 return;
712 }
713 /* We have to set this ourselves because we don't get it for this type */
714 obj->accuracy = -1;
715 obj->data[0] = lux;
716 obj->timestamp = clock_convert(timestamp);
717 ecore_event_add(EEZE_SENSOR_EVENT_LIGHT, obj, _dummy_free, NULL);
718 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_LIGHT));
719}
720
721static void
722proximity_read_cb(unsigned long long timestamp, float distance, void *user_data)
723{
724 Eeze_Sensor_Obj *obj = user_data;
725
726 sensor_proximity_unset_cb(sensor_handle);
727
728 if (obj == NULL)
729 {
730 ERR("No matching sensor object given.");
731 return;
732 }
733 /* We have to set this ourselves because we don't get it for this type */
734 obj->accuracy = -1;
735 obj->data[0] = distance;
736 obj->timestamp = clock_convert(timestamp);
737 ecore_event_add(EEZE_SENSOR_EVENT_PROXIMITY, obj, _dummy_free, NULL);
738 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_PROXIMITY));
739}
740
741static void
742snap_read_cb(unsigned long long timestamp, sensor_motion_snap_e snap, void *user_data)
743{
744 Eeze_Sensor_Obj *obj = user_data;
745
746 sensor_motion_snap_unset_cb(sensor_handle);
747
748 if (obj == NULL)
749 {
750 ERR("No matching sensor object given.");
751 return;
752 }
753 /* We have to set this ourselves because we don't get it for this type */
754 obj->accuracy = -1;
755 obj->data[0] = snap;
756 obj->timestamp = clock_convert(timestamp);
757 ecore_event_add(EEZE_SENSOR_EVENT_SNAP, obj, _dummy_free, NULL);
758 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_SNAP));
759}
760
761static void
762shake_read_cb(unsigned long long timestamp, sensor_motion_shake_e shake, void *user_data)
763{
764 Eeze_Sensor_Obj *obj = user_data;
765
766 sensor_motion_shake_unset_cb(sensor_handle);
767
768 if (obj == NULL)
769 {
770 ERR("No matching sensor object given.");
771 return;
772 }
773 /* We have to set this ourselves because we don't get it for this type */
774 obj->accuracy = -1;
775 obj->data[0] = shake;
776 obj->timestamp = clock_convert(timestamp);
777 ecore_event_add(EEZE_SENSOR_EVENT_SHAKE, obj, _dummy_free, NULL);
778 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_SHAKE));
779}
780
781static void
782doubletap_read_cb(unsigned long long timestamp, void *user_data)
783{
784 Eeze_Sensor_Obj *obj = user_data;
785
786 sensor_motion_doubletap_unset_cb(sensor_handle);
787
788 if (obj == NULL)
789 {
790 ERR("No matching sensor object given.");
791 return;
792 }
793 /* We have to set this ourselves because we don't get it for this type */
794 obj->accuracy = -1;
795 obj->timestamp = clock_convert(timestamp);
796 ecore_event_add(EEZE_SENSOR_EVENT_DOUBLETAP, obj, _dummy_free, NULL);
797 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_DOUBLETAP));
798}
799
800static void
801panning_read_cb(unsigned long long timestamp, int x, int y, void *user_data)
802{
803 Eeze_Sensor_Obj *obj = user_data;
804
805 sensor_motion_panning_unset_cb(sensor_handle);
806
807 if (obj == NULL)
808 {
809 ERR("No matching sensor object given.");
810 return;
811 }
812 /* We have to set this ourselves because we don't get it for this type */
813 obj->accuracy = -1;
814 obj->data[0] = x;
815 obj->data[1] = y;
816 obj->timestamp = clock_convert(timestamp);
817 ecore_event_add(EEZE_SENSOR_EVENT_PANNING, obj, _dummy_free, NULL);
818 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_PANNING));
819}
820
821static void
822panning_browse_read_cb(unsigned long long timestamp, int x, int y, void *user_data)
823{
824 Eeze_Sensor_Obj *obj = user_data;
825
826 sensor_motion_panning_browse_unset_cb(sensor_handle);
827
828 if (obj == NULL)
829 {
830 ERR("No matching sensor object given.");
831 return;
832 }
833 /* We have to set this ourselves because we don't get it for this type */
834 obj->accuracy = -1;
835 obj->data[0] = x;
836 obj->data[1] = y;
837 obj->timestamp = clock_convert(timestamp);
838 ecore_event_add(EEZE_SENSOR_EVENT_PANNING_BROWSE, obj, _dummy_free, NULL);
839 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_PANNING_BROWSE));
840}
841
842static void
843tilt_read_cb(unsigned long long timestamp, int x, int y, void *user_data)
844{
845 Eeze_Sensor_Obj *obj = user_data;
846
847 sensor_motion_tilt_unset_cb(sensor_handle);
848
849 if (obj == NULL)
850 {
851 ERR("No matching sensor object given.");
852 return;
853 }
854 /* We have to set this ourselves because we don't get it for this type */
855 obj->accuracy = -1;
856 obj->data[0] = x;
857 obj->data[1] = y;
858 obj->timestamp = clock_convert(timestamp);
859 ecore_event_add(EEZE_SENSOR_EVENT_TILT, obj, _dummy_free, NULL);
860 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_TILT));
861}
862
863static void
864facedown_read_cb(unsigned long long timestamp, void *user_data)
865{
866 Eeze_Sensor_Obj *obj = user_data;
867
868 sensor_motion_facedown_unset_cb(sensor_handle);
869
870 if (obj == NULL)
871 {
872 ERR("No matching sensor object given.");
873 return;
874 }
875 /* We have to set this ourselves because we don't get it for this type */
876 obj->accuracy = -1;
877 obj->timestamp = clock_convert(timestamp);
878 ecore_event_add(EEZE_SENSOR_EVENT_FACEDOWN, obj, _dummy_free, NULL);
879 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_FACEDOWN));
880}
881
882static void
883directcall_read_cb(unsigned long long timestamp, void *user_data)
884{
885 Eeze_Sensor_Obj *obj = user_data;
886
887 sensor_motion_directcall_unset_cb(sensor_handle);
888
889 if (obj == NULL)
890 {
891 ERR("No matching sensor object given.");
892 return;
893 }
894 /* We have to set this ourselves because we don't get it for this type */
895 obj->accuracy = -1;
896 obj->timestamp = clock_convert(timestamp);
897 ecore_event_add(EEZE_SENSOR_EVENT_DIRECT_CALL, obj, _dummy_free, NULL);
898 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_DIRECT_CALL));
899}
900
901static void
902smart_alert_read_cb(unsigned long long timestamp, void *user_data)
903{
904 Eeze_Sensor_Obj *obj = user_data;
905
906 sensor_motion_smart_alert_unset_cb(sensor_handle);
907
908 if (obj == NULL)
909 {
910 ERR("No matching sensor object given.");
911 return;
912 }
913 /* We have to set this ourselves because we don't get it for this type */
914 obj->accuracy = -1;
915 obj->timestamp = clock_convert(timestamp);
916 ecore_event_add(EEZE_SENSOR_EVENT_SMART_ALERT, obj, _dummy_free, NULL);
917 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_SMART_ALERT));
918}
919
920static void
921no_move_read_cb(unsigned long long timestamp, void *user_data)
922{
923 Eeze_Sensor_Obj *obj = user_data;
924
925 sensor_motion_no_move_unset_cb(sensor_handle);
926
927 if (obj == NULL)
928 {
929 ERR("No matching sensor object given.");
930 return;
931 }
932 /* We have to set this ourselves because we don't get it for this type */
933 obj->accuracy = -1;
934 obj->timestamp = clock_convert(timestamp);
935 ecore_event_add(EEZE_SENSOR_EVENT_NO_MOVE, obj, _dummy_free, NULL);
936 sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_NO_MOVE));
937}
938
939/* Synchronous read function for sensor data. It uses the blocking calls to read
940 * out the data and returns after it finishes the readout. Be aware that this
941 * might take quite some time depending on the sensor and how it is connected to
942 * the system. Normally it is better to use the asynchronous reading functions.
943 */
944static Eina_Bool
945eeze_sensor_tizen_read(Eeze_Sensor_Obj *obj)
946{
947 sensor_data_accuracy_e accuracy;
948 float x, y, z;
949 float azimuth, pitch, roll, lux, distance, yaw;
950 bool supported;
951 sensor_type_e type;
952
953 type = eeze_to_tizen(obj->type);
954
955 /* Don't attempt to do anything if the sensor is not available on the system
956 * we are running on.
957 */
958 sensor_is_supported(type, &supported);
959 if (!supported)
960 {
961 ERR("Sensor type %d not available on this device.", type);
962 return EINA_FALSE;
963 }
964
965 sensor_start(sensor_handle, type);
966
967 switch (type)
968 {
969 case SENSOR_ACCELEROMETER:
970 sensor_accelerometer_read_data(sensor_handle, &accuracy, &x, &y, &z);
971 obj->accuracy = accuracy;
972 obj->data[0] = x;
973 obj->data[1] = y;
974 obj->data[2] = z;
975 obj->timestamp = ecore_time_get();
976 break;
977
978 case SENSOR_GRAVITY:
979 sensor_gravity_read_data(sensor_handle, &accuracy, &x, &y, &z);
980 obj->accuracy = accuracy;
981 obj->data[0] = x;
982 obj->data[1] = y;
983 obj->data[2] = z;
984 obj->timestamp = ecore_time_get();
985 break;
986
987 case SENSOR_LINEAR_ACCELERATION:
988 sensor_linear_acceleration_read_data(sensor_handle, &accuracy, &x, &y, &z);
989 obj->accuracy = accuracy;
990 obj->data[0] = x;
991 obj->data[1] = y;
992 obj->data[2] = z;
993 obj->timestamp = ecore_time_get();
994 break;
995
996 case SENSOR_DEVICE_ORIENTATION:
997 sensor_device_orientation_read_data(sensor_handle, &accuracy, &yaw, &pitch, &roll);
998 obj->accuracy = accuracy;
999 obj->data[0] = yaw;
1000 obj->data[1] = pitch;
1001 obj->data[2] = roll;
1002 obj->timestamp = ecore_time_get();
1003 break;
1004
1005 case SENSOR_MAGNETIC:
1006 sensor_magnetic_read_data(sensor_handle, &accuracy, &x, &y, &z);
1007 obj->accuracy = accuracy;
1008 obj->data[0] = x;
1009 obj->data[1] = y;
1010 obj->data[2] = z;
1011 obj->timestamp = ecore_time_get();
1012 break;
1013
1014 case SENSOR_ORIENTATION:
1015 sensor_orientation_read_data(sensor_handle, &accuracy, &azimuth, &pitch, &roll);
1016 obj->accuracy = accuracy;
1017 obj->data[0] = azimuth;
1018 obj->data[1] = pitch;
1019 obj->data[2] = roll;
1020 obj->timestamp = ecore_time_get();
1021 break;
1022
1023 case SENSOR_GYROSCOPE:
1024 sensor_gyroscope_read_data(sensor_handle, &accuracy, &x, &y, &z);
1025 obj->accuracy = accuracy;
1026 obj->data[0] = x;
1027 obj->data[1] = y;
1028 obj->data[2] = z;
1029 obj->timestamp = ecore_time_get();
1030 break;
1031
1032 case SENSOR_LIGHT:
1033 sensor_light_read_data(sensor_handle, &lux);
1034 /* As we do not get any accuracy value from the system we go with -1 */
1035 obj->accuracy = -1;
1036 obj->data[0] = lux;
1037 obj->timestamp = ecore_time_get();
1038 break;
1039
1040 case SENSOR_PROXIMITY:
1041 sensor_proximity_read_data(sensor_handle, &distance);
1042 /* As we do not get any accuracy value from the system we go with -1 */
1043 obj->accuracy = -1;
1044 obj->data[0] = distance;
1045 obj->timestamp = ecore_time_get();
1046 break;
1047
1048 default:
1049 ERR("Not possible to read from this sensor type.");
1050 return EINA_FALSE;
1051 }
1052
1053 sensor_stop(sensor_handle, type);
1054 return EINA_TRUE;
1055}
1056
1057// FIXME ho to handle this without explicit callback setting
1058#if 0
1059static Eina_Bool
1060eeze_sensor_tizen_cb_set(Eeze_Sensor *handle, Eeze_Sensor_Type sensor_type, void *cb_function, void *user_data)
1061{
1062 sensor_type_e type;
1063
1064 type = eeze_to_tizen(sensor_type);
1065
1066 handle->cb_function = cb_function;
1067
1068 sensor_start(sensor_handle, type);
1069
1070 switch (type)
1071 {
1072 case SENSOR_ACCELEROMETER:
1073 sensor_accelerometer_set_cb(sensor_handle, 0, accelerometer_cb, handle);
1074 break;
1075
1076 case SENSOR_GRAVITY:
1077 sensor_gravity_set_cb(sensor_handle, 0, gravity_cb, handle);
1078 break;
1079
1080 case SENSOR_LINEAR_ACCELERATION:
1081 sensor_linear_acceleration_set_cb(sensor_handle, 0, linear_acceleration_cb, handle);
1082 break;
1083
1084 case SENSOR_DEVICE_ORIENTATION:
1085 sensor_device_orientation_set_cb(sensor_handle, 0, device_orientation_cb, handle);
1086 break;
1087
1088 case SENSOR_MAGNETIC:
1089 sensor_magnetic_set_cb(sensor_handle, 0, magnetic_cb, handle);
1090 break;
1091
1092 case SENSOR_ORIENTATION:
1093 sensor_orientation_set_cb(sensor_handle, 0, orientation_cb, handle);
1094 break;
1095
1096 case SENSOR_GYROSCOPE:
1097 sensor_gyroscope_set_cb(sensor_handle, 0, gyroscope_cb, handle);
1098 break;
1099
1100 case SENSOR_LIGHT:
1101 sensor_light_set_cb(sensor_handle, 0, light_cb, handle);
1102 break;
1103
1104 case SENSOR_PROXIMITY:
1105 sensor_proximity_set_cb(sensor_handle, 0, proximity_cb, handle);
1106 break;
1107
1108 case SENSOR_MOTION_SNAP:
1109 sensor_motion_snap_set_cb(sensor_handle, snap_cb, handle);
1110 break;
1111
1112 case SENSOR_MOTION_SHAKE:
1113 sensor_motion_shake_set_cb(sensor_handle, shake_cb, handle);
1114 break;
1115
1116 case SENSOR_MOTION_DOUBLETAP:
1117 sensor_motion_doubletap_set_cb(sensor_handle, doubletap_cb, handle);
1118 break;
1119
1120 case SENSOR_MOTION_PANNING:
1121 sensor_motion_panning_set_cb(sensor_handle, panning_cb, handle);
1122 break;
1123
1124 case SENSOR_MOTION_PANNING_BROWSE:
1125 sensor_motion_panning_browse_set_cb(sensor_handle, panning_browse_cb, handle);
1126 break;
1127
1128 case SENSOR_MOTION_TILT:
1129 sensor_motion_tilt_set_cb(sensor_handle, tilt_cb, handle);
1130 break;
1131
1132 case SENSOR_MOTION_FACEDOWN:
1133 sensor_motion_facedown_set_cb(sensor_handle, facedown_cb, handle);
1134 break;
1135
1136 case SENSOR_MOTION_DIRECTCALL:
1137 sensor_motion_directcall_set_cb(sensor_handle, directcall_cb, handle);
1138 break;
1139
1140 case SENSOR_MOTION_SMART_ALERT:
1141 sensor_motion_smart_alert_set_cb(sensor_handle, smart_alert_cb, handle);
1142 break;
1143
1144 case SENSOR_MOTION_NO_MOVE:
1145 sensor_motion_no_move_set_cb(sensor_handle, no_move_cb, handle);
1146 break;
1147
1148 default:
1149 ERR("Not possible to set a callback for this sensor type.");
1150 return EINA_FALSE;
1151 }
1152 return EINA_TRUE;
1153}
1154#endif
1155
1156/* For the asynchronous reads we only start the sensor her and trigger the
1157 * readout. The callbacks above are actually taking care about putting the data
1158 * into the matching sensor objects and informing all subscribers with an ecore
1159 * event. The public API function does actually return right away with the cached
1160 * data. This is handled in the core and not in the different modules though.
1161 */
1162static Eina_Bool
1163eeze_sensor_tizen_async_read(Eeze_Sensor_Obj *obj, void *user_data)
1164{
1165 sensor_type_e type;
1166
1167 if (user_data)
1168 obj->user_data = user_data;
1169
1170 type = eeze_to_tizen(obj->type);
1171
1172 sensor_start(sensor_handle, type);
1173
1174 switch (type)
1175 {
1176 case SENSOR_ACCELEROMETER:
1177 sensor_accelerometer_set_cb(sensor_handle, 0, accelerometer_read_cb, obj);
1178 break;
1179
1180 case SENSOR_GRAVITY:
1181 sensor_gravity_set_cb(sensor_handle, 0, gravity_read_cb, obj);
1182 break;
1183
1184 case SENSOR_LINEAR_ACCELERATION:
1185 sensor_linear_acceleration_set_cb(sensor_handle, 0, linear_acceleration_read_cb, obj);
1186 break;
1187
1188 case SENSOR_DEVICE_ORIENTATION:
1189 sensor_device_orientation_set_cb(sensor_handle, 0, device_orientation_read_cb, obj);
1190 break;
1191
1192 case SENSOR_MAGNETIC:
1193 sensor_magnetic_set_cb(sensor_handle, 0, magnetic_read_cb, obj);
1194 break;
1195
1196 case SENSOR_ORIENTATION:
1197 sensor_orientation_set_cb(sensor_handle, 0, orientation_read_cb, obj);
1198 break;
1199
1200 case SENSOR_GYROSCOPE:
1201 sensor_gyroscope_set_cb(sensor_handle, 0, gyroscope_read_cb, obj);
1202 break;
1203
1204 case SENSOR_LIGHT:
1205 sensor_light_set_cb(sensor_handle, 0, light_read_cb, obj);
1206 break;
1207
1208 case SENSOR_PROXIMITY:
1209 sensor_proximity_set_cb(sensor_handle, 0, proximity_read_cb, obj);
1210 break;
1211
1212 case SENSOR_MOTION_SNAP:
1213 sensor_motion_snap_set_cb(sensor_handle, snap_read_cb, obj);
1214 break;
1215
1216 case SENSOR_MOTION_SHAKE:
1217 sensor_motion_shake_set_cb(sensor_handle, shake_read_cb, obj);
1218 break;
1219
1220 case SENSOR_MOTION_DOUBLETAP:
1221 sensor_motion_doubletap_set_cb(sensor_handle, doubletap_read_cb, obj);
1222 break;
1223
1224 case SENSOR_MOTION_PANNING:
1225 sensor_motion_panning_set_cb(sensor_handle, panning_read_cb, obj);
1226 break;
1227
1228 case SENSOR_MOTION_PANNING_BROWSE:
1229 sensor_motion_panning_browse_set_cb(sensor_handle, panning_browse_read_cb, obj);
1230 break;
1231
1232 case SENSOR_MOTION_TILT:
1233 sensor_motion_tilt_set_cb(sensor_handle, tilt_read_cb, obj);
1234 break;
1235
1236 case SENSOR_MOTION_FACEDOWN:
1237 sensor_motion_facedown_set_cb(sensor_handle, facedown_read_cb, obj);
1238 break;
1239
1240 case SENSOR_MOTION_DIRECTCALL:
1241 sensor_motion_directcall_set_cb(sensor_handle, directcall_read_cb, obj);
1242 break;
1243
1244 case SENSOR_MOTION_SMART_ALERT:
1245 sensor_motion_smart_alert_set_cb(sensor_handle, smart_alert_read_cb, obj);
1246 break;
1247
1248 case SENSOR_MOTION_NO_MOVE:
1249 sensor_motion_no_move_set_cb(sensor_handle, no_move_read_cb, obj);
1250 break;
1251
1252 default:
1253 ERR("Not possible to set a callback for this sensor type.");
1254 return EINA_FALSE;
1255 }
1256 return EINA_TRUE;
1257}
1258
1259/* Go through all potential Tizen sensor and test if they are available on the
1260 * system we are running on. If yes, create a matching sensor object and put it
1261 * the list of available sensor for the core.
1262 */
1263static void
1264eeze_sensor_tizen_sensors_find(void)
1265{
1266 sensor_type_e type;
1267 bool supported = 0;
1268
1269 for (type = SENSOR_ACCELEROMETER; type <= SENSOR_LAST; type++)
1270 {
1271 sensor_is_supported(type, &supported);
1272 if (supported)
1273 {
1274 Eeze_Sensor_Obj *obj = calloc(1, sizeof(Eeze_Sensor_Obj));
1275 obj->type = tizen_to_eeze(type);
1276 esensor_module->sensor_list = eina_list_append(esensor_module->sensor_list, obj);
1277 }
1278 }
1279}
1280
1281/* Cleanup when getting the shutdown callback from core */
1282static Eina_Bool
1283eeze_sensor_tizen_shutdown(void)
1284{
1285 Eeze_Sensor_Obj *obj;
1286
1287 EINA_LIST_FREE(esensor_module->sensor_list, obj)
1288 free(obj);
1289
1290 sensor_stop(sensor_handle, SENSOR_MOTION_FACEDOWN);
1291 sensor_stop(sensor_handle, SENSOR_MOTION_DOUBLETAP);
1292 if (sensor_destroy(sensor_handle) != 0)
1293 {
1294 ERR("Failing to destroy sensor handle.");
1295 return EINA_FALSE;
1296 }
1297 return EINA_TRUE;
1298}
1299
1300/* Callback from core once we registered as a module. Create the Tizen sensor
1301 * handle and find all available sensors.
1302 */
1303static Eina_Bool
1304eeze_sensor_tizen_init(void)
1305{
1306
1307 if (sensor_create(&sensor_handle) != 0)
1308 {
1309 ERR("Failing to create sensor handle.");
1310 return EINA_FALSE;
1311 }
1312
1313 eeze_sensor_tizen_sensors_find();
1314
1315 /* FIXME add other motion events in here */
1316 sensor_start(sensor_handle, SENSOR_MOTION_FACEDOWN);
1317 sensor_start(sensor_handle, SENSOR_MOTION_DOUBLETAP);
1318 sensor_motion_doubletap_set_cb(sensor_handle, doubletap_cb,
1319 eeze_sensor_obj_get(EEZE_SENSOR_TYPE_MOTION_DOUBLETAP));
1320 sensor_motion_facedown_set_cb(sensor_handle, facedown_cb,
1321 eeze_sensor_obj_get(EEZE_SENSOR_TYPE_MOTION_FACEDOWN));
1322
1323 return EINA_TRUE;
1324}
1325
1326/* This function gets called when the module is loaded from the disk. Its the
1327 * entry point to anything in this module. After setting ourself up we register
1328 * into the core of eeze sensor to make our functionality available.
1329 */
1330static Eina_Bool
1331sensor_tizen_init(void)
1332{
1333
1334 _eeze_sensor_tizen_log_dom = eina_log_domain_register("eeze_sensor_tizen", EINA_COLOR_BLUE);
1335 if (_eeze_sensor_tizen_log_dom < 0)
1336 {
1337 EINA_LOG_ERR("Could not register 'eeze_sensor_tizen' log domain.");
1338 return EINA_FALSE;
1339 }
1340
1341 /* Check to avoid multi-init */
1342 if (esensor_module) return EINA_FALSE;
1343
1344 /* Set module function pointer to allow calls into the module */
1345 esensor_module = calloc(1, sizeof(Eeze_Sensor_Module));
1346 if (!esensor_module) return EINA_FALSE;
1347
1348 esensor_module->init = eeze_sensor_tizen_init;
1349 esensor_module->shutdown = eeze_sensor_tizen_shutdown;
1350 esensor_module->read = eeze_sensor_tizen_read;
1351 esensor_module->async_read = eeze_sensor_tizen_async_read;
1352
1353 if (!eeze_sensor_module_register("tizen", esensor_module))
1354 {
1355 ERR("Failed to register tizen module");
1356 return EINA_FALSE;
1357 }
1358 return EINA_TRUE;
1359}
1360
1361/* Cleanup when the module gets unloaded. Unregister ourself from the core to
1362 * avoid calls into a not loaded module.
1363 */
1364static void
1365sensor_tizen_shutdown(void)
1366{
1367 Eeze_Sensor_Obj *sens;
1368
1369 eeze_sensor_module_unregister("tizen");
1370 EINA_LIST_FREE(esensor_module->sensor_list, sens)
1371 free(sens);
1372
1373 eina_log_domain_unregister(_eeze_sensor_tizen_log_dom);
1374
1375 free(esensor_module);
1376 esensor_module = NULL;
1377
1378 _eeze_sensor_tizen_log_dom = -1;
1379}
1380
1381EINA_MODULE_INIT(sensor_tizen_init);
1382EINA_MODULE_SHUTDOWN(sensor_tizen_shutdown);
1383