diff options
| author | Fenrir <[email protected]> | 2018-02-06 23:06:43 -0700 |
|---|---|---|
| committer | FenrirWolf <[email protected]> | 2018-02-06 23:17:14 -0700 |
| commit | fc0e124f4390deba03193d277dd4fe93ae5443a3 (patch) | |
| tree | 8cdfccf5658381cb66256068cff7a4994385c0f8 /examples/src/bin/buttons.rs | |
| parent | Fix unsoundness in Console's API (diff) | |
| download | archived-ctru-rs-fc0e124f4390deba03193d277dd4fe93ae5443a3.tar.xz archived-ctru-rs-fc0e124f4390deba03193d277dd4fe93ae5443a3.zip | |
Use bitflags 1.0 for button presses
Diffstat (limited to 'examples/src/bin/buttons.rs')
| -rw-r--r-- | examples/src/bin/buttons.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/src/bin/buttons.rs b/examples/src/bin/buttons.rs index 00dd33e..b906e59 100644 --- a/examples/src/bin/buttons.rs +++ b/examples/src/bin/buttons.rs @@ -3,14 +3,14 @@ extern crate ctru; use ctru::gfx::Gfx; use ctru::console::Console; use ctru::services::apt::Apt; -use ctru::services::hid::{self, Hid, KeyPad}; +use ctru::services::hid::{Hid, KeyPad}; fn main() { // Setup services let apt = Apt::init().unwrap(); let hid = Hid::init().unwrap(); let mut gfx = Gfx::default(); - let mut console = Console::default(); + let console = Console::default(); println!("Hi there! Try pressing a button"); println!("\x1b[29;16HPress Start to exit"); @@ -47,19 +47,19 @@ fn main() { // You can also use the .bits() method to do direct comparisons on // the underlying bits - if keys.contains(hid::KEY_A) { + if keys.contains(KeyPad::KEY_A) { println!("You held A!"); } - if keys.bits() & hid::KEY_B.bits() != 0 { + if keys.bits() & KeyPad::KEY_B.bits() != 0 { println!("You held B!"); } - if keys.contains(hid::KEY_X | hid::KEY_Y) { + if keys.contains(KeyPad::KEY_X | KeyPad::KEY_Y) { println!("You held X and Y!"); } - if keys.intersects(hid::KEY_L | hid::KEY_R | hid::KEY_ZL | hid::KEY_ZR) { + if keys.intersects(KeyPad::KEY_L | KeyPad::KEY_R | KeyPad::KEY_ZL | KeyPad::KEY_ZR) { println!("You held a shoulder button!"); } - if keys.intersects(hid::KEY_START) { + if keys.intersects(KeyPad::KEY_START) { println!("See ya!"); break } |