mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 20:30:27 +01:00
Switch the fallback and touchpad backends to use struct evdev_event
These two use enough shared functions that they cannot be switched separatly. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1215>
This commit is contained in:
parent
41e988c99e
commit
4be243d0e7
12 changed files with 347 additions and 294 deletions
|
|
@ -173,12 +173,12 @@ debounce_notify_button(struct fallback_dispatch *fallback,
|
|||
enum libinput_button_state state)
|
||||
{
|
||||
struct evdev_device *device = fallback->device;
|
||||
unsigned int code = fallback->debounce.button_code;
|
||||
evdev_usage_t usage = fallback->debounce.button_usage;
|
||||
uint64_t time = fallback->debounce.button_time;
|
||||
|
||||
code = evdev_to_left_handed(device, code);
|
||||
usage = evdev_to_left_handed(device, usage);
|
||||
|
||||
fallback_notify_physical_button(fallback, device, time, code, state);
|
||||
fallback_notify_physical_button(fallback, device, time, usage, state);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -484,16 +484,17 @@ void
|
|||
fallback_debounce_handle_state(struct fallback_dispatch *dispatch,
|
||||
uint64_t time)
|
||||
{
|
||||
unsigned int changed[16] = {0}; /* event codes of changed buttons */
|
||||
evdev_usage_t changed[16] = {0}; /* usage of changed buttons */
|
||||
size_t nchanged = 0;
|
||||
bool flushed = false;
|
||||
|
||||
for (unsigned int code = 0; code <= KEY_MAX; code++) {
|
||||
if (get_key_type(code) != KEY_TYPE_BUTTON)
|
||||
for (uint32_t u = EVDEV_KEY_RESERVED; u <= EVDEV_KEY_MAX; u++) {
|
||||
evdev_usage_t usage = evdev_usage_from_uint32_t(u);
|
||||
if (get_key_type(usage) != KEY_TYPE_BUTTON)
|
||||
continue;
|
||||
|
||||
if (hw_key_has_changed(dispatch, code))
|
||||
changed[nchanged++] = code;
|
||||
if (hw_key_has_changed(dispatch, usage))
|
||||
changed[nchanged++] = usage;
|
||||
|
||||
/* If you manage to press more than 16 buttons in the same
|
||||
* frame, we just quietly ignore the rest of them */
|
||||
|
|
@ -504,7 +505,7 @@ fallback_debounce_handle_state(struct fallback_dispatch *dispatch,
|
|||
/* If we have more than one button this frame or a different button,
|
||||
* flush the state machine with otherbutton */
|
||||
if (nchanged > 1 ||
|
||||
changed[0] != dispatch->debounce.button_code) {
|
||||
evdev_usage_cmp(changed[0], dispatch->debounce.button_usage) != 0) {
|
||||
debounce_handle_event(dispatch,
|
||||
DEBOUNCE_EVENT_OTHERBUTTON,
|
||||
time);
|
||||
|
|
@ -530,7 +531,7 @@ fallback_debounce_handle_state(struct fallback_dispatch *dispatch,
|
|||
flushed = false;
|
||||
}
|
||||
|
||||
dispatch->debounce.button_code = changed[i];
|
||||
dispatch->debounce.button_usage = changed[i];
|
||||
debounce_handle_event(dispatch,
|
||||
is_down ?
|
||||
DEBOUNCE_EVENT_PRESS :
|
||||
|
|
|
|||
|
|
@ -35,16 +35,16 @@ static void
|
|||
fallback_keyboard_notify_key(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
uint64_t time,
|
||||
int key,
|
||||
evdev_usage_t usage,
|
||||
enum libinput_key_state state)
|
||||
{
|
||||
int down_count;
|
||||
|
||||
down_count = evdev_update_key_down_count(device, key, state);
|
||||
down_count = evdev_update_key_down_count(device, usage, state);
|
||||
|
||||
if ((state == LIBINPUT_KEY_STATE_PRESSED && down_count == 1) ||
|
||||
(state == LIBINPUT_KEY_STATE_RELEASED && down_count == 0))
|
||||
keyboard_notify_key(&device->base, time, key, state);
|
||||
keyboard_notify_key(&device->base, time, evdev_usage_code(usage), state);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -65,7 +65,7 @@ void
|
|||
fallback_notify_physical_button(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
uint64_t time,
|
||||
int button,
|
||||
evdev_usage_t button,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
evdev_pointer_notify_physical_button(device, time, button, state);
|
||||
|
|
@ -466,7 +466,7 @@ fallback_process_touch_button(struct fallback_dispatch *dispatch,
|
|||
static inline void
|
||||
fallback_process_key(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
struct input_event *e, uint64_t time)
|
||||
struct evdev_event *e, uint64_t time)
|
||||
{
|
||||
enum key_type type;
|
||||
|
||||
|
|
@ -474,7 +474,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
|
|||
if (e->value == 2)
|
||||
return;
|
||||
|
||||
if (e->code == BTN_TOUCH) {
|
||||
if (evdev_usage_eq(e->usage, EVDEV_BTN_TOUCH)) {
|
||||
if (!device->is_mt)
|
||||
fallback_process_touch_button(dispatch,
|
||||
device,
|
||||
|
|
@ -483,7 +483,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
|
|||
return;
|
||||
}
|
||||
|
||||
type = get_key_type(e->code);
|
||||
type = get_key_type(e->usage);
|
||||
|
||||
/* Ignore key release events from the kernel for keys that libinput
|
||||
* never got a pressed event for or key presses for keys that we
|
||||
|
|
@ -493,15 +493,15 @@ fallback_process_key(struct fallback_dispatch *dispatch,
|
|||
break;
|
||||
case KEY_TYPE_KEY:
|
||||
case KEY_TYPE_BUTTON:
|
||||
if ((e->value && hw_is_key_down(dispatch, e->code)) ||
|
||||
(e->value == 0 && !hw_is_key_down(dispatch, e->code)))
|
||||
if ((e->value && hw_is_key_down(dispatch, e->usage)) ||
|
||||
(e->value == 0 && !hw_is_key_down(dispatch, e->usage)))
|
||||
return;
|
||||
|
||||
dispatch->pending_event |= EVDEV_KEY;
|
||||
break;
|
||||
}
|
||||
|
||||
hw_set_key_down(dispatch, e->code, e->value);
|
||||
hw_set_key_down(dispatch, e->usage, e->value);
|
||||
|
||||
switch (type) {
|
||||
case KEY_TYPE_NONE:
|
||||
|
|
@ -511,7 +511,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
|
|||
dispatch,
|
||||
device,
|
||||
time,
|
||||
e->code,
|
||||
e->usage,
|
||||
e->value ? LIBINPUT_KEY_STATE_PRESSED :
|
||||
LIBINPUT_KEY_STATE_RELEASED);
|
||||
break;
|
||||
|
|
@ -523,12 +523,13 @@ fallback_process_key(struct fallback_dispatch *dispatch,
|
|||
static void
|
||||
fallback_process_touch(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
struct input_event *e,
|
||||
struct evdev_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
struct mt_slot *slot = &dispatch->mt.slots[dispatch->mt.slot];
|
||||
|
||||
if (e->code == ABS_MT_SLOT) {
|
||||
switch (evdev_usage_enum(e->usage)) {
|
||||
case EVDEV_ABS_MT_SLOT:
|
||||
if ((size_t)e->value >= dispatch->mt.slots_len) {
|
||||
evdev_log_bug_libinput(device,
|
||||
"exceeded slot count (%d of max %zd)\n",
|
||||
|
|
@ -538,10 +539,7 @@ fallback_process_touch(struct fallback_dispatch *dispatch,
|
|||
}
|
||||
dispatch->mt.slot = e->value;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (e->code) {
|
||||
case ABS_MT_TRACKING_ID:
|
||||
case EVDEV_ABS_MT_TRACKING_ID:
|
||||
if (e->value >= 0) {
|
||||
dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
|
||||
slot->state = SLOT_STATE_BEGIN;
|
||||
|
|
@ -568,19 +566,19 @@ fallback_process_touch(struct fallback_dispatch *dispatch,
|
|||
}
|
||||
slot->dirty = true;
|
||||
break;
|
||||
case ABS_MT_POSITION_X:
|
||||
evdev_device_check_abs_axis_range(device, e->code, e->value);
|
||||
case EVDEV_ABS_MT_POSITION_X:
|
||||
evdev_device_check_abs_axis_range(device, e->usage, e->value);
|
||||
dispatch->mt.slots[dispatch->mt.slot].point.x = e->value;
|
||||
dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
|
||||
slot->dirty = true;
|
||||
break;
|
||||
case ABS_MT_POSITION_Y:
|
||||
evdev_device_check_abs_axis_range(device, e->code, e->value);
|
||||
case EVDEV_ABS_MT_POSITION_Y:
|
||||
evdev_device_check_abs_axis_range(device, e->usage, e->value);
|
||||
dispatch->mt.slots[dispatch->mt.slot].point.y = e->value;
|
||||
dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
|
||||
slot->dirty = true;
|
||||
break;
|
||||
case ABS_MT_TOOL_TYPE:
|
||||
case EVDEV_ABS_MT_TOOL_TYPE:
|
||||
/* The transitions matter - we (may) need to send a touch
|
||||
* cancel event if we just switched to a palm touch. And the
|
||||
* kernel may switch back to finger but we keep the touch as
|
||||
|
|
@ -600,25 +598,29 @@ fallback_process_touch(struct fallback_dispatch *dispatch,
|
|||
dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
|
||||
slot->dirty = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
fallback_process_absolute_motion(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
struct input_event *e)
|
||||
struct evdev_event *e)
|
||||
{
|
||||
switch (e->code) {
|
||||
case ABS_X:
|
||||
evdev_device_check_abs_axis_range(device, e->code, e->value);
|
||||
switch (evdev_usage_enum(e->usage)) {
|
||||
case EVDEV_ABS_X:
|
||||
evdev_device_check_abs_axis_range(device, e->usage, e->value);
|
||||
dispatch->abs.point.x = e->value;
|
||||
dispatch->pending_event |= EVDEV_ABSOLUTE_MOTION;
|
||||
break;
|
||||
case ABS_Y:
|
||||
evdev_device_check_abs_axis_range(device, e->code, e->value);
|
||||
case EVDEV_ABS_Y:
|
||||
evdev_device_check_abs_axis_range(device, e->usage, e->value);
|
||||
dispatch->abs.point.y = e->value;
|
||||
dispatch->pending_event |= EVDEV_ABSOLUTE_MOTION;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -701,7 +703,7 @@ fallback_lid_toggle_keyboard_listeners(struct fallback_dispatch *dispatch,
|
|||
static inline void
|
||||
fallback_process_switch(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
struct input_event *e,
|
||||
struct evdev_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
enum libinput_switch_state state;
|
||||
|
|
@ -709,8 +711,8 @@ fallback_process_switch(struct fallback_dispatch *dispatch,
|
|||
|
||||
/* TODO: this should to move to handle_state */
|
||||
|
||||
switch (e->code) {
|
||||
case SW_LID:
|
||||
switch (evdev_usage_enum(e->usage)) {
|
||||
case EVDEV_SW_LID:
|
||||
is_closed = !!e->value;
|
||||
|
||||
fallback_lid_toggle_keyboard_listeners(dispatch, is_closed);
|
||||
|
|
@ -721,7 +723,7 @@ fallback_process_switch(struct fallback_dispatch *dispatch,
|
|||
dispatch->lid.is_closed = is_closed;
|
||||
fallback_lid_notify_toggle(dispatch, device, time);
|
||||
break;
|
||||
case SW_TABLET_MODE:
|
||||
case EVDEV_SW_TABLET_MODE:
|
||||
if (dispatch->tablet_mode.sw.state == e->value)
|
||||
return;
|
||||
|
||||
|
|
@ -735,42 +737,51 @@ fallback_process_switch(struct fallback_dispatch *dispatch,
|
|||
LIBINPUT_SWITCH_TABLET_MODE,
|
||||
state);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool
|
||||
fallback_reject_relative(struct evdev_device *device,
|
||||
const struct input_event *e,
|
||||
const struct evdev_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
if ((e->code == REL_X || e->code == REL_Y) &&
|
||||
(device->seat_caps & EVDEV_DEVICE_POINTER) == 0) {
|
||||
evdev_log_bug_libinput_ratelimit(device,
|
||||
&device->nonpointer_rel_limit,
|
||||
"REL_X/Y from a non-pointer device\n");
|
||||
return true;
|
||||
switch (evdev_usage_enum(e->usage)) {
|
||||
case EVDEV_REL_X:
|
||||
case EVDEV_REL_Y:
|
||||
if ((device->seat_caps & EVDEV_DEVICE_POINTER) == 0) {
|
||||
evdev_log_bug_libinput_ratelimit(device,
|
||||
&device->nonpointer_rel_limit,
|
||||
"REL_X/Y from a non-pointer device\n");
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void
|
||||
fallback_process_relative(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
struct input_event *e, uint64_t time)
|
||||
struct evdev_event *e, uint64_t time)
|
||||
{
|
||||
if (fallback_reject_relative(device, e, time))
|
||||
return;
|
||||
|
||||
switch (e->code) {
|
||||
case REL_X:
|
||||
switch (evdev_usage_enum(e->usage)) {
|
||||
case EVDEV_REL_X:
|
||||
dispatch->rel.x += e->value;
|
||||
dispatch->pending_event |= EVDEV_RELATIVE_MOTION;
|
||||
break;
|
||||
case REL_Y:
|
||||
case EVDEV_REL_Y:
|
||||
dispatch->rel.y += e->value;
|
||||
dispatch->pending_event |= EVDEV_RELATIVE_MOTION;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
fallback_wheel_process_relative(dispatch, device, e, time);
|
||||
|
|
@ -779,7 +790,7 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
|
|||
static inline void
|
||||
fallback_process_absolute(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
struct input_event *e,
|
||||
struct evdev_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
if (device->is_mt) {
|
||||
|
|
@ -793,11 +804,13 @@ static inline bool
|
|||
fallback_any_button_down(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device)
|
||||
{
|
||||
unsigned int button;
|
||||
|
||||
for (button = BTN_LEFT; button < BTN_JOYSTICK; button++) {
|
||||
if (libevdev_has_event_code(device->evdev, EV_KEY, button) &&
|
||||
hw_is_key_down(dispatch, button))
|
||||
uint32_t button;
|
||||
for (button = EVDEV_BTN_LEFT; button < EVDEV_BTN_JOYSTICK; button++) {
|
||||
evdev_usage_t usage = evdev_usage_from_uint32_t(button);
|
||||
if (libevdev_has_event_code(device->evdev,
|
||||
EV_KEY,
|
||||
evdev_usage_code(usage)) &&
|
||||
hw_is_key_down(dispatch, usage))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -942,11 +955,12 @@ fallback_handle_state(struct fallback_dispatch *dispatch,
|
|||
/* Buttons and keys */
|
||||
if (dispatch->pending_event & EVDEV_KEY) {
|
||||
bool want_debounce = false;
|
||||
for (unsigned int code = 0; code <= KEY_MAX; code++) {
|
||||
if (!hw_key_has_changed(dispatch, code))
|
||||
for (uint32_t u = EVDEV_KEY_RESERVED; u <= EVDEV_KEY_MAX; u++) {
|
||||
evdev_usage_t usage = evdev_usage_from_uint32_t(u);
|
||||
if (!hw_key_has_changed(dispatch, usage))
|
||||
continue;
|
||||
|
||||
if (get_key_type(code) == KEY_TYPE_BUTTON) {
|
||||
if (get_key_type(usage) == KEY_TYPE_BUTTON) {
|
||||
want_debounce = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -964,12 +978,14 @@ fallback_handle_state(struct fallback_dispatch *dispatch,
|
|||
static void
|
||||
fallback_interface_process(struct evdev_dispatch *evdev_dispatch,
|
||||
struct evdev_device *device,
|
||||
struct input_event *event,
|
||||
struct input_event *input_event,
|
||||
uint64_t time)
|
||||
{
|
||||
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
||||
static bool warned = false;
|
||||
|
||||
struct evdev_event event = evdev_event_from_input_event(input_event, NULL);
|
||||
|
||||
if (dispatch->arbitration.in_arbitration) {
|
||||
if (!warned) {
|
||||
evdev_log_debug(device, "dropping events due to touch arbitration\n");
|
||||
|
|
@ -980,18 +996,19 @@ fallback_interface_process(struct evdev_dispatch *evdev_dispatch,
|
|||
|
||||
warned = false;
|
||||
|
||||
switch (event->type) {
|
||||
uint16_t type = evdev_event_type(&event);
|
||||
switch (type) {
|
||||
case EV_REL:
|
||||
fallback_process_relative(dispatch, device, event, time);
|
||||
fallback_process_relative(dispatch, device, &event, time);
|
||||
break;
|
||||
case EV_ABS:
|
||||
fallback_process_absolute(dispatch, device, event, time);
|
||||
fallback_process_absolute(dispatch, device, &event, time);
|
||||
break;
|
||||
case EV_KEY:
|
||||
fallback_process_key(dispatch, device, event, time);
|
||||
fallback_process_key(dispatch, device, &event, time);
|
||||
break;
|
||||
case EV_SW:
|
||||
fallback_process_switch(dispatch, device, event, time);
|
||||
fallback_process_switch(dispatch, device, &event, time);
|
||||
break;
|
||||
case EV_SYN:
|
||||
fallback_handle_state(dispatch, device, time);
|
||||
|
|
@ -1038,10 +1055,9 @@ release_pressed_keys(struct fallback_dispatch *dispatch,
|
|||
struct evdev_device *device,
|
||||
uint64_t time)
|
||||
{
|
||||
int code;
|
||||
|
||||
for (code = 0; code < KEY_CNT; code++) {
|
||||
int count = get_key_down_count(device, code);
|
||||
for (uint32_t u = EVDEV_KEY_RESERVED; u <= EVDEV_KEY_MAX; u++) {
|
||||
evdev_usage_t usage = evdev_usage_from_uint32_t(u);
|
||||
int count = get_key_down_count(device, usage);
|
||||
|
||||
if (count == 0)
|
||||
continue;
|
||||
|
|
@ -1049,11 +1065,11 @@ release_pressed_keys(struct fallback_dispatch *dispatch,
|
|||
if (count > 1) {
|
||||
evdev_log_bug_libinput(device,
|
||||
"key %d is down %d times.\n",
|
||||
code,
|
||||
u,
|
||||
count);
|
||||
}
|
||||
|
||||
switch (get_key_type(code)) {
|
||||
switch (get_key_type(usage)) {
|
||||
case KEY_TYPE_NONE:
|
||||
break;
|
||||
case KEY_TYPE_KEY:
|
||||
|
|
@ -1061,7 +1077,7 @@ release_pressed_keys(struct fallback_dispatch *dispatch,
|
|||
dispatch,
|
||||
device,
|
||||
time,
|
||||
code,
|
||||
usage,
|
||||
LIBINPUT_KEY_STATE_RELEASED);
|
||||
break;
|
||||
case KEY_TYPE_BUTTON:
|
||||
|
|
@ -1073,16 +1089,16 @@ release_pressed_keys(struct fallback_dispatch *dispatch,
|
|||
evdev_pointer_notify_button(
|
||||
device,
|
||||
time,
|
||||
code,
|
||||
usage,
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
break;
|
||||
}
|
||||
|
||||
count = get_key_down_count(device, code);
|
||||
count = get_key_down_count(device, usage);
|
||||
if (count != 0) {
|
||||
evdev_log_bug_libinput(device,
|
||||
"releasing key %d failed.\n",
|
||||
code);
|
||||
evdev_usage_enum(usage));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1457,7 +1473,7 @@ fallback_change_scroll_method(struct evdev_device *device)
|
|||
struct fallback_dispatch *dispatch = fallback_dispatch(device->dispatch);
|
||||
|
||||
if (device->scroll.want_method == device->scroll.method &&
|
||||
device->scroll.want_button == device->scroll.button &&
|
||||
evdev_usage_cmp(device->scroll.want_button, device->scroll.button) == 0 &&
|
||||
device->scroll.want_lock_enabled == device->scroll.lock_enabled)
|
||||
return;
|
||||
|
||||
|
|
@ -1683,7 +1699,7 @@ fallback_dispatch_create(struct libinput_device *libinput_device)
|
|||
evdev_init_left_handed(device,
|
||||
fallback_change_to_left_handed);
|
||||
|
||||
if (device->scroll.want_button)
|
||||
if (evdev_usage_enum(device->scroll.want_button))
|
||||
evdev_init_button_scroll(device,
|
||||
fallback_change_scroll_method);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#define EVDEV_FALLBACK_H
|
||||
|
||||
#include "evdev.h"
|
||||
#include "util-input-event.h"
|
||||
|
||||
enum debounce_state {
|
||||
DEBOUNCE_STATE_IS_UP = 100,
|
||||
|
|
@ -142,7 +143,7 @@ struct fallback_dispatch {
|
|||
enum evdev_event_type pending_event;
|
||||
|
||||
struct {
|
||||
unsigned int button_code;
|
||||
evdev_usage_t button_usage;
|
||||
uint64_t button_time;
|
||||
struct libinput_timer timer;
|
||||
struct libinput_timer timer_short;
|
||||
|
|
@ -190,49 +191,59 @@ enum key_type {
|
|||
};
|
||||
|
||||
static inline enum key_type
|
||||
get_key_type(uint16_t code)
|
||||
get_key_type(evdev_usage_t evdev_usage)
|
||||
{
|
||||
switch (code) {
|
||||
case BTN_TOOL_PEN:
|
||||
case BTN_TOOL_RUBBER:
|
||||
case BTN_TOOL_BRUSH:
|
||||
case BTN_TOOL_PENCIL:
|
||||
case BTN_TOOL_AIRBRUSH:
|
||||
case BTN_TOOL_MOUSE:
|
||||
case BTN_TOOL_LENS:
|
||||
case BTN_TOOL_QUINTTAP:
|
||||
case BTN_TOOL_DOUBLETAP:
|
||||
case BTN_TOOL_TRIPLETAP:
|
||||
case BTN_TOOL_QUADTAP:
|
||||
case BTN_TOOL_FINGER:
|
||||
case BTN_TOUCH:
|
||||
switch (evdev_usage_enum(evdev_usage)) {
|
||||
case EVDEV_BTN_TOOL_PEN:
|
||||
case EVDEV_BTN_TOOL_RUBBER:
|
||||
case EVDEV_BTN_TOOL_BRUSH:
|
||||
case EVDEV_BTN_TOOL_PENCIL:
|
||||
case EVDEV_BTN_TOOL_AIRBRUSH:
|
||||
case EVDEV_BTN_TOOL_MOUSE:
|
||||
case EVDEV_BTN_TOOL_LENS:
|
||||
case EVDEV_BTN_TOOL_QUINTTAP:
|
||||
case EVDEV_BTN_TOOL_DOUBLETAP:
|
||||
case EVDEV_BTN_TOOL_TRIPLETAP:
|
||||
case EVDEV_BTN_TOOL_QUADTAP:
|
||||
case EVDEV_BTN_TOOL_FINGER:
|
||||
case EVDEV_BTN_TOUCH:
|
||||
return KEY_TYPE_NONE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (code >= KEY_ESC && code <= KEY_MICMUTE)
|
||||
enum evdev_usage usage = evdev_usage_enum(evdev_usage);
|
||||
if (usage >= EVDEV_KEY_ESC && usage <= EVDEV_KEY_MICMUTE)
|
||||
return KEY_TYPE_KEY;
|
||||
if (code >= BTN_MISC && code <= BTN_GEAR_UP)
|
||||
if (usage >= EVDEV_BTN_MISC && usage <= EVDEV_BTN_GEAR_UP)
|
||||
return KEY_TYPE_BUTTON;
|
||||
if (code >= KEY_OK && code <= KEY_LIGHTS_TOGGLE)
|
||||
if (usage >= EVDEV_KEY_OK && usage <= EVDEV_KEY_LIGHTS_TOGGLE)
|
||||
return KEY_TYPE_KEY;
|
||||
if (code >= BTN_DPAD_UP && code <= BTN_DPAD_RIGHT)
|
||||
if (usage >= EVDEV_BTN_DPAD_UP && usage <= EVDEV_BTN_DPAD_RIGHT)
|
||||
return KEY_TYPE_BUTTON;
|
||||
if (code >= KEY_ALS_TOGGLE && code < BTN_TRIGGER_HAPPY)
|
||||
if (usage >= EVDEV_KEY_ALS_TOGGLE && usage < EVDEV_BTN_TRIGGER_HAPPY)
|
||||
return KEY_TYPE_KEY;
|
||||
if (code >= BTN_TRIGGER_HAPPY && code <= BTN_TRIGGER_HAPPY40)
|
||||
if (usage >= EVDEV_BTN_TRIGGER_HAPPY && usage <= EVDEV_BTN_TRIGGER_HAPPY40)
|
||||
return KEY_TYPE_BUTTON;
|
||||
|
||||
return KEY_TYPE_NONE;
|
||||
}
|
||||
|
||||
static inline void
|
||||
hw_set_key_down(struct fallback_dispatch *dispatch, int code, int pressed)
|
||||
hw_set_key_down(struct fallback_dispatch *dispatch, evdev_usage_t usage, int pressed)
|
||||
{
|
||||
assert(evdev_usage_type(usage) == EV_KEY);
|
||||
|
||||
unsigned int code = evdev_usage_code(usage);
|
||||
long_set_bit_state(dispatch->hw_key_mask, code, pressed);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
hw_key_has_changed(struct fallback_dispatch *dispatch, int code)
|
||||
hw_key_has_changed(struct fallback_dispatch *dispatch, evdev_usage_t usage)
|
||||
{
|
||||
assert(evdev_usage_type(usage) == EV_KEY);
|
||||
|
||||
unsigned int code = evdev_usage_code(usage);
|
||||
return long_bit_is_set(dispatch->hw_key_mask, code) !=
|
||||
long_bit_is_set(dispatch->last_hw_key_mask, code);
|
||||
}
|
||||
|
|
@ -250,14 +261,18 @@ hw_key_update_last_state(struct fallback_dispatch *dispatch)
|
|||
}
|
||||
|
||||
static inline bool
|
||||
hw_is_key_down(struct fallback_dispatch *dispatch, int code)
|
||||
hw_is_key_down(struct fallback_dispatch *dispatch, evdev_usage_t usage)
|
||||
{
|
||||
assert(evdev_usage_type(usage) == EV_KEY);
|
||||
unsigned int code = evdev_usage_code(usage);
|
||||
return long_bit_is_set(dispatch->hw_key_mask, code);
|
||||
}
|
||||
|
||||
static inline int
|
||||
get_key_down_count(struct evdev_device *device, int code)
|
||||
get_key_down_count(struct evdev_device *device, evdev_usage_t usage)
|
||||
{
|
||||
assert(evdev_usage_type(usage) == EV_KEY);
|
||||
unsigned int code = evdev_usage_code(usage);
|
||||
return device->key_count[code];
|
||||
}
|
||||
|
||||
|
|
@ -268,7 +283,7 @@ void
|
|||
fallback_notify_physical_button(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
uint64_t time,
|
||||
int button,
|
||||
evdev_usage_t button,
|
||||
enum libinput_button_state state);
|
||||
|
||||
void
|
||||
|
|
@ -278,7 +293,7 @@ fallback_init_wheel(struct fallback_dispatch *dispatch,
|
|||
void
|
||||
fallback_wheel_process_relative(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
struct input_event *e, uint64_t time);
|
||||
struct evdev_event *e, uint64_t time);
|
||||
|
||||
void
|
||||
fallback_wheel_handle_state(struct fallback_dispatch *dispatch,
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ middlebutton_set_state(struct evdev_device *device,
|
|||
static void
|
||||
middlebutton_post_event(struct evdev_device *device,
|
||||
uint64_t now,
|
||||
int button,
|
||||
evdev_usage_t button,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
evdev_pointer_notify_button(device,
|
||||
|
|
@ -175,13 +175,13 @@ evdev_middlebutton_ldown_handle_event(struct evdev_device *device,
|
|||
break;
|
||||
case MIDDLEBUTTON_EVENT_R_DOWN:
|
||||
middlebutton_post_event(device, time,
|
||||
BTN_MIDDLE,
|
||||
evdev_usage_from(EVDEV_BTN_MIDDLE),
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
middlebutton_set_state(device, MIDDLEBUTTON_MIDDLE, time);
|
||||
break;
|
||||
case MIDDLEBUTTON_EVENT_OTHER:
|
||||
middlebutton_post_event(device, time,
|
||||
BTN_LEFT,
|
||||
evdev_usage_from(EVDEV_BTN_LEFT),
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
middlebutton_set_state(device,
|
||||
MIDDLEBUTTON_PASSTHROUGH,
|
||||
|
|
@ -193,17 +193,17 @@ evdev_middlebutton_ldown_handle_event(struct evdev_device *device,
|
|||
case MIDDLEBUTTON_EVENT_L_UP:
|
||||
middlebutton_post_event(device,
|
||||
device->middlebutton.first_event_time,
|
||||
BTN_LEFT,
|
||||
evdev_usage_from(EVDEV_BTN_LEFT),
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
middlebutton_post_event(device, time,
|
||||
BTN_LEFT,
|
||||
evdev_usage_from(EVDEV_BTN_LEFT),
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
middlebutton_set_state(device, MIDDLEBUTTON_IDLE, time);
|
||||
break;
|
||||
case MIDDLEBUTTON_EVENT_TIMEOUT:
|
||||
middlebutton_post_event(device,
|
||||
device->middlebutton.first_event_time,
|
||||
BTN_LEFT,
|
||||
evdev_usage_from(EVDEV_BTN_LEFT),
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
middlebutton_set_state(device,
|
||||
MIDDLEBUTTON_PASSTHROUGH,
|
||||
|
|
@ -225,7 +225,7 @@ evdev_middlebutton_rdown_handle_event(struct evdev_device *device,
|
|||
switch (event) {
|
||||
case MIDDLEBUTTON_EVENT_L_DOWN:
|
||||
middlebutton_post_event(device, time,
|
||||
BTN_MIDDLE,
|
||||
evdev_usage_from(EVDEV_BTN_MIDDLE),
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
middlebutton_set_state(device, MIDDLEBUTTON_MIDDLE, time);
|
||||
break;
|
||||
|
|
@ -235,7 +235,7 @@ evdev_middlebutton_rdown_handle_event(struct evdev_device *device,
|
|||
case MIDDLEBUTTON_EVENT_OTHER:
|
||||
middlebutton_post_event(device,
|
||||
device->middlebutton.first_event_time,
|
||||
BTN_RIGHT,
|
||||
evdev_usage_from(EVDEV_BTN_RIGHT),
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
middlebutton_set_state(device,
|
||||
MIDDLEBUTTON_PASSTHROUGH,
|
||||
|
|
@ -244,10 +244,10 @@ evdev_middlebutton_rdown_handle_event(struct evdev_device *device,
|
|||
case MIDDLEBUTTON_EVENT_R_UP:
|
||||
middlebutton_post_event(device,
|
||||
device->middlebutton.first_event_time,
|
||||
BTN_RIGHT,
|
||||
evdev_usage_from(EVDEV_BTN_RIGHT),
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
middlebutton_post_event(device, time,
|
||||
BTN_RIGHT,
|
||||
evdev_usage_from(EVDEV_BTN_RIGHT),
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
middlebutton_set_state(device, MIDDLEBUTTON_IDLE, time);
|
||||
break;
|
||||
|
|
@ -257,7 +257,7 @@ evdev_middlebutton_rdown_handle_event(struct evdev_device *device,
|
|||
case MIDDLEBUTTON_EVENT_TIMEOUT:
|
||||
middlebutton_post_event(device,
|
||||
device->middlebutton.first_event_time,
|
||||
BTN_RIGHT,
|
||||
evdev_usage_from(EVDEV_BTN_RIGHT),
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
middlebutton_set_state(device,
|
||||
MIDDLEBUTTON_PASSTHROUGH,
|
||||
|
|
@ -283,13 +283,13 @@ evdev_middlebutton_middle_handle_event(struct evdev_device *device,
|
|||
break;
|
||||
case MIDDLEBUTTON_EVENT_OTHER:
|
||||
middlebutton_post_event(device, time,
|
||||
BTN_MIDDLE,
|
||||
evdev_usage_from(EVDEV_BTN_MIDDLE),
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
middlebutton_set_state(device, MIDDLEBUTTON_IGNORE_LR, time);
|
||||
return 0;
|
||||
case MIDDLEBUTTON_EVENT_R_UP:
|
||||
middlebutton_post_event(device, time,
|
||||
BTN_MIDDLE,
|
||||
evdev_usage_from(EVDEV_BTN_MIDDLE),
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
middlebutton_set_state(device,
|
||||
MIDDLEBUTTON_LEFT_UP_PENDING,
|
||||
|
|
@ -297,7 +297,7 @@ evdev_middlebutton_middle_handle_event(struct evdev_device *device,
|
|||
break;
|
||||
case MIDDLEBUTTON_EVENT_L_UP:
|
||||
middlebutton_post_event(device, time,
|
||||
BTN_MIDDLE,
|
||||
evdev_usage_from(EVDEV_BTN_MIDDLE),
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
middlebutton_set_state(device,
|
||||
MIDDLEBUTTON_RIGHT_UP_PENDING,
|
||||
|
|
@ -325,7 +325,7 @@ evdev_middlebutton_lup_pending_handle_event(struct evdev_device *device,
|
|||
break;
|
||||
case MIDDLEBUTTON_EVENT_R_DOWN:
|
||||
middlebutton_post_event(device, time,
|
||||
BTN_MIDDLE,
|
||||
evdev_usage_from(EVDEV_BTN_MIDDLE),
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
middlebutton_set_state(device, MIDDLEBUTTON_MIDDLE, time);
|
||||
break;
|
||||
|
|
@ -357,7 +357,7 @@ evdev_middlebutton_rup_pending_handle_event(struct evdev_device *device,
|
|||
switch (event) {
|
||||
case MIDDLEBUTTON_EVENT_L_DOWN:
|
||||
middlebutton_post_event(device, time,
|
||||
BTN_MIDDLE,
|
||||
evdev_usage_from(EVDEV_BTN_MIDDLE),
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
middlebutton_set_state(device, MIDDLEBUTTON_MIDDLE, time);
|
||||
break;
|
||||
|
|
@ -577,26 +577,26 @@ evdev_middlebutton_apply_config(struct evdev_device *device)
|
|||
bool
|
||||
evdev_middlebutton_filter_button(struct evdev_device *device,
|
||||
uint64_t time,
|
||||
int button,
|
||||
evdev_usage_t button,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
enum evdev_middlebutton_event event;
|
||||
bool is_press = state == LIBINPUT_BUTTON_STATE_PRESSED;
|
||||
int rc;
|
||||
unsigned int btnbit = (button - BTN_LEFT);
|
||||
unsigned int btnbit = (evdev_usage_enum(button) - EVDEV_BTN_LEFT);
|
||||
uint32_t old_mask = 0;
|
||||
|
||||
if (!device->middlebutton.enabled)
|
||||
return false;
|
||||
|
||||
switch (button) {
|
||||
case BTN_LEFT:
|
||||
switch (evdev_usage_enum(button)) {
|
||||
case EVDEV_BTN_LEFT:
|
||||
if (is_press)
|
||||
event = MIDDLEBUTTON_EVENT_L_DOWN;
|
||||
else
|
||||
event = MIDDLEBUTTON_EVENT_L_UP;
|
||||
break;
|
||||
case BTN_RIGHT:
|
||||
case EVDEV_BTN_RIGHT:
|
||||
if (is_press)
|
||||
event = MIDDLEBUTTON_EVENT_R_DOWN;
|
||||
else
|
||||
|
|
@ -605,18 +605,17 @@ evdev_middlebutton_filter_button(struct evdev_device *device,
|
|||
|
||||
/* BTN_MIDDLE counts as "other" and resets middle button
|
||||
* emulation */
|
||||
case BTN_MIDDLE:
|
||||
case EVDEV_BTN_MIDDLE:
|
||||
default:
|
||||
event = MIDDLEBUTTON_EVENT_OTHER;
|
||||
break;
|
||||
}
|
||||
|
||||
if (button < BTN_LEFT ||
|
||||
if (evdev_usage_lt(button, EVDEV_BTN_LEFT) ||
|
||||
btnbit >= sizeof(device->middlebutton.button_mask) * 8) {
|
||||
evdev_log_bug_libinput(device,
|
||||
"Button mask too small for %s\n",
|
||||
libevdev_event_code_get_name(EV_KEY,
|
||||
button));
|
||||
evdev_usage_code_name(button));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -589,16 +589,16 @@ tp_button_handle_timeout(uint64_t now, void *data)
|
|||
|
||||
void
|
||||
tp_process_button(struct tp_dispatch *tp,
|
||||
const struct input_event *e,
|
||||
const struct evdev_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
uint32_t mask = bit(e->code - BTN_LEFT);
|
||||
uint32_t mask = bit(evdev_usage_enum(e->usage) - EVDEV_BTN_LEFT);
|
||||
|
||||
/* Ignore other buttons on clickpads */
|
||||
if (tp->buttons.is_clickpad && e->code != BTN_LEFT) {
|
||||
if (tp->buttons.is_clickpad && evdev_usage_ne(e->usage, EVDEV_BTN_LEFT)) {
|
||||
evdev_log_bug_kernel(tp->device,
|
||||
"received %s button event on a clickpad\n",
|
||||
libevdev_event_code_get_name(EV_KEY, e->code));
|
||||
evdev_event_get_code_name(e));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1079,20 +1079,21 @@ tp_post_physical_buttons(struct tp_dispatch *tp, uint64_t time)
|
|||
|
||||
current = tp->buttons.state;
|
||||
old = tp->buttons.old_state;
|
||||
button = BTN_LEFT;
|
||||
button = EVDEV_BTN_LEFT;
|
||||
|
||||
while (current || old) {
|
||||
enum libinput_button_state state;
|
||||
|
||||
if ((current & 0x1) ^ (old & 0x1)) {
|
||||
uint32_t b;
|
||||
evdev_usage_t b;
|
||||
|
||||
if (!!(current & 0x1))
|
||||
state = LIBINPUT_BUTTON_STATE_PRESSED;
|
||||
else
|
||||
state = LIBINPUT_BUTTON_STATE_RELEASED;
|
||||
|
||||
b = evdev_to_left_handed(tp->device, button);
|
||||
b = evdev_to_left_handed(tp->device,
|
||||
evdev_usage_from_uint32_t(button));
|
||||
evdev_pointer_notify_physical_button(tp->device,
|
||||
time,
|
||||
b,
|
||||
|
|
@ -1162,7 +1163,7 @@ out:
|
|||
return within_distance;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
static evdev_usage_t
|
||||
tp_clickfinger_set_button(struct tp_dispatch *tp)
|
||||
{
|
||||
uint32_t button;
|
||||
|
|
@ -1170,9 +1171,9 @@ tp_clickfinger_set_button(struct tp_dispatch *tp)
|
|||
struct tp_touch *t;
|
||||
struct tp_touch *first = NULL,
|
||||
*second = NULL;
|
||||
int32_t button_map[2][3] = {
|
||||
{ BTN_LEFT, BTN_RIGHT, BTN_MIDDLE },
|
||||
{ BTN_LEFT, BTN_MIDDLE, BTN_RIGHT },
|
||||
uint32_t button_map[2][3] = {
|
||||
{ EVDEV_BTN_LEFT, EVDEV_BTN_RIGHT, EVDEV_BTN_MIDDLE },
|
||||
{ EVDEV_BTN_LEFT, EVDEV_BTN_MIDDLE, EVDEV_BTN_RIGHT },
|
||||
};
|
||||
|
||||
tp_for_each_touch(tp, t) {
|
||||
|
|
@ -1209,19 +1210,21 @@ out:
|
|||
switch (nfingers) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3: button = button_map[tp->buttons.map][nfingers-1]; break;
|
||||
case 3:
|
||||
button = button_map[tp->buttons.map][nfingers-1];
|
||||
break;
|
||||
default:
|
||||
button = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return button;
|
||||
return evdev_usage_from_uint32_t(button);
|
||||
}
|
||||
|
||||
static int
|
||||
tp_notify_clickpadbutton(struct tp_dispatch *tp,
|
||||
uint64_t time,
|
||||
uint32_t button,
|
||||
evdev_usage_t button,
|
||||
uint32_t is_topbutton,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
|
|
@ -1233,7 +1236,7 @@ tp_notify_clickpadbutton(struct tp_dispatch *tp,
|
|||
int value;
|
||||
|
||||
value = (state == LIBINPUT_BUTTON_STATE_PRESSED) ? 1 : 0;
|
||||
event = input_event_init(time, EV_KEY, button, value);
|
||||
event = input_event_init(time, EV_KEY, evdev_usage_code(button), value);
|
||||
syn_report = input_event_init(time, EV_SYN, SYN_REPORT, 0);
|
||||
dispatch->interface->process(dispatch,
|
||||
tp->buttons.trackpoint,
|
||||
|
|
@ -1263,7 +1266,7 @@ tp_notify_clickpadbutton(struct tp_dispatch *tp,
|
|||
button = tp_clickfinger_set_button(tp);
|
||||
tp->buttons.active = button;
|
||||
|
||||
if (!button)
|
||||
if (evdev_usage_eq(button, 0))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1274,7 +1277,8 @@ tp_notify_clickpadbutton(struct tp_dispatch *tp,
|
|||
static int
|
||||
tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time)
|
||||
{
|
||||
uint32_t current, old, button, is_top;
|
||||
uint32_t current, old, is_top;
|
||||
evdev_usage_t button = evdev_usage_from_uint32_t(0);
|
||||
enum libinput_button_state state;
|
||||
enum { AREA = 0x01, LEFT = 0x02, MIDDLE = 0x04, RIGHT = 0x08 };
|
||||
bool want_left_handed = true;
|
||||
|
|
@ -1339,15 +1343,15 @@ tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time)
|
|||
|
||||
if ((tp->device->middlebutton.enabled || is_top) &&
|
||||
(area & LEFT) && (area & RIGHT)) {
|
||||
button = BTN_MIDDLE;
|
||||
button = evdev_usage_from(EVDEV_BTN_MIDDLE);
|
||||
} else if (area & MIDDLE) {
|
||||
button = BTN_MIDDLE;
|
||||
button = evdev_usage_from(EVDEV_BTN_MIDDLE);
|
||||
} else if (area & RIGHT) {
|
||||
button = BTN_RIGHT;
|
||||
button = evdev_usage_from(EVDEV_BTN_RIGHT);
|
||||
} else if (area & LEFT) {
|
||||
button = BTN_LEFT;
|
||||
button = evdev_usage_from(EVDEV_BTN_LEFT);
|
||||
} else { /* main or no area (for clickfinger) is always BTN_LEFT */
|
||||
button = BTN_LEFT;
|
||||
button = evdev_usage_from(EVDEV_BTN_LEFT);
|
||||
want_left_handed = false;
|
||||
}
|
||||
|
||||
|
|
@ -1363,14 +1367,14 @@ tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time)
|
|||
} else {
|
||||
button = tp->buttons.active;
|
||||
is_top = tp->buttons.active_is_topbutton;
|
||||
tp->buttons.active = 0;
|
||||
tp->buttons.active = evdev_usage_from_uint32_t(0);
|
||||
tp->buttons.active_is_topbutton = 0;
|
||||
state = LIBINPUT_BUTTON_STATE_RELEASED;
|
||||
}
|
||||
|
||||
tp->buttons.click_pending = false;
|
||||
|
||||
if (button)
|
||||
if (evdev_usage_ne(button, 0))
|
||||
return tp_notify_clickpadbutton(tp,
|
||||
time,
|
||||
button,
|
||||
|
|
|
|||
|
|
@ -1030,7 +1030,7 @@ tp_gesture_handle_event_on_state_3fg_drag(struct tp_dispatch *tp,
|
|||
/* If the gesture is cancelled we release the button immediately */
|
||||
evdev_pointer_notify_button(tp->device,
|
||||
tp->gesture.drag_3fg_release_time,
|
||||
BTN_LEFT,
|
||||
evdev_usage_from(EVDEV_BTN_LEFT),
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
tp->gesture.state = GESTURE_STATE_NONE;
|
||||
break;
|
||||
|
|
@ -1044,7 +1044,7 @@ tp_gesture_handle_event_on_state_3fg_drag(struct tp_dispatch *tp,
|
|||
if (tp->gesture.finger_count_pending < 2) {
|
||||
evdev_pointer_notify_button(tp->device,
|
||||
tp->gesture.drag_3fg_release_time,
|
||||
BTN_LEFT,
|
||||
evdev_usage_from(EVDEV_BTN_LEFT),
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
tp->gesture.state = GESTURE_STATE_NONE;
|
||||
}
|
||||
|
|
@ -1082,7 +1082,7 @@ tp_gesture_handle_event_on_state_3fg_drag_released(struct tp_dispatch *tp,
|
|||
libinput_timer_cancel(&tp->gesture.finger_count_switch_timer);
|
||||
evdev_pointer_notify_button(tp->device,
|
||||
tp->gesture.drag_3fg_release_time,
|
||||
BTN_LEFT,
|
||||
evdev_usage_from(EVDEV_BTN_LEFT),
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
tp->gesture.state = GESTURE_STATE_NONE;
|
||||
break;
|
||||
|
|
@ -1100,7 +1100,7 @@ tp_gesture_handle_event_on_state_3fg_drag_released(struct tp_dispatch *tp,
|
|||
libinput_timer_cancel(&tp->gesture.drag_3fg_timer);
|
||||
evdev_pointer_notify_button(tp->device,
|
||||
tp->gesture.drag_3fg_release_time,
|
||||
BTN_LEFT,
|
||||
evdev_usage_from(EVDEV_BTN_LEFT),
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
tp->gesture.state = GESTURE_STATE_POINTER_MOTION;
|
||||
break;
|
||||
|
|
@ -1114,7 +1114,7 @@ tp_gesture_handle_event_on_state_3fg_drag_released(struct tp_dispatch *tp,
|
|||
libinput_timer_cancel(&tp->gesture.drag_3fg_timer);
|
||||
evdev_pointer_notify_button(tp->device,
|
||||
tp->gesture.drag_3fg_release_time,
|
||||
BTN_LEFT,
|
||||
evdev_usage_from(EVDEV_BTN_LEFT),
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
tp->gesture.state = GESTURE_STATE_SCROLL_START;
|
||||
break;
|
||||
|
|
@ -1709,7 +1709,7 @@ tp_gesture_handle_state_3fg_drag_start(struct tp_dispatch *tp, uint64_t time)
|
|||
{
|
||||
evdev_pointer_notify_button(tp->device,
|
||||
time,
|
||||
BTN_LEFT,
|
||||
evdev_usage_from(EVDEV_BTN_LEFT),
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
/* FIXME: immediately send a motion event? */
|
||||
tp->gesture.state = GESTURE_STATE_3FG_DRAG;
|
||||
|
|
|
|||
|
|
@ -126,9 +126,9 @@ tp_tap_notify(struct tp_dispatch *tp,
|
|||
enum libinput_button_state state)
|
||||
{
|
||||
int32_t button;
|
||||
int32_t button_map[2][3] = {
|
||||
{ BTN_LEFT, BTN_RIGHT, BTN_MIDDLE },
|
||||
{ BTN_LEFT, BTN_MIDDLE, BTN_RIGHT },
|
||||
uint32_t button_map[2][3] = {
|
||||
{ EVDEV_BTN_LEFT, EVDEV_BTN_RIGHT, EVDEV_BTN_MIDDLE },
|
||||
{ EVDEV_BTN_LEFT, EVDEV_BTN_MIDDLE, EVDEV_BTN_RIGHT },
|
||||
};
|
||||
|
||||
assert(tp->tap.map < ARRAY_LENGTH(button_map));
|
||||
|
|
@ -147,7 +147,7 @@ tp_tap_notify(struct tp_dispatch *tp,
|
|||
|
||||
evdev_pointer_notify_button(tp->device,
|
||||
time,
|
||||
button,
|
||||
evdev_usage_from_uint32_t(button),
|
||||
state);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -290,29 +290,29 @@ tp_fake_finger_is_touching(struct tp_dispatch *tp)
|
|||
|
||||
static inline void
|
||||
tp_fake_finger_set(struct tp_dispatch *tp,
|
||||
unsigned int code,
|
||||
evdev_usage_t usage,
|
||||
bool is_press)
|
||||
{
|
||||
unsigned int shift;
|
||||
|
||||
switch (code) {
|
||||
case BTN_TOUCH:
|
||||
switch (evdev_usage_enum(usage)) {
|
||||
case EVDEV_BTN_TOUCH:
|
||||
if (!is_press)
|
||||
tp->fake_touches &= ~FAKE_FINGER_OVERFLOW;
|
||||
shift = 0;
|
||||
break;
|
||||
case BTN_TOOL_FINGER:
|
||||
case EVDEV_BTN_TOOL_FINGER:
|
||||
shift = 1;
|
||||
break;
|
||||
case BTN_TOOL_DOUBLETAP:
|
||||
case BTN_TOOL_TRIPLETAP:
|
||||
case BTN_TOOL_QUADTAP:
|
||||
shift = code - BTN_TOOL_DOUBLETAP + 2;
|
||||
case EVDEV_BTN_TOOL_DOUBLETAP:
|
||||
case EVDEV_BTN_TOOL_TRIPLETAP:
|
||||
case EVDEV_BTN_TOOL_QUADTAP:
|
||||
shift = evdev_usage_enum(usage) - EVDEV_BTN_TOOL_DOUBLETAP + 2;
|
||||
break;
|
||||
/* when QUINTTAP is released we're either switching to 6 fingers
|
||||
(flag stays in place until BTN_TOUCH is released) or
|
||||
one of DOUBLE/TRIPLE/QUADTAP (will clear the flag on press) */
|
||||
case BTN_TOOL_QUINTTAP:
|
||||
case EVDEV_BTN_TOOL_QUINTTAP:
|
||||
if (is_press)
|
||||
tp->fake_touches |= FAKE_FINGER_OVERFLOW;
|
||||
return;
|
||||
|
|
@ -493,20 +493,20 @@ tp_get_delta(struct tp_touch *t)
|
|||
}
|
||||
|
||||
static inline int32_t
|
||||
rotated(struct tp_dispatch *tp, unsigned int code, int value)
|
||||
rotated(struct tp_dispatch *tp, evdev_usage_t usage, int value)
|
||||
{
|
||||
const struct input_absinfo *absinfo;
|
||||
|
||||
if (!tp->left_handed.rotate)
|
||||
return value;
|
||||
|
||||
switch (code) {
|
||||
case ABS_X:
|
||||
case ABS_MT_POSITION_X:
|
||||
switch (evdev_usage_enum(usage)) {
|
||||
case EVDEV_ABS_X:
|
||||
case EVDEV_ABS_MT_POSITION_X:
|
||||
absinfo = tp->device->abs.absinfo_x;
|
||||
break;
|
||||
case ABS_Y:
|
||||
case ABS_MT_POSITION_Y:
|
||||
case EVDEV_ABS_Y:
|
||||
case EVDEV_ABS_MT_POSITION_Y:
|
||||
absinfo = tp->device->abs.absinfo_y;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -517,32 +517,32 @@ rotated(struct tp_dispatch *tp, unsigned int code, int value)
|
|||
|
||||
static void
|
||||
tp_process_absolute(struct tp_dispatch *tp,
|
||||
const struct input_event *e,
|
||||
const struct evdev_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
struct tp_touch *t = tp_current_touch(tp);
|
||||
|
||||
switch(e->code) {
|
||||
case ABS_MT_POSITION_X:
|
||||
switch (evdev_usage_enum(e->usage)) {
|
||||
case EVDEV_ABS_MT_POSITION_X:
|
||||
evdev_device_check_abs_axis_range(tp->device,
|
||||
e->code,
|
||||
e->usage,
|
||||
e->value);
|
||||
t->point.x = rotated(tp, e->code, e->value);
|
||||
t->point.x = rotated(tp, e->usage, e->value);
|
||||
t->dirty = true;
|
||||
tp->queued |= TOUCHPAD_EVENT_MOTION;
|
||||
break;
|
||||
case ABS_MT_POSITION_Y:
|
||||
case EVDEV_ABS_MT_POSITION_Y:
|
||||
evdev_device_check_abs_axis_range(tp->device,
|
||||
e->code,
|
||||
e->usage,
|
||||
e->value);
|
||||
t->point.y = rotated(tp, e->code, e->value);
|
||||
t->point.y = rotated(tp, e->usage, e->value);
|
||||
t->dirty = true;
|
||||
tp->queued |= TOUCHPAD_EVENT_MOTION;
|
||||
break;
|
||||
case ABS_MT_SLOT:
|
||||
case EVDEV_ABS_MT_SLOT:
|
||||
tp->slot = e->value;
|
||||
break;
|
||||
case ABS_MT_TRACKING_ID:
|
||||
case EVDEV_ABS_MT_TRACKING_ID:
|
||||
if (e->value != -1) {
|
||||
tp->nactive_slots += 1;
|
||||
tp_new_touch(tp, t, time);
|
||||
|
|
@ -551,58 +551,62 @@ tp_process_absolute(struct tp_dispatch *tp,
|
|||
tp_end_sequence(tp, t, time);
|
||||
}
|
||||
break;
|
||||
case ABS_MT_PRESSURE:
|
||||
case EVDEV_ABS_MT_PRESSURE:
|
||||
t->pressure = e->value;
|
||||
t->dirty = true;
|
||||
tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
|
||||
break;
|
||||
case ABS_MT_TOOL_TYPE:
|
||||
case EVDEV_ABS_MT_TOOL_TYPE:
|
||||
t->is_tool_palm = e->value == MT_TOOL_PALM;
|
||||
t->dirty = true;
|
||||
tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
|
||||
break;
|
||||
case ABS_MT_TOUCH_MAJOR:
|
||||
case EVDEV_ABS_MT_TOUCH_MAJOR:
|
||||
t->major = e->value;
|
||||
t->dirty = true;
|
||||
tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
|
||||
break;
|
||||
case ABS_MT_TOUCH_MINOR:
|
||||
case EVDEV_ABS_MT_TOUCH_MINOR:
|
||||
t->minor = e->value;
|
||||
t->dirty = true;
|
||||
tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tp_process_absolute_st(struct tp_dispatch *tp,
|
||||
const struct input_event *e,
|
||||
const struct evdev_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
struct tp_touch *t = tp_current_touch(tp);
|
||||
|
||||
switch(e->code) {
|
||||
case ABS_X:
|
||||
switch (evdev_usage_enum(e->usage)) {
|
||||
case EVDEV_ABS_X:
|
||||
evdev_device_check_abs_axis_range(tp->device,
|
||||
e->code,
|
||||
e->usage,
|
||||
e->value);
|
||||
t->point.x = rotated(tp, e->code, e->value);
|
||||
t->point.x = rotated(tp, e->usage, e->value);
|
||||
t->dirty = true;
|
||||
tp->queued |= TOUCHPAD_EVENT_MOTION;
|
||||
break;
|
||||
case ABS_Y:
|
||||
case EVDEV_ABS_Y:
|
||||
evdev_device_check_abs_axis_range(tp->device,
|
||||
e->code,
|
||||
e->usage,
|
||||
e->value);
|
||||
t->point.y = rotated(tp, e->code, e->value);
|
||||
t->point.y = rotated(tp, e->usage, e->value);
|
||||
t->dirty = true;
|
||||
tp->queued |= TOUCHPAD_EVENT_MOTION;
|
||||
break;
|
||||
case ABS_PRESSURE:
|
||||
case EVDEV_ABS_PRESSURE:
|
||||
t->pressure = e->value;
|
||||
t->dirty = true;
|
||||
tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -709,7 +713,7 @@ tp_process_fake_touches(struct tp_dispatch *tp,
|
|||
|
||||
static void
|
||||
tp_process_trackpoint_button(struct tp_dispatch *tp,
|
||||
const struct input_event *e,
|
||||
const struct evdev_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
struct evdev_dispatch *dispatch;
|
||||
|
|
@ -727,18 +731,18 @@ tp_process_trackpoint_button(struct tp_dispatch *tp,
|
|||
|
||||
dispatch = tp->buttons.trackpoint->dispatch;
|
||||
|
||||
event = *e;
|
||||
syn_report.input_event_sec = e->input_event_sec;
|
||||
syn_report.input_event_usec = e->input_event_usec;
|
||||
event = evdev_event_to_input_event(e, time);
|
||||
syn_report.input_event_sec = event.input_event_sec;
|
||||
syn_report.input_event_usec = event.input_event_usec;
|
||||
|
||||
switch (event.code) {
|
||||
case BTN_0:
|
||||
switch (evdev_usage_enum(e->usage)) {
|
||||
case EVDEV_BTN_0:
|
||||
event.code = BTN_LEFT;
|
||||
break;
|
||||
case BTN_1:
|
||||
case EVDEV_BTN_1:
|
||||
event.code = BTN_RIGHT;
|
||||
break;
|
||||
case BTN_2:
|
||||
case EVDEV_BTN_2:
|
||||
event.code = BTN_MIDDLE;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -755,41 +759,43 @@ tp_process_trackpoint_button(struct tp_dispatch *tp,
|
|||
|
||||
static void
|
||||
tp_process_key(struct tp_dispatch *tp,
|
||||
const struct input_event *e,
|
||||
const struct evdev_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
/* ignore kernel key repeat */
|
||||
if (e->value == 2)
|
||||
return;
|
||||
|
||||
switch (e->code) {
|
||||
case BTN_LEFT:
|
||||
case BTN_MIDDLE:
|
||||
case BTN_RIGHT:
|
||||
tp_process_button(tp, e, time);
|
||||
break;
|
||||
case BTN_TOUCH:
|
||||
case BTN_TOOL_FINGER:
|
||||
case BTN_TOOL_DOUBLETAP:
|
||||
case BTN_TOOL_TRIPLETAP:
|
||||
case BTN_TOOL_QUADTAP:
|
||||
case BTN_TOOL_QUINTTAP:
|
||||
tp_fake_finger_set(tp, e->code, !!e->value);
|
||||
break;
|
||||
case BTN_0:
|
||||
case BTN_1:
|
||||
case BTN_2:
|
||||
tp_process_trackpoint_button(tp, e, time);
|
||||
break;
|
||||
switch (evdev_usage_enum(e->usage)) {
|
||||
case EVDEV_BTN_LEFT:
|
||||
case EVDEV_BTN_MIDDLE:
|
||||
case EVDEV_BTN_RIGHT:
|
||||
tp_process_button(tp, e, time);
|
||||
break;
|
||||
case EVDEV_BTN_TOUCH:
|
||||
case EVDEV_BTN_TOOL_FINGER:
|
||||
case EVDEV_BTN_TOOL_DOUBLETAP:
|
||||
case EVDEV_BTN_TOOL_TRIPLETAP:
|
||||
case EVDEV_BTN_TOOL_QUADTAP:
|
||||
case EVDEV_BTN_TOOL_QUINTTAP:
|
||||
tp_fake_finger_set(tp, e->usage, !!e->value);
|
||||
break;
|
||||
case EVDEV_BTN_0:
|
||||
case EVDEV_BTN_1:
|
||||
case EVDEV_BTN_2:
|
||||
tp_process_trackpoint_button(tp, e, time);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tp_process_msc(struct tp_dispatch *tp,
|
||||
const struct input_event *e,
|
||||
const struct evdev_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
if (e->code != MSC_TIMESTAMP)
|
||||
if (evdev_usage_eq(e->usage, EVDEV_MSC_TIMESTAMP))
|
||||
return;
|
||||
|
||||
tp->quirks.msc_timestamp.now = e->value;
|
||||
|
|
@ -1939,23 +1945,25 @@ tp_debug_touch_state(struct tp_dispatch *tp,
|
|||
static void
|
||||
tp_interface_process(struct evdev_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
struct input_event *e,
|
||||
struct input_event *input_event,
|
||||
uint64_t time)
|
||||
{
|
||||
struct tp_dispatch *tp = tp_dispatch(dispatch);
|
||||
struct evdev_event e = evdev_event_from_input_event(input_event, NULL);
|
||||
|
||||
switch (e->type) {
|
||||
uint16_t type = evdev_event_type(&e);
|
||||
switch (type) {
|
||||
case EV_ABS:
|
||||
if (tp->has_mt)
|
||||
tp_process_absolute(tp, e, time);
|
||||
tp_process_absolute(tp, &e, time);
|
||||
else
|
||||
tp_process_absolute_st(tp, e, time);
|
||||
tp_process_absolute_st(tp, &e, time);
|
||||
break;
|
||||
case EV_KEY:
|
||||
tp_process_key(tp, e, time);
|
||||
tp_process_key(tp, &e, time);
|
||||
break;
|
||||
case EV_MSC:
|
||||
tp_process_msc(tp, e, time);
|
||||
tp_process_msc(tp, &e, time);
|
||||
break;
|
||||
case EV_SYN:
|
||||
tp_handle_state(tp, time);
|
||||
|
|
@ -2643,8 +2651,8 @@ tp_interface_device_removed(struct evdev_device *device,
|
|||
|
||||
if (removed_device == tp->buttons.trackpoint) {
|
||||
/* Clear any pending releases for the trackpoint */
|
||||
if (tp->buttons.active && tp->buttons.active_is_topbutton) {
|
||||
tp->buttons.active = 0;
|
||||
if (evdev_usage_ne(tp->buttons.active, 0) && tp->buttons.active_is_topbutton) {
|
||||
tp->buttons.active = evdev_usage_from_uint32_t(0);
|
||||
tp->buttons.active_is_topbutton = false;
|
||||
}
|
||||
if (tp->palm.monitor_trackpoint)
|
||||
|
|
@ -2964,7 +2972,7 @@ tp_init_slots(struct tp_dispatch *tp,
|
|||
* performed.
|
||||
*/
|
||||
if (libevdev_get_event_value(device->evdev, EV_KEY, BTN_TOOL_FINGER))
|
||||
tp_fake_finger_set(tp, BTN_TOOL_FINGER, 1);
|
||||
tp_fake_finger_set(tp, evdev_usage_from(EVDEV_BTN_TOOL_FINGER), true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ struct tp_dispatch {
|
|||
double x_scale_coeff;
|
||||
double y_scale_coeff;
|
||||
} motion_dist; /* for pinned touches */
|
||||
unsigned int active; /* currently active button, for release event */
|
||||
evdev_usage_t active; /* currently active button, for release event */
|
||||
bool active_is_topbutton; /* is active a top button? */
|
||||
|
||||
/* Only used for clickpads. The software button areas are
|
||||
|
|
@ -664,7 +664,7 @@ tp_remove_buttons(struct tp_dispatch *tp);
|
|||
|
||||
void
|
||||
tp_process_button(struct tp_dispatch *tp,
|
||||
const struct input_event *e,
|
||||
const struct evdev_event *e,
|
||||
uint64_t time);
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -307,18 +307,20 @@ wheel_handle_state_scrolling(struct fallback_dispatch *dispatch,
|
|||
|
||||
static void
|
||||
wheel_handle_direction_change(struct fallback_dispatch *dispatch,
|
||||
struct input_event *e,
|
||||
struct evdev_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
enum wheel_direction new_dir = WHEEL_DIR_UNKNOW;
|
||||
|
||||
switch (e->code) {
|
||||
case REL_WHEEL_HI_RES:
|
||||
switch (evdev_usage_enum(e->usage)) {
|
||||
case EVDEV_REL_WHEEL_HI_RES:
|
||||
new_dir = (e->value > 0) ? WHEEL_DIR_VPOS : WHEEL_DIR_VNEG;
|
||||
break;
|
||||
case REL_HWHEEL_HI_RES:
|
||||
case EVDEV_REL_HWHEEL_HI_RES:
|
||||
new_dir = (e->value > 0) ? WHEEL_DIR_HPOS : WHEEL_DIR_HNEG;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (new_dir != WHEEL_DIR_UNKNOW && new_dir != dispatch->wheel.dir) {
|
||||
|
|
@ -332,7 +334,7 @@ wheel_handle_direction_change(struct fallback_dispatch *dispatch,
|
|||
static void
|
||||
fallback_rotate_wheel(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
struct input_event *e)
|
||||
struct evdev_event *e)
|
||||
{
|
||||
/* Special case: if we're upside down (-ish),
|
||||
* swap the direction of the wheels so that user-down
|
||||
|
|
@ -347,10 +349,10 @@ fallback_rotate_wheel(struct fallback_dispatch *dispatch,
|
|||
void
|
||||
fallback_wheel_process_relative(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
struct input_event *e, uint64_t time)
|
||||
struct evdev_event *e, uint64_t time)
|
||||
{
|
||||
switch (e->code) {
|
||||
case REL_WHEEL:
|
||||
switch (evdev_usage_enum(e->usage)) {
|
||||
case EVDEV_REL_WHEEL:
|
||||
fallback_rotate_wheel(dispatch, device, e);
|
||||
dispatch->wheel.lo_res.y += e->value;
|
||||
if (dispatch->wheel.emulate_hi_res_wheel)
|
||||
|
|
@ -358,7 +360,7 @@ fallback_wheel_process_relative(struct fallback_dispatch *dispatch,
|
|||
dispatch->pending_event |= EVDEV_WHEEL;
|
||||
wheel_handle_event(dispatch, WHEEL_EVENT_SCROLL, time);
|
||||
break;
|
||||
case REL_HWHEEL:
|
||||
case EVDEV_REL_HWHEEL:
|
||||
fallback_rotate_wheel(dispatch, device, e);
|
||||
dispatch->wheel.lo_res.x += e->value;
|
||||
if (dispatch->wheel.emulate_hi_res_wheel)
|
||||
|
|
@ -366,7 +368,7 @@ fallback_wheel_process_relative(struct fallback_dispatch *dispatch,
|
|||
dispatch->pending_event |= EVDEV_WHEEL;
|
||||
wheel_handle_event(dispatch, WHEEL_EVENT_SCROLL, time);
|
||||
break;
|
||||
case REL_WHEEL_HI_RES:
|
||||
case EVDEV_REL_WHEEL_HI_RES:
|
||||
fallback_rotate_wheel(dispatch, device, e);
|
||||
dispatch->wheel.hi_res.y += e->value;
|
||||
dispatch->wheel.hi_res_event_received = true;
|
||||
|
|
@ -374,7 +376,7 @@ fallback_wheel_process_relative(struct fallback_dispatch *dispatch,
|
|||
wheel_handle_direction_change(dispatch, e, time);
|
||||
wheel_handle_event(dispatch, WHEEL_EVENT_SCROLL, time);
|
||||
break;
|
||||
case REL_HWHEEL_HI_RES:
|
||||
case EVDEV_REL_HWHEEL_HI_RES:
|
||||
fallback_rotate_wheel(dispatch, device, e);
|
||||
dispatch->wheel.hi_res.x += e->value;
|
||||
dispatch->wheel.hi_res_event_received = true;
|
||||
|
|
@ -382,6 +384,8 @@ fallback_wheel_process_relative(struct fallback_dispatch *dispatch,
|
|||
wheel_handle_direction_change(dispatch, e, time);
|
||||
wheel_handle_event(dispatch, WHEEL_EVENT_SCROLL, time);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
39
src/evdev.c
39
src/evdev.c
|
|
@ -129,11 +129,13 @@ parse_udev_flag(struct evdev_device *device,
|
|||
|
||||
int
|
||||
evdev_update_key_down_count(struct evdev_device *device,
|
||||
int code,
|
||||
evdev_usage_t usage,
|
||||
int pressed)
|
||||
{
|
||||
int key_count = 0;
|
||||
assert(code >= 0 && code < KEY_CNT);
|
||||
assert(evdev_usage_ge(usage, EVDEV_KEY_RESERVED) && evdev_usage_le(usage, EVDEV_KEY_MAX));
|
||||
|
||||
unsigned int code = evdev_usage_code(usage);
|
||||
|
||||
if (pressed) {
|
||||
key_count = ++device->key_count[code];
|
||||
|
|
@ -142,8 +144,9 @@ evdev_update_key_down_count(struct evdev_device *device,
|
|||
key_count = --device->key_count[code];
|
||||
} else {
|
||||
evdev_log_bug_libinput(device,
|
||||
"releasing key %s with count %d\n",
|
||||
"releasing key %s (%#x) with count %d\n",
|
||||
libevdev_event_code_get_name(EV_KEY, code),
|
||||
evdev_usage_as_uint32_t(usage),
|
||||
device->key_count[code]);
|
||||
}
|
||||
}
|
||||
|
|
@ -171,7 +174,7 @@ evdev_device_switch_get_state(struct evdev_device *device,
|
|||
void
|
||||
evdev_pointer_notify_physical_button(struct evdev_device *device,
|
||||
uint64_t time,
|
||||
int button,
|
||||
evdev_usage_t button,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
if (evdev_middlebutton_filter_button(device,
|
||||
|
|
@ -182,23 +185,25 @@ evdev_pointer_notify_physical_button(struct evdev_device *device,
|
|||
|
||||
evdev_pointer_notify_button(device,
|
||||
time,
|
||||
(unsigned int)button,
|
||||
button,
|
||||
state);
|
||||
}
|
||||
|
||||
static void
|
||||
evdev_pointer_post_button(struct evdev_device *device,
|
||||
uint64_t time,
|
||||
unsigned int button,
|
||||
evdev_usage_t button,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
int down_count;
|
||||
|
||||
down_count = evdev_update_key_down_count(device, button, state);
|
||||
down_count = evdev_update_key_down_count(device,
|
||||
button,
|
||||
state);
|
||||
|
||||
if ((state == LIBINPUT_BUTTON_STATE_PRESSED && down_count == 1) ||
|
||||
(state == LIBINPUT_BUTTON_STATE_RELEASED && down_count == 0)) {
|
||||
pointer_notify_button(&device->base, time, button, state);
|
||||
pointer_notify_button(&device->base, time, evdev_usage_code(button), state);
|
||||
|
||||
if (state == LIBINPUT_BUTTON_STATE_RELEASED) {
|
||||
if (device->left_handed.change_to_enabled)
|
||||
|
|
@ -251,7 +256,7 @@ evdev_button_scroll_button(struct evdev_device *device,
|
|||
}
|
||||
|
||||
if (is_press) {
|
||||
if (device->scroll.button < BTN_MOUSE + 5) {
|
||||
if (evdev_usage_lt(device->scroll.button, EVDEV_BTN_LEFT + 5)) {
|
||||
/* For mouse buttons 1-5 (0x110 to 0x114) we apply a timeout before scrolling
|
||||
* since the button could also be used for regular clicking. */
|
||||
enum timer_flags flags = TIMER_FLAG_NONE;
|
||||
|
|
@ -266,8 +271,8 @@ evdev_button_scroll_button(struct evdev_device *device,
|
|||
* for a negative timer to be set.
|
||||
*/
|
||||
if (device->middlebutton.enabled &&
|
||||
(device->scroll.button == BTN_LEFT ||
|
||||
device->scroll.button == BTN_RIGHT)) {
|
||||
(evdev_usage_eq(device->scroll.button, EVDEV_BTN_LEFT) ||
|
||||
evdev_usage_eq(device->scroll.button, EVDEV_BTN_RIGHT))) {
|
||||
flags = TIMER_FLAG_ALLOW_NEGATIVE;
|
||||
}
|
||||
|
||||
|
|
@ -318,11 +323,11 @@ evdev_button_scroll_button(struct evdev_device *device,
|
|||
void
|
||||
evdev_pointer_notify_button(struct evdev_device *device,
|
||||
uint64_t time,
|
||||
unsigned int button,
|
||||
evdev_usage_t button,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
if (device->scroll.method == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN &&
|
||||
button == device->scroll.button) {
|
||||
evdev_usage_cmp(button, device->scroll.button) == 0) {
|
||||
evdev_button_scroll_button(device, time, state);
|
||||
return;
|
||||
}
|
||||
|
|
@ -790,7 +795,7 @@ evdev_scroll_set_button(struct libinput_device *device,
|
|||
{
|
||||
struct evdev_device *evdev = evdev_device(device);
|
||||
|
||||
evdev->scroll.want_button = button;
|
||||
evdev->scroll.want_button = evdev_usage_from_code(EV_KEY, button);
|
||||
evdev->scroll.change_scroll_method(evdev);
|
||||
|
||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
|
|
@ -803,7 +808,7 @@ evdev_scroll_get_button(struct libinput_device *device)
|
|||
|
||||
/* return the wanted configuration, even if it hasn't taken
|
||||
* effect yet! */
|
||||
return evdev->scroll.want_button;
|
||||
return evdev_usage_code(evdev->scroll.want_button);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
|
|
@ -902,7 +907,7 @@ evdev_init_button_scroll(struct evdev_device *device,
|
|||
device->base.config.scroll_method = &device->scroll.config;
|
||||
device->scroll.method = evdev_scroll_get_default_method((struct libinput_device *)device);
|
||||
device->scroll.want_method = device->scroll.method;
|
||||
device->scroll.button = evdev_scroll_get_default_button((struct libinput_device *)device);
|
||||
device->scroll.button = evdev_usage_from_code(EV_KEY, evdev_scroll_get_default_button((struct libinput_device *)device));
|
||||
device->scroll.want_button = device->scroll.button;
|
||||
device->scroll.change_scroll_method = change_scroll_method;
|
||||
}
|
||||
|
|
@ -2149,7 +2154,7 @@ evdev_configure_device(struct evdev_device *device)
|
|||
/* want button scrolling config option */
|
||||
if (libevdev_has_event_code(evdev, EV_REL, REL_X) ||
|
||||
libevdev_has_event_code(evdev, EV_REL, REL_Y))
|
||||
device->scroll.want_button = 1;
|
||||
device->scroll.want_button = evdev_usage_from_code(EV_KEY, 1);
|
||||
}
|
||||
|
||||
if (udev_tags & EVDEV_UDEV_TAG_KEYBOARD) {
|
||||
|
|
|
|||
39
src/evdev.h
39
src/evdev.h
|
|
@ -37,6 +37,7 @@
|
|||
#include "timer.h"
|
||||
#include "filter.h"
|
||||
#include "quirks.h"
|
||||
#include "evdev-frame.h"
|
||||
#include "util-input-event.h"
|
||||
|
||||
/* The fake resolution value for abs devices without resolution */
|
||||
|
|
@ -212,13 +213,13 @@ struct evdev_device {
|
|||
struct libinput_device_config_scroll_method config;
|
||||
/* Currently enabled method, button */
|
||||
enum libinput_config_scroll_method method;
|
||||
uint32_t button;
|
||||
evdev_usage_t button;
|
||||
uint64_t button_down_time;
|
||||
|
||||
/* set during device init, used at runtime to delay changes
|
||||
* until all buttons are up */
|
||||
enum libinput_config_scroll_method want_method;
|
||||
uint32_t want_button;
|
||||
evdev_usage_t want_button;
|
||||
/* Checks if buttons are down and commits the setting */
|
||||
void (*change_scroll_method)(struct evdev_device *device);
|
||||
enum evdev_button_scroll_state button_scroll_state;
|
||||
|
|
@ -569,12 +570,12 @@ evdev_notify_resumed_device(struct evdev_device *device);
|
|||
void
|
||||
evdev_pointer_notify_button(struct evdev_device *device,
|
||||
uint64_t time,
|
||||
unsigned int button,
|
||||
evdev_usage_t button,
|
||||
enum libinput_button_state state);
|
||||
void
|
||||
evdev_pointer_notify_physical_button(struct evdev_device *device,
|
||||
uint64_t time,
|
||||
int button,
|
||||
evdev_usage_t button,
|
||||
enum libinput_button_state state);
|
||||
|
||||
void
|
||||
|
|
@ -590,7 +591,7 @@ evdev_set_button_scroll_lock_enabled(struct evdev_device *device,
|
|||
|
||||
int
|
||||
evdev_update_key_down_count(struct evdev_device *device,
|
||||
int code,
|
||||
evdev_usage_t code,
|
||||
int pressed);
|
||||
|
||||
void
|
||||
|
|
@ -636,7 +637,7 @@ evdev_device_destroy(struct evdev_device *device);
|
|||
bool
|
||||
evdev_middlebutton_filter_button(struct evdev_device *device,
|
||||
uint64_t time,
|
||||
int button,
|
||||
evdev_usage_t button,
|
||||
enum libinput_button_state state);
|
||||
|
||||
void
|
||||
|
|
@ -668,15 +669,15 @@ void
|
|||
evdev_init_left_handed(struct evdev_device *device,
|
||||
void (*change_to_left_handed)(struct evdev_device *));
|
||||
|
||||
static inline uint32_t
|
||||
static inline evdev_usage_t
|
||||
evdev_to_left_handed(struct evdev_device *device,
|
||||
uint32_t button)
|
||||
evdev_usage_t button)
|
||||
{
|
||||
if (device->left_handed.enabled) {
|
||||
if (button == BTN_LEFT)
|
||||
return BTN_RIGHT;
|
||||
else if (button == BTN_RIGHT)
|
||||
return BTN_LEFT;
|
||||
if (evdev_usage_eq(button, EVDEV_BTN_LEFT))
|
||||
return evdev_usage_from(EVDEV_BTN_RIGHT);
|
||||
else if (evdev_usage_eq(button, EVDEV_BTN_RIGHT))
|
||||
return evdev_usage_from(EVDEV_BTN_LEFT);
|
||||
}
|
||||
return button;
|
||||
}
|
||||
|
|
@ -1002,19 +1003,19 @@ evdev_device_init_abs_range_warnings(struct evdev_device *device)
|
|||
|
||||
static inline void
|
||||
evdev_device_check_abs_axis_range(struct evdev_device *device,
|
||||
unsigned int code,
|
||||
evdev_usage_t usage,
|
||||
int value)
|
||||
{
|
||||
int min, max;
|
||||
|
||||
switch(code) {
|
||||
case ABS_X:
|
||||
case ABS_MT_POSITION_X:
|
||||
switch (evdev_usage_enum(usage)) {
|
||||
case EVDEV_ABS_X:
|
||||
case EVDEV_ABS_MT_POSITION_X:
|
||||
min = device->abs.warning_range.min.x;
|
||||
max = device->abs.warning_range.max.x;
|
||||
break;
|
||||
case ABS_Y:
|
||||
case ABS_MT_POSITION_Y:
|
||||
case EVDEV_ABS_Y:
|
||||
case EVDEV_ABS_MT_POSITION_Y:
|
||||
min = device->abs.warning_range.min.y;
|
||||
max = device->abs.warning_range.max.y;
|
||||
break;
|
||||
|
|
@ -1027,7 +1028,7 @@ evdev_device_check_abs_axis_range(struct evdev_device *device,
|
|||
&device->abs.warning_range.range_warn_limit,
|
||||
"Axis %#x value %d is outside expected range [%d, %d]\n"
|
||||
"See %s/absolute-coordinate-ranges.html for details\n",
|
||||
code, value, min, max,
|
||||
evdev_usage_enum(usage), value, min, max,
|
||||
HTTP_DOC_LINK);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue