mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
This is an initial port to feedbackd for the haptics plugin. This implementation is a simple port to have the motor enabled for a certain duration. We will eventually want to use feedbackd events to trigger these instead. Related MR for qtfeedback: https://invent.kde.org/jbbgameich/ktactilefeedback/-/merge_requests/2 https://invent.kde.org/teams/plasma-mobile/issues/-/issues/10
29 lines
1 KiB
C++
29 lines
1 KiB
C++
// SPDX-FileCopyrightText: 2023-2025 Devin Lin <devin@kde.org>
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "vibrationmanager.h"
|
|
|
|
VibrationManager::VibrationManager(QObject *parent)
|
|
: QObject{parent}
|
|
{
|
|
qDBusRegisterMetaType<VibrationEvent>();
|
|
qDBusRegisterMetaType<VibrationEventList>();
|
|
}
|
|
|
|
QCoro::Task<void> VibrationManager::vibrate(int durationMs)
|
|
{
|
|
// Only create interface when needed.
|
|
if (!m_interface) {
|
|
const auto objectPath = QStringLiteral("/org/sigxcpu/Feedback");
|
|
m_interface = new OrgSigxcpuFeedbackHapticInterface("org.sigxcpu.Feedback", objectPath, QDBusConnection::sessionBus(), this);
|
|
}
|
|
|
|
const QString appId = QStringLiteral("org.kde.plasmashell");
|
|
const VibrationEvent event{1.0, static_cast<quint32>(durationMs)};
|
|
const VibrationEventList pattern = {event};
|
|
QDBusPendingReply<bool> reply = co_await m_interface->Vibrate(appId, pattern);
|
|
|
|
if (!reply.isValid() || !reply.value()) {
|
|
qWarning() << "feedbackd vibration failed";
|
|
}
|
|
}
|