7 static GMainLoop *mainloop;
10 static void sig_quit(int signo)
14 g_main_loop_quit(mainloop);
17 if(haptic_deinitialize() == HAPTIC_ERROR_NONE){
18 printf("haptic device closed\n");
20 printf("haptic_close fail\n");
24 static gboolean play_ptn(gpointer data)
26 haptic_vibration_iter_s ptn[] = {
27 {0, HAPTIC_LEVEL_5, 1000},
28 {0, HAPTIC_LEVEL_1, 1000},
29 {0, HAPTIC_LEVEL_1, 1000},
30 {0, HAPTIC_LEVEL_5, 1000},
31 {0, HAPTIC_LEVEL_1, 1000},
32 {0, HAPTIC_LEVEL_1, 1000},
33 {0, HAPTIC_LEVEL_5, 1000},
36 if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
37 printf("haptic play fail\n");
39 printf("haptic play success\n");
45 static gboolean stop_play(gpointer data)
50 printf("-- stop!! [%d]\n", id);
51 err = haptic_stop_pattern(id);
53 printf("-- error!! when stop play!!\n");
58 static gboolean stop_and_play(gpointer data)
63 printf("-- stop!! [%d]\n", id);
64 err = haptic_stop_pattern(id);
66 printf("-- error!! when stop play!!\n");
69 // g_timeout_add(6000, play_ptn, NULL);
70 g_timeout_add(10000, play_ptn, NULL);
75 static gboolean stop_device(gpointer data)
77 haptic_stop_device(0);
82 int main(int argc, char *argv[])
84 haptic_vibration_iter_s ptn[] = {
85 {0, HAPTIC_LEVEL_1, 3000},
86 {0, HAPTIC_LEVEL_0, 10},
87 {0, HAPTIC_LEVEL_3, 2000},
88 {0, HAPTIC_LEVEL_0, 10},
89 {0, HAPTIC_LEVEL_5, 1000},
90 {0, HAPTIC_LEVEL_0, 10},
91 {0, HAPTIC_LEVEL_2, 3000},
94 signal(SIGINT, sig_quit);
95 signal(SIGTERM, sig_quit);
96 signal(SIGQUIT, sig_quit);
98 mainloop = g_main_loop_new(NULL, FALSE);
100 if(haptic_initialize() == HAPTIC_ERROR_NONE){
101 printf("haptic device opened\n");
103 printf("haptic_open fail\n");
105 if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
106 printf("haptic play fail\n");
108 printf("haptic play success\n");
110 if(haptic_deinitialize() == HAPTIC_ERROR_NONE){
111 printf("haptic device closed\n");
113 printf("haptic_close fail\n");
115 if(haptic_initialize() == HAPTIC_ERROR_NONE){
116 printf("haptic device opened\n");
118 printf("haptic_open fail\n");
120 if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
121 printf("haptic play fail\n");
123 printf("haptic play success\n");
125 if(haptic_deinitialize() == HAPTIC_ERROR_NONE){
126 printf("haptic device closed\n");
128 printf("haptic_close fail\n");
132 g_main_loop_run(mainloop);
133 g_main_loop_unref(mainloop);