2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2016-05-20 13:48:11 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
2016-05-20 13:48:11 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2016-05-20 13:48:11 +00:00
|
|
|
#include "mock_libinput.h"
|
2016-08-03 07:31:47 +00:00
|
|
|
#include <config-kwin.h>
|
2016-05-20 13:48:11 +00:00
|
|
|
|
2016-05-25 15:25:58 +00:00
|
|
|
#include <linux/input.h>
|
|
|
|
|
2016-05-20 13:48:11 +00:00
|
|
|
int libinput_device_keyboard_has_key(struct libinput_device *device, uint32_t code)
|
|
|
|
{
|
2016-05-30 06:22:04 +00:00
|
|
|
return device->keys.contains(code);
|
2016-05-20 13:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_device_has_capability(struct libinput_device *device, enum libinput_device_capability capability)
|
|
|
|
{
|
|
|
|
switch (capability) {
|
|
|
|
case LIBINPUT_DEVICE_CAP_KEYBOARD:
|
|
|
|
return device->keyboard;
|
|
|
|
case LIBINPUT_DEVICE_CAP_POINTER:
|
|
|
|
return device->pointer;
|
|
|
|
case LIBINPUT_DEVICE_CAP_TOUCH:
|
|
|
|
return device->touch;
|
|
|
|
case LIBINPUT_DEVICE_CAP_GESTURE:
|
|
|
|
return device->gestureSupported;
|
2016-08-03 07:31:47 +00:00
|
|
|
case LIBINPUT_DEVICE_CAP_TABLET_TOOL:
|
|
|
|
return device->tabletTool;
|
2017-12-27 16:57:00 +00:00
|
|
|
case LIBINPUT_DEVICE_CAP_SWITCH:
|
|
|
|
return device->switchDevice;
|
2016-05-20 13:48:11 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *libinput_device_get_name(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->name.constData();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *libinput_device_get_sysname(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->sysName.constData();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *libinput_device_get_output_name(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->outputName.constData();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int libinput_device_get_id_product(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->product;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int libinput_device_get_id_vendor(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->vendor;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_device_config_tap_get_finger_count(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->tapFingerCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_tap_state libinput_device_config_tap_get_enabled(struct libinput_device *device)
|
|
|
|
{
|
2016-08-11 13:13:36 +00:00
|
|
|
if (device->tapToClick) {
|
|
|
|
return LIBINPUT_CONFIG_TAP_ENABLED;
|
|
|
|
} else {
|
|
|
|
return LIBINPUT_CONFIG_TAP_DISABLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_tap_set_enabled(struct libinput_device *device, enum libinput_config_tap_state enable)
|
|
|
|
{
|
|
|
|
if (device->setTapToClickReturnValue == 0) {
|
|
|
|
device->tapToClick = (enable == LIBINPUT_CONFIG_TAP_ENABLED);
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
2016-05-20 13:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_tap_state libinput_device_config_tap_get_default_enabled(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
if (device->tapEnabledByDefault) {
|
|
|
|
return LIBINPUT_CONFIG_TAP_ENABLED;
|
|
|
|
} else {
|
|
|
|
return LIBINPUT_CONFIG_TAP_DISABLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-11 14:02:26 +00:00
|
|
|
enum libinput_config_drag_state libinput_device_config_tap_get_default_drag_enabled(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
if (device->tapAndDragEnabledByDefault) {
|
|
|
|
return LIBINPUT_CONFIG_DRAG_ENABLED;
|
|
|
|
} else {
|
|
|
|
return LIBINPUT_CONFIG_DRAG_DISABLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_drag_state libinput_device_config_tap_get_drag_enabled(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
if (device->tapAndDrag) {
|
|
|
|
return LIBINPUT_CONFIG_DRAG_ENABLED;
|
|
|
|
} else {
|
|
|
|
return LIBINPUT_CONFIG_DRAG_DISABLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_tap_set_drag_enabled(struct libinput_device *device, enum libinput_config_drag_state enable)
|
|
|
|
{
|
|
|
|
if (device->setTapAndDragReturnValue == 0) {
|
|
|
|
device->tapAndDrag = (enable == LIBINPUT_CONFIG_DRAG_ENABLED);
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
2016-08-11 14:32:00 +00:00
|
|
|
enum libinput_config_drag_lock_state libinput_device_config_tap_get_default_drag_lock_enabled(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
if (device->tapDragLockEnabledByDefault) {
|
|
|
|
return LIBINPUT_CONFIG_DRAG_LOCK_ENABLED;
|
|
|
|
} else {
|
|
|
|
return LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_drag_lock_state libinput_device_config_tap_get_drag_lock_enabled(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
if (device->tapDragLock) {
|
|
|
|
return LIBINPUT_CONFIG_DRAG_LOCK_ENABLED;
|
|
|
|
} else {
|
|
|
|
return LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_tap_set_drag_lock_enabled(struct libinput_device *device, enum libinput_config_drag_lock_state enable)
|
|
|
|
{
|
|
|
|
if (device->setTapDragLockReturnValue == 0) {
|
|
|
|
device->tapDragLock = (enable == LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
2016-05-20 13:48:11 +00:00
|
|
|
int libinput_device_config_dwt_is_available(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->supportsDisableWhileTyping;
|
|
|
|
}
|
|
|
|
|
2016-12-02 13:58:56 +00:00
|
|
|
enum libinput_config_status libinput_device_config_dwt_set_enabled(struct libinput_device *device, enum libinput_config_dwt_state state)
|
|
|
|
{
|
|
|
|
if (device->setDisableWhileTypingReturnValue == 0) {
|
|
|
|
if (!device->supportsDisableWhileTyping) {
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
device->disableWhileTyping = state;
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_dwt_state libinput_device_config_dwt_get_enabled(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->disableWhileTyping;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_dwt_state libinput_device_config_dwt_get_default_enabled(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->disableWhileTypingEnabledByDefault;
|
|
|
|
}
|
|
|
|
|
2016-05-20 13:48:11 +00:00
|
|
|
int libinput_device_config_accel_is_available(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->supportsPointerAcceleration;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_device_config_calibration_has_matrix(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->supportsCalibrationMatrix;
|
|
|
|
}
|
|
|
|
|
2017-11-10 17:07:15 +00:00
|
|
|
enum libinput_config_status libinput_device_config_calibration_set_matrix(struct libinput_device *device, const float matrix[6])
|
|
|
|
{
|
|
|
|
for (std::size_t i = 0; i < 6; i++) {
|
|
|
|
device->calibrationMatrix[i] = matrix[i];
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_device_config_calibration_get_default_matrix(struct libinput_device *device, float matrix[6])
|
|
|
|
{
|
|
|
|
for (std::size_t i = 0; i < 6; i++) {
|
|
|
|
matrix[i] = device->defaultCalibrationMatrix[i];
|
|
|
|
}
|
|
|
|
return device->defaultCalibrationMatrixIsIdentity ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
2016-05-20 13:48:11 +00:00
|
|
|
int libinput_device_config_left_handed_is_available(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->supportsLeftHanded;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t libinput_device_config_send_events_get_modes(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
uint32_t modes = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
|
|
|
if (device->supportsDisableEvents) {
|
|
|
|
modes |= LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
|
|
|
|
}
|
|
|
|
if (device->supportsDisableEventsOnExternalMouse) {
|
|
|
|
modes |= LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
|
|
|
|
}
|
|
|
|
return modes;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_device_config_left_handed_get(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->leftHanded;
|
|
|
|
}
|
|
|
|
|
2016-12-02 13:58:56 +00:00
|
|
|
double libinput_device_config_accel_get_default_speed(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->defaultPointerAcceleration;
|
|
|
|
}
|
|
|
|
|
2016-11-22 13:49:01 +00:00
|
|
|
int libinput_device_config_left_handed_get_default(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->leftHandedEnabledByDefault;
|
|
|
|
}
|
|
|
|
|
2016-05-20 13:48:11 +00:00
|
|
|
double libinput_device_config_accel_get_speed(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->pointerAcceleration;
|
|
|
|
}
|
|
|
|
|
2016-12-02 13:58:56 +00:00
|
|
|
uint32_t libinput_device_config_accel_get_profiles(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->supportedPointerAccelerationProfiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_accel_profile libinput_device_config_accel_get_default_profile(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->defaultPointerAccelerationProfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_accel_set_profile(struct libinput_device *device, enum libinput_config_accel_profile profile)
|
|
|
|
{
|
|
|
|
if (device->setPointerAccelerationProfileReturnValue == 0) {
|
|
|
|
if (!(device->supportedPointerAccelerationProfiles & profile) && profile!= LIBINPUT_CONFIG_ACCEL_PROFILE_NONE) {
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
device->pointerAccelerationProfile = profile;
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_accel_profile libinput_device_config_accel_get_profile(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->pointerAccelerationProfile;
|
|
|
|
}
|
|
|
|
|
[libinput] Add support for clickfinger and button areas click method
Summary:
Added support for libinput clickfinger , areas method for touchpad KCM
Also added mock methods.
Included commits in branch libinputClickMethod:
Added libinput mock methods
Added : 1. setScrollMethod 2. added key value pair in QMap 3. added methods for Q_Props
Added Q_Props for click method, signal
Added variables and initialize in constructor
Reviewers: #kwin, graesslin, davidedmundson, zzag
Reviewed By: #kwin, graesslin, zzag
Subscribers: zzag, graesslin, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17577
2018-12-22 16:29:41 +00:00
|
|
|
uint32_t libinput_device_config_click_get_methods(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->supportedClickMethods;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_click_method libinput_device_config_click_get_default_method(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->defaultClickMethod;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_click_method libinput_device_config_click_get_method(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->clickMethod;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_click_set_method(struct libinput_device *device, enum libinput_config_click_method method)
|
|
|
|
{
|
|
|
|
if (device->setClickMethodReturnValue == 0) {
|
|
|
|
if (!(device->supportedClickMethods & method) && method != LIBINPUT_CONFIG_CLICK_METHOD_NONE) {
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
device->clickMethod = method;
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
2016-05-20 13:48:11 +00:00
|
|
|
uint32_t libinput_device_config_send_events_get_mode(struct libinput_device *device)
|
|
|
|
{
|
2016-05-30 14:04:06 +00:00
|
|
|
if (device->enabled) {
|
|
|
|
return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
|
|
|
} else {
|
|
|
|
// TODO: disabled on eternal mouse
|
|
|
|
return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
|
|
|
|
}
|
2016-05-20 13:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct libinput_device *libinput_device_ref(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct libinput_device *libinput_device_unref(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_device_get_size(struct libinput_device *device, double *width, double *height)
|
|
|
|
{
|
|
|
|
if (device->deviceSizeReturnValue) {
|
|
|
|
return device->deviceSizeReturnValue;
|
|
|
|
}
|
|
|
|
if (width) {
|
|
|
|
*width = device->deviceSize.width();
|
|
|
|
}
|
|
|
|
if (height) {
|
|
|
|
*height = device->deviceSize.height();
|
|
|
|
}
|
|
|
|
return device->deviceSizeReturnValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_device_pointer_has_button(struct libinput_device *device, uint32_t code)
|
|
|
|
{
|
2016-05-25 15:25:58 +00:00
|
|
|
switch (code) {
|
|
|
|
case BTN_LEFT:
|
|
|
|
return device->supportedButtons.testFlag(Qt::LeftButton);
|
|
|
|
case BTN_MIDDLE:
|
|
|
|
return device->supportedButtons.testFlag(Qt::MiddleButton);
|
|
|
|
case BTN_RIGHT:
|
|
|
|
return device->supportedButtons.testFlag(Qt::RightButton);
|
|
|
|
case BTN_SIDE:
|
|
|
|
return device->supportedButtons.testFlag(Qt::ExtraButton1);
|
|
|
|
case BTN_EXTRA:
|
|
|
|
return device->supportedButtons.testFlag(Qt::ExtraButton2);
|
|
|
|
case BTN_BACK:
|
|
|
|
return device->supportedButtons.testFlag(Qt::BackButton);
|
|
|
|
case BTN_FORWARD:
|
|
|
|
return device->supportedButtons.testFlag(Qt::ForwardButton);
|
|
|
|
case BTN_TASK:
|
|
|
|
return device->supportedButtons.testFlag(Qt::TaskButton);
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2016-05-20 13:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_left_handed_set(struct libinput_device *device, int left_handed)
|
|
|
|
{
|
|
|
|
if (device->setLeftHandedReturnValue == 0) {
|
|
|
|
device->leftHanded = left_handed;
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_accel_set_speed(struct libinput_device *device, double speed)
|
|
|
|
{
|
|
|
|
if (device->setPointerAccelerationReturnValue == 0) {
|
|
|
|
device->pointerAcceleration = speed;
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_send_events_set_mode(struct libinput_device *device, uint32_t mode)
|
|
|
|
{
|
2016-05-30 14:04:06 +00:00
|
|
|
if (device->setEnableModeReturnValue == 0) {
|
|
|
|
device->enabled = (mode == LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
2016-05-20 13:48:11 +00:00
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
2016-05-30 15:46:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
enum libinput_event_type libinput_event_get_type(struct libinput_event *event)
|
|
|
|
{
|
|
|
|
return event->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct libinput_device *libinput_event_get_device(struct libinput_event *event)
|
|
|
|
{
|
|
|
|
return event->device;
|
|
|
|
}
|
|
|
|
|
|
|
|
void libinput_event_destroy(struct libinput_event *event)
|
|
|
|
{
|
|
|
|
delete event;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct libinput_event_keyboard *libinput_event_get_keyboard_event(struct libinput_event *event)
|
|
|
|
{
|
|
|
|
if (event->type == LIBINPUT_EVENT_KEYBOARD_KEY) {
|
|
|
|
return reinterpret_cast<libinput_event_keyboard *>(event);
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct libinput_event_pointer *libinput_event_get_pointer_event(struct libinput_event *event)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
if (event->type == LIBINPUT_EVENT_POINTER_MOTION ||
|
|
|
|
event->type == LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE ||
|
|
|
|
event->type == LIBINPUT_EVENT_POINTER_BUTTON ||
|
|
|
|
event->type == LIBINPUT_EVENT_POINTER_AXIS) {
|
|
|
|
return reinterpret_cast<libinput_event_pointer *>(event);
|
|
|
|
}
|
2016-05-30 15:46:53 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct libinput_event_touch *libinput_event_get_touch_event(struct libinput_event *event)
|
|
|
|
{
|
2016-05-31 08:14:28 +00:00
|
|
|
if (event->type == LIBINPUT_EVENT_TOUCH_DOWN ||
|
|
|
|
event->type == LIBINPUT_EVENT_TOUCH_UP ||
|
|
|
|
event->type == LIBINPUT_EVENT_TOUCH_MOTION ||
|
|
|
|
event->type == LIBINPUT_EVENT_TOUCH_CANCEL ||
|
|
|
|
event->type == LIBINPUT_EVENT_TOUCH_FRAME) {
|
|
|
|
return reinterpret_cast<libinput_event_touch *>(event);
|
|
|
|
}
|
2016-05-30 15:46:53 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-08-05 12:35:33 +00:00
|
|
|
struct libinput_event_gesture *libinput_event_get_gesture_event(struct libinput_event *event)
|
|
|
|
{
|
|
|
|
if (event->type == LIBINPUT_EVENT_GESTURE_PINCH_BEGIN ||
|
|
|
|
event->type == LIBINPUT_EVENT_GESTURE_PINCH_UPDATE ||
|
|
|
|
event->type == LIBINPUT_EVENT_GESTURE_PINCH_END ||
|
|
|
|
event->type == LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN ||
|
|
|
|
event->type == LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE ||
|
|
|
|
event->type == LIBINPUT_EVENT_GESTURE_SWIPE_END) {
|
|
|
|
return reinterpret_cast<libinput_event_gesture *>(event);
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_event_gesture_get_cancelled(struct libinput_event_gesture *event)
|
|
|
|
{
|
|
|
|
if (event->type == LIBINPUT_EVENT_GESTURE_PINCH_END || event->type == LIBINPUT_EVENT_GESTURE_SWIPE_END) {
|
|
|
|
return event->cancelled;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t libinput_event_gesture_get_time(struct libinput_event_gesture *event)
|
|
|
|
{
|
|
|
|
return event->time;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_event_gesture_get_finger_count(struct libinput_event_gesture *event)
|
|
|
|
{
|
|
|
|
return event->fingerCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_gesture_get_dx(struct libinput_event_gesture *event)
|
|
|
|
{
|
|
|
|
if (event->type == LIBINPUT_EVENT_GESTURE_PINCH_UPDATE || event->type == LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE) {
|
|
|
|
return event->delta.width();
|
|
|
|
}
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_gesture_get_dy(struct libinput_event_gesture *event)
|
|
|
|
{
|
|
|
|
if (event->type == LIBINPUT_EVENT_GESTURE_PINCH_UPDATE || event->type == LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE) {
|
|
|
|
return event->delta.height();
|
|
|
|
}
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_gesture_get_scale(struct libinput_event_gesture *event)
|
|
|
|
{
|
|
|
|
switch (event->type) {
|
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
|
|
|
|
return 1.0;
|
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
|
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_END:
|
|
|
|
return event->scale;
|
|
|
|
default:
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_gesture_get_angle_delta(struct libinput_event_gesture *event)
|
|
|
|
{
|
|
|
|
if (event->type == LIBINPUT_EVENT_GESTURE_PINCH_UPDATE) {
|
|
|
|
return event->angleDelta;
|
|
|
|
}
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2016-05-30 15:46:53 +00:00
|
|
|
uint32_t libinput_event_keyboard_get_key(struct libinput_event_keyboard *event)
|
|
|
|
{
|
|
|
|
return event->key;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_key_state libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event)
|
|
|
|
{
|
|
|
|
return event->state;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t libinput_event_keyboard_get_time(struct libinput_event_keyboard *event)
|
|
|
|
{
|
|
|
|
return event->time;
|
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
return event->absolutePos.x();
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
return event->absolutePos.y();
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_pointer_get_absolute_x_transformed(struct libinput_event_pointer *event, uint32_t width)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
double deviceWidth = 0.0;
|
|
|
|
double deviceHeight = 0.0;
|
|
|
|
libinput_device_get_size(event->device, &deviceWidth, &deviceHeight);
|
|
|
|
return event->absolutePos.x() / deviceWidth * width;
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_pointer_get_absolute_y_transformed(struct libinput_event_pointer *event, uint32_t height)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
double deviceWidth = 0.0;
|
|
|
|
double deviceHeight = 0.0;
|
|
|
|
libinput_device_get_size(event->device, &deviceWidth, &deviceHeight);
|
|
|
|
return event->absolutePos.y() / deviceHeight * height;
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_pointer_get_dx(struct libinput_event_pointer *event)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
return event->delta.width();
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_pointer_get_dy(struct libinput_event_pointer *event)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
return event->delta.height();
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
2016-10-07 12:47:25 +00:00
|
|
|
double libinput_event_pointer_get_dx_unaccelerated(struct libinput_event_pointer *event)
|
|
|
|
{
|
|
|
|
return event->delta.width();
|
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_pointer_get_dy_unaccelerated(struct libinput_event_pointer *event)
|
|
|
|
{
|
|
|
|
return event->delta.height();
|
|
|
|
}
|
|
|
|
|
2016-05-30 15:46:53 +00:00
|
|
|
uint32_t libinput_event_pointer_get_time(struct libinput_event_pointer *event)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
return event->time;
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
2016-10-07 12:47:25 +00:00
|
|
|
uint64_t libinput_event_pointer_get_time_usec(struct libinput_event_pointer *event)
|
|
|
|
{
|
|
|
|
return quint64(event->time * 1000);
|
|
|
|
}
|
|
|
|
|
2016-05-30 15:46:53 +00:00
|
|
|
uint32_t libinput_event_pointer_get_button(struct libinput_event_pointer *event)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
return event->button;
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_button_state libinput_event_pointer_get_button_state(struct libinput_event_pointer *event)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
return event->buttonState;
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_event_pointer_has_axis(struct libinput_event_pointer *event, enum libinput_pointer_axis axis)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
if (axis == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) {
|
|
|
|
return event->verticalAxis;
|
|
|
|
} else {
|
|
|
|
return event->horizontalAxis;
|
|
|
|
}
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event, enum libinput_pointer_axis axis)
|
|
|
|
{
|
2016-05-31 07:23:12 +00:00
|
|
|
if (axis == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) {
|
|
|
|
return event->verticalAxisValue;
|
|
|
|
} else {
|
|
|
|
return event->horizontalAxisValue;
|
|
|
|
}
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.
BUG: 404152
FIXED-IN: 5.17.0
Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
in all three cases wayland debug looked the same (except diagonal scroll
motions).
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19000
2019-02-12 09:14:51 +00:00
|
|
|
double libinput_event_pointer_get_axis_value_discrete(struct libinput_event_pointer *event, enum libinput_pointer_axis axis)
|
|
|
|
{
|
|
|
|
if (axis == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) {
|
|
|
|
return event->verticalDiscreteAxisValue;
|
|
|
|
} else {
|
|
|
|
return event->horizontalDiscreteAxisValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_pointer_axis_source libinput_event_pointer_get_axis_source(struct libinput_event_pointer *event)
|
|
|
|
{
|
|
|
|
return event->axisSource;
|
|
|
|
}
|
|
|
|
|
2016-05-30 15:46:53 +00:00
|
|
|
uint32_t libinput_event_touch_get_time(struct libinput_event_touch *event)
|
|
|
|
{
|
2016-05-31 08:14:28 +00:00
|
|
|
return event->time;
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_touch_get_x(struct libinput_event_touch *event)
|
|
|
|
{
|
2016-05-31 08:14:28 +00:00
|
|
|
return event->absolutePos.x();
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_touch_get_y(struct libinput_event_touch *event)
|
|
|
|
{
|
2016-05-31 08:14:28 +00:00
|
|
|
return event->absolutePos.y();
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_touch_get_x_transformed(struct libinput_event_touch *event, uint32_t width)
|
|
|
|
{
|
2016-05-31 08:14:28 +00:00
|
|
|
double deviceWidth = 0.0;
|
|
|
|
double deviceHeight = 0.0;
|
|
|
|
libinput_device_get_size(event->device, &deviceWidth, &deviceHeight);
|
|
|
|
return event->absolutePos.x() / deviceWidth * width;
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double libinput_event_touch_get_y_transformed(struct libinput_event_touch *event, uint32_t height)
|
|
|
|
{
|
2016-05-31 08:14:28 +00:00
|
|
|
double deviceWidth = 0.0;
|
|
|
|
double deviceHeight = 0.0;
|
|
|
|
libinput_device_get_size(event->device, &deviceWidth, &deviceHeight);
|
|
|
|
return event->absolutePos.y() / deviceHeight * height;
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
2021-01-12 13:08:31 +00:00
|
|
|
int32_t libinput_event_touch_get_seat_slot(struct libinput_event_touch *event)
|
2016-05-30 15:46:53 +00:00
|
|
|
{
|
2016-05-31 08:14:28 +00:00
|
|
|
return event->slot;
|
2016-05-30 15:46:53 +00:00
|
|
|
}
|
2016-06-02 05:46:09 +00:00
|
|
|
|
|
|
|
struct libinput *libinput_udev_create_context(const struct libinput_interface *interface, void *user_data, struct udev *udev)
|
|
|
|
{
|
|
|
|
if (!udev) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
Q_UNUSED(interface)
|
|
|
|
Q_UNUSED(user_data)
|
|
|
|
return new libinput;
|
|
|
|
}
|
|
|
|
|
|
|
|
void libinput_log_set_priority(struct libinput *libinput, enum libinput_log_priority priority)
|
|
|
|
{
|
|
|
|
Q_UNUSED(libinput)
|
|
|
|
Q_UNUSED(priority)
|
|
|
|
}
|
|
|
|
|
|
|
|
void libinput_log_set_handler(struct libinput *libinput, libinput_log_handler log_handler)
|
|
|
|
{
|
|
|
|
Q_UNUSED(libinput)
|
|
|
|
Q_UNUSED(log_handler)
|
|
|
|
}
|
|
|
|
|
|
|
|
struct libinput *libinput_unref(struct libinput *libinput)
|
|
|
|
{
|
|
|
|
libinput->refCount--;
|
|
|
|
if (libinput->refCount == 0) {
|
|
|
|
delete libinput;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return libinput;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_udev_assign_seat(struct libinput *libinput, const char *seat_id)
|
|
|
|
{
|
|
|
|
if (libinput->assignSeatRetVal == 0) {
|
|
|
|
libinput->seat = QByteArray(seat_id);
|
|
|
|
}
|
|
|
|
return libinput->assignSeatRetVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_get_fd(struct libinput *libinput)
|
|
|
|
{
|
|
|
|
Q_UNUSED(libinput)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_dispatch(struct libinput *libinput)
|
|
|
|
{
|
|
|
|
Q_UNUSED(libinput)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct libinput_event *libinput_get_event(struct libinput *libinput)
|
|
|
|
{
|
|
|
|
Q_UNUSED(libinput)
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void libinput_suspend(struct libinput *libinput)
|
|
|
|
{
|
|
|
|
Q_UNUSED(libinput)
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_resume(struct libinput *libinput)
|
|
|
|
{
|
|
|
|
Q_UNUSED(libinput)
|
|
|
|
return 0;
|
|
|
|
}
|
2016-10-27 17:06:34 +00:00
|
|
|
|
|
|
|
int libinput_device_config_middle_emulation_is_available(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->supportsMiddleEmulation;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_middle_emulation_set_enabled(struct libinput_device *device, enum libinput_config_middle_emulation_state enable)
|
|
|
|
{
|
|
|
|
if (device->setMiddleEmulationReturnValue == 0) {
|
|
|
|
if (!device->supportsMiddleEmulation) {
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
device->middleEmulation = (enable == LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_middle_emulation_state libinput_device_config_middle_emulation_get_enabled(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
if (device->middleEmulation) {
|
|
|
|
return LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED;
|
|
|
|
} else {
|
|
|
|
return LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_middle_emulation_state libinput_device_config_middle_emulation_get_default_enabled(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
if (device->middleEmulationEnabledByDefault) {
|
|
|
|
return LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED;
|
|
|
|
} else {
|
|
|
|
return LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
|
|
|
|
}
|
|
|
|
}
|
2016-10-28 16:30:10 +00:00
|
|
|
|
|
|
|
int libinput_device_config_scroll_has_natural_scroll(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->supportsNaturalScroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_scroll_set_natural_scroll_enabled(struct libinput_device *device, int enable)
|
|
|
|
{
|
|
|
|
if (device->setNaturalScrollReturnValue == 0) {
|
|
|
|
if (!device->supportsNaturalScroll) {
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
device->naturalScroll = enable;
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_device_config_scroll_get_natural_scroll_enabled(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->naturalScroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->naturalScrollEnabledByDefault;
|
|
|
|
}
|
2016-10-28 18:17:20 +00:00
|
|
|
|
2016-12-02 13:58:56 +00:00
|
|
|
enum libinput_config_tap_button_map libinput_device_config_tap_get_default_button_map(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->defaultTapButtonMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_tap_set_button_map(struct libinput_device *device, enum libinput_config_tap_button_map map)
|
|
|
|
{
|
|
|
|
if (device->setTapButtonMapReturnValue == 0) {
|
|
|
|
if (device->tapFingerCount == 0) {
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
device->tapButtonMap = map;
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_tap_button_map libinput_device_config_tap_get_button_map(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->tapButtonMap;
|
|
|
|
}
|
|
|
|
|
2016-10-28 18:17:20 +00:00
|
|
|
uint32_t libinput_device_config_scroll_get_methods(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->supportedScrollMethods;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_scroll_method libinput_device_config_scroll_get_default_method(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->defaultScrollMethod;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_scroll_set_method(struct libinput_device *device, enum libinput_config_scroll_method method)
|
|
|
|
{
|
|
|
|
if (device->setScrollMethodReturnValue == 0) {
|
2016-11-03 16:51:32 +00:00
|
|
|
if (!(device->supportedScrollMethods & method) && method != LIBINPUT_CONFIG_SCROLL_NO_SCROLL) {
|
2016-10-28 18:17:20 +00:00
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
device->scrollMethod = method;
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_scroll_method libinput_device_config_scroll_get_method(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->scrollMethod;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_config_status libinput_device_config_scroll_set_button(struct libinput_device *device, uint32_t button)
|
|
|
|
{
|
|
|
|
if (device->setScrollButtonReturnValue == 0) {
|
|
|
|
if (!(device->supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)) {
|
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
device->scrollButton = button;
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t libinput_device_config_scroll_get_button(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->scrollButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t libinput_device_config_scroll_get_default_button(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->defaultScrollButton;
|
|
|
|
}
|
2017-12-27 16:57:00 +00:00
|
|
|
|
|
|
|
int libinput_device_switch_has_switch(struct libinput_device *device, enum libinput_switch sw)
|
|
|
|
{
|
|
|
|
switch (sw) {
|
|
|
|
case LIBINPUT_SWITCH_LID:
|
|
|
|
return device->lidSwitch;
|
|
|
|
case LIBINPUT_SWITCH_TABLET_MODE:
|
|
|
|
return device->tabletModeSwitch;
|
|
|
|
default:
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct libinput_event_switch *libinput_event_get_switch_event(struct libinput_event *event)
|
|
|
|
{
|
|
|
|
if (event->type == LIBINPUT_EVENT_SWITCH_TOGGLE) {
|
|
|
|
return reinterpret_cast<libinput_event_switch*>(event);
|
|
|
|
} else {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum libinput_switch_state libinput_event_switch_get_switch_state(struct libinput_event_switch *event)
|
|
|
|
{
|
|
|
|
switch (event->state) {
|
|
|
|
case libinput_event_switch::State::On:
|
|
|
|
return LIBINPUT_SWITCH_STATE_ON;
|
|
|
|
case libinput_event_switch::State::Off:
|
|
|
|
return LIBINPUT_SWITCH_STATE_OFF;
|
|
|
|
default:
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t libinput_event_switch_get_time(struct libinput_event_switch *event)
|
|
|
|
{
|
|
|
|
return event->time;;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t libinput_event_switch_get_time_usec(struct libinput_event_switch *event)
|
|
|
|
{
|
|
|
|
return event->timeMicroseconds;
|
|
|
|
}
|
2019-12-01 17:51:15 +00:00
|
|
|
|
|
|
|
struct libinput_event_tablet_pad *libinput_event_get_tablet_pad_event(struct libinput_event *event)
|
|
|
|
{
|
|
|
|
if (event->type == LIBINPUT_EVENT_TABLET_PAD_BUTTON) {
|
|
|
|
return reinterpret_cast<libinput_event_tablet_pad *>(event);
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct libinput_event_tablet_tool *
|
|
|
|
libinput_event_get_tablet_tool_event(struct libinput_event *event)
|
|
|
|
{
|
|
|
|
if (event->type == LIBINPUT_EVENT_TABLET_TOOL_AXIS ||
|
|
|
|
event->type == LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY ||
|
|
|
|
event->type == LIBINPUT_EVENT_TABLET_TOOL_TIP) {
|
|
|
|
return reinterpret_cast<libinput_event_tablet_tool *>(event);
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-03-17 14:21:35 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
libinput_device_tablet_pad_get_num_strips(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->stripCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
libinput_device_tablet_pad_get_num_rings(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->ringCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
libinput_device_tablet_pad_get_num_buttons(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
return device->buttonCount;
|
|
|
|
}
|
2021-01-07 01:56:19 +00:00
|
|
|
|
|
|
|
struct libinput_device_group *
|
|
|
|
libinput_device_get_device_group(struct libinput_device *device)
|
|
|
|
{
|
|
|
|
Q_UNUSED(device);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
libinput_device_group_get_user_data(struct libinput_device_group *group)
|
|
|
|
{
|
|
|
|
Q_UNUSED(group);
|
|
|
|
return nullptr;
|
|
|
|
}
|