Skip to content

value on InputEvent got it the wrong way around #165

@madsbyriel

Description

@madsbyriel

Docs maybe got it the wrong way around

When writing a key listening program using evdev in Rust I found this documentation to have it the wrong way around.

What I receive:
1 when I press the button
2 when the button is held
0 when it is released

evdev/src/lib.rs

Lines 391 to 399 in b946f93

/// Returns the raw "value" field directly from input_event.
///
/// For keys and switches the values 0 and 1 map to pressed and not pressed respectively.
/// For axes, the values depend on the hardware and driver implementation.
#[inline]
pub fn value(&self) -> i32 {
self.0.value
}

to reproduce just listen on the events of some device using into_event_stream from the feature tokio

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions