Formatting
This commit is contained in:
parent
de2c4e026d
commit
2373a4e262
1 changed files with 32 additions and 28 deletions
60
src/lib.rs
60
src/lib.rs
|
@ -772,9 +772,13 @@ impl Device {
|
||||||
dev.phys = ioctl_get_cstring(eviocgphys, dev.file.as_raw_fd());
|
dev.phys = ioctl_get_cstring(eviocgphys, dev.file.as_raw_fd());
|
||||||
dev.uniq = ioctl_get_cstring(eviocguniq, dev.file.as_raw_fd());
|
dev.uniq = ioctl_get_cstring(eviocguniq, dev.file.as_raw_fd());
|
||||||
|
|
||||||
unsafe { eviocgid(dev.file.as_raw_fd(), &mut dev.id)? };
|
unsafe {
|
||||||
|
eviocgid(dev.file.as_raw_fd(), &mut dev.id)?;
|
||||||
|
}
|
||||||
let mut driver_version: i32 = 0;
|
let mut driver_version: i32 = 0;
|
||||||
unsafe { eviocgversion(dev.file.as_raw_fd(), &mut driver_version)? };
|
unsafe {
|
||||||
|
eviocgversion(dev.file.as_raw_fd(), &mut driver_version)?;
|
||||||
|
}
|
||||||
dev.driver_version = (
|
dev.driver_version = (
|
||||||
((driver_version >> 16) & 0xff) as u8,
|
((driver_version >> 16) & 0xff) as u8,
|
||||||
((driver_version >> 8) & 0xff) as u8,
|
((driver_version >> 8) & 0xff) as u8,
|
||||||
|
@ -783,8 +787,8 @@ impl Device {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let (_, bits_as_u8_slice, _) = std::slice::from_mut(&mut bits).align_to_mut();
|
let (_, bits_as_u8_slice, _) = std::slice::from_mut(&mut bits).align_to_mut();
|
||||||
eviocgprop(dev.file.as_raw_fd(), bits_as_u8_slice)?
|
eviocgprop(dev.file.as_raw_fd(), bits_as_u8_slice)?;
|
||||||
}; // FIXME: handle old kernel
|
} // FIXME: handle old kernel
|
||||||
dev.props = Props::from_bits(bits).expect("evdev: unexpected prop bits! report a bug");
|
dev.props = Props::from_bits(bits).expect("evdev: unexpected prop bits! report a bug");
|
||||||
|
|
||||||
if dev.ty.contains(Types::KEY) {
|
if dev.ty.contains(Types::KEY) {
|
||||||
|
@ -796,8 +800,8 @@ impl Device {
|
||||||
dev.file.as_raw_fd(),
|
dev.file.as_raw_fd(),
|
||||||
Types::KEY.number(),
|
Types::KEY.number(),
|
||||||
key_bits_as_u8_slice,
|
key_bits_as_u8_slice,
|
||||||
)?
|
)?;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if dev.ty.contains(Types::RELATIVE) {
|
if dev.ty.contains(Types::RELATIVE) {
|
||||||
|
@ -807,8 +811,8 @@ impl Device {
|
||||||
dev.file.as_raw_fd(),
|
dev.file.as_raw_fd(),
|
||||||
Types::RELATIVE.number(),
|
Types::RELATIVE.number(),
|
||||||
bits_as_u8_slice,
|
bits_as_u8_slice,
|
||||||
)?
|
)?;
|
||||||
};
|
}
|
||||||
dev.rel =
|
dev.rel =
|
||||||
RelativeAxis::from_bits(bits).expect("evdev: unexpected rel bits! report a bug");
|
RelativeAxis::from_bits(bits).expect("evdev: unexpected rel bits! report a bug");
|
||||||
}
|
}
|
||||||
|
@ -820,8 +824,8 @@ impl Device {
|
||||||
dev.file.as_raw_fd(),
|
dev.file.as_raw_fd(),
|
||||||
Types::ABSOLUTE.number(),
|
Types::ABSOLUTE.number(),
|
||||||
bits64_as_u8_slice,
|
bits64_as_u8_slice,
|
||||||
)?
|
)?;
|
||||||
};
|
}
|
||||||
dev.abs =
|
dev.abs =
|
||||||
AbsoluteAxis::from_bits(bits64).expect("evdev: unexpected abs bits! report a bug");
|
AbsoluteAxis::from_bits(bits64).expect("evdev: unexpected abs bits! report a bug");
|
||||||
dev.state.abs_vals = vec![input_absinfo_default(); 0x3f];
|
dev.state.abs_vals = vec![input_absinfo_default(); 0x3f];
|
||||||
|
@ -834,8 +838,8 @@ impl Device {
|
||||||
dev.file.as_raw_fd(),
|
dev.file.as_raw_fd(),
|
||||||
Types::SWITCH.number(),
|
Types::SWITCH.number(),
|
||||||
bits_as_u8_slice,
|
bits_as_u8_slice,
|
||||||
)?
|
)?;
|
||||||
};
|
}
|
||||||
dev.switch =
|
dev.switch =
|
||||||
Switch::from_bits(bits).expect("evdev: unexpected switch bits! report a bug");
|
Switch::from_bits(bits).expect("evdev: unexpected switch bits! report a bug");
|
||||||
}
|
}
|
||||||
|
@ -843,20 +847,20 @@ impl Device {
|
||||||
if dev.ty.contains(Types::LED) {
|
if dev.ty.contains(Types::LED) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let (_, bits_as_u8_slice, _) = std::slice::from_mut(&mut bits).align_to_mut();
|
let (_, bits_as_u8_slice, _) = std::slice::from_mut(&mut bits).align_to_mut();
|
||||||
eviocgbit(dev.file.as_raw_fd(), Types::LED.number(), bits_as_u8_slice)?
|
eviocgbit(dev.file.as_raw_fd(), Types::LED.number(), bits_as_u8_slice)?;
|
||||||
};
|
}
|
||||||
dev.led = Led::from_bits(bits).expect("evdev: unexpected led bits! report a bug");
|
dev.led = Led::from_bits(bits).expect("evdev: unexpected led bits! report a bug");
|
||||||
}
|
}
|
||||||
|
|
||||||
if dev.ty.contains(Types::MISC) {
|
if dev.ty.contains(Types::MISC) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let (_, bits_as_u8_slice, _) = std::slice::from_mut(&mut bits).align_to_mut();
|
let (_, bits_as_u8_slice, _) = std::slice::from_mut(&mut bits).align_to_mut();
|
||||||
eviocgbit(dev.file.as_raw_fd(), Types::MISC.number(), bits_as_u8_slice)?
|
eviocgbit(dev.file.as_raw_fd(), Types::MISC.number(), bits_as_u8_slice)?;
|
||||||
};
|
}
|
||||||
dev.misc = Misc::from_bits(bits).expect("evdev: unexpected misc bits! report a bug");
|
dev.misc = Misc::from_bits(bits).expect("evdev: unexpected misc bits! report a bug");
|
||||||
}
|
}
|
||||||
|
|
||||||
//unsafe { eviocgbit(dev.file.as_raw_fd(), ffs(FORCEFEEDBACK.bits()), 0x7f, bits_as_u8_slice)? };
|
//unsafe { eviocgbit(dev.file.as_raw_fd(), ffs(FORCEFEEDBACK.bits()), 0x7f, bits_as_u8_slice)?; }
|
||||||
|
|
||||||
if dev.ty.contains(Types::SOUND) {
|
if dev.ty.contains(Types::SOUND) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -865,8 +869,8 @@ impl Device {
|
||||||
dev.file.as_raw_fd(),
|
dev.file.as_raw_fd(),
|
||||||
Types::SOUND.number(),
|
Types::SOUND.number(),
|
||||||
bits_as_u8_slice,
|
bits_as_u8_slice,
|
||||||
)?
|
)?;
|
||||||
};
|
}
|
||||||
dev.snd = Sound::from_bits(bits).expect("evdev: unexpected sound bits! report a bug");
|
dev.snd = Sound::from_bits(bits).expect("evdev: unexpected sound bits! report a bug");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -883,8 +887,8 @@ impl Device {
|
||||||
unsafe {
|
unsafe {
|
||||||
let key_slice = &mut self.key_bits.as_mut_slice();
|
let key_slice = &mut self.key_bits.as_mut_slice();
|
||||||
let (_, key_vals_as_u8_slice, _) = key_slice.align_to_mut();
|
let (_, key_vals_as_u8_slice, _) = key_slice.align_to_mut();
|
||||||
eviocgkey(self.file.as_raw_fd(), key_vals_as_u8_slice)?
|
eviocgkey(self.file.as_raw_fd(), key_vals_as_u8_slice)?;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
if self.ty.contains(Types::ABSOLUTE) {
|
if self.ty.contains(Types::ABSOLUTE) {
|
||||||
for idx in 0..0x3f {
|
for idx in 0..0x3f {
|
||||||
|
@ -899,8 +903,8 @@ impl Device {
|
||||||
self.file.as_raw_fd(),
|
self.file.as_raw_fd(),
|
||||||
idx as u32,
|
idx as u32,
|
||||||
&mut self.state.abs_vals[idx as usize],
|
&mut self.state.abs_vals[idx as usize],
|
||||||
)?
|
)?;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -908,15 +912,15 @@ impl Device {
|
||||||
unsafe {
|
unsafe {
|
||||||
let switch_slice = &mut self.state.switch_vals.as_mut_slice();
|
let switch_slice = &mut self.state.switch_vals.as_mut_slice();
|
||||||
let (_, switch_vals_as_u8_slice, _) = switch_slice.align_to_mut();
|
let (_, switch_vals_as_u8_slice, _) = switch_slice.align_to_mut();
|
||||||
eviocgsw(self.file.as_raw_fd(), switch_vals_as_u8_slice)?
|
eviocgsw(self.file.as_raw_fd(), switch_vals_as_u8_slice)?;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
if self.ty.contains(Types::LED) {
|
if self.ty.contains(Types::LED) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let led_slice = &mut self.state.led_vals.as_mut_slice();
|
let led_slice = &mut self.state.led_vals.as_mut_slice();
|
||||||
let (_, led_vals_as_u8_slice, _) = led_slice.align_to_mut();
|
let (_, led_vals_as_u8_slice, _) = led_slice.align_to_mut();
|
||||||
eviocgled(self.file.as_raw_fd(), led_vals_as_u8_slice)?
|
eviocgled(self.file.as_raw_fd(), led_vals_as_u8_slice)?;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1055,7 +1059,7 @@ impl Device {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
return Err(e.into());
|
return Err(e.into());
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue