找回密码
 立即注册
查看: 3451|回复: 0

执行Tizen设备的振动代码

[复制链接]
发表于 2015-8-12 13:24:13 | 显示全部楼层 |阅读模式
使用设备指定的时间和instensity水平开始震动。代码也包含振动器initizalization,如果你不关闭连接,您不必每次都进行初始化。可选的评论也有例如停振和密切的联系方式的使用。
  1. //    PRIVILEGE needed to be set in tizen-manifest.xml:
  2. //    http://tizen.org/privilege/haptic

  3. #include <dlog.h> // for logging purposes
  4. #include <device/haptic.h>

  5. static void
  6. device_vibrate(int duration, int feedback) {
  7.         haptic_device_h haptic_handle;
  8.         haptic_effect_h effect_handle;

  9.         if(device_haptic_open(0, &haptic_handle) == DEVICE_ERROR_NONE) {

  10.                 LOGI("Connection to vibrator established");

  11.                 if(device_haptic_vibrate(haptic_handle, duration, feedback, &effect_handle) == DEVICE_ERROR_NONE) {
  12.                         LOGI("Device vibrates!");
  13.                 }

  14. //                To stop vibration which are being played use below code with proper handles
  15. //                if(device_haptic_stop(haptic_handle, effect_handle) == DEVICE_ERROR_NONE) {
  16. //                        LOGI("Device vibration stopped");
  17. //                }

  18. //                When you decided not to use haptic anymore disconnect it
  19. //                if(device_haptic_close(haptic_handle) == DEVICE_ERROR_NONE) {
  20. //                        LOGI("Vibrator disconnected");
  21. //                }
  22.         }
  23. }
复制代码
欢迎来到泰泽网:http://www.tizennet.com/ 泰泽论坛:http://bbs.tizennet.com/ 好没有内涵哦,快到设置中更改这个无聊的签名吧!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|泰泽应用|泰泽论坛|泰泽网|小黑屋|Archiver|手机版|泰泽邮箱|泰泽网 ( 蜀ICP备13024062号-1 )

GMT+8, 2024-3-29 20:04 , Processed in 0.060120 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表