1 // Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "runtime/vibration_manager.h"
9 #include "common/logger.h"
15 class VibrationImpl : public VibrationManager {
18 virtual ~VibrationImpl();
19 virtual void Start(int ms);
23 // haptic_devce_h was declared as int
24 haptic_device_h handle_;
28 VibrationImpl::VibrationImpl()
32 VibrationImpl::~VibrationImpl() {
34 haptic_close(handle_);
39 bool VibrationImpl::Initialize() {
43 int ret = haptic_open(HAPTIC_DEVICE_0, &handle_);
44 if (ret != HAPTIC_ERROR_NONE) {
45 LOGGER(ERROR) << "Fail to open haptic device";
52 void VibrationImpl::Start(int ms) {
54 haptic_vibrate_monotone(handle_, ms, NULL);
58 void VibrationImpl::Stop() {
60 haptic_stop_all_effects(handle_);
64 VibrationManager* VibrationManager::GetInstance() {
65 static VibrationImpl instance;
70 } // namespace platform