wayland: implement wl_touch
Co-authored-by: Julian Orth <ju.orth@gmail.com>
This commit is contained in:
parent
905e2dd7ba
commit
681c1ad033
35 changed files with 1071 additions and 52 deletions
|
|
@ -131,6 +131,8 @@ pub enum DeviceCommand {
|
|||
MapToOutput(MapToOutputArgs),
|
||||
/// Removes the mapping from this device to an output.
|
||||
RemoveMapping,
|
||||
/// Set the calibration matrix.
|
||||
SetCalibrationMatrix(SetCalibrationMatrixArgs),
|
||||
}
|
||||
|
||||
#[derive(ValueEnum, Debug, Clone)]
|
||||
|
|
@ -200,6 +202,16 @@ pub struct SetTransformMatrixArgs {
|
|||
pub m22: f64,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug, Clone)]
|
||||
pub struct SetCalibrationMatrixArgs {
|
||||
pub m00: f32,
|
||||
pub m01: f32,
|
||||
pub m02: f32,
|
||||
pub m10: f32,
|
||||
pub m11: f32,
|
||||
pub m12: f32,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug, Clone)]
|
||||
pub struct MapToOutputArgs {
|
||||
/// The output to map to.
|
||||
|
|
@ -272,6 +284,7 @@ struct InputDevice {
|
|||
pub px_per_wheel_scroll: Option<f64>,
|
||||
pub transform_matrix: Option<[[f64; 2]; 2]>,
|
||||
pub output: Option<String>,
|
||||
pub calibration_matrix: Option<[[f32; 3]; 2]>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
|
|
@ -595,6 +608,21 @@ impl Input {
|
|||
output: None,
|
||||
});
|
||||
}
|
||||
DeviceCommand::SetCalibrationMatrix(a) => {
|
||||
self.handle_error(input, |e| {
|
||||
eprintln!("Could not modify the calibration matrix: {}", e);
|
||||
});
|
||||
tc.send(jay_input::SetCalibrationMatrix {
|
||||
self_id: input,
|
||||
id: args.device,
|
||||
m00: a.m00,
|
||||
m01: a.m01,
|
||||
m02: a.m02,
|
||||
m10: a.m10,
|
||||
m11: a.m11,
|
||||
m12: a.m12,
|
||||
});
|
||||
}
|
||||
}
|
||||
tc.round_trip().await;
|
||||
}
|
||||
|
|
@ -728,6 +756,9 @@ impl Input {
|
|||
if let Some(v) = &device.output {
|
||||
println!("{prefix} mapped to output: {}", v);
|
||||
}
|
||||
if let Some(v) = &device.calibration_matrix {
|
||||
println!("{prefix} calibration matrix: {:?}", v);
|
||||
}
|
||||
}
|
||||
|
||||
async fn get(self: &Rc<Self>, input: JayInputId) -> Data {
|
||||
|
|
@ -792,6 +823,7 @@ impl Input {
|
|||
px_per_wheel_scroll: is_pointer.then_some(msg.px_per_wheel_scroll),
|
||||
transform_matrix: uapi::pod_read(msg.transform_matrix).ok(),
|
||||
output: None,
|
||||
calibration_matrix: None,
|
||||
});
|
||||
});
|
||||
jay_input::InputDeviceOutput::handle(tc, input, data.clone(), |data, msg| {
|
||||
|
|
@ -800,6 +832,13 @@ impl Input {
|
|||
last.output = Some(msg.output.to_string());
|
||||
}
|
||||
});
|
||||
jay_input::CalibrationMatrix::handle(tc, input, data.clone(), |data, msg| {
|
||||
let mut data = data.borrow_mut();
|
||||
if let Some(last) = data.input_device.last_mut() {
|
||||
last.calibration_matrix =
|
||||
Some([[msg.m00, msg.m01, msg.m02], [msg.m10, msg.m11, msg.m12]]);
|
||||
}
|
||||
});
|
||||
tc.round_trip().await;
|
||||
let x = data.borrow_mut().clone();
|
||||
x
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue