2 * Copyright (c) 2010 Samsung Electronics, Inc.
5 * This software is a confidential and proprietary information
6 * of Samsung Electronics, Inc. ("Confidential Information"). You
7 * shall not disclose such Confidential Information and shall use
8 * it only in accordance with the terms of the license agreement
9 * you entered into with Samsung Electronics.
11 #include "setting_control_haptic.h"
14 static struct _haptic_data h_data;
15 static Ecore_Timer * vibration_timer = NULL;
17 static haptic_device_h hnd_hpt;
21 int haptic_return = 0;
22 haptic_return = haptic_open(HAPTIC_DEVICE_0, &hnd_hpt);
23 if (haptic_return < 0) {
24 DBG("Setting - Failed haptic_open");
28 h_data.is_haptic_opened = 1;
35 return h_data.is_haptic_opened;
38 Eina_Bool __vibration_timeout(void *data)
40 if( _is_haptic_open() ) {
44 vibration_timer = NULL;
46 return ECORE_CALLBACK_CANCEL;
49 void _start_vibration(int level, int feedback_rate, char * res_path)
51 if( _is_haptic_open() ) {
60 err = haptic_get_file_duration(hnd_hpt, res_path, &duration);
63 DBG("Setting - haptic_get_file_duration() failed");
67 DBG("Setting - duration : %d", duration);
69 err = haptic_vibrate_file_with_detail(hnd_hpt, res_path,
70 HAPTIC_ITERATION_ONCE, feedback_rate, HAPTIC_PRIORITY_HIGH, NULL);
72 DBG("Setting - haptic_vibrate_file_with_detail() failed");
74 double real_duration = (double)(duration / 1000.0);
76 DBG("Setting - duration2 : %f", real_duration);
80 ecore_timer_del(vibration_timer);
81 vibration_timer = NULL;
83 vibration_timer = ecore_timer_add(real_duration, (Ecore_Task_Cb)__vibration_timeout, NULL);
89 int ret = haptic_close(hnd_hpt);
91 DBG("Setting - Failed haptic_deinitialize");
95 if( vibration_timer ) {
96 ecore_timer_del(vibration_timer);
97 vibration_timer = NULL;
100 h_data.is_haptic_opened = 0;