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 #define TEST_IVT "/usr/share/immersion/01_Touch/touch_20ms_sharp.ivt"
27 static GMainLoop *mainloop;
29 static void sig_quit(int signo)
33 g_main_loop_quit(mainloop);
37 static char* error_msg(int err){
39 case HAPTIC_ERROR_NONE :
40 return "HAPTIC_ERROR_NONE";
41 case HAPTIC_ERROR_INVALID_PARAMETER :
42 return "HAPTIC_ERROR_INVALID_PARAMETER";
43 case HAPTIC_ERROR_NO_SUCH_FILE :
44 return "HAPTIC_ERROR_NO_SUCH_FILE";
45 case HAPTIC_ERROR_NOT_SUPPORTED_FORMAT :
46 return "HAPTIC_ERROR_NOT_SUPPORTED_FORMAT";
47 case HAPTIC_ERROR_NOT_INITIALIZED :
48 return "HAPTIC_ERROR_NOT_INITIALIZED";
49 case HAPTIC_ERROR_OPERATION_FAILED :
50 return "HAPTIC_ERROR_OPERATION_FAILED";
55 int main(int argc, char *argv[])
58 if(haptic_initialize() == HAPTIC_ERROR_NONE){
59 printf("haptic device opened\n");
61 printf("haptic_open fail\n");
64 signal(SIGINT, sig_quit);
65 signal(SIGTERM, sig_quit);
66 signal(SIGQUIT, sig_quit);
68 mainloop = g_main_loop_new(NULL, FALSE);
70 haptic_get_count(&count);
72 printf("count = %d\n", count);
74 for(i=0; i<=count;i++){
75 printf("play with device(%d)\n", i);
77 if((err = haptic_vibrate_monotone(count, 1000)) < 0){
78 printf("haptic play fail [%s]\n", error_msg(err));
80 printf("haptic play success\n");
83 if(haptic_stop_device(count) < 0){
84 printf("haptic play fail\n");
86 printf("haptic play success\n");
89 if(haptic_vibrate_file(count, TEST_IVT, 1, HAPTIC_LEVEL_AUTO) < 0){
90 printf("haptic play fail\n");
92 printf("haptic play success\n");
97 g_main_loop_run(mainloop);
98 g_main_loop_unref(mainloop);
100 if(haptic_deinitialize() == HAPTIC_ERROR_NONE){
101 printf("haptic device closed\n");
103 printf("haptic_close fail\n");