3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
23 #include <sys/types.h>
27 #include <haptic_plugin_intf.h>
28 #include "haptic_module_log.h"
31 #define EXTAPI __attribute__ ((visibility("default")))
34 #define DEFAULT_MOTOR_COUNT 1
35 #define DEFAULT_DEVICE_HANDLE 0x01
36 #define DEFAULT_EFFECT_HANDLE 0x02
38 int haptic_internal_get_device_count(int *count)
41 return HAPTIC_MODULE_INVALID_ARGUMENT;
43 *count = DEFAULT_MOTOR_COUNT;
44 return HAPTIC_MODULE_ERROR_NONE;
47 int haptic_internal_open_device(int device_index, int *device_handle)
49 if (device_index < HAPTIC_MODULE_DEVICE_0 || device_index > HAPTIC_MODULE_DEVICE_ALL)
50 return HAPTIC_MODULE_INVALID_ARGUMENT;
52 if (device_handle == NULL)
53 return HAPTIC_MODULE_INVALID_ARGUMENT;
55 *device_handle = DEFAULT_DEVICE_HANDLE;
56 return HAPTIC_MODULE_ERROR_NONE;
59 int haptic_internal_close_device(int device_handle)
61 if (device_handle < 0)
62 return HAPTIC_MODULE_INVALID_ARGUMENT;
64 return HAPTIC_MODULE_ERROR_NONE;
67 int haptic_internal_vibrate_monotone(int device_handle, int duration, int feedback, int priority, int *effect_handle)
69 if (device_handle < 0)
70 return HAPTIC_MODULE_INVALID_ARGUMENT;
73 return HAPTIC_MODULE_INVALID_ARGUMENT;
75 if (feedback < HAPTIC_MODULE_FEEDBACK_MIN || feedback > HAPTIC_MODULE_FEEDBACK_MAX)
76 return HAPTIC_MODULE_INVALID_ARGUMENT;
78 if (priority < HAPTIC_MODULE_PRIORITY_MIN || priority > HAPTIC_MODULE_PRIORITY_HIGH)
79 return HAPTIC_MODULE_INVALID_ARGUMENT;
81 if (effect_handle == NULL)
82 return HAPTIC_MODULE_INVALID_ARGUMENT;
84 if (feedback == HAPTIC_MODULE_FEEDBACK_MIN)
85 return HAPTIC_MODULE_ERROR_NONE;
87 MODULE_LOG("call %s function", __func__);
89 *effect_handle = DEFAULT_EFFECT_HANDLE;
90 return HAPTIC_MODULE_ERROR_NONE;
93 int haptic_internal_vibrate_file(int device_handle, const char *file_path, int iteration, int feedback, int priority, int *effect_handle)
95 if (device_handle < 0)
96 return HAPTIC_MODULE_INVALID_ARGUMENT;
98 if (file_path == NULL)
99 return HAPTIC_MODULE_INVALID_ARGUMENT;
101 if (iteration < HAPTIC_MODULE_ITERATION_ONCE || iteration > HAPTIC_MODULE_ITERATION_INFINITE)
102 return HAPTIC_MODULE_INVALID_ARGUMENT;
104 if (feedback < HAPTIC_MODULE_FEEDBACK_MIN || feedback > HAPTIC_MODULE_FEEDBACK_MAX)
105 return HAPTIC_MODULE_INVALID_ARGUMENT;
107 if (priority < HAPTIC_MODULE_PRIORITY_MIN || priority > HAPTIC_MODULE_PRIORITY_HIGH)
108 return HAPTIC_MODULE_INVALID_ARGUMENT;
110 if (effect_handle == NULL)
111 return HAPTIC_MODULE_INVALID_ARGUMENT;
113 if (feedback == HAPTIC_MODULE_FEEDBACK_MIN)
114 return HAPTIC_MODULE_ERROR_NONE;
116 MODULE_LOG("call %s function", __func__);
118 *effect_handle = DEFAULT_EFFECT_HANDLE;
119 return HAPTIC_MODULE_ERROR_NONE;
122 int haptic_internal_vibrate_buffer(int device_handle, const unsigned char *vibe_buffer, int iteration, int feedback, int priority, int *effect_handle)
124 if (device_handle < 0)
125 return HAPTIC_MODULE_INVALID_ARGUMENT;
127 if (vibe_buffer == NULL)
128 return HAPTIC_MODULE_INVALID_ARGUMENT;
130 if (iteration < HAPTIC_MODULE_ITERATION_ONCE || iteration > HAPTIC_MODULE_ITERATION_INFINITE)
131 return HAPTIC_MODULE_INVALID_ARGUMENT;
133 if (feedback < HAPTIC_MODULE_FEEDBACK_MIN || feedback > HAPTIC_MODULE_FEEDBACK_MAX)
134 return HAPTIC_MODULE_INVALID_ARGUMENT;
136 if (priority < HAPTIC_MODULE_PRIORITY_MIN || priority > HAPTIC_MODULE_PRIORITY_HIGH)
137 return HAPTIC_MODULE_INVALID_ARGUMENT;
139 if (effect_handle == NULL)
140 return HAPTIC_MODULE_INVALID_ARGUMENT;
142 if (feedback == HAPTIC_MODULE_FEEDBACK_MIN)
143 return HAPTIC_MODULE_ERROR_NONE;
145 MODULE_LOG("call %s function", __func__);
147 *effect_handle = DEFAULT_EFFECT_HANDLE;
148 return HAPTIC_MODULE_ERROR_NONE;
151 int haptic_internal_stop_effect(int device_handle, int effect_handle)
153 if (device_handle < 0)
154 return HAPTIC_MODULE_INVALID_ARGUMENT;
156 if (effect_handle < 0)
157 return HAPTIC_MODULE_INVALID_ARGUMENT;
159 MODULE_LOG("call %s function", __func__);
161 return HAPTIC_MODULE_ERROR_NONE;
164 int haptic_internal_stop_all_effects(int device_handle)
166 if (device_handle < 0)
167 return HAPTIC_MODULE_INVALID_ARGUMENT;
169 MODULE_LOG("call %s function", __func__);
171 return HAPTIC_MODULE_ERROR_NONE;
174 int haptic_internal_pause_effect(int device_handle, int effect_handle)
176 if (device_handle < 0)
177 return HAPTIC_MODULE_INVALID_ARGUMENT;
179 if (effect_handle < 0)
180 return HAPTIC_MODULE_INVALID_ARGUMENT;
182 MODULE_LOG("call %s function", __func__);
184 return HAPTIC_MODULE_ERROR_NONE;
187 int haptic_internal_resume_effect(int device_handle, int effect_handle)
189 if (device_handle < 0)
190 return HAPTIC_MODULE_INVALID_ARGUMENT;
192 if (effect_handle < 0)
193 return HAPTIC_MODULE_INVALID_ARGUMENT;
195 MODULE_LOG("call %s function", __func__);
197 return HAPTIC_MODULE_ERROR_NONE;
200 int haptic_internal_get_effect_state(int device_handle, int effect_handle, int *effect_state)
202 if (device_handle < 0)
203 return HAPTIC_MODULE_INVALID_ARGUMENT;
205 if (effect_handle < 0)
206 return HAPTIC_MODULE_INVALID_ARGUMENT;
208 if (effect_state == NULL)
209 return HAPTIC_MODULE_INVALID_ARGUMENT;
211 MODULE_LOG("call %s function", __func__);
213 return HAPTIC_MODULE_ERROR_NONE;
216 int haptic_internal_create_effect(const unsigned char *vibe_buffer, int max_bufsize, haptic_module_effect_element *elem_arr, int max_elemcnt)
218 if (vibe_buffer == NULL)
219 return HAPTIC_MODULE_INVALID_ARGUMENT;
222 return HAPTIC_MODULE_INVALID_ARGUMENT;
224 if (elem_arr == NULL)
225 return HAPTIC_MODULE_INVALID_ARGUMENT;
228 return HAPTIC_MODULE_INVALID_ARGUMENT;
230 MODULE_LOG("call %s function", __func__);
232 return HAPTIC_MODULE_ERROR_NONE;
235 int haptic_internal_save_effect(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path)
237 if (vibe_buffer == NULL)
238 return HAPTIC_MODULE_INVALID_ARGUMENT;
241 return HAPTIC_MODULE_INVALID_ARGUMENT;
243 if (file_path == NULL)
244 return HAPTIC_MODULE_INVALID_ARGUMENT;
246 MODULE_LOG("call %s function", __func__);
248 return HAPTIC_MODULE_ERROR_NONE;
251 int haptic_internal_get_file_duration(int device_handle, const char *file_path, int *file_duration)
253 if (device_handle < 0)
254 return HAPTIC_MODULE_INVALID_ARGUMENT;
256 if (file_path == NULL)
257 return HAPTIC_MODULE_INVALID_ARGUMENT;
259 if (file_duration == NULL)
260 return HAPTIC_MODULE_INVALID_ARGUMENT;
262 MODULE_LOG("call %s function", __func__);
264 return HAPTIC_MODULE_ERROR_NONE;
267 int haptic_internal_get_buffer_duration(int device_handle, const unsigned char *vibe_buffer, int *buffer_duration)
269 if (device_handle < 0)
270 return HAPTIC_MODULE_INVALID_ARGUMENT;
272 if (vibe_buffer == NULL)
273 return HAPTIC_MODULE_INVALID_ARGUMENT;
275 if (buffer_duration == NULL)
276 return HAPTIC_MODULE_INVALID_ARGUMENT;
278 MODULE_LOG("call %s function", __func__);
280 return HAPTIC_MODULE_ERROR_NONE;
283 int haptic_internal_convert_binary (void)
285 MODULE_ERROR("This device is not supported this function(%s)", __func__);
286 return HAPTIC_MODULE_NOT_SUPPORTED;
289 static haptic_plugin_interface haptic_plugin_emul;
292 const haptic_plugin_interface *get_haptic_plugin_interface()
294 haptic_plugin_emul.haptic_internal_get_device_count = &haptic_internal_get_device_count;
295 haptic_plugin_emul.haptic_internal_open_device = &haptic_internal_open_device;
296 haptic_plugin_emul.haptic_internal_close_device = &haptic_internal_close_device;
297 haptic_plugin_emul.haptic_internal_vibrate_monotone = &haptic_internal_vibrate_monotone;
298 haptic_plugin_emul.haptic_internal_vibrate_file = &haptic_internal_vibrate_file;
299 haptic_plugin_emul.haptic_internal_vibrate_buffer = &haptic_internal_vibrate_buffer;
300 haptic_plugin_emul.haptic_internal_stop_effect = &haptic_internal_stop_effect;
301 haptic_plugin_emul.haptic_internal_stop_all_effects = &haptic_internal_stop_all_effects;
302 haptic_plugin_emul.haptic_internal_pause_effect = &haptic_internal_pause_effect;
303 haptic_plugin_emul.haptic_internal_resume_effect = &haptic_internal_resume_effect;
304 haptic_plugin_emul.haptic_internal_get_effect_state = &haptic_internal_get_effect_state;
305 haptic_plugin_emul.haptic_internal_create_effect = &haptic_internal_create_effect;
306 haptic_plugin_emul.haptic_internal_save_effect = &haptic_internal_save_effect;
307 haptic_plugin_emul.haptic_internal_get_file_duration = &haptic_internal_get_file_duration;
308 haptic_plugin_emul.haptic_internal_get_buffer_duration = &haptic_internal_get_buffer_duration;
309 haptic_plugin_emul.haptic_internal_convert_binary = &haptic_internal_convert_binary;
311 return &haptic_plugin_emul;