2 * Copyright (c) 2015 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.
18 #include "runtime/vibration_manager.h"
20 #include <dd-haptic.h>
22 #include "common/logger.h"
28 class VibrationImpl : public VibrationManager {
31 virtual ~VibrationImpl();
32 virtual void Start(int ms);
36 // haptic_devce_h was declared as int
37 haptic_device_h handle_;
41 VibrationImpl::VibrationImpl()
45 VibrationImpl::~VibrationImpl() {
47 haptic_close(handle_);
52 bool VibrationImpl::Initialize() {
56 int ret = haptic_open(HAPTIC_DEVICE_0, &handle_);
57 if (ret != HAPTIC_ERROR_NONE) {
58 LOGGER(ERROR) << "Fail to open haptic device";
65 void VibrationImpl::Start(int ms) {
67 haptic_vibrate_monotone(handle_, ms, NULL);
71 void VibrationImpl::Stop() {
73 haptic_stop_all_effects(handle_);
77 VibrationManager* VibrationManager::GetInstance() {
78 static VibrationImpl instance;
83 } // namespace platform