2014-06-05 23:20:36 -04:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2014 Red Hat, Inc.
|
|
|
|
|
* Copyright © 2014 Stephen Chandler "Lyude" Paul
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef EVDEV_TABLET_H
|
|
|
|
|
#define EVDEV_TABLET_H
|
|
|
|
|
|
|
|
|
|
#include "evdev.h"
|
|
|
|
|
|
2015-02-10 11:29:34 +10:00
|
|
|
#define LIBINPUT_TABLET_AXIS_NONE 0
|
2015-02-19 10:59:46 +10:00
|
|
|
#define LIBINPUT_TOOL_NONE 0
|
2015-02-10 11:29:34 +10:00
|
|
|
|
2014-06-05 23:20:36 -04:00
|
|
|
enum tablet_status {
|
|
|
|
|
TABLET_NONE = 0,
|
2014-06-10 16:48:19 -04:00
|
|
|
TABLET_AXES_UPDATED = 1 << 0,
|
2014-06-26 21:31:52 -04:00
|
|
|
TABLET_BUTTONS_PRESSED = 1 << 1,
|
|
|
|
|
TABLET_BUTTONS_RELEASED = 1 << 2,
|
|
|
|
|
TABLET_STYLUS_IN_CONTACT = 1 << 3,
|
|
|
|
|
TABLET_TOOL_LEAVING_PROXIMITY = 1 << 4,
|
|
|
|
|
TABLET_TOOL_OUT_OF_PROXIMITY = 1 << 5,
|
|
|
|
|
TABLET_TOOL_ENTERING_PROXIMITY = 1 << 6
|
2014-06-10 23:14:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct button_state {
|
2015-02-19 15:46:29 +10:00
|
|
|
unsigned char stylus_buttons[NCHARS(KEY_CNT)];
|
2014-06-05 23:20:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct tablet_dispatch {
|
|
|
|
|
struct evdev_dispatch base;
|
|
|
|
|
struct evdev_device *device;
|
|
|
|
|
unsigned char status;
|
2015-02-10 11:29:34 +10:00
|
|
|
unsigned char changed_axes[NCHARS(LIBINPUT_TABLET_AXIS_MAX + 1)];
|
|
|
|
|
double axes[LIBINPUT_TABLET_AXIS_MAX + 1];
|
|
|
|
|
unsigned char axis_caps[NCHARS(LIBINPUT_TABLET_AXIS_MAX + 1)];
|
2014-06-10 16:48:19 -04:00
|
|
|
|
2014-08-07 19:00:52 -04:00
|
|
|
/* Only used for tablets that don't report serial numbers */
|
|
|
|
|
struct list tool_list;
|
|
|
|
|
|
2014-06-10 23:14:41 -04:00
|
|
|
struct button_state button_state;
|
|
|
|
|
struct button_state prev_button_state;
|
|
|
|
|
|
2014-06-10 16:48:19 -04:00
|
|
|
enum libinput_tool_type current_tool_type;
|
2015-02-19 14:56:34 +10:00
|
|
|
uint32_t current_tool_id;
|
2014-06-10 16:48:19 -04:00
|
|
|
uint32_t current_tool_serial;
|
2014-06-05 23:20:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static inline enum libinput_tablet_axis
|
|
|
|
|
evcode_to_axis(const uint32_t evcode)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_tablet_axis axis;
|
|
|
|
|
|
|
|
|
|
switch (evcode) {
|
|
|
|
|
case ABS_X:
|
|
|
|
|
axis = LIBINPUT_TABLET_AXIS_X;
|
|
|
|
|
break;
|
|
|
|
|
case ABS_Y:
|
|
|
|
|
axis = LIBINPUT_TABLET_AXIS_Y;
|
|
|
|
|
break;
|
2014-06-06 20:31:38 -04:00
|
|
|
case ABS_DISTANCE:
|
|
|
|
|
axis = LIBINPUT_TABLET_AXIS_DISTANCE;
|
|
|
|
|
break;
|
|
|
|
|
case ABS_PRESSURE:
|
|
|
|
|
axis = LIBINPUT_TABLET_AXIS_PRESSURE;
|
|
|
|
|
break;
|
|
|
|
|
case ABS_TILT_X:
|
2014-07-10 15:10:12 -04:00
|
|
|
axis = LIBINPUT_TABLET_AXIS_TILT_X;
|
2014-06-06 20:31:38 -04:00
|
|
|
break;
|
|
|
|
|
case ABS_TILT_Y:
|
2014-07-10 15:10:12 -04:00
|
|
|
axis = LIBINPUT_TABLET_AXIS_TILT_Y;
|
2014-06-06 20:31:38 -04:00
|
|
|
break;
|
2014-06-05 23:20:36 -04:00
|
|
|
default:
|
|
|
|
|
axis = LIBINPUT_TABLET_AXIS_NONE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return axis;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint32_t
|
|
|
|
|
axis_to_evcode(const enum libinput_tablet_axis axis)
|
|
|
|
|
{
|
|
|
|
|
uint32_t evcode;
|
|
|
|
|
|
|
|
|
|
switch (axis) {
|
|
|
|
|
case LIBINPUT_TABLET_AXIS_X:
|
|
|
|
|
evcode = ABS_X;
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_TABLET_AXIS_Y:
|
|
|
|
|
evcode = ABS_Y;
|
|
|
|
|
break;
|
2014-06-06 20:31:38 -04:00
|
|
|
case LIBINPUT_TABLET_AXIS_DISTANCE:
|
|
|
|
|
evcode = ABS_DISTANCE;
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_TABLET_AXIS_PRESSURE:
|
|
|
|
|
evcode = ABS_PRESSURE;
|
|
|
|
|
break;
|
2014-07-09 01:14:48 -04:00
|
|
|
case LIBINPUT_TABLET_AXIS_TILT_X:
|
2014-06-06 20:31:38 -04:00
|
|
|
evcode = ABS_TILT_X;
|
|
|
|
|
break;
|
2014-07-09 01:14:48 -04:00
|
|
|
case LIBINPUT_TABLET_AXIS_TILT_Y:
|
2014-06-06 20:31:38 -04:00
|
|
|
evcode = ABS_TILT_Y;
|
|
|
|
|
break;
|
2014-06-05 23:20:36 -04:00
|
|
|
default:
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return evcode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|