mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-24 22:50:05 +01:00
Preparation work for a pressure threshold where we can't just send a BTN_TOUCH and expect it to trigger the tip event. So the event sequence now needs to resemble the right order so the threshold will be triggered. In some cases requires processing an axis event before the tip event. That behavior will be changed in a follow-up commit. It also requires that all tablets set ABS_PRESSURE on proximity in. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
241 lines
6.2 KiB
C
241 lines
6.2 KiB
C
/*
|
|
* Copyright © 2014 Red Hat, Inc.
|
|
*
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
* the above copyright notice appear in all copies and that both that copyright
|
|
* notice and this permission notice appear in supporting documentation, and
|
|
* that the name of the copyright holders not be used in advertising or
|
|
* publicity pertaining to distribution of the software without specific,
|
|
* written prior permission. The copyright holders make no representations
|
|
* about the suitability of this software for any purpose. It is provided "as
|
|
* is" without express or implied warranty.
|
|
*
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
* OF THIS SOFTWARE.
|
|
*/
|
|
|
|
#if HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include "litest.h"
|
|
#include "litest-int.h"
|
|
|
|
static void litest_waltop_tablet_setup(void)
|
|
{
|
|
struct litest_device *d = litest_create_device(LITEST_WALTOP);
|
|
litest_set_current_device(d);
|
|
}
|
|
|
|
static struct input_event proximity_in[] = {
|
|
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
|
|
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
|
|
{ .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
|
|
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
|
|
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
|
|
{ .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
|
|
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
|
|
{ .type = -1, .code = -1 },
|
|
};
|
|
|
|
static struct input_event proximity_out[] = {
|
|
{ .type = EV_ABS, .code = ABS_X, .value = 0 },
|
|
{ .type = EV_ABS, .code = ABS_Y, .value = 0 },
|
|
{ .type = EV_ABS, .code = ABS_TILT_X, .value = 0 },
|
|
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
|
|
{ .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
|
|
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
|
|
{ .type = -1, .code = -1 },
|
|
};
|
|
|
|
static struct input_event motion[] = {
|
|
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
|
|
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
|
|
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
|
|
{ .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
|
|
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
|
|
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
|
|
{ .type = -1, .code = -1 },
|
|
};
|
|
|
|
static int
|
|
get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
|
|
{
|
|
switch (evcode) {
|
|
case ABS_TILT_X:
|
|
case ABS_TILT_Y:
|
|
*value = 0;
|
|
return 0;
|
|
case ABS_PRESSURE:
|
|
*value = 100;
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static struct litest_device_interface interface = {
|
|
.tablet_proximity_in_events = proximity_in,
|
|
.tablet_proximity_out_events = proximity_out,
|
|
.tablet_motion_events = motion,
|
|
|
|
.get_axis_default = get_axis_default,
|
|
};
|
|
|
|
static struct input_absinfo absinfo[] = {
|
|
{ ABS_X, 0, 32000, 0, 0, 0 },
|
|
{ ABS_Y, 0, 32000, 0, 0, 0 },
|
|
{ ABS_PRESSURE, 0, 2047, 0, 0, 0 },
|
|
{ ABS_TILT_X, -127, 127, 0, 0, 0 },
|
|
{ ABS_TILT_Y, -127, 127, 0, 0, 0 },
|
|
{ .value = -1 },
|
|
};
|
|
|
|
static struct input_id input_id = {
|
|
.bustype = 0x3,
|
|
.vendor = 0x172f,
|
|
.product = 0x509,
|
|
};
|
|
|
|
static int events[] = {
|
|
EV_KEY, KEY_ESC,
|
|
EV_KEY, KEY_1,
|
|
EV_KEY, KEY_2,
|
|
EV_KEY, KEY_3,
|
|
EV_KEY, KEY_4,
|
|
EV_KEY, KEY_5,
|
|
EV_KEY, KEY_6,
|
|
EV_KEY, KEY_7,
|
|
EV_KEY, KEY_8,
|
|
EV_KEY, KEY_9,
|
|
EV_KEY, KEY_0,
|
|
EV_KEY, KEY_MINUS,
|
|
EV_KEY, KEY_EQUAL,
|
|
EV_KEY, KEY_BACKSPACE,
|
|
EV_KEY, KEY_TAB,
|
|
EV_KEY, KEY_Q,
|
|
EV_KEY, KEY_W,
|
|
EV_KEY, KEY_E,
|
|
EV_KEY, KEY_R,
|
|
EV_KEY, KEY_T,
|
|
EV_KEY, KEY_Y,
|
|
EV_KEY, KEY_U,
|
|
EV_KEY, KEY_I,
|
|
EV_KEY, KEY_O,
|
|
EV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
|
|
-1, -1,
|
|
};
|
|
|
|
struct litest_test_device litest_waltop_tablet_device = {
|
|
.type = LITEST_WALTOP,
|
|
.features = LITEST_TABLET | LITEST_WHEEL | LITEST_TILT,
|
|
.shortname = "waltop-tablet",
|
|
.setup = litest_waltop_tablet_setup,
|
|
.interface = &interface,
|
|
|
|
.name = " WALTOP Batteryless Tablet ", /* sic */
|
|
.id = &input_id,
|
|
.events = events,
|
|
.absinfo = absinfo,
|
|
};
|