2020-11-05 07:27:56 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-11-05 07:27:56 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
#ifndef WAYLAND_SERVER_TABLET_INTERFACE_H
|
|
|
|
#define WAYLAND_SERVER_TABLET_INTERFACE_H
|
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
#include <KWaylandServer/kwaylandserver_export.h>
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-11-05 07:26:01 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QVector>
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
2020-11-04 17:17:26 +00:00
|
|
|
class TabletSeatV2Interface;
|
2020-02-12 15:20:38 +00:00
|
|
|
class Display;
|
|
|
|
class SeatInterface;
|
|
|
|
class SurfaceInterface;
|
2020-11-04 17:17:26 +00:00
|
|
|
class TabletV2Interface;
|
|
|
|
class TabletCursorV2;
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is an implementation of wayland-protocols/unstable/tablet/tablet-unstable-v2.xml
|
|
|
|
*
|
|
|
|
* This class is just the means to get a @class TabletSeatInterface, which is
|
|
|
|
* the class that will have all of the information we need.
|
|
|
|
*
|
|
|
|
* @since 5.69
|
|
|
|
*/
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT TabletManagerV2Interface : public QObject
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-11-04 17:17:26 +00:00
|
|
|
virtual ~TabletManagerV2Interface();
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletSeatV2Interface *seat(SeatInterface *seat) const;
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class Display;
|
2020-11-04 17:17:26 +00:00
|
|
|
explicit TabletManagerV2Interface(Display *d, QObject *parent);
|
2020-02-12 15:20:38 +00:00
|
|
|
class Private;
|
|
|
|
QScopedPointer<Private> d;
|
|
|
|
};
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT TabletToolV2Interface : public QObject
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-11-04 17:17:26 +00:00
|
|
|
virtual ~TabletToolV2Interface();
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
enum Type {
|
|
|
|
Pen = 0x140, ///< Pen
|
|
|
|
Eraser = 0x141, ///< Eraser
|
|
|
|
Brush = 0x142, ///< Brush
|
|
|
|
Pencil = 0x143, ///< Pencil
|
|
|
|
Airbrush = 0x144, ///< Airbrush
|
|
|
|
Finger = 0x145, ///< Finger
|
|
|
|
Mouse = 0x146, ///< Mouse
|
|
|
|
Lens = 0x147, ///< Lens
|
|
|
|
Totem
|
|
|
|
};
|
|
|
|
Q_ENUM(Type)
|
|
|
|
|
|
|
|
enum Capability {
|
|
|
|
Tilt = 1, ///< Tilt axeis
|
|
|
|
Pressure = 2, ///< Pressure axis
|
|
|
|
Distance = 3, ///< Distance axis
|
|
|
|
Rotation = 4, ///< Z-rotation axis
|
|
|
|
Slider = 5, ///< Slider axis
|
|
|
|
Wheel = 6 ///< Wheel axis
|
|
|
|
};
|
|
|
|
Q_ENUM(Capability)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the surface the events will be sent to.
|
|
|
|
*
|
|
|
|
* Make sure the surface supports being sent events to.
|
|
|
|
*
|
2020-11-04 17:17:26 +00:00
|
|
|
* @see TabletV2Interface::isSurfaceSupported
|
2020-02-12 15:20:38 +00:00
|
|
|
*/
|
|
|
|
void setCurrentSurface(SurfaceInterface *surface);
|
|
|
|
bool isClientSupported() const;
|
|
|
|
|
|
|
|
void sendRemoved();
|
2020-11-04 17:17:26 +00:00
|
|
|
void sendProximityIn(TabletV2Interface *tablet);
|
2020-02-12 15:20:38 +00:00
|
|
|
void sendProximityOut();
|
|
|
|
void sendUp();
|
|
|
|
void sendDown();
|
|
|
|
void sendPressure(quint32 pressure);
|
|
|
|
void sendDistance(quint32 distance);
|
|
|
|
void sendTilt(qreal degreesX, qreal degreesY);
|
|
|
|
void sendRotation(qreal degrees);
|
|
|
|
void sendSlider(qint32 position);
|
|
|
|
void sendWheel(qint32 degrees, qint32 clicks);
|
|
|
|
void sendButton(quint32 button, bool pressed);
|
|
|
|
void sendFrame(quint32 time);
|
|
|
|
void sendMotion(const QPointF &pos);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
2020-11-04 17:17:26 +00:00
|
|
|
void cursorChanged(TabletCursorV2 *cursor) const;
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
private:
|
2020-11-04 17:17:26 +00:00
|
|
|
friend class TabletSeatV2Interface;
|
|
|
|
explicit TabletToolV2Interface(Display *display, Type type, quint32 hsh, quint32 hsl, quint32 hih, quint32 hil, const QVector<Capability> &capability, QObject *parent);
|
2020-02-12 15:20:38 +00:00
|
|
|
class Private;
|
|
|
|
QScopedPointer<Private> d;
|
|
|
|
};
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT TabletCursorV2 : public QObject
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-11-04 17:17:26 +00:00
|
|
|
~TabletCursorV2() override;
|
2020-02-12 15:20:38 +00:00
|
|
|
QPoint hotspot() const;
|
|
|
|
quint32 enteredSerial() const;
|
|
|
|
SurfaceInterface* surface() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void changed();
|
|
|
|
|
|
|
|
private:
|
2020-11-04 17:17:26 +00:00
|
|
|
friend class TabletToolV2Interface;
|
|
|
|
TabletCursorV2();
|
2020-02-12 15:20:38 +00:00
|
|
|
class Private;
|
|
|
|
const QScopedPointer<Private> d;
|
|
|
|
};
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT TabletV2Interface : public QObject
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-11-04 17:17:26 +00:00
|
|
|
virtual ~TabletV2Interface();
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns true if the surface has been bound to the tablet.
|
|
|
|
*/
|
|
|
|
bool isSurfaceSupported(SurfaceInterface *surface) const;
|
|
|
|
|
|
|
|
void sendRemoved();
|
|
|
|
|
|
|
|
private:
|
2020-11-04 17:17:26 +00:00
|
|
|
friend class TabletSeatV2Interface;
|
|
|
|
friend class TabletToolV2Interface;
|
|
|
|
explicit TabletV2Interface(quint32 vendorId, quint32 productId, const QString &name, const QStringList &paths, QObject *parent);
|
2020-02-12 15:20:38 +00:00
|
|
|
class Private;
|
|
|
|
QScopedPointer<Private> d;
|
|
|
|
};
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT TabletSeatV2Interface : public QObject
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-11-04 17:17:26 +00:00
|
|
|
virtual ~TabletSeatV2Interface();
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletV2Interface *addTablet(quint32 vendorId, quint32 productId, const QString &sysname, const QString &name, const QStringList &paths);
|
|
|
|
TabletToolV2Interface *addTool(TabletToolV2Interface::Type type, quint64 hardwareSerial, quint64 hardwareId, const QVector<TabletToolV2Interface::Capability> &capabilities);
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletToolV2Interface *toolByHardwareId(quint64 hardwareId) const;
|
|
|
|
TabletToolV2Interface *toolByHardwareSerial(quint64 hardwareSerial) const;
|
|
|
|
TabletV2Interface *tabletByName(const QString &sysname) const;
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
void removeTablet(const QString &sysname);
|
|
|
|
|
|
|
|
private:
|
2020-11-04 17:17:26 +00:00
|
|
|
friend class TabletManagerV2Interface;
|
|
|
|
explicit TabletSeatV2Interface(Display *display, QObject *parent);
|
2020-02-12 15:20:38 +00:00
|
|
|
class Private;
|
|
|
|
QScopedPointer<Private> d;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
Q_DECLARE_METATYPE(KWaylandServer::TabletSeatV2Interface *)
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
#endif
|