2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file view_logic_vibration_support.cpp
18 * @author Jihoon Chung (jihoon.chung@samsung.com)
21 #include "view_logic_vibration_support.h"
22 #include <dpl/log/log.h>
25 namespace ViewModule {
29 const int WRT_HAPTIC_DEVICE_ID = 0;
32 VibrationSupport::VibrationSupport(): m_initialized(false)
36 VibrationSupport::~VibrationSupport()
38 Assert(!m_initialized);
41 void VibrationSupport::initialize(void)
43 LogDebug("initialize");
44 initializeVibration();
47 void VibrationSupport::deinitialize(void)
49 LogDebug("deinitialize");
50 int ret = haptic_deinitialize();
52 if (HAPTIC_ERROR_NOT_INITIALIZED == ret) {
53 LogDebug("not initialized");
54 m_initialized = false;
55 } else if (HAPTIC_ERROR_NONE == ret) {
57 m_initialized = false;
59 LogDebug("deinitialize failed");
63 void VibrationSupport::startVibration(const long vibrationTime)
65 LogDebug("startVibration called");
68 if (!initializeVibration()) {
72 int time = static_cast<int>(vibrationTime);
73 if (HAPTIC_ERROR_NONE != haptic_vibrate_monotone(WRT_HAPTIC_DEVICE_ID,
77 LogDebug("haptic_vibrate_monotone failed.");
82 void VibrationSupport::stopVibration(void)
84 LogDebug("stopVibration called");
89 if (HAPTIC_ERROR_NONE != haptic_stop_device(WRT_HAPTIC_DEVICE_ID)) {
90 LogDebug("haptic_stop_device failed");
95 bool VibrationSupport::initializeVibration(void)
97 LogDebug("initializeVibration called");
98 if (HAPTIC_ERROR_NONE == haptic_initialize()) {
102 LogDebug("haptic_initialize failed");
107 } // namespace ViewModule