1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/*
*
* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
* PROPRIETARY/CONFIDENTIAL
*
* This software is the confidential and proprietary information of SAMSUNG
* ELECTRONICS ("Confidential Information"). You agree and acknowledge that
* this software is owned by Samsung and you shall not disclose such
* Confidential Information and shall use it only in accordance with the terms
* of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG
* make no representations or warranties about the suitability of the software,
* either express or implied, including but not limited to the implied
* warranties of merchantability, fitness for a particular purpose, or
* non-infringement. SAMSUNG shall not be liable for any damages suffered by
* licensee arising out of or related to this software.
*
*/
#include <string.h>
#include <signal.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef WIDTH
# define WIDTH 480
#endif
#ifndef HEIGHT
# define HEIGHT 640
#endif
#include <Ecore_Evas.h>
#include <Ecore.h>
#include <Edje.h>
#include <feedback.h>
struct three_axis_s{
float x,y,z;
};
const float Alpha = 0.8;
struct three_axis_s gravitys = {0,0,0};
struct three_axis_s linear_accelation = {0,0,0};
static void
efl_resize_window(Ecore_Evas *ee) {
Evas_Coord w, h;
/* check how big the window is currently */
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
/* set the evas-object (edje) to the window size */
evas_object_resize(evas_object_top_get(ecore_evas_get(ee)), w, h);
}
void cb_debug_signal(void *data, Evas_Object *o, const char *emission, const char *source)
{
printf("------------ [%s / %s]\n", emission, source);
}
void cb_click_btn(void *data, Evas_Object *o, const char *emission, const char *source)
{
printf("------------ [%s / %s]\n", emission, source);
if (strncmp(source, "key_tap", 7) == 0){
feedback_react(FEEDBACK_PATTERN_TOUCH_TAP);
}else if (strncmp(source, "key_multi", 9) == 0){
feedback_react(FEEDBACK_PATTERN_TOUCH_MULTI_TAP);
}else if (strncmp(source, "key_hold", 8) == 0){
feedback_react(FEEDBACK_PATTERN_TOUCH_KEY);
}else if (strncmp(source, "key_txt", 7) == 0){
feedback_react(FEEDBACK_PATTERN_TOUCH_HOLD);
}else if (strncmp(source, "key_hw_hold", 11) == 0){
feedback_react(FEEDBACK_PATTERN_TOUCH_TAP);
}
}
int
main(int argc, char **argv){
ecore_evas_init();
Ecore_Evas* ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, WIDTH, HEIGHT);
// ecore_evas_rotation_with_resize_set(ee, 90);
ecore_evas_callback_resize_set(ee, efl_resize_window);
ecore_evas_title_set(ee, "feedback");
ecore_evas_borderless_set(ee, 0);
ecore_evas_shaped_set(ee, 0);
ecore_evas_show(ee);
Evas* evas = ecore_evas_get(ee);
edje_init();
feedback_initialize();
Evas_Object* edje = edje_object_add(evas);
if(!edje_object_file_set(edje, "./feedback.edj", "main")){
printf("Couldn't load the edje theme. It should be ./feedback.edj\n");
return 1;
}
{
Evas_Coord w, h;
evas_object_move(edje, 0, 0);
edje_object_signal_callback_add(edje, "DEBUG", "*", cb_debug_signal, edje);
edje_object_signal_callback_add(edje, "mouse,down,1", "key_*", cb_click_btn, edje);
edje_object_size_min_get(edje, &w, &h);
evas_object_resize(edje, w, h);
evas_object_show(edje);
ecore_evas_resize(ee, (int)w, (int)h);
ecore_evas_show(ee);
}
ecore_main_loop_begin();
edje_shutdown();
evas_shutdown();
feedback_deinitialize();
return 0;
}
|