1
0
Fork 0
forked from wry/wry

tablet: implement version 2

This commit is contained in:
Julian Orth 2025-04-22 22:22:31 +02:00
parent 1d017ec2c2
commit dee0066f1a
25 changed files with 426 additions and 31 deletions

View file

@ -697,6 +697,7 @@ impl InputDevice for MetalInputDevice {
name: dev.name(),
pid: dev.product(),
vid: dev.vendor(),
bustype: dev.bustype(),
path: self.syspath.as_bytes().as_bstr().to_string(),
}))
}
@ -718,6 +719,7 @@ impl InputDevice for MetalInputDevice {
let buttons = dev.pad_num_buttons();
let strips = dev.pad_num_strips();
let rings = dev.pad_num_rings();
let dials = dev.pad_num_dials();
let mut groups = vec![];
for n in 0..dev.pad_num_mode_groups() {
let Some(group) = dev.pad_mode_group(n) else {
@ -727,6 +729,7 @@ impl InputDevice for MetalInputDevice {
buttons: (0..buttons).filter(|b| group.has_button(*b)).collect(),
rings: (0..rings).filter(|b| group.has_ring(*b)).collect(),
strips: (0..strips).filter(|b| group.has_strip(*b)).collect(),
dials: (0..dials).filter(|b| group.has_dial(*b)).collect(),
modes: group.num_modes(),
mode: group.mode(),
});
@ -738,6 +741,7 @@ impl InputDevice for MetalInputDevice {
buttons,
strips,
rings,
dials,
groups,
}))
}

View file

@ -71,7 +71,7 @@ impl MetalBackend {
break;
}
Ok(n) if n.intersects(c::POLLERR | c::POLLHUP) => {
log::error!("libinput fd fd is in an error state");
log::error!("libinput fd is in an error state");
break;
}
_ => {}
@ -121,6 +121,7 @@ impl MetalBackend {
c::LIBINPUT_EVENT_TABLET_PAD_BUTTON => self.handle_tablet_pad_button(event),
c::LIBINPUT_EVENT_TABLET_PAD_RING => self.handle_tablet_pad_ring(event),
c::LIBINPUT_EVENT_TABLET_PAD_STRIP => self.handle_tablet_pad_strip(event),
c::LIBINPUT_EVENT_TABLET_PAD_DIAL => self.handle_tablet_pad_dial(event),
c::LIBINPUT_EVENT_TOUCH_DOWN => self.handle_touch_down(event),
c::LIBINPUT_EVENT_TOUCH_UP => self.handle_touch_up(event),
c::LIBINPUT_EVENT_TOUCH_MOTION => self.handle_touch_motion(event),
@ -545,6 +546,25 @@ impl MetalBackend {
});
}
fn handle_tablet_pad_dial(self: &Rc<Self>, event: LibInputEvent) {
let (event, dev) = unpack!(self, event, tablet_pad_event);
let Some(dial) = event.dial_number() else {
return;
};
let Some(value120) = event.dial_delta_v120() else {
return;
};
dev.event(InputEvent::TabletPadDial {
time_usec: event.time_usec(),
pad: match dev.tablet_pad_id.get() {
None => return,
Some(id) => id,
},
dial,
value120: value120 as _,
});
}
fn handle_touch_down(self: &Rc<Self>, event: LibInputEvent) {
let (event, dev) = unpack!(self, event, touch_event);
dev.event(InputEvent::TouchDown {