2014-06-27 14:41:47 +01:00
|
|
|
/**
|
2018-04-02 19:20:24 +01:00
|
|
|
* Copyright 2018 Albert Vaca Cintora <albertvaka@gmail.com>
|
2015-07-03 08:25:34 +01:00
|
|
|
* Copyright 2015 Martin Gräßlin <mgraesslin@kde.org>
|
2018-04-02 19:20:24 +01:00
|
|
|
* Copyright 2014 Ahmed I. Khalil <ahmedibrahimkhali@gmail.com>
|
2014-06-27 14:41:47 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License or (at your option) version 3 or any later version
|
|
|
|
* accepted by the membership of KDE e.V. (or its successor approved
|
|
|
|
* by the membership of KDE e.V.), which shall act as a proxy
|
|
|
|
* defined in Section 14 of version 3 of the license.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-03-23 16:29:26 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2014-06-27 14:41:47 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mousepadplugin.h"
|
2014-09-22 01:37:10 +01:00
|
|
|
#include <KPluginFactory>
|
2015-07-03 08:25:34 +01:00
|
|
|
#include <KLocalizedString>
|
2018-04-09 17:23:54 +01:00
|
|
|
#include <QGuiApplication>
|
2016-05-31 16:16:01 +01:00
|
|
|
|
2018-04-02 19:20:24 +01:00
|
|
|
#if HAVE_WINDOWS
|
|
|
|
#include "windowsremoteinput.h"
|
|
|
|
#else
|
|
|
|
#if HAVE_X11
|
|
|
|
#include "x11remoteinput.h"
|
|
|
|
#endif
|
|
|
|
#if HAVE_WAYLAND
|
|
|
|
#include "waylandremoteinput.h"
|
|
|
|
#endif
|
2016-05-31 16:16:01 +01:00
|
|
|
#endif
|
2014-09-22 01:37:10 +01:00
|
|
|
|
2015-07-03 08:25:34 +01:00
|
|
|
|
2015-03-19 15:36:53 +00:00
|
|
|
K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_mousepad.json", registerPlugin< MousepadPlugin >(); )
|
2014-06-27 14:41:47 +01:00
|
|
|
|
|
|
|
MousepadPlugin::MousepadPlugin(QObject* parent, const QVariantList& args)
|
2016-05-31 16:16:01 +01:00
|
|
|
: KdeConnectPlugin(parent, args)
|
2018-04-08 18:20:51 +01:00
|
|
|
, m_impl(nullptr)
|
2014-06-29 16:21:54 +01:00
|
|
|
{
|
2018-04-02 19:20:24 +01:00
|
|
|
#if HAVE_WINDOWS
|
|
|
|
m_impl = new WindowsRemoteInput(this);
|
|
|
|
#else
|
|
|
|
#if HAVE_X11
|
2018-04-08 18:20:51 +01:00
|
|
|
if (QGuiApplication::platformName() == QLatin1String("xcb")) {
|
2018-04-02 19:20:24 +01:00
|
|
|
m_impl = new X11RemoteInput(this);
|
2018-04-08 18:20:51 +01:00
|
|
|
}
|
2018-04-02 19:20:24 +01:00
|
|
|
#endif
|
2018-04-08 18:20:51 +01:00
|
|
|
|
2018-04-02 19:20:24 +01:00
|
|
|
#if HAVE_WAYLAND
|
2018-04-08 18:20:51 +01:00
|
|
|
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
|
2018-04-02 19:20:24 +01:00
|
|
|
m_impl = new WaylandRemoteInput(this);
|
2016-09-29 09:54:33 +01:00
|
|
|
}
|
2018-04-08 18:20:51 +01:00
|
|
|
#endif
|
2016-09-29 09:54:33 +01:00
|
|
|
#endif
|
2018-04-08 18:20:51 +01:00
|
|
|
|
|
|
|
if (!m_impl) {
|
|
|
|
qDebug() << "KDE Connect was built without" << QGuiApplication::platformName() << "support";
|
|
|
|
}
|
|
|
|
|
2014-06-27 14:41:47 +01:00
|
|
|
}
|
2014-07-02 00:39:38 +01:00
|
|
|
|
2018-04-02 19:20:24 +01:00
|
|
|
MousepadPlugin::~MousepadPlugin()
|
2015-07-03 08:25:34 +01:00
|
|
|
{
|
2018-04-02 19:20:24 +01:00
|
|
|
delete m_impl;
|
2015-07-03 08:25:34 +01:00
|
|
|
}
|
|
|
|
|
2018-04-02 19:20:24 +01:00
|
|
|
bool MousepadPlugin::receivePacket(const NetworkPacket& np)
|
2015-07-03 08:25:34 +01:00
|
|
|
{
|
2018-04-08 18:20:51 +01:00
|
|
|
if (m_impl) {
|
|
|
|
return m_impl->handlePacket(np);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2015-07-03 08:25:34 +01:00
|
|
|
}
|
|
|
|
|
2018-05-12 16:51:55 +01:00
|
|
|
|
|
|
|
void MousepadPlugin::connected() {
|
|
|
|
NetworkPacket np(PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE);
|
2018-07-12 15:14:32 +01:00
|
|
|
if (m_impl) {
|
|
|
|
np.set<bool>(QStringLiteral("state"), m_impl->hasKeyboardSupport());
|
|
|
|
}
|
2018-05-12 16:51:55 +01:00
|
|
|
sendPacket(np);
|
|
|
|
}
|
|
|
|
|
2014-07-02 00:39:38 +01:00
|
|
|
#include "mousepadplugin.moc"
|