#include "Utils/FeedbackManager.h"
#include "Utils/Log.h"
+#define FEEDBACK_VIBRATION_PERIOD 2.5
+
namespace utils {
FeedbackManager &FeedbackManager::GetInstance()
ERR("feedback_deinitialize failed[%d]: %s", ret, get_error_message(ret));
}
+static Eina_Bool Vibrate(void *data)
+{
+ int ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_TIMER);
+ if (ret != FEEDBACK_ERROR_NONE)
+ ERR("feedback_play_type failed[%d]: %s", ret, get_error_message(ret));
+
+ return ECORE_CALLBACK_RENEW;
+}
+
void FeedbackManager::VibrationStart()
{
+ timer = ecore_timer_add(FEEDBACK_VIBRATION_PERIOD, Vibrate, this);
+ Vibrate(this);
+
bool status;
int ret = feedback_is_supported_pattern(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_TIMER, &status);
if (ret != FEEDBACK_ERROR_NONE || !status) {
ERR("feedback_is_supported_pattern failed[%d]: %s", ret, get_error_message(ret));
return;
}
-
- ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_TIMER);
- if (ret != FEEDBACK_ERROR_NONE)
- ERR("feedback_play_type failed[%d]: %s", ret, get_error_message(ret));
}
void FeedbackManager::VibrationStop()
{
+ if (timer) {
+ ecore_timer_del(timer);
+ timer = NULL;
+ }
+
int ret = feedback_stop();
if (ret != FEEDBACK_ERROR_NONE)
ERR("feedback_stop failed[%d]: %s", ret, get_error_message(ret));