Skip to content

Commit

Permalink
evdev: Don't send mouse events on EV_ABS
Browse files Browse the repository at this point in the history
A real mouse will send EV_REL events. Joysticks, on the other hand, will
use EV_ABS for their axes. This commit avoids joystick events to be
misinterpreted as mouse events.
  • Loading branch information
pcercuei authored and glebm committed Mar 26, 2021
1 parent ddb1671 commit 3dca329
Showing 1 changed file with 0 additions and 61 deletions.
61 changes: 0 additions & 61 deletions src/core/linux/SDL_evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,67 +302,6 @@ SDL_EVDEV_Poll(void)
}
SDL_EVDEV_kbd_keycode(_this->kbd, events[i].code, events[i].value);
break;
case EV_ABS:
switch(events[i].code) {
case ABS_MT_SLOT:
if (!item->is_touchscreen) /* FIXME: temp hack */
break;
item->touchscreen_data->current_slot = events[i].value;
break;
case ABS_MT_TRACKING_ID:
if (!item->is_touchscreen) /* FIXME: temp hack */
break;
if (events[i].value >= 0) {
item->touchscreen_data->slots[item->touchscreen_data->current_slot].tracking_id = events[i].value;
item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_DOWN;
} else {
item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_UP;
}
break;
case ABS_MT_POSITION_X:
if (!item->is_touchscreen) /* FIXME: temp hack */
break;
item->touchscreen_data->slots[item->touchscreen_data->current_slot].x = events[i].value;
if (item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta == EVDEV_TOUCH_SLOTDELTA_NONE) {
item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_MOVE;
}
break;
case ABS_MT_POSITION_Y:
if (!item->is_touchscreen) /* FIXME: temp hack */
break;
item->touchscreen_data->slots[item->touchscreen_data->current_slot].y = events[i].value;
if (item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta == EVDEV_TOUCH_SLOTDELTA_NONE) {
item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_MOVE;
}
break;
case ABS_MT_PRESSURE:
if (!item->is_touchscreen) /* FIXME: temp hack */
break;
item->touchscreen_data->slots[item->touchscreen_data->current_slot].pressure = events[i].value;
if (item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta == EVDEV_TOUCH_SLOTDELTA_NONE) {
item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_MOVE;
}
break;
case ABS_X:
if (item->is_touchscreen) {
if (item->touchscreen_data->max_slots != 1)
break;
item->touchscreen_data->slots[0].x = events[i].value;
} else
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, events[i].value, mouse->y);
break;
case ABS_Y:
if (item->is_touchscreen) {
if (item->touchscreen_data->max_slots != 1)
break;
item->touchscreen_data->slots[0].y = events[i].value;
} else
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, mouse->x, events[i].value);
break;
default:
break;
}
break;
case EV_REL:
switch(events[i].code) {
case REL_X:
Expand Down

0 comments on commit 3dca329

Please sign in to comment.