namespace ViewModule {
-
-namespace {
-const int WRT_HAPTIC_DEVICE_ID = 0;
-}
-
-VibrationSupport::VibrationSupport(): m_initialized(false)
+VibrationSupport::VibrationSupport(): m_initialized(false),
+ m_handle(NULL),
+ m_effect_handle(NULL)
{
}
void VibrationSupport::deinitialize(void)
{
LogDebug("deinitialize");
- int ret = haptic_deinitialize();
-
- if (HAPTIC_ERROR_NOT_INITIALIZED == ret) {
- LogDebug("not initialized");
- m_initialized = false;
- } else if (HAPTIC_ERROR_NONE == ret) {
- LogDebug("success");
- m_initialized = false;
- } else {
- LogDebug("deinitialize failed");
+
+ if( m_initialized )
+ {
+ int ret = haptic_close(m_handle);
+
+ if( HAPTIC_ERROR_NONE == ret )
+ {
+ m_initialized = false;
+ LogDebug("deinitialize success");
+ }
+ else
+ {
+ m_initialized = true;
+ LogDebug("deinitialize failed - error code : " << ret);
+ }
}
}
{
LogDebug("startVibration called");
- if (!m_initialized) {
- if (!initializeVibration()) {
+ if ( m_initialized == false )
+ {
+ if ( initializeVibration() == false )
+ {
return;
}
}
+
int time = static_cast<int>(vibrationTime);
- if (HAPTIC_ERROR_NONE != haptic_vibrate_monotone(WRT_HAPTIC_DEVICE_ID,
- time,
- HAPTIC_LEVEL_AUTO))
+ int ret = haptic_vibrate_monotone(m_handle, time, &m_effect_handle);
+
+ if( HAPTIC_ERROR_NONE == ret )
{
- LogDebug("haptic_vibrate_monotone failed.");
+ LogDebug("haptic_vibrate_monotone success");
}
+ else
+ {
+ LogDebug("haptic_vibrate_monotone failed - error code : " << ret);
+ }
+
return;
}
void VibrationSupport::stopVibration(void)
{
LogDebug("stopVibration called");
- if (!m_initialized) {
+ if ( m_initialized == false )
+ {
return;
}
- if (HAPTIC_ERROR_NONE != haptic_stop_device(WRT_HAPTIC_DEVICE_ID)) {
- LogDebug("haptic_stop_device failed");
+ int ret = haptic_stop_all_effects(m_handle);
+
+ if( HAPTIC_ERROR_NONE == ret )
+ {
+ LogDebug("haptic_stop_all_effects success");
}
+ else
+ {
+ LogDebug("haptic_stop_all_effects failed - error code : " << ret);
+ }
+
return;
}
bool VibrationSupport::initializeVibration(void)
{
LogDebug("initializeVibration called");
- if (HAPTIC_ERROR_NONE == haptic_initialize()) {
- m_initialized = true;
- return true;
- } else {
- LogDebug("haptic_initialize failed");
- return false;
+
+
+ if ( m_initialized == false )
+ {
+ haptic_device_h handle = NULL;
+ int ret = haptic_open(HAPTIC_DEVICE_0, &handle);
+
+ if ( ret == HAPTIC_ERROR_NONE )
+ {
+ LogDebug("initializeVibration success");
+ m_initialized = true;
+ m_handle = handle;
+ }
+ else
+ {
+ LogDebug("initializeVibration failed - error code : " << ret);
+ m_initialized = false;
+ m_handle = NULL;
+ }
}
+
+ return m_initialized;
}
} // namespace ViewModule
m_cbs(new WRT::UserDelegates),
m_isBackgroundReload(false),
m_appsSupport(new ViewModule::AppsSupport()),
- m_vibrationSupport(),
+ m_vibrationSupport(new ViewModule::VibrationSupport()),
m_attachedToCustomHandlerDao(false)
{
}
ViewModule::StorageSupport::deinitializeStorage(m_model);
m_appsSupport->deinitialize();
- // temp
- // m_vibrationSupport->deinitialize();
+ m_vibrationSupport->deinitialize();
while (m_ewkViewList.size()) {
LogInfo("pop webview: " << m_ewkViewList.back());
m_appsSupport->initialize(m_model);
m_securityOriginSupport.reset(new ViewModule::SecurityOriginSupport(m_model));
- // temp
- // m_vibrationSupport->initialize();
+ m_vibrationSupport->initialize();
}
void ViewLogic::initializePluginLoading()
Assert(eventInfo);
const long vibrationTime = *(static_cast<const long*>(eventInfo));
- // temp
- // This->m_vibrationSupport->startVibration(vibrationTime);
+ This->m_vibrationSupport->startVibration(vibrationTime);
return;
}
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
- // temp
- // This->m_vibrationSupport->stopVibration();
+ This->m_vibrationSupport->stopVibration();
return;
}