Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all --all-features
args: --all --all-features --all-targets

check-minimal:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: check
args: --all --all-features -Z minimal-versions
args: --all --all-features --all-targets -Z minimal-versions

test:
needs:
Expand Down
38 changes: 1 addition & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,4 @@ Fedora
dnf install libinput-devel
```

Configure and run event loop:

```rust
use input::{Libinput, LibinputInterface};
use libc::{O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY};
use std::fs::{File, OpenOptions};
use std::os::unix::{fs::OpenOptionsExt, io::OwnedFd};
use std::path::Path;

struct Interface;

impl LibinputInterface for Interface {
fn open_restricted(&mut self, path: &Path, flags: i32) -> Result<OwnedFd, i32> {
OpenOptions::new()
.custom_flags(flags)
.read((flags & O_ACCMODE == O_RDONLY) | (flags & O_ACCMODE == O_RDWR))
.write((flags & O_ACCMODE == O_WRONLY) | (flags & O_ACCMODE == O_RDWR))
.open(path)
.map(|file| file.into())
.map_err(|err| err.raw_os_error().unwrap())
}
fn close_restricted(&mut self, fd: OwnedFd) {
drop(File::from(fd));
}
}

fn main() {
let mut input = Libinput::new_with_udev(Interface);
input.udev_assign_seat("seat0").unwrap();
loop {
input.dispatch().unwrap();
for event in &mut input {
println!("Got event: {:?}", event);
}
}
}
```
For usage examples, see [Examples](https://github.com/Smithay/input.rs/tree/master/examples).
35 changes: 35 additions & 0 deletions examples/event_loop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//! Configure and run event loop

use input::{Libinput, LibinputInterface};
use libc::{O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY};
use std::fs::{File, OpenOptions};
use std::os::unix::{fs::OpenOptionsExt, io::OwnedFd};
use std::path::Path;

struct Interface;

impl LibinputInterface for Interface {
fn open_restricted(&mut self, path: &Path, flags: i32) -> Result<OwnedFd, i32> {
OpenOptions::new()
.custom_flags(flags)
.read((flags & O_ACCMODE == O_RDONLY) | (flags & O_ACCMODE == O_RDWR))
.write((flags & O_ACCMODE == O_WRONLY) | (flags & O_ACCMODE == O_RDWR))
.open(path)
.map(|file| file.into())
.map_err(|err| err.raw_os_error().unwrap())
}
fn close_restricted(&mut self, fd: OwnedFd) {
drop(File::from(fd));
}
}

fn main() {
let mut input = Libinput::new_with_udev(Interface);
input.udev_assign_seat("seat0").unwrap();
loop {
input.dispatch().unwrap();
for event in &mut input {
println!("Got event: {:?}", event);
}
}
}
Loading