Perform device vibration
Start vibration using haptic device for specified time and instensity level. Code contains also initizalization of vibrator, if you do not close connection you do not have to initialize it every time. Optionally in comments there are example of usage of stop vibration and close connection methods.
// PRIVILEGE needed to be set in tizen-manifest.xml:
// http://tizen.org/privilege/haptic
#include <dlog.h> // for logging purposes
#include <device/haptic.h>
static void
device_vibrate(int duration, int feedback) {
haptic_device_h haptic_handle;
haptic_effect_h effect_handle;
if(device_haptic_open(0, &haptic_handle) == DEVICE_ERROR_NONE) {
LOGI("Connection to vibrator established");
if(device_haptic_vibrate(haptic_handle, duration, feedback, &effect_handle) == DEVICE_ERROR_NONE) {
LOGI("Device vibrates!");
}
// To stop vibration which are being played use below code with proper handles
// if(device_haptic_stop(haptic_handle, effect_handle) == DEVICE_ERROR_NONE) {
// LOGI("Device vibration stopped");
// }
// When you decided not to use haptic anymore disconnect it
// if(device_haptic_close(haptic_handle) == DEVICE_ERROR_NONE) {
// LOGI("Vibrator disconnected");
// }
}
}