device/builder: remove All events for Absolute and Relative

This commit is contained in:
meh 2016-04-25 17:12:39 +02:00
parent 8b5ba80253
commit c743be9596
3 changed files with 14 additions and 72 deletions

View File

@ -82,10 +82,8 @@ impl Builder {
pub fn event<T: Into<Event>>(mut self, value: T) -> Res<Self> {
match value.into() {
Event::All => {
try!(try!(try!(self.event(Event::Keyboard(event::Keyboard::All)))
.event(Event::Controller(event::Controller::All)))
.event(Event::Relative(event::Relative::All)))
.event(Event::Absolute(event::Absolute::All))
try!(self.event(Event::Keyboard(event::Keyboard::All)))
.event(Event::Controller(event::Controller::All))
}
Event::Keyboard(value) => {
@ -199,71 +197,23 @@ impl Builder {
}
Event::Relative(value) => {
match value {
event::Relative::All => {
let mut builder = self;
for item in event::relative::Position::iter_variants() {
builder = try!(builder.event(item));
}
for item in event::relative::Wheel::iter_variants() {
builder = try!(builder.event(item));
}
Ok(builder)
}
value => {
unsafe {
try!(Errno::result(ui_set_evbit(self.fd, value.kind())));
try!(Errno::result(ui_set_relbit(self.fd, value.code())));
}
Ok(self)
}
unsafe {
try!(Errno::result(ui_set_evbit(self.fd, value.kind())));
try!(Errno::result(ui_set_relbit(self.fd, value.code())));
}
Ok(self)
}
Event::Absolute(value) => {
match value {
event::Absolute::All => {
let mut builder = self;
for item in event::absolute::Position::iter_variants() {
builder = try!(builder.event(item));
}
for item in event::absolute::Wheel::iter_variants() {
builder = try!(builder.event(item));
}
for item in event::absolute::Hat::iter_variants() {
builder = try!(builder.event(item));
}
for item in event::absolute::Digi::iter_variants() {
builder = try!(builder.event(item));
}
for item in event::absolute::Multi::iter_variants() {
builder = try!(builder.event(item));
}
Ok(builder)
}
value => {
unsafe {
try!(Errno::result(ui_set_evbit(self.fd, value.kind())));
try!(Errno::result(ui_set_absbit(self.fd, value.code())));
}
self.code = value.code();
Ok(self)
}
unsafe {
try!(Errno::result(ui_set_evbit(self.fd, value.kind())));
try!(Errno::result(ui_set_absbit(self.fd, value.code())));
}
self.code = value.code();
Ok(self)
}
}
}

View File

@ -5,8 +5,6 @@ use super::{Kind, Code};
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Absolute {
All,
Position(Position),
Wheel(Wheel),
Hat(Hat),
@ -31,8 +29,6 @@ impl Kind for Absolute {
impl Code for Absolute {
fn code(&self) -> c_int {
match self {
&Absolute::All => unreachable!(),
&Absolute::Position(ref v) => v.code(),
&Absolute::Wheel(ref v) => v.code(),
&Absolute::Hat(ref v) => v.code(),

View File

@ -5,8 +5,6 @@ use super::{Kind, Code};
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Relative {
All,
Position(Position),
Wheel(Wheel),
}
@ -28,8 +26,6 @@ impl Kind for Relative {
impl Code for Relative {
fn code(&self) -> c_int {
match self {
&Relative::All => unreachable!(),
&Relative::Position(ref v) => v.code(),
&Relative::Wheel(ref v) => v.code(),
}