执行Tizen设备的振动代码
使用设备指定的时间和instensity水平开始震动。代码也包含振动器initizalization,如果你不关闭连接,您不必每次都进行初始化。可选的评论也有例如停振和密切的联系方式的使用。// 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");
// }
}
}
页:
[1]