device/builder: remove All events for Absolute and Relative
This commit is contained in:
parent
8b5ba80253
commit
c743be9596
@ -82,10 +82,8 @@ impl Builder {
|
|||||||
pub fn event<T: Into<Event>>(mut self, value: T) -> Res<Self> {
|
pub fn event<T: Into<Event>>(mut self, value: T) -> Res<Self> {
|
||||||
match value.into() {
|
match value.into() {
|
||||||
Event::All => {
|
Event::All => {
|
||||||
try!(try!(try!(self.event(Event::Keyboard(event::Keyboard::All)))
|
try!(self.event(Event::Keyboard(event::Keyboard::All)))
|
||||||
.event(Event::Controller(event::Controller::All)))
|
.event(Event::Controller(event::Controller::All))
|
||||||
.event(Event::Relative(event::Relative::All)))
|
|
||||||
.event(Event::Absolute(event::Absolute::All))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::Keyboard(value) => {
|
Event::Keyboard(value) => {
|
||||||
@ -199,71 +197,23 @@ impl Builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Event::Relative(value) => {
|
Event::Relative(value) => {
|
||||||
match value {
|
unsafe {
|
||||||
event::Relative::All => {
|
try!(Errno::result(ui_set_evbit(self.fd, value.kind())));
|
||||||
let mut builder = self;
|
try!(Errno::result(ui_set_relbit(self.fd, value.code())));
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::Absolute(value) => {
|
Event::Absolute(value) => {
|
||||||
match value {
|
unsafe {
|
||||||
event::Absolute::All => {
|
try!(Errno::result(ui_set_evbit(self.fd, value.kind())));
|
||||||
let mut builder = self;
|
try!(Errno::result(ui_set_absbit(self.fd, value.code())));
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.code = value.code();
|
||||||
|
|
||||||
|
Ok(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ use super::{Kind, Code};
|
|||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub enum Absolute {
|
pub enum Absolute {
|
||||||
All,
|
|
||||||
|
|
||||||
Position(Position),
|
Position(Position),
|
||||||
Wheel(Wheel),
|
Wheel(Wheel),
|
||||||
Hat(Hat),
|
Hat(Hat),
|
||||||
@ -31,8 +29,6 @@ impl Kind for Absolute {
|
|||||||
impl Code for Absolute {
|
impl Code for Absolute {
|
||||||
fn code(&self) -> c_int {
|
fn code(&self) -> c_int {
|
||||||
match self {
|
match self {
|
||||||
&Absolute::All => unreachable!(),
|
|
||||||
|
|
||||||
&Absolute::Position(ref v) => v.code(),
|
&Absolute::Position(ref v) => v.code(),
|
||||||
&Absolute::Wheel(ref v) => v.code(),
|
&Absolute::Wheel(ref v) => v.code(),
|
||||||
&Absolute::Hat(ref v) => v.code(),
|
&Absolute::Hat(ref v) => v.code(),
|
||||||
|
@ -5,8 +5,6 @@ use super::{Kind, Code};
|
|||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub enum Relative {
|
pub enum Relative {
|
||||||
All,
|
|
||||||
|
|
||||||
Position(Position),
|
Position(Position),
|
||||||
Wheel(Wheel),
|
Wheel(Wheel),
|
||||||
}
|
}
|
||||||
@ -28,8 +26,6 @@ impl Kind for Relative {
|
|||||||
impl Code for Relative {
|
impl Code for Relative {
|
||||||
fn code(&self) -> c_int {
|
fn code(&self) -> c_int {
|
||||||
match self {
|
match self {
|
||||||
&Relative::All => unreachable!(),
|
|
||||||
|
|
||||||
&Relative::Position(ref v) => v.code(),
|
&Relative::Position(ref v) => v.code(),
|
||||||
&Relative::Wheel(ref v) => v.code(),
|
&Relative::Wheel(ref v) => v.code(),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user