3 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * PROPRIETARY/CONFIDENTIAL
6 * This software is the confidential and proprietary information of SAMSUNG
7 * ELECTRONICS ("Confidential Information"). You agree and acknowledge that
8 * this software is owned by Samsung and you shall not disclose such
9 * Confidential Information and shall use it only in accordance with the terms
10 * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG
11 * make no representations or warranties about the suitability of the software,
12 * either express or implied, including but not limited to the implied
13 * warranties of merchantability, fitness for a particular purpose, or
14 * non-infringement. SAMSUNG shall not be liable for any damages suffered by
15 * licensee arising out of or related to this software.
25 static GMainLoop *mainloop;
28 static void sig_quit(int signo)
32 g_main_loop_quit(mainloop);
36 static gboolean play_ptn(gpointer data)
38 haptic_vibration_iter_s ptn[] = {
39 {0, HAPTIC_LEVEL_5, 1000},
40 {0, HAPTIC_LEVEL_1, 1000},
41 {0, HAPTIC_LEVEL_1, 1000},
42 {0, HAPTIC_LEVEL_5, 1000},
43 {0, HAPTIC_LEVEL_1, 1000},
44 {0, HAPTIC_LEVEL_1, 1000},
45 {0, HAPTIC_LEVEL_5, 1000},
48 if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
49 printf("haptic play fail\n");
51 printf("haptic play success\n");
57 static gboolean stop_play(gpointer data)
62 printf("-- stop!! [%d]\n", id);
63 err = haptic_stop_pattern(id);
65 printf("-- error!! when stop play!!\n");
70 static gboolean stop_and_play(gpointer data)
75 printf("-- stop!! [%d]\n", id);
76 err = haptic_stop_pattern(id);
78 printf("-- error!! when stop play!!\n");
81 // g_timeout_add(6000, play_ptn, NULL);
82 g_timeout_add(10000, play_ptn, NULL);
87 static gboolean stop_device(gpointer data)
89 haptic_stop_device(0);
94 int main(int argc, char *argv[])
96 haptic_vibration_iter_s ptn[] = {
97 {0, HAPTIC_LEVEL_1, 3000},
98 {0, HAPTIC_LEVEL_0, 10},
99 {0, HAPTIC_LEVEL_3, 2000},
100 {0, HAPTIC_LEVEL_0, 10},
101 {0, HAPTIC_LEVEL_5, 1000},
102 {0, HAPTIC_LEVEL_0, 10},
103 {0, HAPTIC_LEVEL_2, 3000},
106 if(haptic_initialize() == HAPTIC_ERROR_NONE){
107 printf("haptic device opened\n");
109 printf("haptic_open fail\n");
112 signal(SIGINT, sig_quit);
113 signal(SIGTERM, sig_quit);
114 signal(SIGQUIT, sig_quit);
116 mainloop = g_main_loop_new(NULL, FALSE);
118 if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
119 printf("haptic play fail\n");
121 printf("haptic play success\n");
123 g_timeout_add(4000, stop_play, (gpointer)ptn_id);
125 if(haptic_play_pattern(ptn, 7, 2, 0, &ptn_id) < 0){
126 printf("haptic play fail\n");
128 printf("haptic play success\n");
130 g_timeout_add(2000, stop_play, (gpointer)ptn_id);
132 if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){
133 printf("haptic play fail\n");
135 printf("haptic play success\n");
137 g_timeout_add(7000, stop_play, (gpointer)ptn_id);
139 if(haptic_play_pattern(ptn, 7, 3, 0, &ptn_id) < 0){
140 printf("haptic play fail\n");
142 printf("haptic play success\n");
144 g_timeout_add(10, stop_and_play, (gpointer)ptn_id);
147 g_timeout_add(4000, stop_device, NULL);
150 g_main_loop_run(mainloop);
151 g_main_loop_unref(mainloop);
153 if(haptic_deinitialize() == HAPTIC_ERROR_NONE){
154 printf("haptic device closed\n");
156 printf("haptic_close fail\n");