mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 16:10:06 +01:00
Some tablets such as those in the XP-PEN PRO series use "dials" which are actually scrollwheels and emit EV_REL events. These should not be emulated as rings (which are absolute) so we must expose them as a new tablet event. Adds LIBINPUT_EVENT_TABLET_PAD_DIAL that work largely identical as our high-resolution wheel events (i.e. the values are in multiples or fractions of of 120). Currently supports two dials. This is a lot of copy/paste from the ring axes because the interface is virtually identical. The main difference is that dials give us a v120 value in the same manner as our scroll axes. Notes: - REL_DIAL is mutually exclusive with REL_WHEEL, we assume the kernel doesn't (at this point) give us devices with both. If this changes for devices with three dials (wheel + hwheel + dial) we need to add code for that. - REL_DIAL does not have a high-resolution axis and we assume that any device with REL_WHEEL_HI_RES will also have REL_HWHEEL_HI_RES (if the second wheel exists). - With dials being REL_DIAL or REL_WHEEL there is no possibility of detecting a finger release (the kernel does not route EV_RELs with a value of zero). Unless this is implemented via a side-channel - and it doesn't look like any hardware that supports dials does that - we cannot forward any information here. So unlike absolute rings we cannot provide a source information here. Closes #600 Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/967>
177 lines
5.6 KiB
C
177 lines
5.6 KiB
C
/*
|
|
* Copyright © 2013 Red Hat, Inc.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include "config.h"
|
|
#include <limits.h>
|
|
|
|
#ifndef LITEST_INT_H
|
|
#define LITEST_INT_H
|
|
#include "litest.h"
|
|
|
|
/* Use as designater for litest to change the value */
|
|
#define LITEST_AUTO_ASSIGN INT_MIN
|
|
|
|
/* Special event code to auto-assign the BTN_TOOL_PEN and friends */
|
|
#define LITEST_BTN_TOOL_AUTO (KEY_MAX << 1)
|
|
|
|
struct litest_test_device {
|
|
struct list node; /* global test device list */
|
|
|
|
enum litest_device_type type;
|
|
int64_t features;
|
|
const char *shortname;
|
|
void (*setup)(void); /* test fixture, used by check */
|
|
void (*teardown)(void); /* test fixture, used by check */
|
|
/**
|
|
* If create is non-NULL it will be called to initialize the device.
|
|
* For such devices, no overrides are possible. If create is NULL,
|
|
* the information in name, id, events, absinfo is used to
|
|
* create the device instead.
|
|
*
|
|
* @return true if the device needs to be created by litest, false if
|
|
* the device creates itself
|
|
*/
|
|
bool (*create)(struct litest_device *d);
|
|
|
|
/**
|
|
* The device name. Only used when create is NULL.
|
|
*/
|
|
const char *name;
|
|
/**
|
|
* The device id. Only used when create is NULL.
|
|
*/
|
|
const struct input_id *id;
|
|
/**
|
|
* List of event type/code tuples, terminated with -1, e.g.
|
|
* EV_REL, REL_X, EV_KEY, BTN_LEFT, -1
|
|
* Special tuple is INPUT_PROP_MAX, <actual property> to set.
|
|
*
|
|
* Any EV_ABS codes in this list will be initialized with a default
|
|
* axis range.
|
|
*/
|
|
int *events;
|
|
/**
|
|
* List of abs codes to enable, with absinfo.value determining the
|
|
* code to set. List must be terminated with absinfo.value -1
|
|
*/
|
|
struct input_absinfo *absinfo;
|
|
struct litest_device_interface *interface;
|
|
|
|
const char *udev_rule;
|
|
const char *quirk_file;
|
|
|
|
const struct key_value_str udev_properties[32];
|
|
};
|
|
|
|
struct litest_device_interface {
|
|
bool (*touch_down)(struct litest_device *d, unsigned int slot, double x, double y);
|
|
bool (*touch_move)(struct litest_device *d, unsigned int slot, double x, double y);
|
|
bool (*touch_up)(struct litest_device *d, unsigned int slot);
|
|
|
|
/**
|
|
* Default value for the given EV_ABS axis.
|
|
* @return 0 on success, nonzero otherwise
|
|
*/
|
|
int (*get_axis_default)(struct litest_device *d, unsigned int code, int32_t *value);
|
|
|
|
/**
|
|
* Set of of events to execute on touch down, terminated by a .type
|
|
* and .code value of -1. If the event value is LITEST_AUTO_ASSIGN,
|
|
* it will be automatically assigned by the framework (valid for x,
|
|
* y, tracking id and slot).
|
|
*
|
|
* These events are only used if touch_down is NULL.
|
|
*/
|
|
struct input_event *touch_down_events;
|
|
struct input_event *touch_move_events;
|
|
struct input_event *touch_up_events;
|
|
|
|
/**
|
|
* Tablet events, LITEST_AUTO_ASSIGN is allowed on event values for
|
|
* ABS_X, ABS_Y, ABS_DISTANCE and ABS_PRESSURE.
|
|
*/
|
|
struct input_event *tablet_proximity_in_events;
|
|
struct input_event *tablet_proximity_out_events;
|
|
struct input_event *tablet_motion_events;
|
|
|
|
bool (*tablet_proximity_in)(struct litest_device *d,
|
|
unsigned int tool_type,
|
|
double *x, double *y,
|
|
struct axis_replacement *axes);
|
|
bool (*tablet_proximity_out)(struct litest_device *d, unsigned int tool_type);
|
|
bool (*tablet_tip_down)(struct litest_device *d,
|
|
double *x, double *y,
|
|
struct axis_replacement *axes);
|
|
bool (*tablet_tip_up)(struct litest_device *d,
|
|
double *x, double *y,
|
|
struct axis_replacement *axes);
|
|
bool (*tablet_motion)(struct litest_device *d,
|
|
double *x, double *y,
|
|
struct axis_replacement *axes);
|
|
|
|
/**
|
|
* Pad events, LITEST_AUTO_ASSIGN is allowed on event values
|
|
* for ABS_WHEEL
|
|
*/
|
|
struct input_event *pad_ring_start_events;
|
|
struct input_event *pad_ring_change_events;
|
|
struct input_event *pad_ring_end_events;
|
|
|
|
/**
|
|
* Pad events, LITEST_AUTO_ASSIGN is allowed on event values
|
|
* for ABS_WHEEL
|
|
*/
|
|
struct input_event *pad_dial_start_events;
|
|
struct input_event *pad_dial_change_events;
|
|
struct input_event *pad_dial_end_events;
|
|
|
|
/**
|
|
* Pad events, LITEST_AUTO_ASSIGN is allowed on event values
|
|
* for ABS_RX
|
|
*/
|
|
struct input_event *pad_strip_start_events;
|
|
struct input_event *pad_strip_change_events;
|
|
struct input_event *pad_strip_end_events;
|
|
|
|
int min[2]; /* x/y axis minimum */
|
|
int max[2]; /* x/y axis maximum */
|
|
|
|
unsigned int tool_type;
|
|
};
|
|
|
|
struct path {
|
|
struct list link;
|
|
char *path;
|
|
int fd;
|
|
};
|
|
|
|
struct litest_context {
|
|
struct litest_user_data *user_data;
|
|
struct list paths;
|
|
};
|
|
|
|
void litest_set_current_device(struct litest_device *device);
|
|
int litest_scale(const struct litest_device *d, unsigned int axis, double val);
|
|
void litest_generic_device_teardown(void);
|
|
|
|
#endif
|